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// Updates the status for the specified job. Use this operation to confirm that you 19// want to run a job or to cancel an existing job. For more information, see S3 20// Batch Operations 21// (https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-basics.html) in the 22// Amazon Simple Storage Service Developer Guide. Related actions include: 23// 24// * 25// CreateJob 26// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_CreateJob.html) 27// 28// * 29// ListJobs 30// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListJobs.html) 31// 32// * 33// DescribeJob 34// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_DescribeJob.html) 35// 36// * 37// UpdateJobStatus 38// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UpdateJobStatus.html) 39func (c *Client) UpdateJobStatus(ctx context.Context, params *UpdateJobStatusInput, optFns ...func(*Options)) (*UpdateJobStatusOutput, error) { 40 if params == nil { 41 params = &UpdateJobStatusInput{} 42 } 43 44 result, metadata, err := c.invokeOperation(ctx, "UpdateJobStatus", params, optFns, addOperationUpdateJobStatusMiddlewares) 45 if err != nil { 46 return nil, err 47 } 48 49 out := result.(*UpdateJobStatusOutput) 50 out.ResultMetadata = metadata 51 return out, nil 52} 53 54type UpdateJobStatusInput struct { 55 56 // 57 // 58 // This member is required. 59 AccountId *string 60 61 // The ID of the job whose status you want to update. 62 // 63 // This member is required. 64 JobId *string 65 66 // The status that you want to move the specified job to. 67 // 68 // This member is required. 69 RequestedJobStatus types.RequestedJobStatus 70 71 // A description of the reason why you want to change the specified job's status. 72 // This field can be any string up to the maximum length. 73 StatusUpdateReason *string 74} 75 76type UpdateJobStatusOutput struct { 77 78 // The ID for the job whose status was updated. 79 JobId *string 80 81 // The current status for the specified job. 82 Status types.JobStatus 83 84 // The reason that the specified job's status was updated. 85 StatusUpdateReason *string 86 87 // Metadata pertaining to the operation's result. 88 ResultMetadata middleware.Metadata 89} 90 91func addOperationUpdateJobStatusMiddlewares(stack *middleware.Stack, options Options) (err error) { 92 err = stack.Serialize.Add(&awsRestxml_serializeOpUpdateJobStatus{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 err = stack.Deserialize.Add(&awsRestxml_deserializeOpUpdateJobStatus{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 if err = addSetLoggerMiddleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addResolveEndpointMiddleware(stack, options); err != nil { 110 return err 111 } 112 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 113 return err 114 } 115 if err = addRetryMiddlewares(stack, options); err != nil { 116 return err 117 } 118 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 125 return err 126 } 127 if err = addClientUserAgent(stack); err != nil { 128 return err 129 } 130 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addEndpointPrefix_opUpdateJobStatusMiddleware(stack); err != nil { 137 return err 138 } 139 if err = addOpUpdateJobStatusValidationMiddleware(stack); err != nil { 140 return err 141 } 142 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateJobStatus(options.Region), middleware.Before); err != nil { 143 return err 144 } 145 if err = addMetadataRetrieverMiddleware(stack); err != nil { 146 return err 147 } 148 if err = addUpdateJobStatusUpdateEndpoint(stack, options); err != nil { 149 return err 150 } 151 if err = addResponseErrorMiddleware(stack); err != nil { 152 return err 153 } 154 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 155 return err 156 } 157 if err = addRequestResponseLogging(stack, options); err != nil { 158 return err 159 } 160 return nil 161} 162 163type endpointPrefix_opUpdateJobStatusMiddleware struct { 164} 165 166func (*endpointPrefix_opUpdateJobStatusMiddleware) ID() string { 167 return "EndpointHostPrefix" 168} 169 170func (m *endpointPrefix_opUpdateJobStatusMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 171 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 172) { 173 if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) { 174 return next.HandleSerialize(ctx, in) 175 } 176 177 req, ok := in.Request.(*smithyhttp.Request) 178 if !ok { 179 return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) 180 } 181 182 input, ok := in.Parameters.(*UpdateJobStatusInput) 183 if !ok { 184 return out, metadata, fmt.Errorf("unknown input type %T", in.Parameters) 185 } 186 187 var prefix strings.Builder 188 if input.AccountId == nil { 189 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so may not be nil")} 190 } else if !smithyhttp.ValidHostLabel(*input.AccountId) { 191 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)} 192 } else { 193 prefix.WriteString(*input.AccountId) 194 } 195 prefix.WriteString(".") 196 req.URL.Host = prefix.String() + req.URL.Host 197 198 return next.HandleSerialize(ctx, in) 199} 200func addEndpointPrefix_opUpdateJobStatusMiddleware(stack *middleware.Stack) error { 201 return stack.Serialize.Insert(&endpointPrefix_opUpdateJobStatusMiddleware{}, `OperationSerializer`, middleware.After) 202} 203 204func newServiceMetadataMiddleware_opUpdateJobStatus(region string) *awsmiddleware.RegisterServiceMetadata { 205 return &awsmiddleware.RegisterServiceMetadata{ 206 Region: region, 207 ServiceID: ServiceID, 208 SigningName: "s3", 209 OperationName: "UpdateJobStatus", 210 } 211} 212 213func copyUpdateJobStatusInputForUpdateEndpoint(params interface{}) (interface{}, error) { 214 input, ok := params.(*UpdateJobStatusInput) 215 if !ok { 216 return nil, fmt.Errorf("expect *UpdateJobStatusInput type, got %T", params) 217 } 218 cpy := *input 219 return &cpy, nil 220} 221func backFillUpdateJobStatusAccountID(input interface{}, v string) error { 222 in := input.(*UpdateJobStatusInput) 223 if in.AccountId != nil { 224 if !strings.EqualFold(*in.AccountId, v) { 225 return fmt.Errorf("error backfilling account id") 226 } 227 return nil 228 } 229 in.AccountId = &v 230 return nil 231} 232func addUpdateJobStatusUpdateEndpoint(stack *middleware.Stack, options Options) error { 233 return s3controlcust.UpdateEndpoint(stack, s3controlcust.UpdateEndpointOptions{ 234 Accessor: s3controlcust.UpdateEndpointParameterAccessor{GetARNInput: nopGetARNAccessor, 235 BackfillAccountID: nopBackfillAccountIDAccessor, 236 GetOutpostIDInput: nopGetOutpostIDFromInput, 237 UpdateARNField: nopSetARNAccessor, 238 CopyInput: copyUpdateJobStatusInputForUpdateEndpoint, 239 }, 240 EndpointResolver: options.EndpointResolver, 241 EndpointResolverOptions: options.EndpointOptions, 242 UseDualstack: options.UseDualstack, 243 UseARNRegion: options.UseARNRegion, 244 }) 245} 246