1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package workspaces 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/workspaces/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Retrieves a list that describes the available WorkSpace bundles. You can filter 16// the results using either bundle ID or owner, but not both. 17func (c *Client) DescribeWorkspaceBundles(ctx context.Context, params *DescribeWorkspaceBundlesInput, optFns ...func(*Options)) (*DescribeWorkspaceBundlesOutput, error) { 18 if params == nil { 19 params = &DescribeWorkspaceBundlesInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "DescribeWorkspaceBundles", params, optFns, addOperationDescribeWorkspaceBundlesMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*DescribeWorkspaceBundlesOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type DescribeWorkspaceBundlesInput struct { 33 34 // The identifiers of the bundles. You cannot combine this parameter with any other 35 // filter. 36 BundleIds []string 37 38 // The token for the next set of results. (You received this token from a previous 39 // call.) 40 NextToken *string 41 42 // The owner of the bundles. You cannot combine this parameter with any other 43 // filter. To describe the bundles provided by AWS, specify AMAZON. To describe the 44 // bundles that belong to your account, don't specify a value. 45 Owner *string 46} 47 48type DescribeWorkspaceBundlesOutput struct { 49 50 // Information about the bundles. 51 Bundles []types.WorkspaceBundle 52 53 // The token to use to retrieve the next page of results. This value is null when 54 // there are no more results to return. This token is valid for one day and must be 55 // used within that time frame. 56 NextToken *string 57 58 // Metadata pertaining to the operation's result. 59 ResultMetadata middleware.Metadata 60} 61 62func addOperationDescribeWorkspaceBundlesMiddlewares(stack *middleware.Stack, options Options) (err error) { 63 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeWorkspaceBundles{}, middleware.After) 64 if err != nil { 65 return err 66 } 67 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeWorkspaceBundles{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 if err = addSetLoggerMiddleware(stack, options); err != nil { 72 return err 73 } 74 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 75 return err 76 } 77 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 78 return err 79 } 80 if err = addResolveEndpointMiddleware(stack, options); err != nil { 81 return err 82 } 83 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 84 return err 85 } 86 if err = addRetryMiddlewares(stack, options); err != nil { 87 return err 88 } 89 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 96 return err 97 } 98 if err = addClientUserAgent(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 105 return err 106 } 107 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeWorkspaceBundles(options.Region), middleware.Before); err != nil { 108 return err 109 } 110 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResponseErrorMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addRequestResponseLogging(stack, options); err != nil { 117 return err 118 } 119 return nil 120} 121 122// DescribeWorkspaceBundlesAPIClient is a client that implements the 123// DescribeWorkspaceBundles operation. 124type DescribeWorkspaceBundlesAPIClient interface { 125 DescribeWorkspaceBundles(context.Context, *DescribeWorkspaceBundlesInput, ...func(*Options)) (*DescribeWorkspaceBundlesOutput, error) 126} 127 128var _ DescribeWorkspaceBundlesAPIClient = (*Client)(nil) 129 130// DescribeWorkspaceBundlesPaginatorOptions is the paginator options for 131// DescribeWorkspaceBundles 132type DescribeWorkspaceBundlesPaginatorOptions struct { 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// DescribeWorkspaceBundlesPaginator is a paginator for DescribeWorkspaceBundles 139type DescribeWorkspaceBundlesPaginator struct { 140 options DescribeWorkspaceBundlesPaginatorOptions 141 client DescribeWorkspaceBundlesAPIClient 142 params *DescribeWorkspaceBundlesInput 143 nextToken *string 144 firstPage bool 145} 146 147// NewDescribeWorkspaceBundlesPaginator returns a new 148// DescribeWorkspaceBundlesPaginator 149func NewDescribeWorkspaceBundlesPaginator(client DescribeWorkspaceBundlesAPIClient, params *DescribeWorkspaceBundlesInput, optFns ...func(*DescribeWorkspaceBundlesPaginatorOptions)) *DescribeWorkspaceBundlesPaginator { 150 if params == nil { 151 params = &DescribeWorkspaceBundlesInput{} 152 } 153 154 options := DescribeWorkspaceBundlesPaginatorOptions{} 155 156 for _, fn := range optFns { 157 fn(&options) 158 } 159 160 return &DescribeWorkspaceBundlesPaginator{ 161 options: options, 162 client: client, 163 params: params, 164 firstPage: true, 165 } 166} 167 168// HasMorePages returns a boolean indicating whether more pages are available 169func (p *DescribeWorkspaceBundlesPaginator) HasMorePages() bool { 170 return p.firstPage || p.nextToken != nil 171} 172 173// NextPage retrieves the next DescribeWorkspaceBundles page. 174func (p *DescribeWorkspaceBundlesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeWorkspaceBundlesOutput, error) { 175 if !p.HasMorePages() { 176 return nil, fmt.Errorf("no more pages available") 177 } 178 179 params := *p.params 180 params.NextToken = p.nextToken 181 182 result, err := p.client.DescribeWorkspaceBundles(ctx, ¶ms, optFns...) 183 if err != nil { 184 return nil, err 185 } 186 p.firstPage = false 187 188 prevToken := p.nextToken 189 p.nextToken = result.NextToken 190 191 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 192 p.nextToken = nil 193 } 194 195 return result, nil 196} 197 198func newServiceMetadataMiddleware_opDescribeWorkspaceBundles(region string) *awsmiddleware.RegisterServiceMetadata { 199 return &awsmiddleware.RegisterServiceMetadata{ 200 Region: region, 201 ServiceID: ServiceID, 202 SigningName: "workspaces", 203 OperationName: "DescribeWorkspaceBundles", 204 } 205} 206