1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package connect 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/connect/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// This API is in preview release for Amazon Connect and is subject to change. 16// Returns a paginated list of all attribute types for the given instance. 17func (c *Client) ListInstanceAttributes(ctx context.Context, params *ListInstanceAttributesInput, optFns ...func(*Options)) (*ListInstanceAttributesOutput, error) { 18 if params == nil { 19 params = &ListInstanceAttributesInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListInstanceAttributes", params, optFns, addOperationListInstanceAttributesMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListInstanceAttributesOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListInstanceAttributesInput struct { 33 34 // The identifier of the Amazon Connect instance. 35 // 36 // This member is required. 37 InstanceId *string 38 39 // The maximimum number of results to return per page. 40 MaxResults int32 41 42 // The token for the next set of results. Use the value returned in the previous 43 // response in the next request to retrieve the next set of results. 44 NextToken *string 45} 46 47type ListInstanceAttributesOutput struct { 48 49 // The attribute types. 50 Attributes []types.Attribute 51 52 // If there are additional results, this is the token for the next set of results. 53 NextToken *string 54 55 // Metadata pertaining to the operation's result. 56 ResultMetadata middleware.Metadata 57} 58 59func addOperationListInstanceAttributesMiddlewares(stack *middleware.Stack, options Options) (err error) { 60 err = stack.Serialize.Add(&awsRestjson1_serializeOpListInstanceAttributes{}, middleware.After) 61 if err != nil { 62 return err 63 } 64 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListInstanceAttributes{}, middleware.After) 65 if err != nil { 66 return err 67 } 68 if err = addSetLoggerMiddleware(stack, options); err != nil { 69 return err 70 } 71 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 72 return err 73 } 74 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 75 return err 76 } 77 if err = addResolveEndpointMiddleware(stack, options); err != nil { 78 return err 79 } 80 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 81 return err 82 } 83 if err = addRetryMiddlewares(stack, options); err != nil { 84 return err 85 } 86 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 87 return err 88 } 89 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 93 return err 94 } 95 if err = addClientUserAgent(stack); err != nil { 96 return err 97 } 98 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 102 return err 103 } 104 if err = addOpListInstanceAttributesValidationMiddleware(stack); err != nil { 105 return err 106 } 107 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListInstanceAttributes(options.Region), middleware.Before); err != nil { 108 return err 109 } 110 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResponseErrorMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addRequestResponseLogging(stack, options); err != nil { 117 return err 118 } 119 return nil 120} 121 122// ListInstanceAttributesAPIClient is a client that implements the 123// ListInstanceAttributes operation. 124type ListInstanceAttributesAPIClient interface { 125 ListInstanceAttributes(context.Context, *ListInstanceAttributesInput, ...func(*Options)) (*ListInstanceAttributesOutput, error) 126} 127 128var _ ListInstanceAttributesAPIClient = (*Client)(nil) 129 130// ListInstanceAttributesPaginatorOptions is the paginator options for 131// ListInstanceAttributes 132type ListInstanceAttributesPaginatorOptions struct { 133 // The maximimum number of results to return per page. 134 Limit int32 135 136 // Set to true if pagination should stop if the service returns a pagination token 137 // that matches the most recent token provided to the service. 138 StopOnDuplicateToken bool 139} 140 141// ListInstanceAttributesPaginator is a paginator for ListInstanceAttributes 142type ListInstanceAttributesPaginator struct { 143 options ListInstanceAttributesPaginatorOptions 144 client ListInstanceAttributesAPIClient 145 params *ListInstanceAttributesInput 146 nextToken *string 147 firstPage bool 148} 149 150// NewListInstanceAttributesPaginator returns a new ListInstanceAttributesPaginator 151func NewListInstanceAttributesPaginator(client ListInstanceAttributesAPIClient, params *ListInstanceAttributesInput, optFns ...func(*ListInstanceAttributesPaginatorOptions)) *ListInstanceAttributesPaginator { 152 options := ListInstanceAttributesPaginatorOptions{} 153 if params.MaxResults != 0 { 154 options.Limit = params.MaxResults 155 } 156 157 for _, fn := range optFns { 158 fn(&options) 159 } 160 161 if params == nil { 162 params = &ListInstanceAttributesInput{} 163 } 164 165 return &ListInstanceAttributesPaginator{ 166 options: options, 167 client: client, 168 params: params, 169 firstPage: true, 170 } 171} 172 173// HasMorePages returns a boolean indicating whether more pages are available 174func (p *ListInstanceAttributesPaginator) HasMorePages() bool { 175 return p.firstPage || p.nextToken != nil 176} 177 178// NextPage retrieves the next ListInstanceAttributes page. 179func (p *ListInstanceAttributesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListInstanceAttributesOutput, error) { 180 if !p.HasMorePages() { 181 return nil, fmt.Errorf("no more pages available") 182 } 183 184 params := *p.params 185 params.NextToken = p.nextToken 186 187 params.MaxResults = p.options.Limit 188 189 result, err := p.client.ListInstanceAttributes(ctx, ¶ms, optFns...) 190 if err != nil { 191 return nil, err 192 } 193 p.firstPage = false 194 195 prevToken := p.nextToken 196 p.nextToken = result.NextToken 197 198 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 199 p.nextToken = nil 200 } 201 202 return result, nil 203} 204 205func newServiceMetadataMiddleware_opListInstanceAttributes(region string) *awsmiddleware.RegisterServiceMetadata { 206 return &awsmiddleware.RegisterServiceMetadata{ 207 Region: region, 208 ServiceID: ServiceID, 209 SigningName: "connect", 210 OperationName: "ListInstanceAttributes", 211 } 212} 213