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

183 lines
5.8 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 pulumix.Output[*bool] `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 = pulumix.Ptr(true)
}
args.OptionalConst = pulumix.Ptr("val")
if args.OptionalEnum == nil {
args.OptionalEnum = pulumix.Ptr(EnumThing(8))
}
if args.OptionalNumber == nil {
args.OptionalNumber = pulumix.Ptr(42.0)
}
if args.OptionalString == nil {
args.OptionalString = pulumix.Ptr("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 = pulumix.Val(true)
}
if args.RequiredEnum == nil {
args.RequiredEnum = pulumix.Val(EnumThing(4))
}
if args.RequiredNumber == nil {
args.RequiredNumber = pulumix.Val(42.0)
}
if args.RequiredString == nil {
args.RequiredString = pulumix.Val("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 pulumix.Input[*bool]
OptionalConst pulumix.Input[*string]
OptionalEnum pulumix.Input[*EnumThing]
OptionalNumber pulumix.Input[*float64]
OptionalString pulumix.Input[*string]
PlainOptionalBool *bool
PlainOptionalConst *string
PlainOptionalNumber *float64
PlainOptionalString *string
PlainRequiredBool bool
PlainRequiredConst string
PlainRequiredNumber float64
PlainRequiredString string
RequiredBool pulumix.Input[bool]
RequiredEnum pulumix.Input[EnumThing]
RequiredNumber pulumix.Input[float64]
RequiredString pulumix.Input[string]
}
func (ModuleResourceArgs) ElementType() reflect.Type {
return reflect.TypeOf((*moduleResourceArgs)(nil)).Elem()
}
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() pulumix.Output[*bool] {
value := pulumix.Apply[ModuleResource](o, func(v ModuleResource) pulumix.Output[*bool] { return v.OptionalBool })
return pulumix.Flatten[*bool, pulumix.Output[*bool]](value)
}
func init() {
pulumi.RegisterOutputType(ModuleResourceOutput{})
}