// Code generated by smithy-go-codegen DO NOT EDIT. package iot import ( "context" "fmt" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/iot/types" "github.com/aws/smithy-go/middleware" smithyhttp "github.com/aws/smithy-go/transport/http" ) // Lists the certificates registered in your AWS account. The results are paginated // with a default page size of 25. You can use the returned marker to retrieve // additional results. func (c *Client) ListCertificates(ctx context.Context, params *ListCertificatesInput, optFns ...func(*Options)) (*ListCertificatesOutput, error) { if params == nil { params = &ListCertificatesInput{} } result, metadata, err := c.invokeOperation(ctx, "ListCertificates", params, optFns, addOperationListCertificatesMiddlewares) if err != nil { return nil, err } out := result.(*ListCertificatesOutput) out.ResultMetadata = metadata return out, nil } // The input for the ListCertificates operation. type ListCertificatesInput struct { // Specifies the order for results. If True, the results are returned in ascending // order, based on the creation date. AscendingOrder bool // The marker for the next set of results. Marker *string // The result page size. PageSize *int32 } // The output of the ListCertificates operation. type ListCertificatesOutput struct { // The descriptions of the certificates. Certificates []types.Certificate // The marker for the next set of results, or null if there are no additional // results. NextMarker *string // Metadata pertaining to the operation's result. ResultMetadata middleware.Metadata } func addOperationListCertificatesMiddlewares(stack *middleware.Stack, options Options) (err error) { err = stack.Serialize.Add(&awsRestjson1_serializeOpListCertificates{}, middleware.After) if err != nil { return err } err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListCertificates{}, middleware.After) if err != nil { return err } if err = addSetLoggerMiddleware(stack, options); err != nil { return err } if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { return err } if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { return err } if err = addRetryMiddlewares(stack, options); err != nil { return err } if err = addHTTPSignerV4Middleware(stack, options); err != nil { return err } if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { return err } if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { return err } if err = addClientUserAgent(stack); err != nil { return err } if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { return err } if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { return err } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCertificates(options.Region), middleware.Before); err != nil { return err } if err = addRequestIDRetrieverMiddleware(stack); err != nil { return err } if err = addResponseErrorMiddleware(stack); err != nil { return err } if err = addRequestResponseLogging(stack, options); err != nil { return err } return nil } // ListCertificatesAPIClient is a client that implements the ListCertificates // operation. type ListCertificatesAPIClient interface { ListCertificates(context.Context, *ListCertificatesInput, ...func(*Options)) (*ListCertificatesOutput, error) } var _ ListCertificatesAPIClient = (*Client)(nil) // ListCertificatesPaginatorOptions is the paginator options for ListCertificates type ListCertificatesPaginatorOptions struct { // The result page size. Limit int32 // Set to true if pagination should stop if the service returns a pagination token // that matches the most recent token provided to the service. StopOnDuplicateToken bool } // ListCertificatesPaginator is a paginator for ListCertificates type ListCertificatesPaginator struct { options ListCertificatesPaginatorOptions client ListCertificatesAPIClient params *ListCertificatesInput nextToken *string firstPage bool } // NewListCertificatesPaginator returns a new ListCertificatesPaginator func NewListCertificatesPaginator(client ListCertificatesAPIClient, params *ListCertificatesInput, optFns ...func(*ListCertificatesPaginatorOptions)) *ListCertificatesPaginator { options := ListCertificatesPaginatorOptions{} if params.PageSize != nil { options.Limit = *params.PageSize } for _, fn := range optFns { fn(&options) } if params == nil { params = &ListCertificatesInput{} } return &ListCertificatesPaginator{ options: options, client: client, params: params, firstPage: true, } } // HasMorePages returns a boolean indicating whether more pages are available func (p *ListCertificatesPaginator) HasMorePages() bool { return p.firstPage || p.nextToken != nil } // NextPage retrieves the next ListCertificates page. func (p *ListCertificatesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCertificatesOutput, error) { if !p.HasMorePages() { return nil, fmt.Errorf("no more pages available") } params := *p.params params.Marker = p.nextToken var limit *int32 if p.options.Limit > 0 { limit = &p.options.Limit } params.PageSize = limit result, err := p.client.ListCertificates(ctx, ¶ms, optFns...) if err != nil { return nil, err } p.firstPage = false prevToken := p.nextToken p.nextToken = result.NextMarker if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { p.nextToken = nil } return result, nil } func newServiceMetadataMiddleware_opListCertificates(region string) *awsmiddleware.RegisterServiceMetadata { return &awsmiddleware.RegisterServiceMetadata{ Region: region, ServiceID: ServiceID, SigningName: "execute-api", OperationName: "ListCertificates", } }