1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ecs
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/ecs/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Updates the Amazon ECS container agent on a specified container instance.
15// Updating the Amazon ECS container agent does not interrupt running tasks or
16// services on the container instance. The process for updating the agent differs
17// depending on whether your container instance was launched with the Amazon
18// ECS-optimized AMI or another operating system. The UpdateContainerAgent API
19// isn't supported for container instances using the Amazon ECS-optimized Amazon
20// Linux 2 (arm64) AMI. To update the container agent, you can update the ecs-init
21// package which will update the agent. For more information, see Updating the
22// Amazon ECS container agent
23// (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/agent-update-ecs-ami.html)
24// in the Amazon Elastic Container Service Developer Guide. The
25// UpdateContainerAgent API requires an Amazon ECS-optimized AMI or Amazon Linux
26// AMI with the ecs-init service installed and running. For help updating the
27// Amazon ECS container agent on other operating systems, see Manually updating the
28// Amazon ECS container agent
29// (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-update.html#manually_update_agent)
30// in the Amazon Elastic Container Service Developer Guide.
31func (c *Client) UpdateContainerAgent(ctx context.Context, params *UpdateContainerAgentInput, optFns ...func(*Options)) (*UpdateContainerAgentOutput, error) {
32	if params == nil {
33		params = &UpdateContainerAgentInput{}
34	}
35
36	result, metadata, err := c.invokeOperation(ctx, "UpdateContainerAgent", params, optFns, c.addOperationUpdateContainerAgentMiddlewares)
37	if err != nil {
38		return nil, err
39	}
40
41	out := result.(*UpdateContainerAgentOutput)
42	out.ResultMetadata = metadata
43	return out, nil
44}
45
46type UpdateContainerAgentInput struct {
47
48	// The container instance ID or full ARN entries for the container instance on
49	// which you would like to update the Amazon ECS container agent.
50	//
51	// This member is required.
52	ContainerInstance *string
53
54	// The short name or full Amazon Resource Name (ARN) of the cluster that your
55	// container instance is running on. If you do not specify a cluster, the default
56	// cluster is assumed.
57	Cluster *string
58
59	noSmithyDocumentSerde
60}
61
62type UpdateContainerAgentOutput struct {
63
64	// The container instance for which the container agent was updated.
65	ContainerInstance *types.ContainerInstance
66
67	// Metadata pertaining to the operation's result.
68	ResultMetadata middleware.Metadata
69
70	noSmithyDocumentSerde
71}
72
73func (c *Client) addOperationUpdateContainerAgentMiddlewares(stack *middleware.Stack, options Options) (err error) {
74	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateContainerAgent{}, middleware.After)
75	if err != nil {
76		return err
77	}
78	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateContainerAgent{}, 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 = addOpUpdateContainerAgentValidationMiddleware(stack); err != nil {
119		return err
120	}
121	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateContainerAgent(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_opUpdateContainerAgent(region string) *awsmiddleware.RegisterServiceMetadata {
137	return &awsmiddleware.RegisterServiceMetadata{
138		Region:        region,
139		ServiceID:     ServiceID,
140		SigningName:   "ecs",
141		OperationName: "UpdateContainerAgent",
142	}
143}
144