1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package s3control 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 s3controlcust "github.com/aws/aws-sdk-go-v2/service/s3control/internal/customizations" 11 "github.com/aws/aws-sdk-go-v2/service/s3control/types" 12 smithy "github.com/aws/smithy-go" 13 "github.com/aws/smithy-go/middleware" 14 smithyhttp "github.com/aws/smithy-go/transport/http" 15 "strings" 16) 17 18// S3 Batch Operations performs large-scale Batch Operations on Amazon S3 objects. 19// Batch Operations can run a single operation or action on lists of Amazon S3 20// objects that you specify. For more information, see S3 Batch Operations 21// (https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-basics.html) in the 22// Amazon Simple Storage Service Developer Guide. This operation creates an S3 23// Batch Operations job. Related actions include: 24// 25// * DescribeJob 26// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_DescribeJob.html) 27// 28// * 29// ListJobs 30// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListJobs.html) 31// 32// * 33// UpdateJobPriority 34// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UpdateJobPriority.html) 35// 36// * 37// UpdateJobStatus 38// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UpdateJobStatus.html) 39func (c *Client) CreateJob(ctx context.Context, params *CreateJobInput, optFns ...func(*Options)) (*CreateJobOutput, error) { 40 if params == nil { 41 params = &CreateJobInput{} 42 } 43 44 result, metadata, err := c.invokeOperation(ctx, "CreateJob", params, optFns, addOperationCreateJobMiddlewares) 45 if err != nil { 46 return nil, err 47 } 48 49 out := result.(*CreateJobOutput) 50 out.ResultMetadata = metadata 51 return out, nil 52} 53 54type CreateJobInput struct { 55 56 // The AWS account ID that creates the job. 57 // 58 // This member is required. 59 AccountId *string 60 61 // An idempotency token to ensure that you don't accidentally submit the same 62 // request twice. You can use any string up to the maximum length. 63 // 64 // This member is required. 65 ClientRequestToken *string 66 67 // Configuration parameters for the manifest. 68 // 69 // This member is required. 70 Manifest *types.JobManifest 71 72 // The operation that you want this job to perform on each object listed in the 73 // manifest. For more information about the available operations, see Operations 74 // (https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-operations.html) in 75 // the Amazon Simple Storage Service Developer Guide. 76 // 77 // This member is required. 78 Operation *types.JobOperation 79 80 // The numerical priority for this job. Higher numbers indicate higher priority. 81 // 82 // This member is required. 83 Priority int32 84 85 // Configuration parameters for the optional job-completion report. 86 // 87 // This member is required. 88 Report *types.JobReport 89 90 // The Amazon Resource Name (ARN) for the AWS Identity and Access Management (IAM) 91 // role that Batch Operations will use to run this job's operation on each object 92 // in the manifest. 93 // 94 // This member is required. 95 RoleArn *string 96 97 // Indicates whether confirmation is required before Amazon S3 runs the job. 98 // Confirmation is only required for jobs created through the Amazon S3 console. 99 ConfirmationRequired bool 100 101 // A description for this job. You can use any string within the permitted length. 102 // Descriptions don't need to be unique and can be used for multiple jobs. 103 Description *string 104 105 // A set of tags to associate with the S3 Batch Operations job. This is an optional 106 // parameter. 107 Tags []types.S3Tag 108} 109 110type CreateJobOutput struct { 111 112 // The ID for this job. Amazon S3 generates this ID automatically and returns it 113 // after a successful Create Job request. 114 JobId *string 115 116 // Metadata pertaining to the operation's result. 117 ResultMetadata middleware.Metadata 118} 119 120func addOperationCreateJobMiddlewares(stack *middleware.Stack, options Options) (err error) { 121 err = stack.Serialize.Add(&awsRestxml_serializeOpCreateJob{}, middleware.After) 122 if err != nil { 123 return err 124 } 125 err = stack.Deserialize.Add(&awsRestxml_deserializeOpCreateJob{}, middleware.After) 126 if err != nil { 127 return err 128 } 129 if err = addSetLoggerMiddleware(stack, options); err != nil { 130 return err 131 } 132 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 133 return err 134 } 135 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 136 return err 137 } 138 if err = addResolveEndpointMiddleware(stack, options); err != nil { 139 return err 140 } 141 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 142 return err 143 } 144 if err = addRetryMiddlewares(stack, options); err != nil { 145 return err 146 } 147 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 148 return err 149 } 150 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 151 return err 152 } 153 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 154 return err 155 } 156 if err = addClientUserAgent(stack); err != nil { 157 return err 158 } 159 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 160 return err 161 } 162 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 163 return err 164 } 165 if err = addEndpointPrefix_opCreateJobMiddleware(stack); err != nil { 166 return err 167 } 168 if err = addIdempotencyToken_opCreateJobMiddleware(stack, options); err != nil { 169 return err 170 } 171 if err = addOpCreateJobValidationMiddleware(stack); err != nil { 172 return err 173 } 174 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateJob(options.Region), middleware.Before); err != nil { 175 return err 176 } 177 if err = addMetadataRetrieverMiddleware(stack); err != nil { 178 return err 179 } 180 if err = addCreateJobUpdateEndpoint(stack, options); err != nil { 181 return err 182 } 183 if err = addResponseErrorMiddleware(stack); err != nil { 184 return err 185 } 186 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 187 return err 188 } 189 if err = addRequestResponseLogging(stack, options); err != nil { 190 return err 191 } 192 return nil 193} 194 195type endpointPrefix_opCreateJobMiddleware struct { 196} 197 198func (*endpointPrefix_opCreateJobMiddleware) ID() string { 199 return "EndpointHostPrefix" 200} 201 202func (m *endpointPrefix_opCreateJobMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 203 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 204) { 205 if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) { 206 return next.HandleSerialize(ctx, in) 207 } 208 209 req, ok := in.Request.(*smithyhttp.Request) 210 if !ok { 211 return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) 212 } 213 214 input, ok := in.Parameters.(*CreateJobInput) 215 if !ok { 216 return out, metadata, fmt.Errorf("unknown input type %T", in.Parameters) 217 } 218 219 var prefix strings.Builder 220 if input.AccountId == nil { 221 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so may not be nil")} 222 } else if !smithyhttp.ValidHostLabel(*input.AccountId) { 223 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so must match \"[a-zA-Z0-9-]{1,63}\", but was \"%s\"", *input.AccountId)} 224 } else { 225 prefix.WriteString(*input.AccountId) 226 } 227 prefix.WriteString(".") 228 req.URL.Host = prefix.String() + req.URL.Host 229 230 return next.HandleSerialize(ctx, in) 231} 232func addEndpointPrefix_opCreateJobMiddleware(stack *middleware.Stack) error { 233 return stack.Serialize.Insert(&endpointPrefix_opCreateJobMiddleware{}, `OperationSerializer`, middleware.After) 234} 235 236type idempotencyToken_initializeOpCreateJob struct { 237 tokenProvider IdempotencyTokenProvider 238} 239 240func (*idempotencyToken_initializeOpCreateJob) ID() string { 241 return "OperationIdempotencyTokenAutoFill" 242} 243 244func (m *idempotencyToken_initializeOpCreateJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 245 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 246) { 247 if m.tokenProvider == nil { 248 return next.HandleInitialize(ctx, in) 249 } 250 251 input, ok := in.Parameters.(*CreateJobInput) 252 if !ok { 253 return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateJobInput ") 254 } 255 256 if input.ClientRequestToken == nil { 257 t, err := m.tokenProvider.GetIdempotencyToken() 258 if err != nil { 259 return out, metadata, err 260 } 261 input.ClientRequestToken = &t 262 } 263 return next.HandleInitialize(ctx, in) 264} 265func addIdempotencyToken_opCreateJobMiddleware(stack *middleware.Stack, cfg Options) error { 266 return stack.Initialize.Add(&idempotencyToken_initializeOpCreateJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 267} 268 269func newServiceMetadataMiddleware_opCreateJob(region string) *awsmiddleware.RegisterServiceMetadata { 270 return &awsmiddleware.RegisterServiceMetadata{ 271 Region: region, 272 ServiceID: ServiceID, 273 SigningName: "s3", 274 OperationName: "CreateJob", 275 } 276} 277 278func copyCreateJobInputForUpdateEndpoint(params interface{}) (interface{}, error) { 279 input, ok := params.(*CreateJobInput) 280 if !ok { 281 return nil, fmt.Errorf("expect *CreateJobInput type, got %T", params) 282 } 283 cpy := *input 284 return &cpy, nil 285} 286func backFillCreateJobAccountID(input interface{}, v string) error { 287 in := input.(*CreateJobInput) 288 if in.AccountId != nil { 289 if !strings.EqualFold(*in.AccountId, v) { 290 return fmt.Errorf("error backfilling account id") 291 } 292 return nil 293 } 294 in.AccountId = &v 295 return nil 296} 297func addCreateJobUpdateEndpoint(stack *middleware.Stack, options Options) error { 298 return s3controlcust.UpdateEndpoint(stack, s3controlcust.UpdateEndpointOptions{ 299 Accessor: s3controlcust.UpdateEndpointParameterAccessor{GetARNInput: nopGetARNAccessor, 300 BackfillAccountID: nopBackfillAccountIDAccessor, 301 GetOutpostIDInput: nopGetOutpostIDFromInput, 302 UpdateARNField: nopSetARNAccessor, 303 CopyInput: copyCreateJobInputForUpdateEndpoint, 304 }, 305 EndpointResolver: options.EndpointResolver, 306 EndpointResolverOptions: options.EndpointOptions, 307 UseDualstack: options.UseDualstack, 308 UseARNRegion: options.UseARNRegion, 309 }) 310} 311