github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/simple-resource-schema/go/example/fooResource.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 FooResource struct {
    14  	pulumi.ResourceState
    15  
    16  	Foo ResourceOutput `pulumi:"foo"`
    17  }
    18  
    19  // NewFooResource registers a new resource with the given unique name, arguments, and options.
    20  func NewFooResource(ctx *pulumi.Context,
    21  	name string, args *FooResourceArgs, opts ...pulumi.ResourceOption) (*FooResource, error) {
    22  	if args == nil {
    23  		args = &FooResourceArgs{}
    24  	}
    25  
    26  	opts = pkgResourceDefaultOpts(opts)
    27  	var resource FooResource
    28  	err := ctx.RegisterRemoteComponentResource("foo::FooResource", name, args, &resource, opts...)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  	return &resource, nil
    33  }
    34  
    35  type fooResourceArgs struct {
    36  	Foo *Resource `pulumi:"foo"`
    37  }
    38  
    39  // The set of arguments for constructing a FooResource resource.
    40  type FooResourceArgs struct {
    41  	Foo ResourceInput
    42  }
    43  
    44  func (FooResourceArgs) ElementType() reflect.Type {
    45  	return reflect.TypeOf((*fooResourceArgs)(nil)).Elem()
    46  }
    47  
    48  type FooResourceInput interface {
    49  	pulumi.Input
    50  
    51  	ToFooResourceOutput() FooResourceOutput
    52  	ToFooResourceOutputWithContext(ctx context.Context) FooResourceOutput
    53  }
    54  
    55  func (*FooResource) ElementType() reflect.Type {
    56  	return reflect.TypeOf((**FooResource)(nil)).Elem()
    57  }
    58  
    59  func (i *FooResource) ToFooResourceOutput() FooResourceOutput {
    60  	return i.ToFooResourceOutputWithContext(context.Background())
    61  }
    62  
    63  func (i *FooResource) ToFooResourceOutputWithContext(ctx context.Context) FooResourceOutput {
    64  	return pulumi.ToOutputWithContext(ctx, i).(FooResourceOutput)
    65  }
    66  
    67  type FooResourceOutput struct{ *pulumi.OutputState }
    68  
    69  func (FooResourceOutput) ElementType() reflect.Type {
    70  	return reflect.TypeOf((**FooResource)(nil)).Elem()
    71  }
    72  
    73  func (o FooResourceOutput) ToFooResourceOutput() FooResourceOutput {
    74  	return o
    75  }
    76  
    77  func (o FooResourceOutput) ToFooResourceOutputWithContext(ctx context.Context) FooResourceOutput {
    78  	return o
    79  }
    80  
    81  func (o FooResourceOutput) Foo() ResourceOutput {
    82  	return o.ApplyT(func(v *FooResource) ResourceOutput { return v.Foo }).(ResourceOutput)
    83  }
    84  
    85  func init() {
    86  	pulumi.RegisterInputType(reflect.TypeOf((*FooResourceInput)(nil)).Elem(), &FooResource{})
    87  	pulumi.RegisterOutputType(FooResourceOutput{})
    88  }