pulumi/tests/testdata/codegen/plain-and-default/go/foo/moduleResource.go

208 lines
6.6 KiB
Go

// Code generated by test DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package foo
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
"plain-and-default/foo/internal"
)
type ModuleResource struct {
pulumi.CustomResourceState
OptionalBool pulumi.BoolPtrOutput `pulumi:"optionalBool"`
}
// NewModuleResource registers a new resource with the given unique name, arguments, and options.
func NewModuleResource(ctx *pulumi.Context,
name string, args *ModuleResourceArgs, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.OptionalBool == nil {
args.OptionalBool = pulumi.BoolPtr(true)
}
args.OptionalConst = pulumi.StringPtr("val")
if args.OptionalEnum == nil {
args.OptionalEnum = EnumThing(8)
}
if args.OptionalNumber == nil {
args.OptionalNumber = pulumi.Float64Ptr(42.0)
}
if args.OptionalString == nil {
args.OptionalString = pulumi.StringPtr("buzzer")
}
if args.PlainOptionalBool == nil {
plainOptionalBool_ := true
args.PlainOptionalBool = &plainOptionalBool_
}
plainOptionalConst_ := "val"
args.PlainOptionalConst = &plainOptionalConst_
if args.PlainOptionalNumber == nil {
plainOptionalNumber_ := 42.0
args.PlainOptionalNumber = &plainOptionalNumber_
}
if args.PlainOptionalString == nil {
plainOptionalString_ := "buzzer"
args.PlainOptionalString = &plainOptionalString_
}
if internal.IsZero(args.PlainRequiredBool) {
args.PlainRequiredBool = true
}
args.PlainRequiredConst = "val"
if internal.IsZero(args.PlainRequiredNumber) {
args.PlainRequiredNumber = 42.0
}
if internal.IsZero(args.PlainRequiredString) {
args.PlainRequiredString = "buzzer"
}
if args.RequiredBool == nil {
args.RequiredBool = pulumi.Bool(true)
}
if args.RequiredEnum == nil {
args.RequiredEnum = EnumThing(4)
}
if args.RequiredNumber == nil {
args.RequiredNumber = pulumi.Float64(42.0)
}
if args.RequiredString == nil {
args.RequiredString = pulumi.String("buzzer")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource ModuleResource
err := ctx.RegisterResource("foobar::ModuleResource", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetModuleResource gets an existing ModuleResource resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetModuleResource(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ModuleResourceState, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
var resource ModuleResource
err := ctx.ReadResource("foobar::ModuleResource", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ModuleResource resources.
type moduleResourceState struct {
}
type ModuleResourceState struct {
}
func (ModuleResourceState) ElementType() reflect.Type {
return reflect.TypeOf((*moduleResourceState)(nil)).Elem()
}
type moduleResourceArgs struct {
OptionalBool *bool `pulumi:"optionalBool"`
OptionalConst *string `pulumi:"optionalConst"`
OptionalEnum *EnumThing `pulumi:"optionalEnum"`
OptionalNumber *float64 `pulumi:"optionalNumber"`
OptionalString *string `pulumi:"optionalString"`
PlainOptionalBool *bool `pulumi:"plainOptionalBool"`
PlainOptionalConst *string `pulumi:"plainOptionalConst"`
PlainOptionalNumber *float64 `pulumi:"plainOptionalNumber"`
PlainOptionalString *string `pulumi:"plainOptionalString"`
PlainRequiredBool bool `pulumi:"plainRequiredBool"`
PlainRequiredConst string `pulumi:"plainRequiredConst"`
PlainRequiredNumber float64 `pulumi:"plainRequiredNumber"`
PlainRequiredString string `pulumi:"plainRequiredString"`
RequiredBool bool `pulumi:"requiredBool"`
RequiredEnum EnumThing `pulumi:"requiredEnum"`
RequiredNumber float64 `pulumi:"requiredNumber"`
RequiredString string `pulumi:"requiredString"`
}
// The set of arguments for constructing a ModuleResource resource.
type ModuleResourceArgs struct {
OptionalBool pulumi.BoolPtrInput
OptionalConst pulumi.StringPtrInput
OptionalEnum EnumThingPtrInput
OptionalNumber pulumi.Float64PtrInput
OptionalString pulumi.StringPtrInput
PlainOptionalBool *bool
PlainOptionalConst *string
PlainOptionalNumber *float64
PlainOptionalString *string
PlainRequiredBool bool
PlainRequiredConst string
PlainRequiredNumber float64
PlainRequiredString string
RequiredBool pulumi.BoolInput
RequiredEnum EnumThingInput
RequiredNumber pulumi.Float64Input
RequiredString pulumi.StringInput
}
func (ModuleResourceArgs) ElementType() reflect.Type {
return reflect.TypeOf((*moduleResourceArgs)(nil)).Elem()
}
type ModuleResourceInput interface {
pulumi.Input
ToModuleResourceOutput() ModuleResourceOutput
ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput
}
func (*ModuleResource) ElementType() reflect.Type {
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
return i.ToModuleResourceOutputWithContext(context.Background())
}
func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
return pulumi.ToOutputWithContext(ctx, i).(ModuleResourceOutput)
}
func (i *ModuleResource) ToOutput(ctx context.Context) pulumix.Output[*ModuleResource] {
return pulumix.Output[*ModuleResource]{
OutputState: i.ToModuleResourceOutputWithContext(ctx).OutputState,
}
}
type ModuleResourceOutput struct{ *pulumi.OutputState }
func (ModuleResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
return o
}
func (o ModuleResourceOutput) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
return o
}
func (o ModuleResourceOutput) ToOutput(ctx context.Context) pulumix.Output[*ModuleResource] {
return pulumix.Output[*ModuleResource]{
OutputState: o.OutputState,
}
}
func (o ModuleResourceOutput) OptionalBool() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ModuleResource) pulumi.BoolPtrOutput { return v.OptionalBool }).(pulumi.BoolPtrOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ModuleResourceInput)(nil)).Elem(), &ModuleResource{})
pulumi.RegisterOutputType(ModuleResourceOutput{})
}