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, c.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 noSmithyDocumentSerde 53} 54 55type ListTypedLinkFacetAttributesOutput struct { 56 57 // An ordered set of attributes associate with the typed link. 58 Attributes []types.TypedLinkAttributeDefinition 59 60 // The pagination token. 61 NextToken *string 62 63 // Metadata pertaining to the operation's result. 64 ResultMetadata middleware.Metadata 65 66 noSmithyDocumentSerde 67} 68 69func (c *Client) addOperationListTypedLinkFacetAttributesMiddlewares(stack *middleware.Stack, options Options) (err error) { 70 err = stack.Serialize.Add(&awsRestjson1_serializeOpListTypedLinkFacetAttributes{}, middleware.After) 71 if err != nil { 72 return err 73 } 74 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListTypedLinkFacetAttributes{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 if err = addSetLoggerMiddleware(stack, options); err != nil { 79 return err 80 } 81 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 82 return err 83 } 84 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 85 return err 86 } 87 if err = addResolveEndpointMiddleware(stack, options); err != nil { 88 return err 89 } 90 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 91 return err 92 } 93 if err = addRetryMiddlewares(stack, options); err != nil { 94 return err 95 } 96 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 103 return err 104 } 105 if err = addClientUserAgent(stack); err != nil { 106 return err 107 } 108 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 112 return err 113 } 114 if err = addOpListTypedLinkFacetAttributesValidationMiddleware(stack); err != nil { 115 return err 116 } 117 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListTypedLinkFacetAttributes(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// ListTypedLinkFacetAttributesAPIClient is a client that implements the 133// ListTypedLinkFacetAttributes operation. 134type ListTypedLinkFacetAttributesAPIClient interface { 135 ListTypedLinkFacetAttributes(context.Context, *ListTypedLinkFacetAttributesInput, ...func(*Options)) (*ListTypedLinkFacetAttributesOutput, error) 136} 137 138var _ ListTypedLinkFacetAttributesAPIClient = (*Client)(nil) 139 140// ListTypedLinkFacetAttributesPaginatorOptions is the paginator options for 141// ListTypedLinkFacetAttributes 142type ListTypedLinkFacetAttributesPaginatorOptions struct { 143 // The maximum number of results to retrieve. 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// ListTypedLinkFacetAttributesPaginator is a paginator for 152// ListTypedLinkFacetAttributes 153type ListTypedLinkFacetAttributesPaginator struct { 154 options ListTypedLinkFacetAttributesPaginatorOptions 155 client ListTypedLinkFacetAttributesAPIClient 156 params *ListTypedLinkFacetAttributesInput 157 nextToken *string 158 firstPage bool 159} 160 161// NewListTypedLinkFacetAttributesPaginator returns a new 162// ListTypedLinkFacetAttributesPaginator 163func NewListTypedLinkFacetAttributesPaginator(client ListTypedLinkFacetAttributesAPIClient, params *ListTypedLinkFacetAttributesInput, optFns ...func(*ListTypedLinkFacetAttributesPaginatorOptions)) *ListTypedLinkFacetAttributesPaginator { 164 if params == nil { 165 params = &ListTypedLinkFacetAttributesInput{} 166 } 167 168 options := ListTypedLinkFacetAttributesPaginatorOptions{} 169 if params.MaxResults != nil { 170 options.Limit = *params.MaxResults 171 } 172 173 for _, fn := range optFns { 174 fn(&options) 175 } 176 177 return &ListTypedLinkFacetAttributesPaginator{ 178 options: options, 179 client: client, 180 params: params, 181 firstPage: true, 182 } 183} 184 185// HasMorePages returns a boolean indicating whether more pages are available 186func (p *ListTypedLinkFacetAttributesPaginator) HasMorePages() bool { 187 return p.firstPage || p.nextToken != nil 188} 189 190// NextPage retrieves the next ListTypedLinkFacetAttributes page. 191func (p *ListTypedLinkFacetAttributesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListTypedLinkFacetAttributesOutput, error) { 192 if !p.HasMorePages() { 193 return nil, fmt.Errorf("no more pages available") 194 } 195 196 params := *p.params 197 params.NextToken = p.nextToken 198 199 var limit *int32 200 if p.options.Limit > 0 { 201 limit = &p.options.Limit 202 } 203 params.MaxResults = limit 204 205 result, err := p.client.ListTypedLinkFacetAttributes(ctx, ¶ms, optFns...) 206 if err != nil { 207 return nil, err 208 } 209 p.firstPage = false 210 211 prevToken := p.nextToken 212 p.nextToken = result.NextToken 213 214 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 215 p.nextToken = nil 216 } 217 218 return result, nil 219} 220 221func newServiceMetadataMiddleware_opListTypedLinkFacetAttributes(region string) *awsmiddleware.RegisterServiceMetadata { 222 return &awsmiddleware.RegisterServiceMetadata{ 223 Region: region, 224 ServiceID: ServiceID, 225 SigningName: "clouddirectory", 226 OperationName: "ListTypedLinkFacetAttributes", 227 } 228} 229