github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/resource-args-python/go/example/pet.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 Pet struct { 14 pulumi.CustomResourceState 15 16 Name pulumi.StringPtrOutput `pulumi:"name"` 17 } 18 19 // NewPet registers a new resource with the given unique name, arguments, and options. 20 func NewPet(ctx *pulumi.Context, 21 name string, args *PetArgs, opts ...pulumi.ResourceOption) (*Pet, error) { 22 if args == nil { 23 args = &PetArgs{} 24 } 25 26 var resource Pet 27 err := ctx.RegisterResource("example::Pet", name, args, &resource, opts...) 28 if err != nil { 29 return nil, err 30 } 31 return &resource, nil 32 } 33 34 // GetPet gets an existing Pet 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 GetPet(ctx *pulumi.Context, 37 name string, id pulumi.IDInput, state *PetState, opts ...pulumi.ResourceOption) (*Pet, error) { 38 var resource Pet 39 err := ctx.ReadResource("example::Pet", 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 Pet resources. 47 type petState struct { 48 } 49 50 type PetState struct { 51 } 52 53 func (PetState) ElementType() reflect.Type { 54 return reflect.TypeOf((*petState)(nil)).Elem() 55 } 56 57 type petArgs struct { 58 Name *string `pulumi:"name"` 59 } 60 61 // The set of arguments for constructing a Pet resource. 62 type PetArgs struct { 63 Name pulumi.StringPtrInput 64 } 65 66 func (PetArgs) ElementType() reflect.Type { 67 return reflect.TypeOf((*petArgs)(nil)).Elem() 68 } 69 70 type PetInput interface { 71 pulumi.Input 72 73 ToPetOutput() PetOutput 74 ToPetOutputWithContext(ctx context.Context) PetOutput 75 } 76 77 func (*Pet) ElementType() reflect.Type { 78 return reflect.TypeOf((**Pet)(nil)).Elem() 79 } 80 81 func (i *Pet) ToPetOutput() PetOutput { 82 return i.ToPetOutputWithContext(context.Background()) 83 } 84 85 func (i *Pet) ToPetOutputWithContext(ctx context.Context) PetOutput { 86 return pulumi.ToOutputWithContext(ctx, i).(PetOutput) 87 } 88 89 // PetArrayInput is an input type that accepts PetArray and PetArrayOutput values. 90 // You can construct a concrete instance of `PetArrayInput` via: 91 // 92 // PetArray{ PetArgs{...} } 93 type PetArrayInput interface { 94 pulumi.Input 95 96 ToPetArrayOutput() PetArrayOutput 97 ToPetArrayOutputWithContext(context.Context) PetArrayOutput 98 } 99 100 type PetArray []PetInput 101 102 func (PetArray) ElementType() reflect.Type { 103 return reflect.TypeOf((*[]*Pet)(nil)).Elem() 104 } 105 106 func (i PetArray) ToPetArrayOutput() PetArrayOutput { 107 return i.ToPetArrayOutputWithContext(context.Background()) 108 } 109 110 func (i PetArray) ToPetArrayOutputWithContext(ctx context.Context) PetArrayOutput { 111 return pulumi.ToOutputWithContext(ctx, i).(PetArrayOutput) 112 } 113 114 // PetMapInput is an input type that accepts PetMap and PetMapOutput values. 115 // You can construct a concrete instance of `PetMapInput` via: 116 // 117 // PetMap{ "key": PetArgs{...} } 118 type PetMapInput interface { 119 pulumi.Input 120 121 ToPetMapOutput() PetMapOutput 122 ToPetMapOutputWithContext(context.Context) PetMapOutput 123 } 124 125 type PetMap map[string]PetInput 126 127 func (PetMap) ElementType() reflect.Type { 128 return reflect.TypeOf((*map[string]*Pet)(nil)).Elem() 129 } 130 131 func (i PetMap) ToPetMapOutput() PetMapOutput { 132 return i.ToPetMapOutputWithContext(context.Background()) 133 } 134 135 func (i PetMap) ToPetMapOutputWithContext(ctx context.Context) PetMapOutput { 136 return pulumi.ToOutputWithContext(ctx, i).(PetMapOutput) 137 } 138 139 type PetOutput struct{ *pulumi.OutputState } 140 141 func (PetOutput) ElementType() reflect.Type { 142 return reflect.TypeOf((**Pet)(nil)).Elem() 143 } 144 145 func (o PetOutput) ToPetOutput() PetOutput { 146 return o 147 } 148 149 func (o PetOutput) ToPetOutputWithContext(ctx context.Context) PetOutput { 150 return o 151 } 152 153 func (o PetOutput) Name() pulumi.StringPtrOutput { 154 return o.ApplyT(func(v *Pet) pulumi.StringPtrOutput { return v.Name }).(pulumi.StringPtrOutput) 155 } 156 157 type PetArrayOutput struct{ *pulumi.OutputState } 158 159 func (PetArrayOutput) ElementType() reflect.Type { 160 return reflect.TypeOf((*[]*Pet)(nil)).Elem() 161 } 162 163 func (o PetArrayOutput) ToPetArrayOutput() PetArrayOutput { 164 return o 165 } 166 167 func (o PetArrayOutput) ToPetArrayOutputWithContext(ctx context.Context) PetArrayOutput { 168 return o 169 } 170 171 func (o PetArrayOutput) Index(i pulumi.IntInput) PetOutput { 172 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Pet { 173 return vs[0].([]*Pet)[vs[1].(int)] 174 }).(PetOutput) 175 } 176 177 type PetMapOutput struct{ *pulumi.OutputState } 178 179 func (PetMapOutput) ElementType() reflect.Type { 180 return reflect.TypeOf((*map[string]*Pet)(nil)).Elem() 181 } 182 183 func (o PetMapOutput) ToPetMapOutput() PetMapOutput { 184 return o 185 } 186 187 func (o PetMapOutput) ToPetMapOutputWithContext(ctx context.Context) PetMapOutput { 188 return o 189 } 190 191 func (o PetMapOutput) MapIndex(k pulumi.StringInput) PetOutput { 192 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Pet { 193 return vs[0].(map[string]*Pet)[vs[1].(string)] 194 }).(PetOutput) 195 } 196 197 func init() { 198 pulumi.RegisterInputType(reflect.TypeOf((*PetInput)(nil)).Elem(), &Pet{}) 199 pulumi.RegisterInputType(reflect.TypeOf((*PetArrayInput)(nil)).Elem(), PetArray{}) 200 pulumi.RegisterInputType(reflect.TypeOf((*PetMapInput)(nil)).Elem(), PetMap{}) 201 pulumi.RegisterOutputType(PetOutput{}) 202 pulumi.RegisterOutputType(PetArrayOutput{}) 203 pulumi.RegisterOutputType(PetMapOutput{}) 204 }