|
| 1 | +// *** WARNING: this file was generated by pulumi-java-gen. *** |
| 2 | +// *** Do not edit by hand unless you're certain you know what you are doing! *** |
| 3 | + |
| 4 | +package com.pulumi.kubernetes.apiextensions; |
| 5 | + |
| 6 | +import java.util.Optional; |
| 7 | +import java.util.concurrent.ExecutionException; |
| 8 | + |
| 9 | +import javax.annotation.Nullable; |
| 10 | + |
| 11 | +import com.pulumi.core.Output; |
| 12 | +import com.pulumi.core.annotations.Export; |
| 13 | +import com.pulumi.core.annotations.ResourceType; |
| 14 | +import com.pulumi.core.internal.Codegen; |
| 15 | +import com.pulumi.core.internal.Internal; |
| 16 | +import com.pulumi.core.internal.OutputInternal; |
| 17 | +import com.pulumi.kubernetes.Utilities; |
| 18 | +import com.pulumi.kubernetes.meta.v1.outputs.ObjectMetaPatch; |
| 19 | +import com.pulumi.resources.ResourceArgs; |
| 20 | + |
| 21 | +/** |
| 22 | + * Patch resources are used to modify existing Kubernetes resources by using |
| 23 | + * Server-Side Apply updates. The name of the resource must be specified, but all other properties are optional. More than |
| 24 | + * one patch may be applied to the same resource, and a random FieldManager name will be used for each Patch resource. |
| 25 | + * Conflicts will result in an error by default, but can be forced using the "pulumi.com/patchForce" annotation. See the |
| 26 | + * [Server-Side Apply Docs](https://www.pulumi.com/registry/packages/kubernetes/how-to-guides/managing-resources-with-server-side-apply/) for |
| 27 | + * additional information about using Server-Side Apply to manage Kubernetes resources with Pulumi. |
| 28 | + * |
| 29 | + * CustomResourcePatch represents an instance of a CustomResourceDefinition (CRD). For example, the |
| 30 | + * CoreOS Prometheus operator exposes a CRD `monitoring.coreos.com/ServiceMonitor`; to |
| 31 | + * instantiate this as a Pulumi resource, one could call `new CustomResourcePatch`, passing the |
| 32 | + * `ServiceMonitor` resource definition as an argument. |
| 33 | + */ |
| 34 | +@ResourceType(type="kubernetes:apiextensions:CustomResourcePatch") |
| 35 | +public class CustomResourcePatch extends com.pulumi.resources.CustomResource { |
| 36 | + /** |
| 37 | + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
| 38 | + * |
| 39 | + */ |
| 40 | + @Export(name="apiVersion", refs={String.class}, tree="[0]") |
| 41 | + private Output</* @Nullable */ String> apiVersion; |
| 42 | + |
| 43 | + /** |
| 44 | + * @return APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
| 45 | + * |
| 46 | + */ |
| 47 | + public Output<Optional<String>> apiVersion() { |
| 48 | + return Codegen.optional(this.apiVersion); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 53 | + * |
| 54 | + */ |
| 55 | + @Export(name="kind", refs={String.class}, tree="[0]") |
| 56 | + private Output</* @Nullable */ String> kind; |
| 57 | + |
| 58 | + /** |
| 59 | + * @return Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 60 | + * |
| 61 | + */ |
| 62 | + public Output<Optional<String>> kind() { |
| 63 | + return Codegen.optional(this.kind); |
| 64 | + } |
| 65 | + /** |
| 66 | + * Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 67 | + * |
| 68 | + */ |
| 69 | + @Export(name="metadata", refs={ObjectMetaPatch.class}, tree="[0]") |
| 70 | + private Output</* @Nullable */ ObjectMetaPatch> metadata; |
| 71 | + |
| 72 | + /** |
| 73 | + * @return Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 74 | + * |
| 75 | + */ |
| 76 | + public Output<Optional<ObjectMetaPatch>> metadata() { |
| 77 | + return Codegen.optional(this.metadata); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * |
| 82 | + * @param name The _unique_ name of the resulting resource. |
| 83 | + */ |
| 84 | + public CustomResourcePatch(String name) { |
| 85 | + this(name, CustomResourcePatchArgs.Empty); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * |
| 90 | + * @param name The _unique_ name of the resulting resource. |
| 91 | + * @param args The arguments to use to populate this resource's properties. |
| 92 | + */ |
| 93 | + public CustomResourcePatch(String name, @Nullable CustomResourcePatchArgsBase args) { |
| 94 | + this(name, args, null); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * |
| 99 | + * @param name The _unique_ name of the resulting resource. |
| 100 | + * @param args The arguments to use to populate this resource's properties. |
| 101 | + * @param options A bag of options that control this resource's behavior. |
| 102 | + */ |
| 103 | + public CustomResourcePatch(String name, @Nullable CustomResourcePatchArgsBase args, @Nullable com.pulumi.resources.CustomResourceOptions options) { |
| 104 | + super(makeType(args), name, makeArgs(args), makeResourceOptions(options, Codegen.empty())); |
| 105 | + } |
| 106 | + |
| 107 | + private static String makeType(@Nullable CustomResourcePatchArgsBase args) { |
| 108 | + String apiVersion = args.apiVersion().map(Internal::of).map(CustomResourcePatch::getOutputValue).orElse(""); |
| 109 | + String kind = args.kind().map(Internal::of).map(CustomResourcePatch::getOutputValue).orElse(""); |
| 110 | + return String.format("kubernetes:%s:%sPatch", apiVersion, kind); |
| 111 | + } |
| 112 | + |
| 113 | + private static String getOutputValue(OutputInternal<String> o) { |
| 114 | + try { |
| 115 | + return o.getValueOrDefault("").get(); |
| 116 | + } catch (InterruptedException | ExecutionException e) { |
| 117 | + throw new RuntimeException(e); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + private static ResourceArgs makeArgs(@Nullable CustomResourcePatchArgsBase args) { |
| 122 | + if (args == null) { |
| 123 | + return null; |
| 124 | + } |
| 125 | + if (args.otherFields().isEmpty() || args.otherFields().get().isEmpty()) { |
| 126 | + // optimization: if there are no "other" fields, we can just use the args as-is. |
| 127 | + // Otherwise we generate a subclass of ResourceArgs that includes the "other" fields. |
| 128 | + return args; |
| 129 | + } |
| 130 | + return Util.generateResourceArgs(args, args.otherFields().get()); |
| 131 | + } |
| 132 | + |
| 133 | + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions( |
| 134 | + @Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) { |
| 135 | + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() |
| 136 | + .version(Utilities.getVersion()) |
| 137 | + .build(); |
| 138 | + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); |
| 139 | + } |
| 140 | +} |
0 commit comments