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, 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
82type CreateRouteOutput struct {
83
84	// Specifies whether a route is managed by API Gateway. If you created an API using
85	// quick create, the $default route is managed by API Gateway. You can't modify the
86	// $default route key.
87	ApiGatewayManaged bool
88
89	// Specifies whether an API key is required for this route. Supported only for
90	// WebSocket APIs.
91	ApiKeyRequired bool
92
93	// A list of authorization scopes configured on a route. The scopes are used with a
94	// JWT authorizer to authorize the method invocation. The authorization works by
95	// matching the route scopes against the scopes parsed from the access token in the
96	// incoming request. The method invocation is authorized if any route scope matches
97	// a claimed scope in the access token. Otherwise, the invocation is not
98	// authorized. When the route scope is configured, the client must provide an
99	// access token instead of an identity token for authorization purposes.
100	AuthorizationScopes []string
101
102	// The authorization type for the route. For WebSocket APIs, valid values are NONE
103	// for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a
104	// Lambda authorizer For HTTP APIs, valid values are NONE for open access, JWT for
105	// using JSON Web Tokens, AWS_IAM for using AWS IAM permissions, and CUSTOM for
106	// using a Lambda authorizer.
107	AuthorizationType types.AuthorizationType
108
109	// The identifier of the Authorizer resource to be associated with this route. The
110	// authorizer identifier is generated by API Gateway when you created the
111	// authorizer.
112	AuthorizerId *string
113
114	// The model selection expression for the route. Supported only for WebSocket APIs.
115	ModelSelectionExpression *string
116
117	// The operation name for the route.
118	OperationName *string
119
120	// The request models for the route. Supported only for WebSocket APIs.
121	RequestModels map[string]string
122
123	// The request parameters for the route. Supported only for WebSocket APIs.
124	RequestParameters map[string]types.ParameterConstraints
125
126	// The route ID.
127	RouteId *string
128
129	// The route key for the route.
130	RouteKey *string
131
132	// The route response selection expression for the route. Supported only for
133	// WebSocket APIs.
134	RouteResponseSelectionExpression *string
135
136	// The target for the route.
137	Target *string
138
139	// Metadata pertaining to the operation's result.
140	ResultMetadata middleware.Metadata
141}
142
143func addOperationCreateRouteMiddlewares(stack *middleware.Stack, options Options) (err error) {
144	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateRoute{}, middleware.After)
145	if err != nil {
146		return err
147	}
148	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateRoute{}, middleware.After)
149	if err != nil {
150		return err
151	}
152	if err = addSetLoggerMiddleware(stack, options); err != nil {
153		return err
154	}
155	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
156		return err
157	}
158	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addResolveEndpointMiddleware(stack, options); err != nil {
162		return err
163	}
164	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
165		return err
166	}
167	if err = addRetryMiddlewares(stack, options); err != nil {
168		return err
169	}
170	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
171		return err
172	}
173	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
174		return err
175	}
176	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
177		return err
178	}
179	if err = addClientUserAgent(stack); err != nil {
180		return err
181	}
182	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
183		return err
184	}
185	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
186		return err
187	}
188	if err = addOpCreateRouteValidationMiddleware(stack); err != nil {
189		return err
190	}
191	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRoute(options.Region), middleware.Before); err != nil {
192		return err
193	}
194	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
195		return err
196	}
197	if err = addResponseErrorMiddleware(stack); err != nil {
198		return err
199	}
200	if err = addRequestResponseLogging(stack, options); err != nil {
201		return err
202	}
203	return nil
204}
205
206func newServiceMetadataMiddleware_opCreateRoute(region string) *awsmiddleware.RegisterServiceMetadata {
207	return &awsmiddleware.RegisterServiceMetadata{
208		Region:        region,
209		ServiceID:     ServiceID,
210		SigningName:   "apigateway",
211		OperationName: "CreateRoute",
212	}
213}
214