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