github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/resource.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package apigateway
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides an API Gateway Resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			myDemoAPI, err := apigateway.NewRestApi(ctx, "MyDemoAPI", &apigateway.RestApiArgs{
    33  //				Name:        pulumi.String("MyDemoAPI"),
    34  //				Description: pulumi.String("This is my API for demonstration purposes"),
    35  //			})
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			_, err = apigateway.NewResource(ctx, "MyDemoResource", &apigateway.ResourceArgs{
    40  //				RestApi:  myDemoAPI.ID(),
    41  //				ParentId: myDemoAPI.RootResourceId,
    42  //				PathPart: pulumi.String("mydemoresource"),
    43  //			})
    44  //			if err != nil {
    45  //				return err
    46  //			}
    47  //			return nil
    48  //		})
    49  //	}
    50  //
    51  // ```
    52  // <!--End PulumiCodeChooser -->
    53  //
    54  // ## Import
    55  //
    56  // Using `pulumi import`, import `aws_api_gateway_resource` using `REST-API-ID/RESOURCE-ID`. For example:
    57  //
    58  // ```sh
    59  // $ pulumi import aws:apigateway/resource:Resource example 12345abcde/67890fghij
    60  // ```
    61  type Resource struct {
    62  	pulumi.CustomResourceState
    63  
    64  	// ID of the parent API resource
    65  	ParentId pulumi.StringOutput `pulumi:"parentId"`
    66  	// Complete path for this API resource, including all parent paths.
    67  	Path pulumi.StringOutput `pulumi:"path"`
    68  	// Last path segment of this API resource.
    69  	PathPart pulumi.StringOutput `pulumi:"pathPart"`
    70  	// ID of the associated REST API
    71  	RestApi pulumi.StringOutput `pulumi:"restApi"`
    72  }
    73  
    74  // NewResource registers a new resource with the given unique name, arguments, and options.
    75  func NewResource(ctx *pulumi.Context,
    76  	name string, args *ResourceArgs, opts ...pulumi.ResourceOption) (*Resource, error) {
    77  	if args == nil {
    78  		return nil, errors.New("missing one or more required arguments")
    79  	}
    80  
    81  	if args.ParentId == nil {
    82  		return nil, errors.New("invalid value for required argument 'ParentId'")
    83  	}
    84  	if args.PathPart == nil {
    85  		return nil, errors.New("invalid value for required argument 'PathPart'")
    86  	}
    87  	if args.RestApi == nil {
    88  		return nil, errors.New("invalid value for required argument 'RestApi'")
    89  	}
    90  	opts = internal.PkgResourceDefaultOpts(opts)
    91  	var resource Resource
    92  	err := ctx.RegisterResource("aws:apigateway/resource:Resource", name, args, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // GetResource gets an existing Resource resource's state with the given name, ID, and optional
   100  // state properties that are used to uniquely qualify the lookup (nil if not required).
   101  func GetResource(ctx *pulumi.Context,
   102  	name string, id pulumi.IDInput, state *ResourceState, opts ...pulumi.ResourceOption) (*Resource, error) {
   103  	var resource Resource
   104  	err := ctx.ReadResource("aws:apigateway/resource:Resource", name, id, state, &resource, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	return &resource, nil
   109  }
   110  
   111  // Input properties used for looking up and filtering Resource resources.
   112  type resourceState struct {
   113  	// ID of the parent API resource
   114  	ParentId *string `pulumi:"parentId"`
   115  	// Complete path for this API resource, including all parent paths.
   116  	Path *string `pulumi:"path"`
   117  	// Last path segment of this API resource.
   118  	PathPart *string `pulumi:"pathPart"`
   119  	// ID of the associated REST API
   120  	RestApi interface{} `pulumi:"restApi"`
   121  }
   122  
   123  type ResourceState struct {
   124  	// ID of the parent API resource
   125  	ParentId pulumi.StringPtrInput
   126  	// Complete path for this API resource, including all parent paths.
   127  	Path pulumi.StringPtrInput
   128  	// Last path segment of this API resource.
   129  	PathPart pulumi.StringPtrInput
   130  	// ID of the associated REST API
   131  	RestApi pulumi.Input
   132  }
   133  
   134  func (ResourceState) ElementType() reflect.Type {
   135  	return reflect.TypeOf((*resourceState)(nil)).Elem()
   136  }
   137  
   138  type resourceArgs struct {
   139  	// ID of the parent API resource
   140  	ParentId string `pulumi:"parentId"`
   141  	// Last path segment of this API resource.
   142  	PathPart string `pulumi:"pathPart"`
   143  	// ID of the associated REST API
   144  	RestApi interface{} `pulumi:"restApi"`
   145  }
   146  
   147  // The set of arguments for constructing a Resource resource.
   148  type ResourceArgs struct {
   149  	// ID of the parent API resource
   150  	ParentId pulumi.StringInput
   151  	// Last path segment of this API resource.
   152  	PathPart pulumi.StringInput
   153  	// ID of the associated REST API
   154  	RestApi pulumi.Input
   155  }
   156  
   157  func (ResourceArgs) ElementType() reflect.Type {
   158  	return reflect.TypeOf((*resourceArgs)(nil)).Elem()
   159  }
   160  
   161  type ResourceInput interface {
   162  	pulumi.Input
   163  
   164  	ToResourceOutput() ResourceOutput
   165  	ToResourceOutputWithContext(ctx context.Context) ResourceOutput
   166  }
   167  
   168  func (*Resource) ElementType() reflect.Type {
   169  	return reflect.TypeOf((**Resource)(nil)).Elem()
   170  }
   171  
   172  func (i *Resource) ToResourceOutput() ResourceOutput {
   173  	return i.ToResourceOutputWithContext(context.Background())
   174  }
   175  
   176  func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
   177  	return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput)
   178  }
   179  
   180  // ResourceArrayInput is an input type that accepts ResourceArray and ResourceArrayOutput values.
   181  // You can construct a concrete instance of `ResourceArrayInput` via:
   182  //
   183  //	ResourceArray{ ResourceArgs{...} }
   184  type ResourceArrayInput interface {
   185  	pulumi.Input
   186  
   187  	ToResourceArrayOutput() ResourceArrayOutput
   188  	ToResourceArrayOutputWithContext(context.Context) ResourceArrayOutput
   189  }
   190  
   191  type ResourceArray []ResourceInput
   192  
   193  func (ResourceArray) ElementType() reflect.Type {
   194  	return reflect.TypeOf((*[]*Resource)(nil)).Elem()
   195  }
   196  
   197  func (i ResourceArray) ToResourceArrayOutput() ResourceArrayOutput {
   198  	return i.ToResourceArrayOutputWithContext(context.Background())
   199  }
   200  
   201  func (i ResourceArray) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
   202  	return pulumi.ToOutputWithContext(ctx, i).(ResourceArrayOutput)
   203  }
   204  
   205  // ResourceMapInput is an input type that accepts ResourceMap and ResourceMapOutput values.
   206  // You can construct a concrete instance of `ResourceMapInput` via:
   207  //
   208  //	ResourceMap{ "key": ResourceArgs{...} }
   209  type ResourceMapInput interface {
   210  	pulumi.Input
   211  
   212  	ToResourceMapOutput() ResourceMapOutput
   213  	ToResourceMapOutputWithContext(context.Context) ResourceMapOutput
   214  }
   215  
   216  type ResourceMap map[string]ResourceInput
   217  
   218  func (ResourceMap) ElementType() reflect.Type {
   219  	return reflect.TypeOf((*map[string]*Resource)(nil)).Elem()
   220  }
   221  
   222  func (i ResourceMap) ToResourceMapOutput() ResourceMapOutput {
   223  	return i.ToResourceMapOutputWithContext(context.Background())
   224  }
   225  
   226  func (i ResourceMap) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
   227  	return pulumi.ToOutputWithContext(ctx, i).(ResourceMapOutput)
   228  }
   229  
   230  type ResourceOutput struct{ *pulumi.OutputState }
   231  
   232  func (ResourceOutput) ElementType() reflect.Type {
   233  	return reflect.TypeOf((**Resource)(nil)).Elem()
   234  }
   235  
   236  func (o ResourceOutput) ToResourceOutput() ResourceOutput {
   237  	return o
   238  }
   239  
   240  func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
   241  	return o
   242  }
   243  
   244  // ID of the parent API resource
   245  func (o ResourceOutput) ParentId() pulumi.StringOutput {
   246  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.ParentId }).(pulumi.StringOutput)
   247  }
   248  
   249  // Complete path for this API resource, including all parent paths.
   250  func (o ResourceOutput) Path() pulumi.StringOutput {
   251  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.Path }).(pulumi.StringOutput)
   252  }
   253  
   254  // Last path segment of this API resource.
   255  func (o ResourceOutput) PathPart() pulumi.StringOutput {
   256  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.PathPart }).(pulumi.StringOutput)
   257  }
   258  
   259  // ID of the associated REST API
   260  func (o ResourceOutput) RestApi() pulumi.StringOutput {
   261  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.RestApi }).(pulumi.StringOutput)
   262  }
   263  
   264  type ResourceArrayOutput struct{ *pulumi.OutputState }
   265  
   266  func (ResourceArrayOutput) ElementType() reflect.Type {
   267  	return reflect.TypeOf((*[]*Resource)(nil)).Elem()
   268  }
   269  
   270  func (o ResourceArrayOutput) ToResourceArrayOutput() ResourceArrayOutput {
   271  	return o
   272  }
   273  
   274  func (o ResourceArrayOutput) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
   275  	return o
   276  }
   277  
   278  func (o ResourceArrayOutput) Index(i pulumi.IntInput) ResourceOutput {
   279  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Resource {
   280  		return vs[0].([]*Resource)[vs[1].(int)]
   281  	}).(ResourceOutput)
   282  }
   283  
   284  type ResourceMapOutput struct{ *pulumi.OutputState }
   285  
   286  func (ResourceMapOutput) ElementType() reflect.Type {
   287  	return reflect.TypeOf((*map[string]*Resource)(nil)).Elem()
   288  }
   289  
   290  func (o ResourceMapOutput) ToResourceMapOutput() ResourceMapOutput {
   291  	return o
   292  }
   293  
   294  func (o ResourceMapOutput) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
   295  	return o
   296  }
   297  
   298  func (o ResourceMapOutput) MapIndex(k pulumi.StringInput) ResourceOutput {
   299  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Resource {
   300  		return vs[0].(map[string]*Resource)[vs[1].(string)]
   301  	}).(ResourceOutput)
   302  }
   303  
   304  func init() {
   305  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceInput)(nil)).Elem(), &Resource{})
   306  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceArrayInput)(nil)).Elem(), ResourceArray{})
   307  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceMapInput)(nil)).Elem(), ResourceMap{})
   308  	pulumi.RegisterOutputType(ResourceOutput{})
   309  	pulumi.RegisterOutputType(ResourceArrayOutput{})
   310  	pulumi.RegisterOutputType(ResourceMapOutput{})
   311  }