github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/external-resource-schema/go/example/component.go (about)

     1  // Code generated by test DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package example
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pkg/errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
    12  	"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes"
    13  	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    14  	storagev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/storage/v1"
    15  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    16  )
    17  
    18  type Component struct {
    19  	pulumi.CustomResourceState
    20  
    21  	Provider       kubernetes.ProviderOutput       `pulumi:"provider"`
    22  	SecurityGroup  ec2.SecurityGroupOutput         `pulumi:"securityGroup"`
    23  	StorageClasses storagev1.StorageClassMapOutput `pulumi:"storageClasses"`
    24  }
    25  
    26  // NewComponent registers a new resource with the given unique name, arguments, and options.
    27  func NewComponent(ctx *pulumi.Context,
    28  	name string, args *ComponentArgs, opts ...pulumi.ResourceOption) (*Component, error) {
    29  	if args == nil {
    30  		return nil, errors.New("missing one or more required arguments")
    31  	}
    32  
    33  	if args.RequiredMetadata == nil {
    34  		return nil, errors.New("invalid value for required argument 'RequiredMetadata'")
    35  	}
    36  	if args.RequiredMetadataArray == nil {
    37  		return nil, errors.New("invalid value for required argument 'RequiredMetadataArray'")
    38  	}
    39  	if args.RequiredMetadataMap == nil {
    40  		return nil, errors.New("invalid value for required argument 'RequiredMetadataMap'")
    41  	}
    42  	var resource Component
    43  	err := ctx.RegisterResource("example::Component", name, args, &resource, opts...)
    44  	if err != nil {
    45  		return nil, err
    46  	}
    47  	return &resource, nil
    48  }
    49  
    50  // GetComponent gets an existing Component resource's state with the given name, ID, and optional
    51  // state properties that are used to uniquely qualify the lookup (nil if not required).
    52  func GetComponent(ctx *pulumi.Context,
    53  	name string, id pulumi.IDInput, state *ComponentState, opts ...pulumi.ResourceOption) (*Component, error) {
    54  	var resource Component
    55  	err := ctx.ReadResource("example::Component", name, id, state, &resource, opts...)
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return &resource, nil
    60  }
    61  
    62  // Input properties used for looking up and filtering Component resources.
    63  type componentState struct {
    64  }
    65  
    66  type ComponentState struct {
    67  }
    68  
    69  func (ComponentState) ElementType() reflect.Type {
    70  	return reflect.TypeOf((*componentState)(nil)).Elem()
    71  }
    72  
    73  type componentArgs struct {
    74  	Metadata              *metav1.ObjectMeta           `pulumi:"metadata"`
    75  	MetadataArray         []metav1.ObjectMeta          `pulumi:"metadataArray"`
    76  	MetadataMap           map[string]metav1.ObjectMeta `pulumi:"metadataMap"`
    77  	RequiredMetadata      metav1.ObjectMeta            `pulumi:"requiredMetadata"`
    78  	RequiredMetadataArray []metav1.ObjectMeta          `pulumi:"requiredMetadataArray"`
    79  	RequiredMetadataMap   map[string]metav1.ObjectMeta `pulumi:"requiredMetadataMap"`
    80  }
    81  
    82  // The set of arguments for constructing a Component resource.
    83  type ComponentArgs struct {
    84  	Metadata              metav1.ObjectMetaPtrInput
    85  	MetadataArray         metav1.ObjectMetaArrayInput
    86  	MetadataMap           metav1.ObjectMetaMapInput
    87  	RequiredMetadata      metav1.ObjectMetaInput
    88  	RequiredMetadataArray metav1.ObjectMetaArrayInput
    89  	RequiredMetadataMap   metav1.ObjectMetaMapInput
    90  }
    91  
    92  func (ComponentArgs) ElementType() reflect.Type {
    93  	return reflect.TypeOf((*componentArgs)(nil)).Elem()
    94  }
    95  
    96  type ComponentInput interface {
    97  	pulumi.Input
    98  
    99  	ToComponentOutput() ComponentOutput
   100  	ToComponentOutputWithContext(ctx context.Context) ComponentOutput
   101  }
   102  
   103  func (*Component) ElementType() reflect.Type {
   104  	return reflect.TypeOf((**Component)(nil)).Elem()
   105  }
   106  
   107  func (i *Component) ToComponentOutput() ComponentOutput {
   108  	return i.ToComponentOutputWithContext(context.Background())
   109  }
   110  
   111  func (i *Component) ToComponentOutputWithContext(ctx context.Context) ComponentOutput {
   112  	return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput)
   113  }
   114  
   115  // ComponentArrayInput is an input type that accepts ComponentArray and ComponentArrayOutput values.
   116  // You can construct a concrete instance of `ComponentArrayInput` via:
   117  //
   118  //	ComponentArray{ ComponentArgs{...} }
   119  type ComponentArrayInput interface {
   120  	pulumi.Input
   121  
   122  	ToComponentArrayOutput() ComponentArrayOutput
   123  	ToComponentArrayOutputWithContext(context.Context) ComponentArrayOutput
   124  }
   125  
   126  type ComponentArray []ComponentInput
   127  
   128  func (ComponentArray) ElementType() reflect.Type {
   129  	return reflect.TypeOf((*[]*Component)(nil)).Elem()
   130  }
   131  
   132  func (i ComponentArray) ToComponentArrayOutput() ComponentArrayOutput {
   133  	return i.ToComponentArrayOutputWithContext(context.Background())
   134  }
   135  
   136  func (i ComponentArray) ToComponentArrayOutputWithContext(ctx context.Context) ComponentArrayOutput {
   137  	return pulumi.ToOutputWithContext(ctx, i).(ComponentArrayOutput)
   138  }
   139  
   140  // ComponentMapInput is an input type that accepts ComponentMap and ComponentMapOutput values.
   141  // You can construct a concrete instance of `ComponentMapInput` via:
   142  //
   143  //	ComponentMap{ "key": ComponentArgs{...} }
   144  type ComponentMapInput interface {
   145  	pulumi.Input
   146  
   147  	ToComponentMapOutput() ComponentMapOutput
   148  	ToComponentMapOutputWithContext(context.Context) ComponentMapOutput
   149  }
   150  
   151  type ComponentMap map[string]ComponentInput
   152  
   153  func (ComponentMap) ElementType() reflect.Type {
   154  	return reflect.TypeOf((*map[string]*Component)(nil)).Elem()
   155  }
   156  
   157  func (i ComponentMap) ToComponentMapOutput() ComponentMapOutput {
   158  	return i.ToComponentMapOutputWithContext(context.Background())
   159  }
   160  
   161  func (i ComponentMap) ToComponentMapOutputWithContext(ctx context.Context) ComponentMapOutput {
   162  	return pulumi.ToOutputWithContext(ctx, i).(ComponentMapOutput)
   163  }
   164  
   165  type ComponentOutput struct{ *pulumi.OutputState }
   166  
   167  func (ComponentOutput) ElementType() reflect.Type {
   168  	return reflect.TypeOf((**Component)(nil)).Elem()
   169  }
   170  
   171  func (o ComponentOutput) ToComponentOutput() ComponentOutput {
   172  	return o
   173  }
   174  
   175  func (o ComponentOutput) ToComponentOutputWithContext(ctx context.Context) ComponentOutput {
   176  	return o
   177  }
   178  
   179  func (o ComponentOutput) Provider() kubernetes.ProviderOutput {
   180  	return o.ApplyT(func(v *Component) kubernetes.ProviderOutput { return v.Provider }).(kubernetes.ProviderOutput)
   181  }
   182  
   183  func (o ComponentOutput) SecurityGroup() ec2.SecurityGroupOutput {
   184  	return o.ApplyT(func(v *Component) ec2.SecurityGroupOutput { return v.SecurityGroup }).(ec2.SecurityGroupOutput)
   185  }
   186  
   187  func (o ComponentOutput) StorageClasses() storagev1.StorageClassMapOutput {
   188  	return o.ApplyT(func(v *Component) storagev1.StorageClassMapOutput { return v.StorageClasses }).(storagev1.StorageClassMapOutput)
   189  }
   190  
   191  type ComponentArrayOutput struct{ *pulumi.OutputState }
   192  
   193  func (ComponentArrayOutput) ElementType() reflect.Type {
   194  	return reflect.TypeOf((*[]*Component)(nil)).Elem()
   195  }
   196  
   197  func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput {
   198  	return o
   199  }
   200  
   201  func (o ComponentArrayOutput) ToComponentArrayOutputWithContext(ctx context.Context) ComponentArrayOutput {
   202  	return o
   203  }
   204  
   205  func (o ComponentArrayOutput) Index(i pulumi.IntInput) ComponentOutput {
   206  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Component {
   207  		return vs[0].([]*Component)[vs[1].(int)]
   208  	}).(ComponentOutput)
   209  }
   210  
   211  type ComponentMapOutput struct{ *pulumi.OutputState }
   212  
   213  func (ComponentMapOutput) ElementType() reflect.Type {
   214  	return reflect.TypeOf((*map[string]*Component)(nil)).Elem()
   215  }
   216  
   217  func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput {
   218  	return o
   219  }
   220  
   221  func (o ComponentMapOutput) ToComponentMapOutputWithContext(ctx context.Context) ComponentMapOutput {
   222  	return o
   223  }
   224  
   225  func (o ComponentMapOutput) MapIndex(k pulumi.StringInput) ComponentOutput {
   226  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Component {
   227  		return vs[0].(map[string]*Component)[vs[1].(string)]
   228  	}).(ComponentOutput)
   229  }
   230  
   231  func init() {
   232  	pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{})
   233  	pulumi.RegisterInputType(reflect.TypeOf((*ComponentArrayInput)(nil)).Elem(), ComponentArray{})
   234  	pulumi.RegisterInputType(reflect.TypeOf((*ComponentMapInput)(nil)).Elem(), ComponentMap{})
   235  	pulumi.RegisterOutputType(ComponentOutput{})
   236  	pulumi.RegisterOutputType(ComponentArrayOutput{})
   237  	pulumi.RegisterOutputType(ComponentMapOutput{})
   238  }