1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudformation
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/cloudformation/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns summary information about extension that have been registered with
16// CloudFormation.
17func (c *Client) ListTypes(ctx context.Context, params *ListTypesInput, optFns ...func(*Options)) (*ListTypesOutput, error) {
18	if params == nil {
19		params = &ListTypesInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "ListTypes", params, optFns, addOperationListTypesMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*ListTypesOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type ListTypesInput struct {
33
34	// The deprecation status of the extension that you want to get summary information
35	// about. Valid values include:
36	//
37	// * LIVE: The extension is registered for use in
38	// CloudFormation operations.
39	//
40	// * DEPRECATED: The extension has been deregistered
41	// and can no longer be used in CloudFormation operations.
42	DeprecatedStatus types.DeprecatedStatus
43
44	// The maximum number of results to be returned with a single call. If the number
45	// of available results exceeds this maximum, the response includes a NextToken
46	// value that you can assign to the NextToken request parameter to get the next set
47	// of results.
48	MaxResults *int32
49
50	// If the previous paginated request didn't return all of the remaining results,
51	// the response object's NextToken parameter value is set to a token. To retrieve
52	// the next set of results, call this action again and assign that token to the
53	// request object's NextToken parameter. If there are no remaining results, the
54	// previous response object's NextToken parameter is set to null.
55	NextToken *string
56
57	// The provisioning behavior of the type. AWS CloudFormation determines the
58	// provisioning type during registration, based on the types of handlers in the
59	// schema handler package submitted. Valid values include:
60	//
61	// * FULLY_MUTABLE: The
62	// extension includes an update handler to process updates to the extension during
63	// stack update operations.
64	//
65	// * IMMUTABLE: The extension does not include an update
66	// handler, so the extension cannot be updated and must instead be replaced during
67	// stack update operations.
68	//
69	// * NON_PROVISIONABLE: The extension does not include
70	// create, read, and delete handlers, and therefore cannot actually be provisioned.
71	ProvisioningType types.ProvisioningType
72
73	// The type of extension.
74	Type types.RegistryType
75
76	// The scope at which the extension is visible and usable in CloudFormation
77	// operations. Valid values include:
78	//
79	// * PRIVATE: The extension is only visible and
80	// usable within the account in which it is registered. Currently, AWS
81	// CloudFormation marks any extension you create as PRIVATE.
82	//
83	// * PUBLIC: The
84	// extension is publically visible and usable within any Amazon account.
85	//
86	// The
87	// default is PRIVATE.
88	Visibility types.Visibility
89}
90
91type ListTypesOutput struct {
92
93	// If the request doesn't return all of the remaining results, NextToken is set to
94	// a token. To retrieve the next set of results, call this action again and assign
95	// that token to the request object's NextToken parameter. If the request returns
96	// all results, NextToken is set to null.
97	NextToken *string
98
99	// A list of TypeSummary structures that contain information about the specified
100	// extensions.
101	TypeSummaries []types.TypeSummary
102
103	// Metadata pertaining to the operation's result.
104	ResultMetadata middleware.Metadata
105}
106
107func addOperationListTypesMiddlewares(stack *middleware.Stack, options Options) (err error) {
108	err = stack.Serialize.Add(&awsAwsquery_serializeOpListTypes{}, middleware.After)
109	if err != nil {
110		return err
111	}
112	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpListTypes{}, middleware.After)
113	if err != nil {
114		return err
115	}
116	if err = addSetLoggerMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResolveEndpointMiddleware(stack, options); err != nil {
126		return err
127	}
128	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
129		return err
130	}
131	if err = addRetryMiddlewares(stack, options); err != nil {
132		return err
133	}
134	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
141		return err
142	}
143	if err = addClientUserAgent(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
147		return err
148	}
149	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
150		return err
151	}
152	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListTypes(options.Region), middleware.Before); err != nil {
153		return err
154	}
155	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
156		return err
157	}
158	if err = addResponseErrorMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addRequestResponseLogging(stack, options); err != nil {
162		return err
163	}
164	return nil
165}
166
167// ListTypesAPIClient is a client that implements the ListTypes operation.
168type ListTypesAPIClient interface {
169	ListTypes(context.Context, *ListTypesInput, ...func(*Options)) (*ListTypesOutput, error)
170}
171
172var _ ListTypesAPIClient = (*Client)(nil)
173
174// ListTypesPaginatorOptions is the paginator options for ListTypes
175type ListTypesPaginatorOptions struct {
176	// The maximum number of results to be returned with a single call. If the number
177	// of available results exceeds this maximum, the response includes a NextToken
178	// value that you can assign to the NextToken request parameter to get the next set
179	// of results.
180	Limit int32
181
182	// Set to true if pagination should stop if the service returns a pagination token
183	// that matches the most recent token provided to the service.
184	StopOnDuplicateToken bool
185}
186
187// ListTypesPaginator is a paginator for ListTypes
188type ListTypesPaginator struct {
189	options   ListTypesPaginatorOptions
190	client    ListTypesAPIClient
191	params    *ListTypesInput
192	nextToken *string
193	firstPage bool
194}
195
196// NewListTypesPaginator returns a new ListTypesPaginator
197func NewListTypesPaginator(client ListTypesAPIClient, params *ListTypesInput, optFns ...func(*ListTypesPaginatorOptions)) *ListTypesPaginator {
198	if params == nil {
199		params = &ListTypesInput{}
200	}
201
202	options := ListTypesPaginatorOptions{}
203	if params.MaxResults != nil {
204		options.Limit = *params.MaxResults
205	}
206
207	for _, fn := range optFns {
208		fn(&options)
209	}
210
211	return &ListTypesPaginator{
212		options:   options,
213		client:    client,
214		params:    params,
215		firstPage: true,
216	}
217}
218
219// HasMorePages returns a boolean indicating whether more pages are available
220func (p *ListTypesPaginator) HasMorePages() bool {
221	return p.firstPage || p.nextToken != nil
222}
223
224// NextPage retrieves the next ListTypes page.
225func (p *ListTypesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListTypesOutput, error) {
226	if !p.HasMorePages() {
227		return nil, fmt.Errorf("no more pages available")
228	}
229
230	params := *p.params
231	params.NextToken = p.nextToken
232
233	var limit *int32
234	if p.options.Limit > 0 {
235		limit = &p.options.Limit
236	}
237	params.MaxResults = limit
238
239	result, err := p.client.ListTypes(ctx, &params, optFns...)
240	if err != nil {
241		return nil, err
242	}
243	p.firstPage = false
244
245	prevToken := p.nextToken
246	p.nextToken = result.NextToken
247
248	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
249		p.nextToken = nil
250	}
251
252	return result, nil
253}
254
255func newServiceMetadataMiddleware_opListTypes(region string) *awsmiddleware.RegisterServiceMetadata {
256	return &awsmiddleware.RegisterServiceMetadata{
257		Region:        region,
258		ServiceID:     ServiceID,
259		SigningName:   "cloudformation",
260		OperationName: "ListTypes",
261	}
262}
263