1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package directconnect
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/directconnect/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Associates a MAC Security (MACsec) Connection Key Name (CKN)/ Connectivity
15// Association Key (CAK) pair with an AWS Direct Connect dedicated connection. You
16// must supply either the secretARN, or the CKN/CAK (ckn and cak) pair in the
17// request. For information about MAC Security (MACsec) key considerations, see
18// MACsec pre-shared CKN/CAK key considerations
19// (https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-mac-sec-getting-started.html#mac-sec-key-consideration)
20// in the AWS Direct Connect User Guide.
21func (c *Client) AssociateMacSecKey(ctx context.Context, params *AssociateMacSecKeyInput, optFns ...func(*Options)) (*AssociateMacSecKeyOutput, error) {
22	if params == nil {
23		params = &AssociateMacSecKeyInput{}
24	}
25
26	result, metadata, err := c.invokeOperation(ctx, "AssociateMacSecKey", params, optFns, addOperationAssociateMacSecKeyMiddlewares)
27	if err != nil {
28		return nil, err
29	}
30
31	out := result.(*AssociateMacSecKeyOutput)
32	out.ResultMetadata = metadata
33	return out, nil
34}
35
36type AssociateMacSecKeyInput struct {
37
38	// The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
39	// (dxlag-xxxx). You can use DescribeConnections or DescribeLags to retrieve
40	// connection ID.
41	//
42	// This member is required.
43	ConnectionId *string
44
45	// The MAC Security (MACsec) CAK to associate with the dedicated connection. You
46	// can create the CKN/CAK pair using an industry standard tool. The valid values
47	// are 64 hexadecimal characters (0-9, A-E). If you use this request parameter, you
48	// must use the ckn request parameter and not use the secretARN request parameter.
49	Cak *string
50
51	// The MAC Security (MACsec) CKN to associate with the dedicated connection. You
52	// can create the CKN/CAK pair using an industry standard tool. The valid values
53	// are 64 hexadecimal characters (0-9, A-E). If you use this request parameter, you
54	// must use the cak request parameter and not use the secretARN request parameter.
55	Ckn *string
56
57	// The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key to
58	// associate with the dedicated connection. You can use DescribeConnections or
59	// DescribeLags to retrieve the MAC Security (MACsec) secret key. If you use this
60	// request parameter, you do not use the ckn and cak request parameters.
61	SecretARN *string
62}
63
64type AssociateMacSecKeyOutput struct {
65
66	// The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
67	// (dxlag-xxxx).
68	ConnectionId *string
69
70	// The MAC Security (MACsec) security keys associated with the dedicated
71	// connection.
72	MacSecKeys []types.MacSecKey
73
74	// Metadata pertaining to the operation's result.
75	ResultMetadata middleware.Metadata
76}
77
78func addOperationAssociateMacSecKeyMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsAwsjson11_serializeOpAssociateMacSecKey{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAssociateMacSecKey{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	if err = addSetLoggerMiddleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
91		return err
92	}
93	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
94		return err
95	}
96	if err = addResolveEndpointMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
100		return err
101	}
102	if err = addRetryMiddlewares(stack, options); err != nil {
103		return err
104	}
105	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
112		return err
113	}
114	if err = addClientUserAgent(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addOpAssociateMacSecKeyValidationMiddleware(stack); err != nil {
124		return err
125	}
126	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAssociateMacSecKey(options.Region), middleware.Before); err != nil {
127		return err
128	}
129	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addResponseErrorMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addRequestResponseLogging(stack, options); err != nil {
136		return err
137	}
138	return nil
139}
140
141func newServiceMetadataMiddleware_opAssociateMacSecKey(region string) *awsmiddleware.RegisterServiceMetadata {
142	return &awsmiddleware.RegisterServiceMetadata{
143		Region:        region,
144		ServiceID:     ServiceID,
145		SigningName:   "directconnect",
146		OperationName: "AssociateMacSecKey",
147	}
148}
149