github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/getRestApi.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 and rootResourceId of a REST API in
    15  // API Gateway. To fetch the REST API you must provide a name to match against.
    16  // As there is no unique name constraint on REST APIs this data source will
    17  // error if there is more than one match.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
    35  //				Name: "my-rest-api",
    36  //			}, nil)
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			return nil
    41  //		})
    42  //	}
    43  //
    44  // ```
    45  // <!--End PulumiCodeChooser -->
    46  func LookupRestApi(ctx *pulumi.Context, args *LookupRestApiArgs, opts ...pulumi.InvokeOption) (*LookupRestApiResult, error) {
    47  	opts = internal.PkgInvokeDefaultOpts(opts)
    48  	var rv LookupRestApiResult
    49  	err := ctx.Invoke("aws:apigateway/getRestApi:getRestApi", args, &rv, opts...)
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  	return &rv, nil
    54  }
    55  
    56  // A collection of arguments for invoking getRestApi.
    57  type LookupRestApiArgs struct {
    58  	// Name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
    59  	Name string `pulumi:"name"`
    60  	// Key-value map of resource tags.
    61  	Tags map[string]string `pulumi:"tags"`
    62  }
    63  
    64  // A collection of values returned by getRestApi.
    65  type LookupRestApiResult struct {
    66  	// Source of the API key for requests.
    67  	ApiKeySource string `pulumi:"apiKeySource"`
    68  	// ARN of the REST API.
    69  	Arn string `pulumi:"arn"`
    70  	// List of binary media types supported by the REST API.
    71  	BinaryMediaTypes []string `pulumi:"binaryMediaTypes"`
    72  	// Description of the REST API.
    73  	Description string `pulumi:"description"`
    74  	// The endpoint configuration of this RestApi showing the endpoint types of the API.
    75  	EndpointConfigurations []GetRestApiEndpointConfiguration `pulumi:"endpointConfigurations"`
    76  	// Execution ARN part to be used in `lambdaPermission`'s `sourceArn` when allowing API Gateway to invoke a Lambda function, e.g., `arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j`, which can be concatenated with allowed stage, method and resource path.
    77  	ExecutionArn string `pulumi:"executionArn"`
    78  	// The provider-assigned unique ID for this managed resource.
    79  	Id string `pulumi:"id"`
    80  	// Minimum response size to compress for the REST API.
    81  	MinimumCompressionSize string `pulumi:"minimumCompressionSize"`
    82  	Name                   string `pulumi:"name"`
    83  	// JSON formatted policy document that controls access to the API Gateway.
    84  	Policy string `pulumi:"policy"`
    85  	// Set to the ID of the API Gateway Resource on the found REST API where the route matches '/'.
    86  	RootResourceId string `pulumi:"rootResourceId"`
    87  	// Key-value map of resource tags.
    88  	Tags map[string]string `pulumi:"tags"`
    89  }
    90  
    91  func LookupRestApiOutput(ctx *pulumi.Context, args LookupRestApiOutputArgs, opts ...pulumi.InvokeOption) LookupRestApiResultOutput {
    92  	return pulumi.ToOutputWithContext(context.Background(), args).
    93  		ApplyT(func(v interface{}) (LookupRestApiResult, error) {
    94  			args := v.(LookupRestApiArgs)
    95  			r, err := LookupRestApi(ctx, &args, opts...)
    96  			var s LookupRestApiResult
    97  			if r != nil {
    98  				s = *r
    99  			}
   100  			return s, err
   101  		}).(LookupRestApiResultOutput)
   102  }
   103  
   104  // A collection of arguments for invoking getRestApi.
   105  type LookupRestApiOutputArgs struct {
   106  	// Name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
   107  	Name pulumi.StringInput `pulumi:"name"`
   108  	// Key-value map of resource tags.
   109  	Tags pulumi.StringMapInput `pulumi:"tags"`
   110  }
   111  
   112  func (LookupRestApiOutputArgs) ElementType() reflect.Type {
   113  	return reflect.TypeOf((*LookupRestApiArgs)(nil)).Elem()
   114  }
   115  
   116  // A collection of values returned by getRestApi.
   117  type LookupRestApiResultOutput struct{ *pulumi.OutputState }
   118  
   119  func (LookupRestApiResultOutput) ElementType() reflect.Type {
   120  	return reflect.TypeOf((*LookupRestApiResult)(nil)).Elem()
   121  }
   122  
   123  func (o LookupRestApiResultOutput) ToLookupRestApiResultOutput() LookupRestApiResultOutput {
   124  	return o
   125  }
   126  
   127  func (o LookupRestApiResultOutput) ToLookupRestApiResultOutputWithContext(ctx context.Context) LookupRestApiResultOutput {
   128  	return o
   129  }
   130  
   131  // Source of the API key for requests.
   132  func (o LookupRestApiResultOutput) ApiKeySource() pulumi.StringOutput {
   133  	return o.ApplyT(func(v LookupRestApiResult) string { return v.ApiKeySource }).(pulumi.StringOutput)
   134  }
   135  
   136  // ARN of the REST API.
   137  func (o LookupRestApiResultOutput) Arn() pulumi.StringOutput {
   138  	return o.ApplyT(func(v LookupRestApiResult) string { return v.Arn }).(pulumi.StringOutput)
   139  }
   140  
   141  // List of binary media types supported by the REST API.
   142  func (o LookupRestApiResultOutput) BinaryMediaTypes() pulumi.StringArrayOutput {
   143  	return o.ApplyT(func(v LookupRestApiResult) []string { return v.BinaryMediaTypes }).(pulumi.StringArrayOutput)
   144  }
   145  
   146  // Description of the REST API.
   147  func (o LookupRestApiResultOutput) Description() pulumi.StringOutput {
   148  	return o.ApplyT(func(v LookupRestApiResult) string { return v.Description }).(pulumi.StringOutput)
   149  }
   150  
   151  // The endpoint configuration of this RestApi showing the endpoint types of the API.
   152  func (o LookupRestApiResultOutput) EndpointConfigurations() GetRestApiEndpointConfigurationArrayOutput {
   153  	return o.ApplyT(func(v LookupRestApiResult) []GetRestApiEndpointConfiguration { return v.EndpointConfigurations }).(GetRestApiEndpointConfigurationArrayOutput)
   154  }
   155  
   156  // Execution ARN part to be used in `lambdaPermission`'s `sourceArn` when allowing API Gateway to invoke a Lambda function, e.g., `arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j`, which can be concatenated with allowed stage, method and resource path.
   157  func (o LookupRestApiResultOutput) ExecutionArn() pulumi.StringOutput {
   158  	return o.ApplyT(func(v LookupRestApiResult) string { return v.ExecutionArn }).(pulumi.StringOutput)
   159  }
   160  
   161  // The provider-assigned unique ID for this managed resource.
   162  func (o LookupRestApiResultOutput) Id() pulumi.StringOutput {
   163  	return o.ApplyT(func(v LookupRestApiResult) string { return v.Id }).(pulumi.StringOutput)
   164  }
   165  
   166  // Minimum response size to compress for the REST API.
   167  func (o LookupRestApiResultOutput) MinimumCompressionSize() pulumi.StringOutput {
   168  	return o.ApplyT(func(v LookupRestApiResult) string { return v.MinimumCompressionSize }).(pulumi.StringOutput)
   169  }
   170  
   171  func (o LookupRestApiResultOutput) Name() pulumi.StringOutput {
   172  	return o.ApplyT(func(v LookupRestApiResult) string { return v.Name }).(pulumi.StringOutput)
   173  }
   174  
   175  // JSON formatted policy document that controls access to the API Gateway.
   176  func (o LookupRestApiResultOutput) Policy() pulumi.StringOutput {
   177  	return o.ApplyT(func(v LookupRestApiResult) string { return v.Policy }).(pulumi.StringOutput)
   178  }
   179  
   180  // Set to the ID of the API Gateway Resource on the found REST API where the route matches '/'.
   181  func (o LookupRestApiResultOutput) RootResourceId() pulumi.StringOutput {
   182  	return o.ApplyT(func(v LookupRestApiResult) string { return v.RootResourceId }).(pulumi.StringOutput)
   183  }
   184  
   185  // Key-value map of resource tags.
   186  func (o LookupRestApiResultOutput) Tags() pulumi.StringMapOutput {
   187  	return o.ApplyT(func(v LookupRestApiResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   188  }
   189  
   190  func init() {
   191  	pulumi.RegisterOutputType(LookupRestApiResultOutput{})
   192  }