github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.30.2/go/kubernetes/apiextensions/customResource.go (about)

     1  // Copyright 2016-2020, Pulumi Corporation.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // *** WARNING: this file was generated by pulumigen. ***
    16  // *** Do not edit by hand unless you're certain you know what you are doing! ***
    17  
    18  package apiextensions
    19  
    20  import (
    21  	"fmt"
    22  	"reflect"
    23  
    24  	"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes"
    25  	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    26  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  )
    28  
    29  // CustomResource represents a resource definition we'd use to create an instance of a
    30  // Kubernetes CustomResourceDefinition (CRD). For example, the CoreOS Prometheus operator
    31  // exposes a CRD `monitoring.coreos.com/ServiceMonitor`; to create a `ServiceMonitor`, we'd
    32  // pass a `CustomResourceArgs` containing the `ServiceMonitor` definition to `apiextensions.CustomResource`.
    33  type CustomResource struct {
    34  	pulumi.CustomResourceState
    35  
    36  	// 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
    37  	ApiVersion pulumi.StringOutput `pulumi:"apiVersion"`
    38  	// 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
    39  	Kind pulumi.StringOutput `pulumi:"kind"`
    40  	// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.
    41  	Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"`
    42  	// Untyped map that holds any user-defined fields.
    43  	OtherFields pulumi.MapOutput `pulumi:""`
    44  }
    45  
    46  // NewCustomResource registers a new resource with the given unique name, arguments, and options.
    47  func NewCustomResource(ctx *pulumi.Context,
    48  	name string, args *CustomResourceArgs, opts ...pulumi.ResourceOption) (*CustomResource, error) {
    49  	if args == nil {
    50  		args = &CustomResourceArgs{}
    51  	}
    52  
    53  	untyped := kubernetes.UntypedArgs{}
    54  	for k, v := range args.OtherFields {
    55  		untyped[k] = v
    56  	}
    57  	untyped["apiVersion"] = args.ApiVersion
    58  	untyped["kind"] = args.Kind
    59  	untyped["metadata"] = args.Metadata
    60  
    61  	var resource CustomResource
    62  	err := ctx.RegisterResource(fmt.Sprintf("kubernetes:%s:%s", args.ApiVersion, args.Kind), name, untyped, &resource, opts...)
    63  	if err != nil {
    64  		return nil, err
    65  	}
    66  	return &resource, nil
    67  }
    68  
    69  // GetCustomResource gets an existing CustomResource resource's state with the given name, ID, and optional
    70  // state properties that are used to uniquely qualify the lookup (nil if not required).
    71  func GetCustomResource(ctx *pulumi.Context,
    72  	name string, id pulumi.IDInput, state *CustomResourceState, opts ...pulumi.ResourceOption) (*CustomResource, error) {
    73  	var resource CustomResource
    74  	err := ctx.ReadResource(fmt.Sprintf("kubernetes:%s:%s", state.ApiVersion, state.Kind), name, id, state, &resource, opts...)
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  	return &resource, nil
    79  }
    80  
    81  // Input properties used for looking up and filtering CustomResource resources.
    82  type customResourceState struct {
    83  	// 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
    84  	ApiVersion *string `pulumi:"apiVersion"`
    85  	// 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
    86  	Kind *string `pulumi:"kind"`
    87  	// Standard object metadata.
    88  	Metadata *metav1.ObjectMeta `pulumi:"metadata"`
    89  }
    90  
    91  type CustomResourceState struct {
    92  	// 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
    93  	ApiVersion pulumi.StringPtrInput
    94  	// 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
    95  	Kind pulumi.StringPtrInput
    96  	// Standard object metadata.
    97  	Metadata metav1.ObjectMetaPtrInput
    98  }
    99  
   100  func (CustomResourceState) ElementType() reflect.Type {
   101  	return reflect.TypeOf((*customResourceState)(nil)).Elem()
   102  }
   103  
   104  type customResourceArgs struct {
   105  	// 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
   106  	ApiVersion string `pulumi:"apiVersion"`
   107  	// 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
   108  	Kind string `pulumi:"kind"`
   109  	// Standard object metadata.
   110  	Metadata *metav1.ObjectMeta `pulumi:"metadata"`
   111  	// Untyped map that holds any user-defined fields.
   112  	OtherFields map[string]interface{} `pulumi:""`
   113  }
   114  
   115  // The set of arguments for constructing a CustomResource resource.
   116  type CustomResourceArgs struct {
   117  	// 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
   118  	ApiVersion pulumi.StringInput
   119  	// 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
   120  	Kind pulumi.StringInput
   121  	// Standard object metadata.
   122  	Metadata metav1.ObjectMetaPtrInput
   123  	// Untyped map that holds any user-defined fields.
   124  	OtherFields kubernetes.UntypedArgs
   125  }
   126  
   127  func (CustomResourceArgs) ElementType() reflect.Type {
   128  	return reflect.TypeOf((*customResourceArgs)(nil)).Elem()
   129  }