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