1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package lakeformation 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/lakeformation/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the resources registered to be managed by the Data Catalog. 16func (c *Client) ListResources(ctx context.Context, params *ListResourcesInput, optFns ...func(*Options)) (*ListResourcesOutput, error) { 17 if params == nil { 18 params = &ListResourcesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListResources", params, optFns, addOperationListResourcesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListResourcesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListResourcesInput struct { 32 33 // Any applicable row-level and/or column-level filtering conditions for the 34 // resources. 35 FilterConditionList []types.FilterCondition 36 37 // The maximum number of resource results. 38 MaxResults *int32 39 40 // A continuation token, if this is not the first call to retrieve these resources. 41 NextToken *string 42} 43 44type ListResourcesOutput struct { 45 46 // A continuation token, if this is not the first call to retrieve these resources. 47 NextToken *string 48 49 // A summary of the data lake resources. 50 ResourceInfoList []types.ResourceInfo 51 52 // Metadata pertaining to the operation's result. 53 ResultMetadata middleware.Metadata 54} 55 56func addOperationListResourcesMiddlewares(stack *middleware.Stack, options Options) (err error) { 57 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListResources{}, middleware.After) 58 if err != nil { 59 return err 60 } 61 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListResources{}, middleware.After) 62 if err != nil { 63 return err 64 } 65 if err = addSetLoggerMiddleware(stack, options); err != nil { 66 return err 67 } 68 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 69 return err 70 } 71 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 72 return err 73 } 74 if err = addResolveEndpointMiddleware(stack, options); err != nil { 75 return err 76 } 77 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 78 return err 79 } 80 if err = addRetryMiddlewares(stack, options); err != nil { 81 return err 82 } 83 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 84 return err 85 } 86 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 87 return err 88 } 89 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 90 return err 91 } 92 if err = addClientUserAgent(stack); err != nil { 93 return err 94 } 95 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 96 return err 97 } 98 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 99 return err 100 } 101 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListResources(options.Region), middleware.Before); err != nil { 102 return err 103 } 104 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 105 return err 106 } 107 if err = addResponseErrorMiddleware(stack); err != nil { 108 return err 109 } 110 if err = addRequestResponseLogging(stack, options); err != nil { 111 return err 112 } 113 return nil 114} 115 116// ListResourcesAPIClient is a client that implements the ListResources operation. 117type ListResourcesAPIClient interface { 118 ListResources(context.Context, *ListResourcesInput, ...func(*Options)) (*ListResourcesOutput, error) 119} 120 121var _ ListResourcesAPIClient = (*Client)(nil) 122 123// ListResourcesPaginatorOptions is the paginator options for ListResources 124type ListResourcesPaginatorOptions struct { 125 // The maximum number of resource results. 126 Limit int32 127 128 // Set to true if pagination should stop if the service returns a pagination token 129 // that matches the most recent token provided to the service. 130 StopOnDuplicateToken bool 131} 132 133// ListResourcesPaginator is a paginator for ListResources 134type ListResourcesPaginator struct { 135 options ListResourcesPaginatorOptions 136 client ListResourcesAPIClient 137 params *ListResourcesInput 138 nextToken *string 139 firstPage bool 140} 141 142// NewListResourcesPaginator returns a new ListResourcesPaginator 143func NewListResourcesPaginator(client ListResourcesAPIClient, params *ListResourcesInput, optFns ...func(*ListResourcesPaginatorOptions)) *ListResourcesPaginator { 144 if params == nil { 145 params = &ListResourcesInput{} 146 } 147 148 options := ListResourcesPaginatorOptions{} 149 if params.MaxResults != nil { 150 options.Limit = *params.MaxResults 151 } 152 153 for _, fn := range optFns { 154 fn(&options) 155 } 156 157 return &ListResourcesPaginator{ 158 options: options, 159 client: client, 160 params: params, 161 firstPage: true, 162 } 163} 164 165// HasMorePages returns a boolean indicating whether more pages are available 166func (p *ListResourcesPaginator) HasMorePages() bool { 167 return p.firstPage || p.nextToken != nil 168} 169 170// NextPage retrieves the next ListResources page. 171func (p *ListResourcesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListResourcesOutput, error) { 172 if !p.HasMorePages() { 173 return nil, fmt.Errorf("no more pages available") 174 } 175 176 params := *p.params 177 params.NextToken = p.nextToken 178 179 var limit *int32 180 if p.options.Limit > 0 { 181 limit = &p.options.Limit 182 } 183 params.MaxResults = limit 184 185 result, err := p.client.ListResources(ctx, ¶ms, optFns...) 186 if err != nil { 187 return nil, err 188 } 189 p.firstPage = false 190 191 prevToken := p.nextToken 192 p.nextToken = result.NextToken 193 194 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 195 p.nextToken = nil 196 } 197 198 return result, nil 199} 200 201func newServiceMetadataMiddleware_opListResources(region string) *awsmiddleware.RegisterServiceMetadata { 202 return &awsmiddleware.RegisterServiceMetadata{ 203 Region: region, 204 ServiceID: ServiceID, 205 SigningName: "lakeformation", 206 OperationName: "ListResources", 207 } 208} 209