1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package amplify
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/amplify/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a new branch for an Amplify app.
15func (c *Client) CreateBranch(ctx context.Context, params *CreateBranchInput, optFns ...func(*Options)) (*CreateBranchOutput, error) {
16	if params == nil {
17		params = &CreateBranchInput{}
18	}
19
20	result, metadata, err := c.invokeOperation(ctx, "CreateBranch", params, optFns, addOperationCreateBranchMiddlewares)
21	if err != nil {
22		return nil, err
23	}
24
25	out := result.(*CreateBranchOutput)
26	out.ResultMetadata = metadata
27	return out, nil
28}
29
30// The request structure for the create branch request.
31type CreateBranchInput struct {
32
33	// The unique ID for an Amplify app.
34	//
35	// This member is required.
36	AppId *string
37
38	// The name for the branch.
39	//
40	// This member is required.
41	BranchName *string
42
43	// The Amazon Resource Name (ARN) for a backend environment that is part of an
44	// Amplify app.
45	BackendEnvironmentArn *string
46
47	// The basic authorization credentials for the branch.
48	BasicAuthCredentials *string
49
50	// The build specification (build spec) for the branch.
51	BuildSpec *string
52
53	// The description for the branch.
54	Description *string
55
56	// The display name for a branch. This is used as the default domain prefix.
57	DisplayName *string
58
59	// Enables auto building for the branch.
60	EnableAutoBuild *bool
61
62	// Enables basic authorization for the branch.
63	EnableBasicAuth *bool
64
65	// Enables notifications for the branch.
66	EnableNotification *bool
67
68	// Enables performance mode for the branch. Performance mode optimizes for faster
69	// hosting performance by keeping content cached at the edge for a longer interval.
70	// When performance mode is enabled, hosting configuration or code changes can take
71	// up to 10 minutes to roll out.
72	EnablePerformanceMode *bool
73
74	// Enables pull request previews for this branch.
75	EnablePullRequestPreview *bool
76
77	// The environment variables for the branch.
78	EnvironmentVariables map[string]string
79
80	// The framework for the branch.
81	Framework *string
82
83	// The Amplify environment name for the pull request.
84	PullRequestEnvironmentName *string
85
86	// Describes the current stage for the branch.
87	Stage types.Stage
88
89	// The tag for the branch.
90	Tags map[string]string
91
92	// The content Time To Live (TTL) for the website in seconds.
93	Ttl *string
94}
95
96// The result structure for create branch request.
97type CreateBranchOutput struct {
98
99	// Describes the branch for an Amplify app, which maps to a third-party repository
100	// branch.
101	//
102	// This member is required.
103	Branch *types.Branch
104
105	// Metadata pertaining to the operation's result.
106	ResultMetadata middleware.Metadata
107}
108
109func addOperationCreateBranchMiddlewares(stack *middleware.Stack, options Options) (err error) {
110	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateBranch{}, middleware.After)
111	if err != nil {
112		return err
113	}
114	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateBranch{}, middleware.After)
115	if err != nil {
116		return err
117	}
118	if err = addSetLoggerMiddleware(stack, options); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addResolveEndpointMiddleware(stack, options); err != nil {
128		return err
129	}
130	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
131		return err
132	}
133	if err = addRetryMiddlewares(stack, options); err != nil {
134		return err
135	}
136	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
137		return err
138	}
139	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
140		return err
141	}
142	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
143		return err
144	}
145	if err = addClientUserAgent(stack); err != nil {
146		return err
147	}
148	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
149		return err
150	}
151	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
152		return err
153	}
154	if err = addOpCreateBranchValidationMiddleware(stack); err != nil {
155		return err
156	}
157	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateBranch(options.Region), middleware.Before); err != nil {
158		return err
159	}
160	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
161		return err
162	}
163	if err = addResponseErrorMiddleware(stack); err != nil {
164		return err
165	}
166	if err = addRequestResponseLogging(stack, options); err != nil {
167		return err
168	}
169	return nil
170}
171
172func newServiceMetadataMiddleware_opCreateBranch(region string) *awsmiddleware.RegisterServiceMetadata {
173	return &awsmiddleware.RegisterServiceMetadata{
174		Region:        region,
175		ServiceID:     ServiceID,
176		SigningName:   "amplify",
177		OperationName: "CreateBranch",
178	}
179}
180