1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package apigateway 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/apigateway/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12 "time" 13) 14 15// A feature of the API Gateway control service for creating a new API from an 16// external API definition file. 17func (c *Client) ImportRestApi(ctx context.Context, params *ImportRestApiInput, optFns ...func(*Options)) (*ImportRestApiOutput, error) { 18 if params == nil { 19 params = &ImportRestApiInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ImportRestApi", params, optFns, addOperationImportRestApiMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ImportRestApiOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32// A POST request to import an API to API Gateway using an input of an API 33// definition file. 34type ImportRestApiInput struct { 35 36 // A query parameter to indicate whether to rollback the API creation (true) or not 37 // (false) when a warning is encountered. The default value is false. 38 FailOnWarnings bool 39 40 // A key-value map of context-specific query string parameters specifying the 41 // behavior of different API importing operations. The following shows 42 // operation-specific parameters and their supported values. To exclude 43 // DocumentationParts from the import, set parameters as ignore=documentation. To 44 // configure the endpoint type, set parameters as endpointConfigurationTypes=EDGE, 45 // endpointConfigurationTypes=REGIONAL, or endpointConfigurationTypes=PRIVATE. The 46 // default endpoint type is EDGE. To handle imported basepath, set parameters as 47 // basepath=ignore, basepath=prepend or basepath=split. For example, the AWS CLI 48 // command to exclude documentation from the imported API is: aws apigateway 49 // import-rest-api --parameters ignore=documentation --body 50 // 'file:///path/to/imported-api-body.json' The AWS CLI command to set the regional 51 // endpoint on the imported API is: aws apigateway import-rest-api --parameters 52 // endpointConfigurationTypes=REGIONAL --body 53 // 'file:///path/to/imported-api-body.json' 54 Parameters map[string]string 55} 56 57// Represents a REST API. Create an API 58// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) 59type ImportRestApiOutput struct { 60 61 // The source of the API key for metering requests according to a usage plan. Valid 62 // values are: 63 // 64 // * HEADER to read the API key from the X-API-Key header of a 65 // request. 66 // 67 // * AUTHORIZER to read the API key from the UsageIdentifierKey from a 68 // custom authorizer. 69 ApiKeySource types.ApiKeySourceType 70 71 // The list of binary media types supported by the RestApi. By default, the RestApi 72 // supports only UTF-8-encoded text payloads. 73 BinaryMediaTypes []string 74 75 // The timestamp when the API was created. 76 CreatedDate *time.Time 77 78 // The API's description. 79 Description *string 80 81 // Specifies whether clients can invoke your API by using the default execute-api 82 // endpoint. By default, clients can invoke your API with the default 83 // https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that 84 // clients use a custom domain name to invoke your API, disable the default 85 // endpoint. 86 DisableExecuteApiEndpoint bool 87 88 // The endpoint configuration of this RestApi showing the endpoint types of the 89 // API. 90 EndpointConfiguration *types.EndpointConfiguration 91 92 // The API's identifier. This identifier is unique across all of your APIs in API 93 // Gateway. 94 Id *string 95 96 // A nullable integer that is used to enable compression (with non-negative between 97 // 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null 98 // value) on an API. When compression is enabled, compression or decompression is 99 // not applied on the payload if the payload size is smaller than this value. 100 // Setting it to zero allows compression for any payload size. 101 MinimumCompressionSize *int32 102 103 // The API's name. 104 Name *string 105 106 // A stringified JSON policy document that applies to this RestApi regardless of 107 // the caller and Method configuration. 108 Policy *string 109 110 // The collection of tags. Each tag element is associated with a given resource. 111 Tags map[string]string 112 113 // A version identifier for the API. 114 Version *string 115 116 // The warning messages reported when failonwarnings is turned on during API 117 // import. 118 Warnings []string 119 120 // Metadata pertaining to the operation's result. 121 ResultMetadata middleware.Metadata 122} 123 124func addOperationImportRestApiMiddlewares(stack *middleware.Stack, options Options) (err error) { 125 err = stack.Serialize.Add(&awsRestjson1_serializeOpImportRestApi{}, middleware.After) 126 if err != nil { 127 return err 128 } 129 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpImportRestApi{}, middleware.After) 130 if err != nil { 131 return err 132 } 133 if err = addSetLoggerMiddleware(stack, options); err != nil { 134 return err 135 } 136 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 137 return err 138 } 139 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 140 return err 141 } 142 if err = addResolveEndpointMiddleware(stack, options); err != nil { 143 return err 144 } 145 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 146 return err 147 } 148 if err = addRetryMiddlewares(stack, options); err != nil { 149 return err 150 } 151 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 152 return err 153 } 154 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 155 return err 156 } 157 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 158 return err 159 } 160 if err = addClientUserAgent(stack); err != nil { 161 return err 162 } 163 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 164 return err 165 } 166 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 167 return err 168 } 169 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opImportRestApi(options.Region), middleware.Before); err != nil { 170 return err 171 } 172 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 173 return err 174 } 175 if err = addResponseErrorMiddleware(stack); err != nil { 176 return err 177 } 178 if err = addAcceptHeader(stack); err != nil { 179 return err 180 } 181 if err = addRequestResponseLogging(stack, options); err != nil { 182 return err 183 } 184 return nil 185} 186 187func newServiceMetadataMiddleware_opImportRestApi(region string) *awsmiddleware.RegisterServiceMetadata { 188 return &awsmiddleware.RegisterServiceMetadata{ 189 Region: region, 190 ServiceID: ServiceID, 191 SigningName: "apigateway", 192 OperationName: "ImportRestApi", 193 } 194} 195