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// Creates a new Stage resource that references a pre-existing Deployment for the
16// API.
17func (c *Client) CreateStage(ctx context.Context, params *CreateStageInput, optFns ...func(*Options)) (*CreateStageOutput, error) {
18	if params == nil {
19		params = &CreateStageInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "CreateStage", params, optFns, addOperationCreateStageMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*CreateStageOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32// Requests API Gateway to create a Stage resource.
33type CreateStageInput struct {
34
35	// [Required] The identifier of the Deployment resource for the Stage resource.
36	//
37	// This member is required.
38	DeploymentId *string
39
40	// [Required] The string identifier of the associated RestApi.
41	//
42	// This member is required.
43	RestApiId *string
44
45	// [Required] The name for the Stage resource. Stage names can only contain
46	// alphanumeric characters, hyphens, and underscores. Maximum length is 128
47	// characters.
48	//
49	// This member is required.
50	StageName *string
51
52	// Whether cache clustering is enabled for the stage.
53	CacheClusterEnabled bool
54
55	// The stage's cache cluster size.
56	CacheClusterSize types.CacheClusterSize
57
58	// The canary deployment settings of this stage.
59	CanarySettings *types.CanarySettings
60
61	// The description of the Stage resource.
62	Description *string
63
64	// The version of the associated API documentation.
65	DocumentationVersion *string
66
67	// The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The
68	// tag key can be up to 128 characters and must not start with aws:. The tag value
69	// can be up to 256 characters.
70	Tags map[string]string
71
72	// Specifies whether active tracing with X-ray is enabled for the Stage.
73	TracingEnabled bool
74
75	// A map that defines the stage variables for the new Stage resource. Variable
76	// names can have alphanumeric and underscore characters, and the values must match
77	// [A-Za-z0-9-._~:/?#&=,]+.
78	Variables map[string]string
79}
80
81// Represents a unique identifier for a version of a deployed RestApi that is
82// callable by users. Deploy an API
83// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api.html)
84type CreateStageOutput struct {
85
86	// Settings for logging access in this stage.
87	AccessLogSettings *types.AccessLogSettings
88
89	// Specifies whether a cache cluster is enabled for the stage.
90	CacheClusterEnabled bool
91
92	// The size of the cache cluster for the stage, if enabled.
93	CacheClusterSize types.CacheClusterSize
94
95	// The status of the cache cluster for the stage, if enabled.
96	CacheClusterStatus types.CacheClusterStatus
97
98	// Settings for the canary deployment in this stage.
99	CanarySettings *types.CanarySettings
100
101	// The identifier of a client certificate for an API stage.
102	ClientCertificateId *string
103
104	// The timestamp when the stage was created.
105	CreatedDate *time.Time
106
107	// The identifier of the Deployment that the stage points to.
108	DeploymentId *string
109
110	// The stage's description.
111	Description *string
112
113	// The version of the associated API documentation.
114	DocumentationVersion *string
115
116	// The timestamp when the stage last updated.
117	LastUpdatedDate *time.Time
118
119	// A map that defines the method settings for a Stage resource. Keys (designated as
120	// /{method_setting_key below) are method paths defined as
121	// {resource_path}/{http_method} for an individual method override, or /\*/\* for
122	// overriding all methods in the stage.
123	MethodSettings map[string]types.MethodSetting
124
125	// The name of the stage is the first path segment in the Uniform Resource
126	// Identifier (URI) of a call to API Gateway. Stage names can only contain
127	// alphanumeric characters, hyphens, and underscores. Maximum length is 128
128	// characters.
129	StageName *string
130
131	// The collection of tags. Each tag element is associated with a given resource.
132	Tags map[string]string
133
134	// Specifies whether active tracing with X-ray is enabled for the Stage.
135	TracingEnabled bool
136
137	// A map that defines the stage variables for a Stage resource. Variable names can
138	// have alphanumeric and underscore characters, and the values must match
139	// [A-Za-z0-9-._~:/?#&=,]+.
140	Variables map[string]string
141
142	// The ARN of the WebAcl associated with the Stage.
143	WebAclArn *string
144
145	// Metadata pertaining to the operation's result.
146	ResultMetadata middleware.Metadata
147}
148
149func addOperationCreateStageMiddlewares(stack *middleware.Stack, options Options) (err error) {
150	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateStage{}, middleware.After)
151	if err != nil {
152		return err
153	}
154	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateStage{}, middleware.After)
155	if err != nil {
156		return err
157	}
158	if err = addSetLoggerMiddleware(stack, options); err != nil {
159		return err
160	}
161	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
162		return err
163	}
164	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
165		return err
166	}
167	if err = addResolveEndpointMiddleware(stack, options); err != nil {
168		return err
169	}
170	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
171		return err
172	}
173	if err = addRetryMiddlewares(stack, options); err != nil {
174		return err
175	}
176	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
177		return err
178	}
179	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
180		return err
181	}
182	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
183		return err
184	}
185	if err = addClientUserAgent(stack); err != nil {
186		return err
187	}
188	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
189		return err
190	}
191	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
192		return err
193	}
194	if err = addOpCreateStageValidationMiddleware(stack); err != nil {
195		return err
196	}
197	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateStage(options.Region), middleware.Before); err != nil {
198		return err
199	}
200	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
201		return err
202	}
203	if err = addResponseErrorMiddleware(stack); err != nil {
204		return err
205	}
206	if err = addAcceptHeader(stack); err != nil {
207		return err
208	}
209	if err = addRequestResponseLogging(stack, options); err != nil {
210		return err
211	}
212	return nil
213}
214
215func newServiceMetadataMiddleware_opCreateStage(region string) *awsmiddleware.RegisterServiceMetadata {
216	return &awsmiddleware.RegisterServiceMetadata{
217		Region:        region,
218		ServiceID:     ServiceID,
219		SigningName:   "apigateway",
220		OperationName: "CreateStage",
221	}
222}
223