1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package alexaforbusiness 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/alexaforbusiness/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Searches room profiles and lists the ones that meet a set of filter criteria. 16func (c *Client) SearchProfiles(ctx context.Context, params *SearchProfilesInput, optFns ...func(*Options)) (*SearchProfilesOutput, error) { 17 if params == nil { 18 params = &SearchProfilesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "SearchProfiles", params, optFns, c.addOperationSearchProfilesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*SearchProfilesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type SearchProfilesInput struct { 32 33 // The filters to use to list a specified set of room profiles. Supported filter 34 // keys are ProfileName and Address. Required. 35 Filters []types.Filter 36 37 // The maximum number of results to include in the response. If more results exist 38 // than the specified MaxResults value, a token is included in the response so that 39 // the remaining results can be retrieved. 40 MaxResults *int32 41 42 // An optional token returned from a prior request. Use this token for pagination 43 // of results from this action. If this parameter is specified, the response 44 // includes only results beyond the token, up to the value specified by MaxResults. 45 NextToken *string 46 47 // The sort order to use in listing the specified set of room profiles. Supported 48 // sort keys are ProfileName and Address. 49 SortCriteria []types.Sort 50 51 noSmithyDocumentSerde 52} 53 54type SearchProfilesOutput struct { 55 56 // The token returned to indicate that there is more data available. 57 NextToken *string 58 59 // The profiles that meet the specified set of filter criteria, in sort order. 60 Profiles []types.ProfileData 61 62 // The total number of room profiles returned. 63 TotalCount *int32 64 65 // Metadata pertaining to the operation's result. 66 ResultMetadata middleware.Metadata 67 68 noSmithyDocumentSerde 69} 70 71func (c *Client) addOperationSearchProfilesMiddlewares(stack *middleware.Stack, options Options) (err error) { 72 err = stack.Serialize.Add(&awsAwsjson11_serializeOpSearchProfiles{}, middleware.After) 73 if err != nil { 74 return err 75 } 76 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpSearchProfiles{}, middleware.After) 77 if err != nil { 78 return err 79 } 80 if err = addSetLoggerMiddleware(stack, options); err != nil { 81 return err 82 } 83 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 84 return err 85 } 86 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 87 return err 88 } 89 if err = addResolveEndpointMiddleware(stack, options); err != nil { 90 return err 91 } 92 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 93 return err 94 } 95 if err = addRetryMiddlewares(stack, options); err != nil { 96 return err 97 } 98 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 99 return err 100 } 101 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 102 return err 103 } 104 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 105 return err 106 } 107 if err = addClientUserAgent(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 111 return err 112 } 113 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addOpSearchProfilesValidationMiddleware(stack); err != nil { 117 return err 118 } 119 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSearchProfiles(options.Region), middleware.Before); err != nil { 120 return err 121 } 122 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addResponseErrorMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addRequestResponseLogging(stack, options); err != nil { 129 return err 130 } 131 return nil 132} 133 134// SearchProfilesAPIClient is a client that implements the SearchProfiles 135// operation. 136type SearchProfilesAPIClient interface { 137 SearchProfiles(context.Context, *SearchProfilesInput, ...func(*Options)) (*SearchProfilesOutput, error) 138} 139 140var _ SearchProfilesAPIClient = (*Client)(nil) 141 142// SearchProfilesPaginatorOptions is the paginator options for SearchProfiles 143type SearchProfilesPaginatorOptions struct { 144 // The maximum number of results to include in the response. If more results exist 145 // than the specified MaxResults value, a token is included in the response so that 146 // the remaining results can be retrieved. 147 Limit int32 148 149 // Set to true if pagination should stop if the service returns a pagination token 150 // that matches the most recent token provided to the service. 151 StopOnDuplicateToken bool 152} 153 154// SearchProfilesPaginator is a paginator for SearchProfiles 155type SearchProfilesPaginator struct { 156 options SearchProfilesPaginatorOptions 157 client SearchProfilesAPIClient 158 params *SearchProfilesInput 159 nextToken *string 160 firstPage bool 161} 162 163// NewSearchProfilesPaginator returns a new SearchProfilesPaginator 164func NewSearchProfilesPaginator(client SearchProfilesAPIClient, params *SearchProfilesInput, optFns ...func(*SearchProfilesPaginatorOptions)) *SearchProfilesPaginator { 165 if params == nil { 166 params = &SearchProfilesInput{} 167 } 168 169 options := SearchProfilesPaginatorOptions{} 170 if params.MaxResults != nil { 171 options.Limit = *params.MaxResults 172 } 173 174 for _, fn := range optFns { 175 fn(&options) 176 } 177 178 return &SearchProfilesPaginator{ 179 options: options, 180 client: client, 181 params: params, 182 firstPage: true, 183 } 184} 185 186// HasMorePages returns a boolean indicating whether more pages are available 187func (p *SearchProfilesPaginator) HasMorePages() bool { 188 return p.firstPage || p.nextToken != nil 189} 190 191// NextPage retrieves the next SearchProfiles page. 192func (p *SearchProfilesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*SearchProfilesOutput, error) { 193 if !p.HasMorePages() { 194 return nil, fmt.Errorf("no more pages available") 195 } 196 197 params := *p.params 198 params.NextToken = p.nextToken 199 200 var limit *int32 201 if p.options.Limit > 0 { 202 limit = &p.options.Limit 203 } 204 params.MaxResults = limit 205 206 result, err := p.client.SearchProfiles(ctx, ¶ms, optFns...) 207 if err != nil { 208 return nil, err 209 } 210 p.firstPage = false 211 212 prevToken := p.nextToken 213 p.nextToken = result.NextToken 214 215 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 216 p.nextToken = nil 217 } 218 219 return result, nil 220} 221 222func newServiceMetadataMiddleware_opSearchProfiles(region string) *awsmiddleware.RegisterServiceMetadata { 223 return &awsmiddleware.RegisterServiceMetadata{ 224 Region: region, 225 ServiceID: ServiceID, 226 SigningName: "a4b", 227 OperationName: "SearchProfiles", 228 } 229} 230