1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package datasync
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/datasync/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Activates an AWS DataSync agent that you have deployed on your host. The
15// activation process associates your agent with your account. In the activation
16// process, you specify information such as the AWS Region that you want to
17// activate the agent in. You activate the agent in the AWS Region where your
18// target locations (in Amazon S3 or Amazon EFS) reside. Your tasks are created in
19// this AWS Region. You can activate the agent in a VPC (virtual private cloud) or
20// provide the agent access to a VPC endpoint so you can run tasks without going
21// over the public internet. You can use an agent for more than one location. If a
22// task uses multiple agents, all of them need to have status AVAILABLE for the
23// task to run. If you use multiple agents for a source location, the status of all
24// the agents must be AVAILABLE for the task to run. Agents are automatically
25// updated by AWS on a regular basis, using a mechanism that ensures minimal
26// interruption to your tasks.
27func (c *Client) CreateAgent(ctx context.Context, params *CreateAgentInput, optFns ...func(*Options)) (*CreateAgentOutput, error) {
28	if params == nil {
29		params = &CreateAgentInput{}
30	}
31
32	result, metadata, err := c.invokeOperation(ctx, "CreateAgent", params, optFns, addOperationCreateAgentMiddlewares)
33	if err != nil {
34		return nil, err
35	}
36
37	out := result.(*CreateAgentOutput)
38	out.ResultMetadata = metadata
39	return out, nil
40}
41
42// CreateAgentRequest
43type CreateAgentInput struct {
44
45	// Your agent activation key. You can get the activation key either by sending an
46	// HTTP GET request with redirects that enable you to get the agent IP address
47	// (port 80). Alternatively, you can get it from the AWS DataSync console. The
48	// redirect URL returned in the response provides you the activation key for your
49	// agent in the query string parameter activationKey. It might also include other
50	// activation-related parameters; however, these are merely defaults. The arguments
51	// you pass to this API call determine the actual configuration of your agent. For
52	// more information, see Activating an Agent in the AWS DataSync User Guide.
53	//
54	// This member is required.
55	ActivationKey *string
56
57	// The name you configured for your agent. This value is a text reference that is
58	// used to identify the agent in the console.
59	AgentName *string
60
61	// The ARNs of the security groups used to protect your data transfer task subnets.
62	// See CreateAgentRequest$SubnetArns.
63	SecurityGroupArns []string
64
65	// The Amazon Resource Names (ARNs) of the subnets in which DataSync will create
66	// elastic network interfaces for each data transfer task. The agent that runs a
67	// task must be private. When you start a task that is associated with an agent
68	// created in a VPC, or one that has access to an IP address in a VPC, then the
69	// task is also private. In this case, DataSync creates four network interfaces for
70	// each task in your subnet. For a data transfer to work, the agent must be able to
71	// route to all these four network interfaces.
72	SubnetArns []string
73
74	// The key-value pair that represents the tag that you want to associate with the
75	// agent. The value can be an empty string. This value helps you manage, filter,
76	// and search for your agents. Valid characters for key and value are letters,
77	// spaces, and numbers representable in UTF-8 format, and the following special
78	// characters: + - = . _ : / @.
79	Tags []types.TagListEntry
80
81	// The ID of the VPC (virtual private cloud) endpoint that the agent has access to.
82	// This is the client-side VPC endpoint, also called a PrivateLink. If you don't
83	// have a PrivateLink VPC endpoint, see Creating a VPC Endpoint Service
84	// Configuration
85	// (https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html#create-endpoint-service)
86	// in the Amazon VPC User Guide. VPC endpoint ID looks like this:
87	// vpce-01234d5aff67890e1.
88	VpcEndpointId *string
89}
90
91// CreateAgentResponse
92type CreateAgentOutput struct {
93
94	// The Amazon Resource Name (ARN) of the agent. Use the ListAgents operation to
95	// return a list of agents for your account and AWS Region.
96	AgentArn *string
97
98	// Metadata pertaining to the operation's result.
99	ResultMetadata middleware.Metadata
100}
101
102func addOperationCreateAgentMiddlewares(stack *middleware.Stack, options Options) (err error) {
103	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateAgent{}, middleware.After)
104	if err != nil {
105		return err
106	}
107	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateAgent{}, middleware.After)
108	if err != nil {
109		return err
110	}
111	if err = addSetLoggerMiddleware(stack, options); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
118		return err
119	}
120	if err = addResolveEndpointMiddleware(stack, options); err != nil {
121		return err
122	}
123	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
124		return err
125	}
126	if err = addRetryMiddlewares(stack, options); err != nil {
127		return err
128	}
129	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
130		return err
131	}
132	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
133		return err
134	}
135	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
136		return err
137	}
138	if err = addClientUserAgent(stack); err != nil {
139		return err
140	}
141	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
145		return err
146	}
147	if err = addOpCreateAgentValidationMiddleware(stack); err != nil {
148		return err
149	}
150	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateAgent(options.Region), middleware.Before); err != nil {
151		return err
152	}
153	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
154		return err
155	}
156	if err = addResponseErrorMiddleware(stack); err != nil {
157		return err
158	}
159	if err = addRequestResponseLogging(stack, options); err != nil {
160		return err
161	}
162	return nil
163}
164
165func newServiceMetadataMiddleware_opCreateAgent(region string) *awsmiddleware.RegisterServiceMetadata {
166	return &awsmiddleware.RegisterServiceMetadata{
167		Region:        region,
168		ServiceID:     ServiceID,
169		SigningName:   "datasync",
170		OperationName: "CreateAgent",
171	}
172}
173