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