1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package clouddirectory
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/clouddirectory/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns a paginated list of all attribute definitions for a particular
16// TypedLinkFacet. For more information, see Typed Links
17// (https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_links.html#directory_objects_links_typedlink).
18func (c *Client) ListTypedLinkFacetAttributes(ctx context.Context, params *ListTypedLinkFacetAttributesInput, optFns ...func(*Options)) (*ListTypedLinkFacetAttributesOutput, error) {
19	if params == nil {
20		params = &ListTypedLinkFacetAttributesInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "ListTypedLinkFacetAttributes", params, optFns, addOperationListTypedLinkFacetAttributesMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*ListTypedLinkFacetAttributesOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33type ListTypedLinkFacetAttributesInput struct {
34
35	// The unique name of the typed link facet.
36	//
37	// This member is required.
38	Name *string
39
40	// The Amazon Resource Name (ARN) that is associated with the schema. For more
41	// information, see arns.
42	//
43	// This member is required.
44	SchemaArn *string
45
46	// The maximum number of results to retrieve.
47	MaxResults *int32
48
49	// The pagination token.
50	NextToken *string
51}
52
53type ListTypedLinkFacetAttributesOutput struct {
54
55	// An ordered set of attributes associate with the typed link.
56	Attributes []types.TypedLinkAttributeDefinition
57
58	// The pagination token.
59	NextToken *string
60
61	// Metadata pertaining to the operation's result.
62	ResultMetadata middleware.Metadata
63}
64
65func addOperationListTypedLinkFacetAttributesMiddlewares(stack *middleware.Stack, options Options) (err error) {
66	err = stack.Serialize.Add(&awsRestjson1_serializeOpListTypedLinkFacetAttributes{}, middleware.After)
67	if err != nil {
68		return err
69	}
70	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListTypedLinkFacetAttributes{}, middleware.After)
71	if err != nil {
72		return err
73	}
74	if err = addSetLoggerMiddleware(stack, options); err != nil {
75		return err
76	}
77	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
78		return err
79	}
80	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
81		return err
82	}
83	if err = addResolveEndpointMiddleware(stack, options); err != nil {
84		return err
85	}
86	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
87		return err
88	}
89	if err = addRetryMiddlewares(stack, options); err != nil {
90		return err
91	}
92	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
99		return err
100	}
101	if err = addClientUserAgent(stack); err != nil {
102		return err
103	}
104	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
105		return err
106	}
107	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
108		return err
109	}
110	if err = addOpListTypedLinkFacetAttributesValidationMiddleware(stack); err != nil {
111		return err
112	}
113	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListTypedLinkFacetAttributes(options.Region), middleware.Before); err != nil {
114		return err
115	}
116	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
117		return err
118	}
119	if err = addResponseErrorMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addRequestResponseLogging(stack, options); err != nil {
123		return err
124	}
125	return nil
126}
127
128// ListTypedLinkFacetAttributesAPIClient is a client that implements the
129// ListTypedLinkFacetAttributes operation.
130type ListTypedLinkFacetAttributesAPIClient interface {
131	ListTypedLinkFacetAttributes(context.Context, *ListTypedLinkFacetAttributesInput, ...func(*Options)) (*ListTypedLinkFacetAttributesOutput, error)
132}
133
134var _ ListTypedLinkFacetAttributesAPIClient = (*Client)(nil)
135
136// ListTypedLinkFacetAttributesPaginatorOptions is the paginator options for
137// ListTypedLinkFacetAttributes
138type ListTypedLinkFacetAttributesPaginatorOptions struct {
139	// The maximum number of results to retrieve.
140	Limit int32
141
142	// Set to true if pagination should stop if the service returns a pagination token
143	// that matches the most recent token provided to the service.
144	StopOnDuplicateToken bool
145}
146
147// ListTypedLinkFacetAttributesPaginator is a paginator for
148// ListTypedLinkFacetAttributes
149type ListTypedLinkFacetAttributesPaginator struct {
150	options   ListTypedLinkFacetAttributesPaginatorOptions
151	client    ListTypedLinkFacetAttributesAPIClient
152	params    *ListTypedLinkFacetAttributesInput
153	nextToken *string
154	firstPage bool
155}
156
157// NewListTypedLinkFacetAttributesPaginator returns a new
158// ListTypedLinkFacetAttributesPaginator
159func NewListTypedLinkFacetAttributesPaginator(client ListTypedLinkFacetAttributesAPIClient, params *ListTypedLinkFacetAttributesInput, optFns ...func(*ListTypedLinkFacetAttributesPaginatorOptions)) *ListTypedLinkFacetAttributesPaginator {
160	if params == nil {
161		params = &ListTypedLinkFacetAttributesInput{}
162	}
163
164	options := ListTypedLinkFacetAttributesPaginatorOptions{}
165	if params.MaxResults != nil {
166		options.Limit = *params.MaxResults
167	}
168
169	for _, fn := range optFns {
170		fn(&options)
171	}
172
173	return &ListTypedLinkFacetAttributesPaginator{
174		options:   options,
175		client:    client,
176		params:    params,
177		firstPage: true,
178	}
179}
180
181// HasMorePages returns a boolean indicating whether more pages are available
182func (p *ListTypedLinkFacetAttributesPaginator) HasMorePages() bool {
183	return p.firstPage || p.nextToken != nil
184}
185
186// NextPage retrieves the next ListTypedLinkFacetAttributes page.
187func (p *ListTypedLinkFacetAttributesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListTypedLinkFacetAttributesOutput, error) {
188	if !p.HasMorePages() {
189		return nil, fmt.Errorf("no more pages available")
190	}
191
192	params := *p.params
193	params.NextToken = p.nextToken
194
195	var limit *int32
196	if p.options.Limit > 0 {
197		limit = &p.options.Limit
198	}
199	params.MaxResults = limit
200
201	result, err := p.client.ListTypedLinkFacetAttributes(ctx, &params, optFns...)
202	if err != nil {
203		return nil, err
204	}
205	p.firstPage = false
206
207	prevToken := p.nextToken
208	p.nextToken = result.NextToken
209
210	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
211		p.nextToken = nil
212	}
213
214	return result, nil
215}
216
217func newServiceMetadataMiddleware_opListTypedLinkFacetAttributes(region string) *awsmiddleware.RegisterServiceMetadata {
218	return &awsmiddleware.RegisterServiceMetadata{
219		Region:        region,
220		ServiceID:     ServiceID,
221		SigningName:   "clouddirectory",
222		OperationName: "ListTypedLinkFacetAttributes",
223	}
224}
225