1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package signer
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/signer/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Lists all available signing profiles in your AWS account. Returns only profiles
16// with an ACTIVE status unless the includeCanceled request field is set to true.
17// If additional jobs remain to be listed, code signing returns a nextToken value.
18// Use this value in subsequent calls to ListSigningJobs to fetch the remaining
19// values. You can continue calling ListSigningJobs with your maxResults parameter
20// and with new values that code signing returns in the nextToken parameter until
21// all of your signing jobs have been returned.
22func (c *Client) ListSigningProfiles(ctx context.Context, params *ListSigningProfilesInput, optFns ...func(*Options)) (*ListSigningProfilesOutput, error) {
23	if params == nil {
24		params = &ListSigningProfilesInput{}
25	}
26
27	result, metadata, err := c.invokeOperation(ctx, "ListSigningProfiles", params, optFns, addOperationListSigningProfilesMiddlewares)
28	if err != nil {
29		return nil, err
30	}
31
32	out := result.(*ListSigningProfilesOutput)
33	out.ResultMetadata = metadata
34	return out, nil
35}
36
37type ListSigningProfilesInput struct {
38
39	// Designates whether to include profiles with the status of CANCELED.
40	IncludeCanceled bool
41
42	// The maximum number of profiles to be returned.
43	MaxResults *int32
44
45	// Value for specifying the next set of paginated results to return. After you
46	// receive a response with truncated results, use this parameter in a subsequent
47	// request. Set it to the value of nextToken from the response that you just
48	// received.
49	NextToken *string
50
51	// Filters results to return only signing jobs initiated for a specified signing
52	// platform.
53	PlatformId *string
54
55	// Filters results to return only signing jobs with statuses in the specified list.
56	Statuses []types.SigningProfileStatus
57}
58
59type ListSigningProfilesOutput struct {
60
61	// Value for specifying the next set of paginated results to return.
62	NextToken *string
63
64	// A list of profiles that are available in the AWS account. This includes profiles
65	// with the status of CANCELED if the includeCanceled parameter is set to true.
66	Profiles []types.SigningProfile
67
68	// Metadata pertaining to the operation's result.
69	ResultMetadata middleware.Metadata
70}
71
72func addOperationListSigningProfilesMiddlewares(stack *middleware.Stack, options Options) (err error) {
73	err = stack.Serialize.Add(&awsRestjson1_serializeOpListSigningProfiles{}, middleware.After)
74	if err != nil {
75		return err
76	}
77	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListSigningProfiles{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	if err = addSetLoggerMiddleware(stack, options); err != nil {
82		return err
83	}
84	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
85		return err
86	}
87	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
88		return err
89	}
90	if err = addResolveEndpointMiddleware(stack, options); err != nil {
91		return err
92	}
93	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
94		return err
95	}
96	if err = addRetryMiddlewares(stack, options); err != nil {
97		return err
98	}
99	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
100		return err
101	}
102	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
106		return err
107	}
108	if err = addClientUserAgent(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListSigningProfiles(options.Region), middleware.Before); err != nil {
118		return err
119	}
120	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addResponseErrorMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addRequestResponseLogging(stack, options); err != nil {
127		return err
128	}
129	return nil
130}
131
132// ListSigningProfilesAPIClient is a client that implements the ListSigningProfiles
133// operation.
134type ListSigningProfilesAPIClient interface {
135	ListSigningProfiles(context.Context, *ListSigningProfilesInput, ...func(*Options)) (*ListSigningProfilesOutput, error)
136}
137
138var _ ListSigningProfilesAPIClient = (*Client)(nil)
139
140// ListSigningProfilesPaginatorOptions is the paginator options for
141// ListSigningProfiles
142type ListSigningProfilesPaginatorOptions struct {
143	// The maximum number of profiles to be returned.
144	Limit int32
145
146	// Set to true if pagination should stop if the service returns a pagination token
147	// that matches the most recent token provided to the service.
148	StopOnDuplicateToken bool
149}
150
151// ListSigningProfilesPaginator is a paginator for ListSigningProfiles
152type ListSigningProfilesPaginator struct {
153	options   ListSigningProfilesPaginatorOptions
154	client    ListSigningProfilesAPIClient
155	params    *ListSigningProfilesInput
156	nextToken *string
157	firstPage bool
158}
159
160// NewListSigningProfilesPaginator returns a new ListSigningProfilesPaginator
161func NewListSigningProfilesPaginator(client ListSigningProfilesAPIClient, params *ListSigningProfilesInput, optFns ...func(*ListSigningProfilesPaginatorOptions)) *ListSigningProfilesPaginator {
162	if params == nil {
163		params = &ListSigningProfilesInput{}
164	}
165
166	options := ListSigningProfilesPaginatorOptions{}
167	if params.MaxResults != nil {
168		options.Limit = *params.MaxResults
169	}
170
171	for _, fn := range optFns {
172		fn(&options)
173	}
174
175	return &ListSigningProfilesPaginator{
176		options:   options,
177		client:    client,
178		params:    params,
179		firstPage: true,
180	}
181}
182
183// HasMorePages returns a boolean indicating whether more pages are available
184func (p *ListSigningProfilesPaginator) HasMorePages() bool {
185	return p.firstPage || p.nextToken != nil
186}
187
188// NextPage retrieves the next ListSigningProfiles page.
189func (p *ListSigningProfilesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListSigningProfilesOutput, error) {
190	if !p.HasMorePages() {
191		return nil, fmt.Errorf("no more pages available")
192	}
193
194	params := *p.params
195	params.NextToken = p.nextToken
196
197	var limit *int32
198	if p.options.Limit > 0 {
199		limit = &p.options.Limit
200	}
201	params.MaxResults = limit
202
203	result, err := p.client.ListSigningProfiles(ctx, &params, optFns...)
204	if err != nil {
205		return nil, err
206	}
207	p.firstPage = false
208
209	prevToken := p.nextToken
210	p.nextToken = result.NextToken
211
212	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
213		p.nextToken = nil
214	}
215
216	return result, nil
217}
218
219func newServiceMetadataMiddleware_opListSigningProfiles(region string) *awsmiddleware.RegisterServiceMetadata {
220	return &awsmiddleware.RegisterServiceMetadata{
221		Region:        region,
222		ServiceID:     ServiceID,
223		SigningName:   "signer",
224		OperationName: "ListSigningProfiles",
225	}
226}
227