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// Creates a task. A task includes a source location and a destination location,
15// and a configuration that specifies how data is transferred. A task always
16// transfers data from the source location to the destination location. The
17// configuration specifies options such as task scheduling, bandwidth limits, etc.
18// A task is the complete definition of a data transfer. When you create a task
19// that transfers data between AWS services in different AWS Regions, one of the
20// two locations that you specify must reside in the Region where DataSync is being
21// used. The other location must be specified in a different Region. You can
22// transfer data between commercial AWS Regions except for China, or between AWS
23// GovCloud (US-East and US-West) Regions. When you use DataSync to copy files or
24// objects between AWS Regions, you pay for data transfer between Regions. This is
25// billed as data transfer OUT from your source Region to your destination Region.
26// For more information, see Data Transfer pricing
27// (http://aws.amazon.com/ec2/pricing/on-demand/#Data_Transfer).
28func (c *Client) CreateTask(ctx context.Context, params *CreateTaskInput, optFns ...func(*Options)) (*CreateTaskOutput, error) {
29	if params == nil {
30		params = &CreateTaskInput{}
31	}
32
33	result, metadata, err := c.invokeOperation(ctx, "CreateTask", params, optFns, addOperationCreateTaskMiddlewares)
34	if err != nil {
35		return nil, err
36	}
37
38	out := result.(*CreateTaskOutput)
39	out.ResultMetadata = metadata
40	return out, nil
41}
42
43// CreateTaskRequest
44type CreateTaskInput struct {
45
46	// The Amazon Resource Name (ARN) of an AWS storage resource's location.
47	//
48	// This member is required.
49	DestinationLocationArn *string
50
51	// The Amazon Resource Name (ARN) of the source location for the task.
52	//
53	// This member is required.
54	SourceLocationArn *string
55
56	// The Amazon Resource Name (ARN) of the Amazon CloudWatch log group that is used
57	// to monitor and log events in the task.
58	CloudWatchLogGroupArn *string
59
60	// A list of filter rules that determines which files to exclude from a task. The
61	// list should contain a single filter string that consists of the patterns to
62	// exclude. The patterns are delimited by "|" (that is, a pipe), for example,
63	// "/folder1|/folder2".
64	Excludes []types.FilterRule
65
66	// The name of a task. This value is a text reference that is used to identify the
67	// task in the console.
68	Name *string
69
70	// The set of configuration options that control the behavior of a single execution
71	// of the task that occurs when you call StartTaskExecution. You can configure
72	// these options to preserve metadata such as user ID (UID) and group ID (GID),
73	// file permissions, data integrity verification, and so on. For each individual
74	// task execution, you can override these options by specifying the OverrideOptions
75	// before starting the task execution. For more information, see the operation.
76	Options *types.Options
77
78	// Specifies a schedule used to periodically transfer files from a source to a
79	// destination location. The schedule should be specified in UTC time. For more
80	// information, see task-scheduling.
81	Schedule *types.TaskSchedule
82
83	// The key-value pair that represents the tag that you want to add to the resource.
84	// The value can be an empty string.
85	Tags []types.TagListEntry
86}
87
88// CreateTaskResponse
89type CreateTaskOutput struct {
90
91	// The Amazon Resource Name (ARN) of the task.
92	TaskArn *string
93
94	// Metadata pertaining to the operation's result.
95	ResultMetadata middleware.Metadata
96}
97
98func addOperationCreateTaskMiddlewares(stack *middleware.Stack, options Options) (err error) {
99	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateTask{}, middleware.After)
100	if err != nil {
101		return err
102	}
103	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateTask{}, middleware.After)
104	if err != nil {
105		return err
106	}
107	if err = addSetLoggerMiddleware(stack, options); err != nil {
108		return err
109	}
110	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
114		return err
115	}
116	if err = addResolveEndpointMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
120		return err
121	}
122	if err = addRetryMiddlewares(stack, options); err != nil {
123		return err
124	}
125	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
126		return err
127	}
128	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
129		return err
130	}
131	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
132		return err
133	}
134	if err = addClientUserAgent(stack); err != nil {
135		return err
136	}
137	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
138		return err
139	}
140	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addOpCreateTaskValidationMiddleware(stack); err != nil {
144		return err
145	}
146	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateTask(options.Region), middleware.Before); err != nil {
147		return err
148	}
149	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
150		return err
151	}
152	if err = addResponseErrorMiddleware(stack); err != nil {
153		return err
154	}
155	if err = addRequestResponseLogging(stack, options); err != nil {
156		return err
157	}
158	return nil
159}
160
161func newServiceMetadataMiddleware_opCreateTask(region string) *awsmiddleware.RegisterServiceMetadata {
162	return &awsmiddleware.RegisterServiceMetadata{
163		Region:        region,
164		ServiceID:     ServiceID,
165		SigningName:   "datasync",
166		OperationName: "CreateTask",
167	}
168}
169