service/s3control/api_op_ListJobs.go (306 lines of code) (raw):

// Code generated by smithy-go-codegen DO NOT EDIT. package s3control import ( "context" "fmt" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" s3controlcust "github.com/aws/aws-sdk-go-v2/service/s3control/internal/customizations" "github.com/aws/aws-sdk-go-v2/service/s3control/types" smithy "github.com/aws/smithy-go" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" smithyhttp "github.com/aws/smithy-go/transport/http" "strings" ) // Lists current S3 Batch Operations jobs as well as the jobs that have ended // within the last 90 days for the Amazon Web Services account making the request. // For more information, see [S3 Batch Operations]in the Amazon S3 User Guide. // // Permissions To use the ListJobs operation, you must have permission to perform // the s3:ListJobs action. // // Related actions include: // // [CreateJob] // // [DescribeJob] // // [UpdateJobPriority] // // [UpdateJobStatus] // // [DescribeJob]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_DescribeJob.html // [S3 Batch Operations]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops.html // [UpdateJobPriority]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UpdateJobPriority.html // [CreateJob]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_CreateJob.html // [UpdateJobStatus]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UpdateJobStatus.html func (c *Client) ListJobs(ctx context.Context, params *ListJobsInput, optFns ...func(*Options)) (*ListJobsOutput, error) { if params == nil { params = &ListJobsInput{} } result, metadata, err := c.invokeOperation(ctx, "ListJobs", params, optFns, c.addOperationListJobsMiddlewares) if err != nil { return nil, err } out := result.(*ListJobsOutput) out.ResultMetadata = metadata return out, nil } type ListJobsInput struct { // The Amazon Web Services account ID associated with the S3 Batch Operations job. // // This member is required. AccountId *string // The List Jobs request returns jobs that match the statuses listed in this // element. JobStatuses []types.JobStatus // The maximum number of jobs that Amazon S3 will include in the List Jobs // response. If there are more jobs than this number, the response will include a // pagination token in the NextToken field to enable you to retrieve the next page // of results. MaxResults *int32 // A pagination token to request the next page of results. Use the token that // Amazon S3 returned in the NextToken element of the ListJobsResult from the // previous List Jobs request. NextToken *string noSmithyDocumentSerde } func (in *ListJobsInput) bindEndpointParams(p *EndpointParameters) { p.AccountId = in.AccountId p.RequiresAccountId = ptr.Bool(true) } type ListJobsOutput struct { // The list of current jobs and jobs that have ended within the last 30 days. Jobs []types.JobListDescriptor // If the List Jobs request produced more than the maximum number of results, you // can pass this value into a subsequent List Jobs request in order to retrieve // the next page of results. NextToken *string // Metadata pertaining to the operation's result. ResultMetadata middleware.Metadata noSmithyDocumentSerde } func (c *Client) addOperationListJobsMiddlewares(stack *middleware.Stack, options Options) (err error) { if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil { return err } err = stack.Serialize.Add(&awsRestxml_serializeOpListJobs{}, middleware.After) if err != nil { return err } err = stack.Deserialize.Add(&awsRestxml_deserializeOpListJobs{}, middleware.After) if err != nil { return err } if err := addProtocolFinalizerMiddlewares(stack, options, "ListJobs"); err != nil { return fmt.Errorf("add protocol finalizers: %v", err) } if err = addlegacyEndpointContextSetter(stack, options); err != nil { return err } if err = addSetLoggerMiddleware(stack, options); err != nil { return err } if err = addClientRequestID(stack); err != nil { return err } if err = addComputeContentLength(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } if err = addComputePayloadSHA256(stack); err != nil { return err } if err = addRetry(stack, options); err != nil { return err } if err = addRawResponseToMetadata(stack); err != nil { return err } if err = addRecordResponseTiming(stack); err != nil { return err } if err = addSpanRetryLoop(stack, options); err != nil { return err } if err = addClientUserAgent(stack, options); err != nil { return err } if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { return err } if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { return err } if err = s3controlcust.AddUpdateOutpostARN(stack); err != nil { return err } if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil { return err } if err = addTimeOffsetBuild(stack, c); err != nil { return err } if err = addUserAgentRetryMode(stack, options); err != nil { return err } if err = addCredentialSource(stack, options); err != nil { return err } if err = addEndpointPrefix_opListJobsMiddleware(stack); err != nil { return err } if err = addOpListJobsValidationMiddleware(stack); err != nil { return err } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListJobs(options.Region), middleware.Before); err != nil { return err } if err = addMetadataRetrieverMiddleware(stack); err != nil { return err } if err = addRecursionDetection(stack); err != nil { return err } if err = addListJobsUpdateEndpoint(stack, options); err != nil { return err } if err = addStashOperationInput(stack); err != nil { return err } if err = addResponseErrorMiddleware(stack); err != nil { return err } if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { return err } if err = addRequestResponseLogging(stack, options); err != nil { return err } if err = addDisableHTTPSMiddleware(stack, options); err != nil { return err } if err = s3controlcust.AddDisableHostPrefixMiddleware(stack); err != nil { return err } if err = addSpanInitializeStart(stack); err != nil { return err } if err = addSpanInitializeEnd(stack); err != nil { return err } if err = addSpanBuildRequestStart(stack); err != nil { return err } if err = addSpanBuildRequestEnd(stack); err != nil { return err } return nil } // ListJobsPaginatorOptions is the paginator options for ListJobs type ListJobsPaginatorOptions struct { // The maximum number of jobs that Amazon S3 will include in the List Jobs // response. If there are more jobs than this number, the response will include a // pagination token in the NextToken field to enable you to retrieve the next page // of results. Limit int32 // Set to true if pagination should stop if the service returns a pagination token // that matches the most recent token provided to the service. StopOnDuplicateToken bool } // ListJobsPaginator is a paginator for ListJobs type ListJobsPaginator struct { options ListJobsPaginatorOptions client ListJobsAPIClient params *ListJobsInput nextToken *string firstPage bool } // NewListJobsPaginator returns a new ListJobsPaginator func NewListJobsPaginator(client ListJobsAPIClient, params *ListJobsInput, optFns ...func(*ListJobsPaginatorOptions)) *ListJobsPaginator { if params == nil { params = &ListJobsInput{} } options := ListJobsPaginatorOptions{} if params.MaxResults != nil { options.Limit = *params.MaxResults } for _, fn := range optFns { fn(&options) } return &ListJobsPaginator{ options: options, client: client, params: params, firstPage: true, nextToken: params.NextToken, } } // HasMorePages returns a boolean indicating whether more pages are available func (p *ListJobsPaginator) HasMorePages() bool { return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0) } // NextPage retrieves the next ListJobs page. func (p *ListJobsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListJobsOutput, error) { if !p.HasMorePages() { return nil, fmt.Errorf("no more pages available") } params := *p.params params.NextToken = p.nextToken var limit *int32 if p.options.Limit > 0 { limit = &p.options.Limit } params.MaxResults = limit optFns = append([]func(*Options){ addIsPaginatorUserAgent, }, optFns...) result, err := p.client.ListJobs(ctx, &params, optFns...) if err != nil { return nil, err } p.firstPage = false prevToken := p.nextToken p.nextToken = result.NextToken if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { p.nextToken = nil } return result, nil } type endpointPrefix_opListJobsMiddleware struct { } func (*endpointPrefix_opListJobsMiddleware) ID() string { return "EndpointHostPrefix" } func (m *endpointPrefix_opListJobsMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( out middleware.FinalizeOutput, metadata middleware.Metadata, err error, ) { if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) { return next.HandleFinalize(ctx, in) } req, ok := in.Request.(*smithyhttp.Request) if !ok { return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) } opaqueInput := getOperationInput(ctx) input, ok := opaqueInput.(*ListJobsInput) if !ok { return out, metadata, fmt.Errorf("unknown input type %T", opaqueInput) } var prefix strings.Builder if input.AccountId == nil { return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("AccountId forms part of the endpoint host and so may not be nil")} } else if !smithyhttp.ValidHostLabel(*input.AccountId) { 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)} } else { prefix.WriteString(*input.AccountId) } prefix.WriteString(".") req.URL.Host = prefix.String() + req.URL.Host return next.HandleFinalize(ctx, in) } func addEndpointPrefix_opListJobsMiddleware(stack *middleware.Stack) error { return stack.Finalize.Insert(&endpointPrefix_opListJobsMiddleware{}, "ResolveEndpointV2", middleware.After) } // ListJobsAPIClient is a client that implements the ListJobs operation. type ListJobsAPIClient interface { ListJobs(context.Context, *ListJobsInput, ...func(*Options)) (*ListJobsOutput, error) } var _ ListJobsAPIClient = (*Client)(nil) func newServiceMetadataMiddleware_opListJobs(region string) *awsmiddleware.RegisterServiceMetadata { return &awsmiddleware.RegisterServiceMetadata{ Region: region, ServiceID: ServiceID, OperationName: "ListJobs", } } func copyListJobsInputForUpdateEndpoint(params interface{}) (interface{}, error) { input, ok := params.(*ListJobsInput) if !ok { return nil, fmt.Errorf("expect *ListJobsInput type, got %T", params) } cpy := *input return &cpy, nil } func (in *ListJobsInput) copy() interface{} { v := *in return &v } func backFillListJobsAccountID(input interface{}, v string) error { in := input.(*ListJobsInput) if in.AccountId != nil { if !strings.EqualFold(*in.AccountId, v) { return fmt.Errorf("error backfilling account id") } return nil } in.AccountId = &v return nil } func addListJobsUpdateEndpoint(stack *middleware.Stack, options Options) error { return s3controlcust.UpdateEndpoint(stack, s3controlcust.UpdateEndpointOptions{ Accessor: s3controlcust.UpdateEndpointParameterAccessor{GetARNInput: nopGetARNAccessor, BackfillAccountID: nopBackfillAccountIDAccessor, GetOutpostIDInput: nopGetOutpostIDFromInput, UpdateARNField: nopSetARNAccessor, CopyInput: copyListJobsInputForUpdateEndpoint, }, EndpointResolver: options.EndpointResolver, EndpointResolverOptions: options.EndpointOptions, UseARNRegion: options.UseARNRegion, }) }