1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package glue 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/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Retrieves the names of all crawler resources in this AWS account, or the 15// resources with the specified tag. This operation allows you to see which 16// resources are available in your account, and their names. This operation takes 17// the optional Tags field, which you can use as a filter on the response so that 18// tagged resources can be retrieved as a group. If you choose to use tags 19// filtering, only resources with the tag are retrieved. 20func (c *Client) ListCrawlers(ctx context.Context, params *ListCrawlersInput, optFns ...func(*Options)) (*ListCrawlersOutput, error) { 21 if params == nil { 22 params = &ListCrawlersInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "ListCrawlers", params, optFns, addOperationListCrawlersMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*ListCrawlersOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33} 34 35type ListCrawlersInput struct { 36 37 // The maximum size of a list to return. 38 MaxResults *int32 39 40 // A continuation token, if this is a continuation request. 41 NextToken *string 42 43 // Specifies to return only these tagged resources. 44 Tags map[string]string 45} 46 47type ListCrawlersOutput struct { 48 49 // The names of all crawlers in the account, or the crawlers with the specified 50 // tags. 51 CrawlerNames []string 52 53 // A continuation token, if the returned list does not contain the last metric 54 // available. 55 NextToken *string 56 57 // Metadata pertaining to the operation's result. 58 ResultMetadata middleware.Metadata 59} 60 61func addOperationListCrawlersMiddlewares(stack *middleware.Stack, options Options) (err error) { 62 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCrawlers{}, middleware.After) 63 if err != nil { 64 return err 65 } 66 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCrawlers{}, 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_opListCrawlers(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// ListCrawlersAPIClient is a client that implements the ListCrawlers operation. 122type ListCrawlersAPIClient interface { 123 ListCrawlers(context.Context, *ListCrawlersInput, ...func(*Options)) (*ListCrawlersOutput, error) 124} 125 126var _ ListCrawlersAPIClient = (*Client)(nil) 127 128// ListCrawlersPaginatorOptions is the paginator options for ListCrawlers 129type ListCrawlersPaginatorOptions struct { 130 // The maximum size of a list to return. 131 Limit int32 132 133 // Set to true if pagination should stop if the service returns a pagination token 134 // that matches the most recent token provided to the service. 135 StopOnDuplicateToken bool 136} 137 138// ListCrawlersPaginator is a paginator for ListCrawlers 139type ListCrawlersPaginator struct { 140 options ListCrawlersPaginatorOptions 141 client ListCrawlersAPIClient 142 params *ListCrawlersInput 143 nextToken *string 144 firstPage bool 145} 146 147// NewListCrawlersPaginator returns a new ListCrawlersPaginator 148func NewListCrawlersPaginator(client ListCrawlersAPIClient, params *ListCrawlersInput, optFns ...func(*ListCrawlersPaginatorOptions)) *ListCrawlersPaginator { 149 options := ListCrawlersPaginatorOptions{} 150 if params.MaxResults != nil { 151 options.Limit = *params.MaxResults 152 } 153 154 for _, fn := range optFns { 155 fn(&options) 156 } 157 158 if params == nil { 159 params = &ListCrawlersInput{} 160 } 161 162 return &ListCrawlersPaginator{ 163 options: options, 164 client: client, 165 params: params, 166 firstPage: true, 167 } 168} 169 170// HasMorePages returns a boolean indicating whether more pages are available 171func (p *ListCrawlersPaginator) HasMorePages() bool { 172 return p.firstPage || p.nextToken != nil 173} 174 175// NextPage retrieves the next ListCrawlers page. 176func (p *ListCrawlersPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCrawlersOutput, error) { 177 if !p.HasMorePages() { 178 return nil, fmt.Errorf("no more pages available") 179 } 180 181 params := *p.params 182 params.NextToken = p.nextToken 183 184 var limit *int32 185 if p.options.Limit > 0 { 186 limit = &p.options.Limit 187 } 188 params.MaxResults = limit 189 190 result, err := p.client.ListCrawlers(ctx, ¶ms, optFns...) 191 if err != nil { 192 return nil, err 193 } 194 p.firstPage = false 195 196 prevToken := p.nextToken 197 p.nextToken = result.NextToken 198 199 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 200 p.nextToken = nil 201 } 202 203 return result, nil 204} 205 206func newServiceMetadataMiddleware_opListCrawlers(region string) *awsmiddleware.RegisterServiceMetadata { 207 return &awsmiddleware.RegisterServiceMetadata{ 208 Region: region, 209 ServiceID: ServiceID, 210 SigningName: "glue", 211 OperationName: "ListCrawlers", 212 } 213} 214