1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package codepipeline
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/codepipeline/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Gets a summary of all AWS CodePipeline action types associated with your
16// account.
17func (c *Client) ListActionTypes(ctx context.Context, params *ListActionTypesInput, optFns ...func(*Options)) (*ListActionTypesOutput, error) {
18	if params == nil {
19		params = &ListActionTypesInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "ListActionTypes", params, optFns, addOperationListActionTypesMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*ListActionTypesOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32// Represents the input of a ListActionTypes action.
33type ListActionTypesInput struct {
34
35	// Filters the list of action types to those created by a specified entity.
36	ActionOwnerFilter types.ActionOwner
37
38	// An identifier that was returned from the previous list action types call, which
39	// can be used to return the next set of action types in the list.
40	NextToken *string
41}
42
43// Represents the output of a ListActionTypes action.
44type ListActionTypesOutput struct {
45
46	// Provides details of the action types.
47	//
48	// This member is required.
49	ActionTypes []types.ActionType
50
51	// If the amount of returned information is significantly large, an identifier is
52	// also returned. It can be used in a subsequent list action types call to return
53	// the next set of action types in the list.
54	NextToken *string
55
56	// Metadata pertaining to the operation's result.
57	ResultMetadata middleware.Metadata
58}
59
60func addOperationListActionTypesMiddlewares(stack *middleware.Stack, options Options) (err error) {
61	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListActionTypes{}, middleware.After)
62	if err != nil {
63		return err
64	}
65	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListActionTypes{}, middleware.After)
66	if err != nil {
67		return err
68	}
69	if err = addSetLoggerMiddleware(stack, options); err != nil {
70		return err
71	}
72	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
73		return err
74	}
75	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
76		return err
77	}
78	if err = addResolveEndpointMiddleware(stack, options); err != nil {
79		return err
80	}
81	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
82		return err
83	}
84	if err = addRetryMiddlewares(stack, options); err != nil {
85		return err
86	}
87	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
91		return err
92	}
93	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
94		return err
95	}
96	if err = addClientUserAgent(stack); err != nil {
97		return err
98	}
99	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
100		return err
101	}
102	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
103		return err
104	}
105	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListActionTypes(options.Region), middleware.Before); err != nil {
106		return err
107	}
108	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
109		return err
110	}
111	if err = addResponseErrorMiddleware(stack); err != nil {
112		return err
113	}
114	if err = addRequestResponseLogging(stack, options); err != nil {
115		return err
116	}
117	return nil
118}
119
120// ListActionTypesAPIClient is a client that implements the ListActionTypes
121// operation.
122type ListActionTypesAPIClient interface {
123	ListActionTypes(context.Context, *ListActionTypesInput, ...func(*Options)) (*ListActionTypesOutput, error)
124}
125
126var _ ListActionTypesAPIClient = (*Client)(nil)
127
128// ListActionTypesPaginatorOptions is the paginator options for ListActionTypes
129type ListActionTypesPaginatorOptions struct {
130	// Set to true if pagination should stop if the service returns a pagination token
131	// that matches the most recent token provided to the service.
132	StopOnDuplicateToken bool
133}
134
135// ListActionTypesPaginator is a paginator for ListActionTypes
136type ListActionTypesPaginator struct {
137	options   ListActionTypesPaginatorOptions
138	client    ListActionTypesAPIClient
139	params    *ListActionTypesInput
140	nextToken *string
141	firstPage bool
142}
143
144// NewListActionTypesPaginator returns a new ListActionTypesPaginator
145func NewListActionTypesPaginator(client ListActionTypesAPIClient, params *ListActionTypesInput, optFns ...func(*ListActionTypesPaginatorOptions)) *ListActionTypesPaginator {
146	options := ListActionTypesPaginatorOptions{}
147
148	for _, fn := range optFns {
149		fn(&options)
150	}
151
152	if params == nil {
153		params = &ListActionTypesInput{}
154	}
155
156	return &ListActionTypesPaginator{
157		options:   options,
158		client:    client,
159		params:    params,
160		firstPage: true,
161	}
162}
163
164// HasMorePages returns a boolean indicating whether more pages are available
165func (p *ListActionTypesPaginator) HasMorePages() bool {
166	return p.firstPage || p.nextToken != nil
167}
168
169// NextPage retrieves the next ListActionTypes page.
170func (p *ListActionTypesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListActionTypesOutput, error) {
171	if !p.HasMorePages() {
172		return nil, fmt.Errorf("no more pages available")
173	}
174
175	params := *p.params
176	params.NextToken = p.nextToken
177
178	result, err := p.client.ListActionTypes(ctx, &params, optFns...)
179	if err != nil {
180		return nil, err
181	}
182	p.firstPage = false
183
184	prevToken := p.nextToken
185	p.nextToken = result.NextToken
186
187	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
188		p.nextToken = nil
189	}
190
191	return result, nil
192}
193
194func newServiceMetadataMiddleware_opListActionTypes(region string) *awsmiddleware.RegisterServiceMetadata {
195	return &awsmiddleware.RegisterServiceMetadata{
196		Region:        region,
197		ServiceID:     ServiceID,
198		SigningName:   "codepipeline",
199		OperationName: "ListActionTypes",
200	}
201}
202