1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package quicksight 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/quicksight/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the namespaces for the specified AWS account. 16func (c *Client) ListNamespaces(ctx context.Context, params *ListNamespacesInput, optFns ...func(*Options)) (*ListNamespacesOutput, error) { 17 if params == nil { 18 params = &ListNamespacesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListNamespaces", params, optFns, addOperationListNamespacesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListNamespacesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListNamespacesInput struct { 32 33 // The ID for the AWS account that contains the QuickSight namespaces that you want 34 // to list. 35 // 36 // This member is required. 37 AwsAccountId *string 38 39 // The maximum number of results to return. 40 MaxResults int32 41 42 // A pagination token that can be used in a subsequent request. 43 NextToken *string 44} 45 46type ListNamespacesOutput struct { 47 48 // The information about the namespaces in this AWS account. The response includes 49 // the namespace ARN, name, AWS Region, notification email address, creation 50 // status, and identity store. 51 Namespaces []types.NamespaceInfoV2 52 53 // A pagination token that can be used in a subsequent request. 54 NextToken *string 55 56 // The AWS request ID for this operation. 57 RequestId *string 58 59 // The HTTP status of the request. 60 Status int32 61 62 // Metadata pertaining to the operation's result. 63 ResultMetadata middleware.Metadata 64} 65 66func addOperationListNamespacesMiddlewares(stack *middleware.Stack, options Options) (err error) { 67 err = stack.Serialize.Add(&awsRestjson1_serializeOpListNamespaces{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListNamespaces{}, middleware.After) 72 if err != nil { 73 return err 74 } 75 if err = addSetLoggerMiddleware(stack, options); err != nil { 76 return err 77 } 78 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 79 return err 80 } 81 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 82 return err 83 } 84 if err = addResolveEndpointMiddleware(stack, options); err != nil { 85 return err 86 } 87 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 88 return err 89 } 90 if err = addRetryMiddlewares(stack, options); err != nil { 91 return err 92 } 93 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 94 return err 95 } 96 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 100 return err 101 } 102 if err = addClientUserAgent(stack); err != nil { 103 return err 104 } 105 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 106 return err 107 } 108 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 109 return err 110 } 111 if err = addOpListNamespacesValidationMiddleware(stack); err != nil { 112 return err 113 } 114 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListNamespaces(options.Region), middleware.Before); err != nil { 115 return err 116 } 117 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addResponseErrorMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addRequestResponseLogging(stack, options); err != nil { 124 return err 125 } 126 return nil 127} 128 129// ListNamespacesAPIClient is a client that implements the ListNamespaces 130// operation. 131type ListNamespacesAPIClient interface { 132 ListNamespaces(context.Context, *ListNamespacesInput, ...func(*Options)) (*ListNamespacesOutput, error) 133} 134 135var _ ListNamespacesAPIClient = (*Client)(nil) 136 137// ListNamespacesPaginatorOptions is the paginator options for ListNamespaces 138type ListNamespacesPaginatorOptions struct { 139 // The maximum number of results to return. 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// ListNamespacesPaginator is a paginator for ListNamespaces 148type ListNamespacesPaginator struct { 149 options ListNamespacesPaginatorOptions 150 client ListNamespacesAPIClient 151 params *ListNamespacesInput 152 nextToken *string 153 firstPage bool 154} 155 156// NewListNamespacesPaginator returns a new ListNamespacesPaginator 157func NewListNamespacesPaginator(client ListNamespacesAPIClient, params *ListNamespacesInput, optFns ...func(*ListNamespacesPaginatorOptions)) *ListNamespacesPaginator { 158 options := ListNamespacesPaginatorOptions{} 159 if params.MaxResults != 0 { 160 options.Limit = params.MaxResults 161 } 162 163 for _, fn := range optFns { 164 fn(&options) 165 } 166 167 if params == nil { 168 params = &ListNamespacesInput{} 169 } 170 171 return &ListNamespacesPaginator{ 172 options: options, 173 client: client, 174 params: params, 175 firstPage: true, 176 } 177} 178 179// HasMorePages returns a boolean indicating whether more pages are available 180func (p *ListNamespacesPaginator) HasMorePages() bool { 181 return p.firstPage || p.nextToken != nil 182} 183 184// NextPage retrieves the next ListNamespaces page. 185func (p *ListNamespacesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListNamespacesOutput, error) { 186 if !p.HasMorePages() { 187 return nil, fmt.Errorf("no more pages available") 188 } 189 190 params := *p.params 191 params.NextToken = p.nextToken 192 193 params.MaxResults = p.options.Limit 194 195 result, err := p.client.ListNamespaces(ctx, ¶ms, optFns...) 196 if err != nil { 197 return nil, err 198 } 199 p.firstPage = false 200 201 prevToken := p.nextToken 202 p.nextToken = result.NextToken 203 204 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 205 p.nextToken = nil 206 } 207 208 return result, nil 209} 210 211func newServiceMetadataMiddleware_opListNamespaces(region string) *awsmiddleware.RegisterServiceMetadata { 212 return &awsmiddleware.RegisterServiceMetadata{ 213 Region: region, 214 ServiceID: ServiceID, 215 SigningName: "quicksight", 216 OperationName: "ListNamespaces", 217 } 218} 219