github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/getResource.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  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Use this data source to get the id of a Resource in API Gateway.
    15  // To fetch the Resource, you must provide the REST API id as well as the full path.
    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  //			myRestApi, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
    33  //				Name: "my-rest-api",
    34  //			}, nil)
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			_, err = apigateway.LookupResource(ctx, &apigateway.LookupResourceArgs{
    39  //				RestApiId: myRestApi.Id,
    40  //				Path:      "/endpoint/path",
    41  //			}, nil)
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			return nil
    46  //		})
    47  //	}
    48  //
    49  // ```
    50  // <!--End PulumiCodeChooser -->
    51  func LookupResource(ctx *pulumi.Context, args *LookupResourceArgs, opts ...pulumi.InvokeOption) (*LookupResourceResult, error) {
    52  	opts = internal.PkgInvokeDefaultOpts(opts)
    53  	var rv LookupResourceResult
    54  	err := ctx.Invoke("aws:apigateway/getResource:getResource", args, &rv, opts...)
    55  	if err != nil {
    56  		return nil, err
    57  	}
    58  	return &rv, nil
    59  }
    60  
    61  // A collection of arguments for invoking getResource.
    62  type LookupResourceArgs struct {
    63  	// Full path of the resource.  If no path is found, an error will be returned.
    64  	Path string `pulumi:"path"`
    65  	// REST API id that owns the resource. If no REST API is found, an error will be returned.
    66  	RestApiId string `pulumi:"restApiId"`
    67  }
    68  
    69  // A collection of values returned by getResource.
    70  type LookupResourceResult struct {
    71  	// The provider-assigned unique ID for this managed resource.
    72  	Id string `pulumi:"id"`
    73  	// Set to the ID of the parent Resource.
    74  	ParentId string `pulumi:"parentId"`
    75  	Path     string `pulumi:"path"`
    76  	// Set to the path relative to the parent Resource.
    77  	PathPart  string `pulumi:"pathPart"`
    78  	RestApiId string `pulumi:"restApiId"`
    79  }
    80  
    81  func LookupResourceOutput(ctx *pulumi.Context, args LookupResourceOutputArgs, opts ...pulumi.InvokeOption) LookupResourceResultOutput {
    82  	return pulumi.ToOutputWithContext(context.Background(), args).
    83  		ApplyT(func(v interface{}) (LookupResourceResult, error) {
    84  			args := v.(LookupResourceArgs)
    85  			r, err := LookupResource(ctx, &args, opts...)
    86  			var s LookupResourceResult
    87  			if r != nil {
    88  				s = *r
    89  			}
    90  			return s, err
    91  		}).(LookupResourceResultOutput)
    92  }
    93  
    94  // A collection of arguments for invoking getResource.
    95  type LookupResourceOutputArgs struct {
    96  	// Full path of the resource.  If no path is found, an error will be returned.
    97  	Path pulumi.StringInput `pulumi:"path"`
    98  	// REST API id that owns the resource. If no REST API is found, an error will be returned.
    99  	RestApiId pulumi.StringInput `pulumi:"restApiId"`
   100  }
   101  
   102  func (LookupResourceOutputArgs) ElementType() reflect.Type {
   103  	return reflect.TypeOf((*LookupResourceArgs)(nil)).Elem()
   104  }
   105  
   106  // A collection of values returned by getResource.
   107  type LookupResourceResultOutput struct{ *pulumi.OutputState }
   108  
   109  func (LookupResourceResultOutput) ElementType() reflect.Type {
   110  	return reflect.TypeOf((*LookupResourceResult)(nil)).Elem()
   111  }
   112  
   113  func (o LookupResourceResultOutput) ToLookupResourceResultOutput() LookupResourceResultOutput {
   114  	return o
   115  }
   116  
   117  func (o LookupResourceResultOutput) ToLookupResourceResultOutputWithContext(ctx context.Context) LookupResourceResultOutput {
   118  	return o
   119  }
   120  
   121  // The provider-assigned unique ID for this managed resource.
   122  func (o LookupResourceResultOutput) Id() pulumi.StringOutput {
   123  	return o.ApplyT(func(v LookupResourceResult) string { return v.Id }).(pulumi.StringOutput)
   124  }
   125  
   126  // Set to the ID of the parent Resource.
   127  func (o LookupResourceResultOutput) ParentId() pulumi.StringOutput {
   128  	return o.ApplyT(func(v LookupResourceResult) string { return v.ParentId }).(pulumi.StringOutput)
   129  }
   130  
   131  func (o LookupResourceResultOutput) Path() pulumi.StringOutput {
   132  	return o.ApplyT(func(v LookupResourceResult) string { return v.Path }).(pulumi.StringOutput)
   133  }
   134  
   135  // Set to the path relative to the parent Resource.
   136  func (o LookupResourceResultOutput) PathPart() pulumi.StringOutput {
   137  	return o.ApplyT(func(v LookupResourceResult) string { return v.PathPart }).(pulumi.StringOutput)
   138  }
   139  
   140  func (o LookupResourceResultOutput) RestApiId() pulumi.StringOutput {
   141  	return o.ApplyT(func(v LookupResourceResult) string { return v.RestApiId }).(pulumi.StringOutput)
   142  }
   143  
   144  func init() {
   145  	pulumi.RegisterOutputType(LookupResourceResultOutput{})
   146  }