1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package redshift
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/redshift/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns information about the specified Amazon Redshift HSM configuration. If no
16// configuration ID is specified, returns information about all the HSM
17// configurations owned by your AWS customer account. If you specify both tag keys
18// and tag values in the same request, Amazon Redshift returns all HSM connections
19// that match any combination of the specified keys and values. For example, if you
20// have owner and environment for tag keys, and admin and test for tag values, all
21// HSM connections that have any combination of those values are returned. If both
22// tag keys and values are omitted from the request, HSM connections are returned
23// regardless of whether they have tag keys or values associated with them.
24func (c *Client) DescribeHsmConfigurations(ctx context.Context, params *DescribeHsmConfigurationsInput, optFns ...func(*Options)) (*DescribeHsmConfigurationsOutput, error) {
25	if params == nil {
26		params = &DescribeHsmConfigurationsInput{}
27	}
28
29	result, metadata, err := c.invokeOperation(ctx, "DescribeHsmConfigurations", params, optFns, addOperationDescribeHsmConfigurationsMiddlewares)
30	if err != nil {
31		return nil, err
32	}
33
34	out := result.(*DescribeHsmConfigurationsOutput)
35	out.ResultMetadata = metadata
36	return out, nil
37}
38
39//
40type DescribeHsmConfigurationsInput struct {
41
42	// The identifier of a specific Amazon Redshift HSM configuration to be described.
43	// If no identifier is specified, information is returned for all HSM
44	// configurations owned by your AWS customer account.
45	HsmConfigurationIdentifier *string
46
47	// An optional parameter that specifies the starting point to return a set of
48	// response records. When the results of a DescribeHsmConfigurations request exceed
49	// the value specified in MaxRecords, AWS returns a value in the Marker field of
50	// the response. You can retrieve the next set of response records by providing the
51	// returned marker value in the Marker parameter and retrying the request.
52	Marker *string
53
54	// The maximum number of response records to return in each call. If the number of
55	// remaining response records exceeds the specified MaxRecords value, a value is
56	// returned in a marker field of the response. You can retrieve the next set of
57	// records by retrying the command with the returned marker value. Default: 100
58	// Constraints: minimum 20, maximum 100.
59	MaxRecords *int32
60
61	// A tag key or keys for which you want to return all matching HSM configurations
62	// that are associated with the specified key or keys. For example, suppose that
63	// you have HSM configurations that are tagged with keys called owner and
64	// environment. If you specify both of these tag keys in the request, Amazon
65	// Redshift returns a response with the HSM configurations that have either or both
66	// of these tag keys associated with them.
67	TagKeys []string
68
69	// A tag value or values for which you want to return all matching HSM
70	// configurations that are associated with the specified tag value or values. For
71	// example, suppose that you have HSM configurations that are tagged with values
72	// called admin and test. If you specify both of these tag values in the request,
73	// Amazon Redshift returns a response with the HSM configurations that have either
74	// or both of these tag values associated with them.
75	TagValues []string
76}
77
78//
79type DescribeHsmConfigurationsOutput struct {
80
81	// A list of HsmConfiguration objects.
82	HsmConfigurations []types.HsmConfiguration
83
84	// A value that indicates the starting point for the next set of response records
85	// in a subsequent request. If a value is returned in a response, you can retrieve
86	// the next set of records by providing this returned marker value in the Marker
87	// parameter and retrying the command. If the Marker field is empty, all response
88	// records have been retrieved for the request.
89	Marker *string
90
91	// Metadata pertaining to the operation's result.
92	ResultMetadata middleware.Metadata
93}
94
95func addOperationDescribeHsmConfigurationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
96	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeHsmConfigurations{}, middleware.After)
97	if err != nil {
98		return err
99	}
100	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeHsmConfigurations{}, middleware.After)
101	if err != nil {
102		return err
103	}
104	if err = addSetLoggerMiddleware(stack, options); err != nil {
105		return err
106	}
107	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
108		return err
109	}
110	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
111		return err
112	}
113	if err = addResolveEndpointMiddleware(stack, options); err != nil {
114		return err
115	}
116	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
117		return err
118	}
119	if err = addRetryMiddlewares(stack, options); err != nil {
120		return err
121	}
122	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
123		return err
124	}
125	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
126		return err
127	}
128	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
129		return err
130	}
131	if err = addClientUserAgent(stack); err != nil {
132		return err
133	}
134	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
135		return err
136	}
137	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
138		return err
139	}
140	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeHsmConfigurations(options.Region), middleware.Before); err != nil {
141		return err
142	}
143	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addResponseErrorMiddleware(stack); err != nil {
147		return err
148	}
149	if err = addRequestResponseLogging(stack, options); err != nil {
150		return err
151	}
152	return nil
153}
154
155// DescribeHsmConfigurationsAPIClient is a client that implements the
156// DescribeHsmConfigurations operation.
157type DescribeHsmConfigurationsAPIClient interface {
158	DescribeHsmConfigurations(context.Context, *DescribeHsmConfigurationsInput, ...func(*Options)) (*DescribeHsmConfigurationsOutput, error)
159}
160
161var _ DescribeHsmConfigurationsAPIClient = (*Client)(nil)
162
163// DescribeHsmConfigurationsPaginatorOptions is the paginator options for
164// DescribeHsmConfigurations
165type DescribeHsmConfigurationsPaginatorOptions struct {
166	// The maximum number of response records to return in each call. If the number of
167	// remaining response records exceeds the specified MaxRecords value, a value is
168	// returned in a marker field of the response. You can retrieve the next set of
169	// records by retrying the command with the returned marker value. Default: 100
170	// Constraints: minimum 20, maximum 100.
171	Limit int32
172
173	// Set to true if pagination should stop if the service returns a pagination token
174	// that matches the most recent token provided to the service.
175	StopOnDuplicateToken bool
176}
177
178// DescribeHsmConfigurationsPaginator is a paginator for DescribeHsmConfigurations
179type DescribeHsmConfigurationsPaginator struct {
180	options   DescribeHsmConfigurationsPaginatorOptions
181	client    DescribeHsmConfigurationsAPIClient
182	params    *DescribeHsmConfigurationsInput
183	nextToken *string
184	firstPage bool
185}
186
187// NewDescribeHsmConfigurationsPaginator returns a new
188// DescribeHsmConfigurationsPaginator
189func NewDescribeHsmConfigurationsPaginator(client DescribeHsmConfigurationsAPIClient, params *DescribeHsmConfigurationsInput, optFns ...func(*DescribeHsmConfigurationsPaginatorOptions)) *DescribeHsmConfigurationsPaginator {
190	if params == nil {
191		params = &DescribeHsmConfigurationsInput{}
192	}
193
194	options := DescribeHsmConfigurationsPaginatorOptions{}
195	if params.MaxRecords != nil {
196		options.Limit = *params.MaxRecords
197	}
198
199	for _, fn := range optFns {
200		fn(&options)
201	}
202
203	return &DescribeHsmConfigurationsPaginator{
204		options:   options,
205		client:    client,
206		params:    params,
207		firstPage: true,
208	}
209}
210
211// HasMorePages returns a boolean indicating whether more pages are available
212func (p *DescribeHsmConfigurationsPaginator) HasMorePages() bool {
213	return p.firstPage || p.nextToken != nil
214}
215
216// NextPage retrieves the next DescribeHsmConfigurations page.
217func (p *DescribeHsmConfigurationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeHsmConfigurationsOutput, error) {
218	if !p.HasMorePages() {
219		return nil, fmt.Errorf("no more pages available")
220	}
221
222	params := *p.params
223	params.Marker = p.nextToken
224
225	var limit *int32
226	if p.options.Limit > 0 {
227		limit = &p.options.Limit
228	}
229	params.MaxRecords = limit
230
231	result, err := p.client.DescribeHsmConfigurations(ctx, &params, optFns...)
232	if err != nil {
233		return nil, err
234	}
235	p.firstPage = false
236
237	prevToken := p.nextToken
238	p.nextToken = result.Marker
239
240	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
241		p.nextToken = nil
242	}
243
244	return result, nil
245}
246
247func newServiceMetadataMiddleware_opDescribeHsmConfigurations(region string) *awsmiddleware.RegisterServiceMetadata {
248	return &awsmiddleware.RegisterServiceMetadata{
249		Region:        region,
250		ServiceID:     ServiceID,
251		SigningName:   "redshift",
252		OperationName: "DescribeHsmConfigurations",
253	}
254}
255