1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package neptune
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/neptune/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns information about endpoints for an Amazon Neptune DB cluster. This
16// operation can also return information for Amazon RDS clusters and Amazon DocDB
17// clusters.
18func (c *Client) DescribeDBClusterEndpoints(ctx context.Context, params *DescribeDBClusterEndpointsInput, optFns ...func(*Options)) (*DescribeDBClusterEndpointsOutput, error) {
19	if params == nil {
20		params = &DescribeDBClusterEndpointsInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "DescribeDBClusterEndpoints", params, optFns, addOperationDescribeDBClusterEndpointsMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*DescribeDBClusterEndpointsOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33type DescribeDBClusterEndpointsInput struct {
34
35	// The identifier of the endpoint to describe. This parameter is stored as a
36	// lowercase string.
37	DBClusterEndpointIdentifier *string
38
39	// The DB cluster identifier of the DB cluster associated with the endpoint. This
40	// parameter is stored as a lowercase string.
41	DBClusterIdentifier *string
42
43	// A set of name-value pairs that define which endpoints to include in the output.
44	// The filters are specified as name-value pairs, in the format
45	// Name=endpoint_type,Values=endpoint_type1,endpoint_type2,.... Name can be one of:
46	// db-cluster-endpoint-type, db-cluster-endpoint-custom-type,
47	// db-cluster-endpoint-id, db-cluster-endpoint-status. Values for the
48	// db-cluster-endpoint-type filter can be one or more of: reader, writer, custom.
49	// Values for the db-cluster-endpoint-custom-type filter can be one or more of:
50	// reader, any. Values for the db-cluster-endpoint-status filter can be one or more
51	// of: available, creating, deleting, inactive, modifying.
52	Filters []types.Filter
53
54	// An optional pagination token provided by a previous DescribeDBClusterEndpoints
55	// request. If this parameter is specified, the response includes only records
56	// beyond the marker, up to the value specified by MaxRecords.
57	Marker *string
58
59	// The maximum number of records to include in the response. If more records exist
60	// than the specified MaxRecords value, a pagination token called a marker is
61	// included in the response so you can retrieve the remaining results. Default: 100
62	// Constraints: Minimum 20, maximum 100.
63	MaxRecords *int32
64}
65
66type DescribeDBClusterEndpointsOutput struct {
67
68	// Contains the details of the endpoints associated with the cluster and matching
69	// any filter conditions.
70	DBClusterEndpoints []types.DBClusterEndpoint
71
72	// An optional pagination token provided by a previous DescribeDBClusterEndpoints
73	// request. If this parameter is specified, the response includes only records
74	// beyond the marker, up to the value specified by MaxRecords.
75	Marker *string
76
77	// Metadata pertaining to the operation's result.
78	ResultMetadata middleware.Metadata
79}
80
81func addOperationDescribeDBClusterEndpointsMiddlewares(stack *middleware.Stack, options Options) (err error) {
82	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeDBClusterEndpoints{}, middleware.After)
83	if err != nil {
84		return err
85	}
86	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeDBClusterEndpoints{}, middleware.After)
87	if err != nil {
88		return err
89	}
90	if err = addSetLoggerMiddleware(stack, options); err != nil {
91		return err
92	}
93	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
94		return err
95	}
96	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
97		return err
98	}
99	if err = addResolveEndpointMiddleware(stack, options); err != nil {
100		return err
101	}
102	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
103		return err
104	}
105	if err = addRetryMiddlewares(stack, options); err != nil {
106		return err
107	}
108	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
115		return err
116	}
117	if err = addClientUserAgent(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addOpDescribeDBClusterEndpointsValidationMiddleware(stack); err != nil {
127		return err
128	}
129	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeDBClusterEndpoints(options.Region), middleware.Before); err != nil {
130		return err
131	}
132	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addResponseErrorMiddleware(stack); err != nil {
136		return err
137	}
138	if err = addRequestResponseLogging(stack, options); err != nil {
139		return err
140	}
141	return nil
142}
143
144// DescribeDBClusterEndpointsAPIClient is a client that implements the
145// DescribeDBClusterEndpoints operation.
146type DescribeDBClusterEndpointsAPIClient interface {
147	DescribeDBClusterEndpoints(context.Context, *DescribeDBClusterEndpointsInput, ...func(*Options)) (*DescribeDBClusterEndpointsOutput, error)
148}
149
150var _ DescribeDBClusterEndpointsAPIClient = (*Client)(nil)
151
152// DescribeDBClusterEndpointsPaginatorOptions is the paginator options for
153// DescribeDBClusterEndpoints
154type DescribeDBClusterEndpointsPaginatorOptions struct {
155	// The maximum number of records to include in the response. If more records exist
156	// than the specified MaxRecords value, a pagination token called a marker is
157	// included in the response so you can retrieve the remaining results. Default: 100
158	// Constraints: Minimum 20, maximum 100.
159	Limit int32
160
161	// Set to true if pagination should stop if the service returns a pagination token
162	// that matches the most recent token provided to the service.
163	StopOnDuplicateToken bool
164}
165
166// DescribeDBClusterEndpointsPaginator is a paginator for
167// DescribeDBClusterEndpoints
168type DescribeDBClusterEndpointsPaginator struct {
169	options   DescribeDBClusterEndpointsPaginatorOptions
170	client    DescribeDBClusterEndpointsAPIClient
171	params    *DescribeDBClusterEndpointsInput
172	nextToken *string
173	firstPage bool
174}
175
176// NewDescribeDBClusterEndpointsPaginator returns a new
177// DescribeDBClusterEndpointsPaginator
178func NewDescribeDBClusterEndpointsPaginator(client DescribeDBClusterEndpointsAPIClient, params *DescribeDBClusterEndpointsInput, optFns ...func(*DescribeDBClusterEndpointsPaginatorOptions)) *DescribeDBClusterEndpointsPaginator {
179	options := DescribeDBClusterEndpointsPaginatorOptions{}
180	if params.MaxRecords != nil {
181		options.Limit = *params.MaxRecords
182	}
183
184	for _, fn := range optFns {
185		fn(&options)
186	}
187
188	if params == nil {
189		params = &DescribeDBClusterEndpointsInput{}
190	}
191
192	return &DescribeDBClusterEndpointsPaginator{
193		options:   options,
194		client:    client,
195		params:    params,
196		firstPage: true,
197	}
198}
199
200// HasMorePages returns a boolean indicating whether more pages are available
201func (p *DescribeDBClusterEndpointsPaginator) HasMorePages() bool {
202	return p.firstPage || p.nextToken != nil
203}
204
205// NextPage retrieves the next DescribeDBClusterEndpoints page.
206func (p *DescribeDBClusterEndpointsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeDBClusterEndpointsOutput, error) {
207	if !p.HasMorePages() {
208		return nil, fmt.Errorf("no more pages available")
209	}
210
211	params := *p.params
212	params.Marker = p.nextToken
213
214	var limit *int32
215	if p.options.Limit > 0 {
216		limit = &p.options.Limit
217	}
218	params.MaxRecords = limit
219
220	result, err := p.client.DescribeDBClusterEndpoints(ctx, &params, optFns...)
221	if err != nil {
222		return nil, err
223	}
224	p.firstPage = false
225
226	prevToken := p.nextToken
227	p.nextToken = result.Marker
228
229	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
230		p.nextToken = nil
231	}
232
233	return result, nil
234}
235
236func newServiceMetadataMiddleware_opDescribeDBClusterEndpoints(region string) *awsmiddleware.RegisterServiceMetadata {
237	return &awsmiddleware.RegisterServiceMetadata{
238		Region:        region,
239		ServiceID:     ServiceID,
240		SigningName:   "rds",
241		OperationName: "DescribeDBClusterEndpoints",
242	}
243}
244