1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package apigatewayv2 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/apigatewayv2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates a Route for an API. 15func (c *Client) CreateRoute(ctx context.Context, params *CreateRouteInput, optFns ...func(*Options)) (*CreateRouteOutput, error) { 16 if params == nil { 17 params = &CreateRouteInput{} 18 } 19 20 result, metadata, err := c.invokeOperation(ctx, "CreateRoute", params, optFns, c.addOperationCreateRouteMiddlewares) 21 if err != nil { 22 return nil, err 23 } 24 25 out := result.(*CreateRouteOutput) 26 out.ResultMetadata = metadata 27 return out, nil 28} 29 30// Creates a new Route resource to represent a route. 31type CreateRouteInput struct { 32 33 // The API identifier. 34 // 35 // This member is required. 36 ApiId *string 37 38 // The route key for the route. 39 // 40 // This member is required. 41 RouteKey *string 42 43 // Specifies whether an API key is required for the route. Supported only for 44 // WebSocket APIs. 45 ApiKeyRequired bool 46 47 // The authorization scopes supported by this route. 48 AuthorizationScopes []string 49 50 // The authorization type for the route. For WebSocket APIs, valid values are NONE 51 // for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a 52 // Lambda authorizer For HTTP APIs, valid values are NONE for open access, JWT for 53 // using JSON Web Tokens, AWS_IAM for using AWS IAM permissions, and CUSTOM for 54 // using a Lambda authorizer. 55 AuthorizationType types.AuthorizationType 56 57 // The identifier of the Authorizer resource to be associated with this route. The 58 // authorizer identifier is generated by API Gateway when you created the 59 // authorizer. 60 AuthorizerId *string 61 62 // The model selection expression for the route. Supported only for WebSocket APIs. 63 ModelSelectionExpression *string 64 65 // The operation name for the route. 66 OperationName *string 67 68 // The request models for the route. Supported only for WebSocket APIs. 69 RequestModels map[string]string 70 71 // The request parameters for the route. Supported only for WebSocket APIs. 72 RequestParameters map[string]types.ParameterConstraints 73 74 // The route response selection expression for the route. Supported only for 75 // WebSocket APIs. 76 RouteResponseSelectionExpression *string 77 78 // The target for the route. 79 Target *string 80 81 noSmithyDocumentSerde 82} 83 84type CreateRouteOutput struct { 85 86 // Specifies whether a route is managed by API Gateway. If you created an API using 87 // quick create, the $default route is managed by API Gateway. You can't modify the 88 // $default route key. 89 ApiGatewayManaged bool 90 91 // Specifies whether an API key is required for this route. Supported only for 92 // WebSocket APIs. 93 ApiKeyRequired bool 94 95 // A list of authorization scopes configured on a route. The scopes are used with a 96 // JWT authorizer to authorize the method invocation. The authorization works by 97 // matching the route scopes against the scopes parsed from the access token in the 98 // incoming request. The method invocation is authorized if any route scope matches 99 // a claimed scope in the access token. Otherwise, the invocation is not 100 // authorized. When the route scope is configured, the client must provide an 101 // access token instead of an identity token for authorization purposes. 102 AuthorizationScopes []string 103 104 // The authorization type for the route. For WebSocket APIs, valid values are NONE 105 // for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a 106 // Lambda authorizer For HTTP APIs, valid values are NONE for open access, JWT for 107 // using JSON Web Tokens, AWS_IAM for using AWS IAM permissions, and CUSTOM for 108 // using a Lambda authorizer. 109 AuthorizationType types.AuthorizationType 110 111 // The identifier of the Authorizer resource to be associated with this route. The 112 // authorizer identifier is generated by API Gateway when you created the 113 // authorizer. 114 AuthorizerId *string 115 116 // The model selection expression for the route. Supported only for WebSocket APIs. 117 ModelSelectionExpression *string 118 119 // The operation name for the route. 120 OperationName *string 121 122 // The request models for the route. Supported only for WebSocket APIs. 123 RequestModels map[string]string 124 125 // The request parameters for the route. Supported only for WebSocket APIs. 126 RequestParameters map[string]types.ParameterConstraints 127 128 // The route ID. 129 RouteId *string 130 131 // The route key for the route. 132 RouteKey *string 133 134 // The route response selection expression for the route. Supported only for 135 // WebSocket APIs. 136 RouteResponseSelectionExpression *string 137 138 // The target for the route. 139 Target *string 140 141 // Metadata pertaining to the operation's result. 142 ResultMetadata middleware.Metadata 143 144 noSmithyDocumentSerde 145} 146 147func (c *Client) addOperationCreateRouteMiddlewares(stack *middleware.Stack, options Options) (err error) { 148 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateRoute{}, middleware.After) 149 if err != nil { 150 return err 151 } 152 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateRoute{}, middleware.After) 153 if err != nil { 154 return err 155 } 156 if err = addSetLoggerMiddleware(stack, options); err != nil { 157 return err 158 } 159 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 160 return err 161 } 162 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 163 return err 164 } 165 if err = addResolveEndpointMiddleware(stack, options); err != nil { 166 return err 167 } 168 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 169 return err 170 } 171 if err = addRetryMiddlewares(stack, options); err != nil { 172 return err 173 } 174 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 175 return err 176 } 177 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 178 return err 179 } 180 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 181 return err 182 } 183 if err = addClientUserAgent(stack); err != nil { 184 return err 185 } 186 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 187 return err 188 } 189 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 190 return err 191 } 192 if err = addOpCreateRouteValidationMiddleware(stack); err != nil { 193 return err 194 } 195 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRoute(options.Region), middleware.Before); err != nil { 196 return err 197 } 198 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 199 return err 200 } 201 if err = addResponseErrorMiddleware(stack); err != nil { 202 return err 203 } 204 if err = addRequestResponseLogging(stack, options); err != nil { 205 return err 206 } 207 return nil 208} 209 210func newServiceMetadataMiddleware_opCreateRoute(region string) *awsmiddleware.RegisterServiceMetadata { 211 return &awsmiddleware.RegisterServiceMetadata{ 212 Region: region, 213 ServiceID: ServiceID, 214 SigningName: "apigateway", 215 OperationName: "CreateRoute", 216 } 217} 218