|
| 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.ObjectMeta; |
| 19 | +import com.pulumi.resources.ResourceArgs; |
| 20 | + |
| 21 | +/** |
| 22 | + * CustomResource represents an instance of a CustomResourceDefinition (CRD). For example, the |
| 23 | + * CoreOS Prometheus operator exposes a CRD `monitoring.coreos.com/ServiceMonitor`; to |
| 24 | + * instantiate this as a Pulumi resource, one could call `new CustomResource`, passing the |
| 25 | + * `ServiceMonitor` resource definition as an argument. |
| 26 | + */ |
| 27 | +@ResourceType(type="kubernetes:apiextensions:CustomResource") |
| 28 | +public class CustomResource extends com.pulumi.resources.CustomResource { |
| 29 | + /** |
| 30 | + * 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 |
| 31 | + * |
| 32 | + */ |
| 33 | + @Export(name="apiVersion", refs={String.class}, tree="[0]") |
| 34 | + private Output<String> apiVersion; |
| 35 | + |
| 36 | + /** |
| 37 | + * @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 |
| 38 | + * |
| 39 | + */ |
| 40 | + public Output<String> apiVersion() { |
| 41 | + return this.apiVersion; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * 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 |
| 46 | + * |
| 47 | + */ |
| 48 | + @Export(name="kind", refs={String.class}, tree="[0]") |
| 49 | + private Output<String> kind; |
| 50 | + |
| 51 | + /** |
| 52 | + * @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 |
| 53 | + * |
| 54 | + */ |
| 55 | + public Output<String> kind() { |
| 56 | + return this.kind; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 61 | + * |
| 62 | + */ |
| 63 | + @Export(name="metadata", refs={ObjectMeta.class}, tree="[0]") |
| 64 | + private Output<ObjectMeta> metadata; |
| 65 | + |
| 66 | + /** |
| 67 | + * @return Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 68 | + * |
| 69 | + */ |
| 70 | + public Output<ObjectMeta> metadata() { |
| 71 | + return this.metadata; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * |
| 76 | + * @param name The _unique_ name of the resulting resource. |
| 77 | + */ |
| 78 | + public CustomResource(String name) { |
| 79 | + this(name, CustomResourceArgs.Empty); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * |
| 84 | + * @param name The _unique_ name of the resulting resource. |
| 85 | + * @param args The arguments to use to populate this resource's properties. |
| 86 | + */ |
| 87 | + public CustomResource(String name, @Nullable CustomResourceArgsBase args) { |
| 88 | + this(name, args, null); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * |
| 93 | + * @param name The _unique_ name of the resulting resource. |
| 94 | + * @param args The arguments to use to populate this resource's properties. |
| 95 | + * @param options A bag of options that control this resource's behavior. |
| 96 | + */ |
| 97 | + public CustomResource(String name, @Nullable CustomResourceArgsBase args, @Nullable com.pulumi.resources.CustomResourceOptions options) { |
| 98 | + super(makeType(args), name, makeArgs(args), makeResourceOptions(options, Codegen.empty())); |
| 99 | + } |
| 100 | + |
| 101 | + protected CustomResource(String name, String apiVersion, String kind, Output<String> id, |
| 102 | + @Nullable com.pulumi.resources.CustomResourceOptions options) { |
| 103 | + super(String.format("kubernetes:%s:%s", apiVersion, kind), name, null, makeResourceOptions(options, id)); |
| 104 | + } |
| 105 | + |
| 106 | + private static String makeType(@Nullable CustomResourceArgsBase args) { |
| 107 | + String apiVersion = args.apiVersion().map(Internal::of).map(CustomResource::getOutputValue).orElse(""); |
| 108 | + String kind = args.kind().map(Internal::of).map(CustomResource::getOutputValue).orElse(""); |
| 109 | + return String.format("kubernetes:%s:%s", apiVersion, kind); |
| 110 | + } |
| 111 | + |
| 112 | + private static String getOutputValue(OutputInternal<String> o) { |
| 113 | + try { |
| 114 | + return o.getValueOrDefault("").get(); |
| 115 | + } catch (InterruptedException | ExecutionException e) { |
| 116 | + throw new RuntimeException(e); |
| 117 | + } |
| 118 | + } |
| 119 | + |
| 120 | + private static ResourceArgs makeArgs(@Nullable CustomResourceArgsBase args) { |
| 121 | + if (args == null) { |
| 122 | + return null; |
| 123 | + } |
| 124 | + if (args.otherFields().isEmpty() || args.otherFields().get().isEmpty()) { |
| 125 | + // optimization: if there are no "other" fields, we can just return the args as-is. |
| 126 | + return args; |
| 127 | + } |
| 128 | + return Util.generateResourceArgs(args, args.otherFields().get()); |
| 129 | + } |
| 130 | + |
| 131 | + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions( |
| 132 | + @Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) { |
| 133 | + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() |
| 134 | + .version(Utilities.getVersion()) |
| 135 | + .build(); |
| 136 | + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Get the state of an existing `CustomResource` resource, as identified by `id`. |
| 141 | + * Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted, |
| 142 | + * then (per Kubernetes convention) the ID becomes default/[name]. |
| 143 | + * |
| 144 | + * @param name The _unique_ name of the resulting resource. |
| 145 | + * @param apiVersion The API version of the CustomResource we wish to select, as defined by the CRD. |
| 146 | + * @param kind The kind of the CustomResource we wish to select, as defined by the CRD. |
| 147 | + * @param id An ID for the Kubernetes resource to retrieve. |
| 148 | + * @param options Optional settings to control the behavior of the CustomResource. |
| 149 | + */ |
| 150 | + public static CustomResource get(String name, String apiVersion, String kind, Output<String> id, |
| 151 | + @Nullable com.pulumi.resources.CustomResourceOptions options) { |
| 152 | + return new CustomResource(name, apiVersion, kind, id, options); |
| 153 | + } |
| 154 | +} |
0 commit comments