github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/simple-resource-schema-custom-pypackage-name/go/example/resource.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/pulumi/pulumi/sdk/v3/go/pulumi"
    11  )
    12  
    13  type Resource struct {
    14  	pulumi.CustomResourceState
    15  
    16  	Bar pulumi.StringPtrOutput `pulumi:"bar"`
    17  }
    18  
    19  // NewResource registers a new resource with the given unique name, arguments, and options.
    20  func NewResource(ctx *pulumi.Context,
    21  	name string, args *ResourceArgs, opts ...pulumi.ResourceOption) (*Resource, error) {
    22  	if args == nil {
    23  		args = &ResourceArgs{}
    24  	}
    25  
    26  	var resource Resource
    27  	err := ctx.RegisterResource("example::Resource", name, args, &resource, opts...)
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  	return &resource, nil
    32  }
    33  
    34  // GetResource gets an existing Resource resource's state with the given name, ID, and optional
    35  // state properties that are used to uniquely qualify the lookup (nil if not required).
    36  func GetResource(ctx *pulumi.Context,
    37  	name string, id pulumi.IDInput, state *ResourceState, opts ...pulumi.ResourceOption) (*Resource, error) {
    38  	var resource Resource
    39  	err := ctx.ReadResource("example::Resource", name, id, state, &resource, opts...)
    40  	if err != nil {
    41  		return nil, err
    42  	}
    43  	return &resource, nil
    44  }
    45  
    46  // Input properties used for looking up and filtering Resource resources.
    47  type resourceState struct {
    48  }
    49  
    50  type ResourceState struct {
    51  }
    52  
    53  func (ResourceState) ElementType() reflect.Type {
    54  	return reflect.TypeOf((*resourceState)(nil)).Elem()
    55  }
    56  
    57  type resourceArgs struct {
    58  	Bar *string `pulumi:"bar"`
    59  }
    60  
    61  // The set of arguments for constructing a Resource resource.
    62  type ResourceArgs struct {
    63  	Bar pulumi.StringPtrInput
    64  }
    65  
    66  func (ResourceArgs) ElementType() reflect.Type {
    67  	return reflect.TypeOf((*resourceArgs)(nil)).Elem()
    68  }
    69  
    70  type ResourceInput interface {
    71  	pulumi.Input
    72  
    73  	ToResourceOutput() ResourceOutput
    74  	ToResourceOutputWithContext(ctx context.Context) ResourceOutput
    75  }
    76  
    77  func (*Resource) ElementType() reflect.Type {
    78  	return reflect.TypeOf((**Resource)(nil)).Elem()
    79  }
    80  
    81  func (i *Resource) ToResourceOutput() ResourceOutput {
    82  	return i.ToResourceOutputWithContext(context.Background())
    83  }
    84  
    85  func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
    86  	return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput)
    87  }
    88  
    89  type ResourceOutput struct{ *pulumi.OutputState }
    90  
    91  func (ResourceOutput) ElementType() reflect.Type {
    92  	return reflect.TypeOf((**Resource)(nil)).Elem()
    93  }
    94  
    95  func (o ResourceOutput) ToResourceOutput() ResourceOutput {
    96  	return o
    97  }
    98  
    99  func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
   100  	return o
   101  }
   102  
   103  func (o ResourceOutput) Bar() pulumi.StringPtrOutput {
   104  	return o.ApplyT(func(v *Resource) pulumi.StringPtrOutput { return v.Bar }).(pulumi.StringPtrOutput)
   105  }
   106  
   107  func init() {
   108  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceInput)(nil)).Elem(), &Resource{})
   109  	pulumi.RegisterOutputType(ResourceOutput{})
   110  }