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 domain association for an Amplify app. This action associates a
15// custom domain with the Amplify app
16func (c *Client) CreateDomainAssociation(ctx context.Context, params *CreateDomainAssociationInput, optFns ...func(*Options)) (*CreateDomainAssociationOutput, error) {
17	if params == nil {
18		params = &CreateDomainAssociationInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "CreateDomainAssociation", params, optFns, addOperationCreateDomainAssociationMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*CreateDomainAssociationOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31// The request structure for the create domain association request.
32type CreateDomainAssociationInput struct {
33
34	// The unique ID for an Amplify app.
35	//
36	// This member is required.
37	AppId *string
38
39	// The domain name for the domain association.
40	//
41	// This member is required.
42	DomainName *string
43
44	// The setting for the subdomain.
45	//
46	// This member is required.
47	SubDomainSettings []types.SubDomainSetting
48
49	// Sets the branch patterns for automatic subdomain creation.
50	AutoSubDomainCreationPatterns []string
51
52	// The required AWS Identity and Access Management (IAM) service role for the
53	// Amazon Resource Name (ARN) for automatically creating subdomains.
54	AutoSubDomainIAMRole *string
55
56	// Enables the automated creation of subdomains for branches.
57	EnableAutoSubDomain *bool
58}
59
60// The result structure for the create domain association request.
61type CreateDomainAssociationOutput struct {
62
63	// Describes the structure of a domain association, which associates a custom
64	// domain with an Amplify app.
65	//
66	// This member is required.
67	DomainAssociation *types.DomainAssociation
68
69	// Metadata pertaining to the operation's result.
70	ResultMetadata middleware.Metadata
71}
72
73func addOperationCreateDomainAssociationMiddlewares(stack *middleware.Stack, options Options) (err error) {
74	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateDomainAssociation{}, middleware.After)
75	if err != nil {
76		return err
77	}
78	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateDomainAssociation{}, middleware.After)
79	if err != nil {
80		return err
81	}
82	if err = addSetLoggerMiddleware(stack, options); err != nil {
83		return err
84	}
85	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
86		return err
87	}
88	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
89		return err
90	}
91	if err = addResolveEndpointMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
95		return err
96	}
97	if err = addRetryMiddlewares(stack, options); err != nil {
98		return err
99	}
100	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
101		return err
102	}
103	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
104		return err
105	}
106	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
107		return err
108	}
109	if err = addClientUserAgent(stack); err != nil {
110		return err
111	}
112	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addOpCreateDomainAssociationValidationMiddleware(stack); err != nil {
119		return err
120	}
121	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDomainAssociation(options.Region), middleware.Before); err != nil {
122		return err
123	}
124	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addResponseErrorMiddleware(stack); err != nil {
128		return err
129	}
130	if err = addRequestResponseLogging(stack, options); err != nil {
131		return err
132	}
133	return nil
134}
135
136func newServiceMetadataMiddleware_opCreateDomainAssociation(region string) *awsmiddleware.RegisterServiceMetadata {
137	return &awsmiddleware.RegisterServiceMetadata{
138		Region:        region,
139		ServiceID:     ServiceID,
140		SigningName:   "amplify",
141		OperationName: "CreateDomainAssociation",
142	}
143}
144