1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package eks
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	"github.com/aws/aws-sdk-go-v2/service/eks/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Updates an Amazon EKS cluster configuration. Your cluster continues to function
16// during the update. The response output includes an update ID that you can use to
17// track the status of your cluster update with the DescribeUpdate API operation.
18// You can use this API operation to enable or disable exporting the Kubernetes
19// control plane logs for your cluster to CloudWatch Logs. By default, cluster
20// control plane logs aren't exported to CloudWatch Logs. For more information, see
21// Amazon EKS Cluster Control Plane Logs
22// (https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html) in
23// the Amazon EKS User Guide . CloudWatch Logs ingestion, archive storage, and data
24// scanning rates apply to exported control plane logs. For more information, see
25// CloudWatch Pricing (http://aws.amazon.com/cloudwatch/pricing/). You can also use
26// this API operation to enable or disable public and private access to your
27// cluster's Kubernetes API server endpoint. By default, public access is enabled,
28// and private access is disabled. For more information, see Amazon EKS cluster
29// endpoint access control
30// (https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html) in the
31// Amazon EKS User Guide . You can't update the subnets or security group IDs for
32// an existing cluster. Cluster updates are asynchronous, and they should finish
33// within a few minutes. During an update, the cluster status moves to UPDATING
34// (this status transition is eventually consistent). When the update is complete
35// (either Failed or Successful), the cluster status moves to Active.
36func (c *Client) UpdateClusterConfig(ctx context.Context, params *UpdateClusterConfigInput, optFns ...func(*Options)) (*UpdateClusterConfigOutput, error) {
37	if params == nil {
38		params = &UpdateClusterConfigInput{}
39	}
40
41	result, metadata, err := c.invokeOperation(ctx, "UpdateClusterConfig", params, optFns, c.addOperationUpdateClusterConfigMiddlewares)
42	if err != nil {
43		return nil, err
44	}
45
46	out := result.(*UpdateClusterConfigOutput)
47	out.ResultMetadata = metadata
48	return out, nil
49}
50
51type UpdateClusterConfigInput struct {
52
53	// The name of the Amazon EKS cluster to update.
54	//
55	// This member is required.
56	Name *string
57
58	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
59	// the request.
60	ClientRequestToken *string
61
62	// Enable or disable exporting the Kubernetes control plane logs for your cluster
63	// to CloudWatch Logs. By default, cluster control plane logs aren't exported to
64	// CloudWatch Logs. For more information, see Amazon EKS cluster control plane logs
65	// (https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html) in
66	// the Amazon EKS User Guide . CloudWatch Logs ingestion, archive storage, and data
67	// scanning rates apply to exported control plane logs. For more information, see
68	// CloudWatch Pricing (http://aws.amazon.com/cloudwatch/pricing/).
69	Logging *types.Logging
70
71	// An object representing the VPC configuration to use for an Amazon EKS cluster.
72	ResourcesVpcConfig *types.VpcConfigRequest
73
74	noSmithyDocumentSerde
75}
76
77type UpdateClusterConfigOutput struct {
78
79	// An object representing an asynchronous update.
80	Update *types.Update
81
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84
85	noSmithyDocumentSerde
86}
87
88func (c *Client) addOperationUpdateClusterConfigMiddlewares(stack *middleware.Stack, options Options) (err error) {
89	err = stack.Serialize.Add(&awsRestjson1_serializeOpUpdateClusterConfig{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpUpdateClusterConfig{}, middleware.After)
94	if err != nil {
95		return err
96	}
97	if err = addSetLoggerMiddleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addResolveEndpointMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
110		return err
111	}
112	if err = addRetryMiddlewares(stack, options); err != nil {
113		return err
114	}
115	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
122		return err
123	}
124	if err = addClientUserAgent(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = addIdempotencyToken_opUpdateClusterConfigMiddleware(stack, options); err != nil {
134		return err
135	}
136	if err = addOpUpdateClusterConfigValidationMiddleware(stack); err != nil {
137		return err
138	}
139	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateClusterConfig(options.Region), middleware.Before); err != nil {
140		return err
141	}
142	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
143		return err
144	}
145	if err = addResponseErrorMiddleware(stack); err != nil {
146		return err
147	}
148	if err = addRequestResponseLogging(stack, options); err != nil {
149		return err
150	}
151	return nil
152}
153
154type idempotencyToken_initializeOpUpdateClusterConfig struct {
155	tokenProvider IdempotencyTokenProvider
156}
157
158func (*idempotencyToken_initializeOpUpdateClusterConfig) ID() string {
159	return "OperationIdempotencyTokenAutoFill"
160}
161
162func (m *idempotencyToken_initializeOpUpdateClusterConfig) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
163	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
164) {
165	if m.tokenProvider == nil {
166		return next.HandleInitialize(ctx, in)
167	}
168
169	input, ok := in.Parameters.(*UpdateClusterConfigInput)
170	if !ok {
171		return out, metadata, fmt.Errorf("expected middleware input to be of type *UpdateClusterConfigInput ")
172	}
173
174	if input.ClientRequestToken == nil {
175		t, err := m.tokenProvider.GetIdempotencyToken()
176		if err != nil {
177			return out, metadata, err
178		}
179		input.ClientRequestToken = &t
180	}
181	return next.HandleInitialize(ctx, in)
182}
183func addIdempotencyToken_opUpdateClusterConfigMiddleware(stack *middleware.Stack, cfg Options) error {
184	return stack.Initialize.Add(&idempotencyToken_initializeOpUpdateClusterConfig{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
185}
186
187func newServiceMetadataMiddleware_opUpdateClusterConfig(region string) *awsmiddleware.RegisterServiceMetadata {
188	return &awsmiddleware.RegisterServiceMetadata{
189		Region:        region,
190		ServiceID:     ServiceID,
191		SigningName:   "eks",
192		OperationName: "UpdateClusterConfig",
193	}
194}
195