1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package macie2 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 "github.com/aws/aws-sdk-go-v2/service/macie2/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Retrieves a subset of information about one or more classification jobs. 16func (c *Client) ListClassificationJobs(ctx context.Context, params *ListClassificationJobsInput, optFns ...func(*Options)) (*ListClassificationJobsOutput, error) { 17 if params == nil { 18 params = &ListClassificationJobsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListClassificationJobs", params, optFns, addOperationListClassificationJobsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListClassificationJobsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListClassificationJobsInput struct { 32 33 // The criteria to use to filter the results. 34 FilterCriteria *types.ListJobsFilterCriteria 35 36 // The maximum number of items to include in each page of the response. 37 MaxResults int32 38 39 // The nextToken string that specifies which page of results to return in a 40 // paginated response. 41 NextToken *string 42 43 // The criteria to use to sort the results. 44 SortCriteria *types.ListJobsSortCriteria 45} 46 47type ListClassificationJobsOutput struct { 48 49 // An array of objects, one for each job that meets the filter criteria specified 50 // in the request. 51 Items []types.JobSummary 52 53 // The string to use in a subsequent request to get the next page of results in a 54 // paginated response. This value is null if there are no additional pages. 55 NextToken *string 56 57 // Metadata pertaining to the operation's result. 58 ResultMetadata middleware.Metadata 59} 60 61func addOperationListClassificationJobsMiddlewares(stack *middleware.Stack, options Options) (err error) { 62 err = stack.Serialize.Add(&awsRestjson1_serializeOpListClassificationJobs{}, middleware.After) 63 if err != nil { 64 return err 65 } 66 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListClassificationJobs{}, middleware.After) 67 if err != nil { 68 return err 69 } 70 if err = addSetLoggerMiddleware(stack, options); err != nil { 71 return err 72 } 73 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 74 return err 75 } 76 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 77 return err 78 } 79 if err = addResolveEndpointMiddleware(stack, options); err != nil { 80 return err 81 } 82 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 83 return err 84 } 85 if err = addRetryMiddlewares(stack, options); err != nil { 86 return err 87 } 88 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 89 return err 90 } 91 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 92 return err 93 } 94 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 95 return err 96 } 97 if err = addClientUserAgent(stack); err != nil { 98 return err 99 } 100 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 101 return err 102 } 103 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 104 return err 105 } 106 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListClassificationJobs(options.Region), middleware.Before); err != nil { 107 return err 108 } 109 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 110 return err 111 } 112 if err = addResponseErrorMiddleware(stack); err != nil { 113 return err 114 } 115 if err = addRequestResponseLogging(stack, options); err != nil { 116 return err 117 } 118 return nil 119} 120 121// ListClassificationJobsAPIClient is a client that implements the 122// ListClassificationJobs operation. 123type ListClassificationJobsAPIClient interface { 124 ListClassificationJobs(context.Context, *ListClassificationJobsInput, ...func(*Options)) (*ListClassificationJobsOutput, error) 125} 126 127var _ ListClassificationJobsAPIClient = (*Client)(nil) 128 129// ListClassificationJobsPaginatorOptions is the paginator options for 130// ListClassificationJobs 131type ListClassificationJobsPaginatorOptions struct { 132 // The maximum number of items to include in each page of the response. 133 Limit int32 134 135 // Set to true if pagination should stop if the service returns a pagination token 136 // that matches the most recent token provided to the service. 137 StopOnDuplicateToken bool 138} 139 140// ListClassificationJobsPaginator is a paginator for ListClassificationJobs 141type ListClassificationJobsPaginator struct { 142 options ListClassificationJobsPaginatorOptions 143 client ListClassificationJobsAPIClient 144 params *ListClassificationJobsInput 145 nextToken *string 146 firstPage bool 147} 148 149// NewListClassificationJobsPaginator returns a new ListClassificationJobsPaginator 150func NewListClassificationJobsPaginator(client ListClassificationJobsAPIClient, params *ListClassificationJobsInput, optFns ...func(*ListClassificationJobsPaginatorOptions)) *ListClassificationJobsPaginator { 151 if params == nil { 152 params = &ListClassificationJobsInput{} 153 } 154 155 options := ListClassificationJobsPaginatorOptions{} 156 if params.MaxResults != 0 { 157 options.Limit = params.MaxResults 158 } 159 160 for _, fn := range optFns { 161 fn(&options) 162 } 163 164 return &ListClassificationJobsPaginator{ 165 options: options, 166 client: client, 167 params: params, 168 firstPage: true, 169 } 170} 171 172// HasMorePages returns a boolean indicating whether more pages are available 173func (p *ListClassificationJobsPaginator) HasMorePages() bool { 174 return p.firstPage || p.nextToken != nil 175} 176 177// NextPage retrieves the next ListClassificationJobs page. 178func (p *ListClassificationJobsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListClassificationJobsOutput, error) { 179 if !p.HasMorePages() { 180 return nil, fmt.Errorf("no more pages available") 181 } 182 183 params := *p.params 184 params.NextToken = p.nextToken 185 186 params.MaxResults = p.options.Limit 187 188 result, err := p.client.ListClassificationJobs(ctx, ¶ms, optFns...) 189 if err != nil { 190 return nil, err 191 } 192 p.firstPage = false 193 194 prevToken := p.nextToken 195 p.nextToken = result.NextToken 196 197 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 198 p.nextToken = nil 199 } 200 201 return result, nil 202} 203 204func newServiceMetadataMiddleware_opListClassificationJobs(region string) *awsmiddleware.RegisterServiceMetadata { 205 return &awsmiddleware.RegisterServiceMetadata{ 206 Region: region, 207 ServiceID: ServiceID, 208 SigningName: "macie2", 209 OperationName: "ListClassificationJobs", 210 } 211} 212