1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ram 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/ram/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the resources that you added to a resource shares or the resources that 16// are shared with you. 17func (c *Client) ListResources(ctx context.Context, params *ListResourcesInput, optFns ...func(*Options)) (*ListResourcesOutput, error) { 18 if params == nil { 19 params = &ListResourcesInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListResources", params, optFns, addOperationListResourcesMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListResourcesOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListResourcesInput struct { 33 34 // The type of owner. 35 // 36 // This member is required. 37 ResourceOwner types.ResourceOwner 38 39 // The maximum number of results to return with a single call. To retrieve the 40 // remaining results, make another call with the returned nextToken value. 41 MaxResults *int32 42 43 // The token for the next page of results. 44 NextToken *string 45 46 // The principal. 47 Principal *string 48 49 // The Amazon Resource Names (ARN) of the resources. 50 ResourceArns []string 51 52 // The Amazon Resource Names (ARN) of the resource shares. 53 ResourceShareArns []string 54 55 // The resource type. Valid values: codebuild:Project | codebuild:ReportGroup | 56 // ec2:CapacityReservation | ec2:DedicatedHost | ec2:Subnet | 57 // ec2:TrafficMirrorTarget | ec2:TransitGateway | imagebuilder:Component | 58 // imagebuilder:Image | imagebuilder:ImageRecipe | 59 // license-manager:LicenseConfiguration I resource-groups:Group | rds:Cluster | 60 // route53resolver:ResolverRule 61 ResourceType *string 62} 63 64type ListResourcesOutput struct { 65 66 // The token to use to retrieve the next page of results. This value is null when 67 // there are no more results to return. 68 NextToken *string 69 70 // Information about the resources. 71 Resources []types.Resource 72 73 // Metadata pertaining to the operation's result. 74 ResultMetadata middleware.Metadata 75} 76 77func addOperationListResourcesMiddlewares(stack *middleware.Stack, options Options) (err error) { 78 err = stack.Serialize.Add(&awsRestjson1_serializeOpListResources{}, middleware.After) 79 if err != nil { 80 return err 81 } 82 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListResources{}, middleware.After) 83 if err != nil { 84 return err 85 } 86 if err = addSetLoggerMiddleware(stack, options); err != nil { 87 return err 88 } 89 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 90 return err 91 } 92 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 93 return err 94 } 95 if err = addResolveEndpointMiddleware(stack, options); err != nil { 96 return err 97 } 98 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 99 return err 100 } 101 if err = addRetryMiddlewares(stack, options); err != nil { 102 return err 103 } 104 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 105 return err 106 } 107 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 108 return err 109 } 110 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 111 return err 112 } 113 if err = addClientUserAgent(stack); err != nil { 114 return err 115 } 116 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 117 return err 118 } 119 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 120 return err 121 } 122 if err = addOpListResourcesValidationMiddleware(stack); err != nil { 123 return err 124 } 125 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListResources(options.Region), middleware.Before); err != nil { 126 return err 127 } 128 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 129 return err 130 } 131 if err = addResponseErrorMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addRequestResponseLogging(stack, options); err != nil { 135 return err 136 } 137 return nil 138} 139 140// ListResourcesAPIClient is a client that implements the ListResources operation. 141type ListResourcesAPIClient interface { 142 ListResources(context.Context, *ListResourcesInput, ...func(*Options)) (*ListResourcesOutput, error) 143} 144 145var _ ListResourcesAPIClient = (*Client)(nil) 146 147// ListResourcesPaginatorOptions is the paginator options for ListResources 148type ListResourcesPaginatorOptions struct { 149 // The maximum number of results to return with a single call. To retrieve the 150 // remaining results, make another call with the returned nextToken value. 151 Limit int32 152 153 // Set to true if pagination should stop if the service returns a pagination token 154 // that matches the most recent token provided to the service. 155 StopOnDuplicateToken bool 156} 157 158// ListResourcesPaginator is a paginator for ListResources 159type ListResourcesPaginator struct { 160 options ListResourcesPaginatorOptions 161 client ListResourcesAPIClient 162 params *ListResourcesInput 163 nextToken *string 164 firstPage bool 165} 166 167// NewListResourcesPaginator returns a new ListResourcesPaginator 168func NewListResourcesPaginator(client ListResourcesAPIClient, params *ListResourcesInput, optFns ...func(*ListResourcesPaginatorOptions)) *ListResourcesPaginator { 169 options := ListResourcesPaginatorOptions{} 170 if params.MaxResults != nil { 171 options.Limit = *params.MaxResults 172 } 173 174 for _, fn := range optFns { 175 fn(&options) 176 } 177 178 if params == nil { 179 params = &ListResourcesInput{} 180 } 181 182 return &ListResourcesPaginator{ 183 options: options, 184 client: client, 185 params: params, 186 firstPage: true, 187 } 188} 189 190// HasMorePages returns a boolean indicating whether more pages are available 191func (p *ListResourcesPaginator) HasMorePages() bool { 192 return p.firstPage || p.nextToken != nil 193} 194 195// NextPage retrieves the next ListResources page. 196func (p *ListResourcesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListResourcesOutput, error) { 197 if !p.HasMorePages() { 198 return nil, fmt.Errorf("no more pages available") 199 } 200 201 params := *p.params 202 params.NextToken = p.nextToken 203 204 var limit *int32 205 if p.options.Limit > 0 { 206 limit = &p.options.Limit 207 } 208 params.MaxResults = limit 209 210 result, err := p.client.ListResources(ctx, ¶ms, optFns...) 211 if err != nil { 212 return nil, err 213 } 214 p.firstPage = false 215 216 prevToken := p.nextToken 217 p.nextToken = result.NextToken 218 219 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 220 p.nextToken = nil 221 } 222 223 return result, nil 224} 225 226func newServiceMetadataMiddleware_opListResources(region string) *awsmiddleware.RegisterServiceMetadata { 227 return &awsmiddleware.RegisterServiceMetadata{ 228 Region: region, 229 ServiceID: ServiceID, 230 SigningName: "ram", 231 OperationName: "ListResources", 232 } 233} 234