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// Lists all of the smart home appliances associated with a room. 16func (c *Client) ListSmartHomeAppliances(ctx context.Context, params *ListSmartHomeAppliancesInput, optFns ...func(*Options)) (*ListSmartHomeAppliancesOutput, error) { 17 if params == nil { 18 params = &ListSmartHomeAppliancesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListSmartHomeAppliances", params, optFns, addOperationListSmartHomeAppliancesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListSmartHomeAppliancesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListSmartHomeAppliancesInput struct { 32 33 // The room that the appliances are associated with. 34 // 35 // This member is required. 36 RoomArn *string 37 38 // The maximum number of appliances to be returned, per paginated calls. 39 MaxResults *int32 40 41 // The tokens used for pagination. 42 NextToken *string 43} 44 45type ListSmartHomeAppliancesOutput struct { 46 47 // The tokens used for pagination. 48 NextToken *string 49 50 // The smart home appliances. 51 SmartHomeAppliances []types.SmartHomeAppliance 52 53 // Metadata pertaining to the operation's result. 54 ResultMetadata middleware.Metadata 55} 56 57func addOperationListSmartHomeAppliancesMiddlewares(stack *middleware.Stack, options Options) (err error) { 58 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListSmartHomeAppliances{}, middleware.After) 59 if err != nil { 60 return err 61 } 62 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListSmartHomeAppliances{}, middleware.After) 63 if err != nil { 64 return err 65 } 66 if err = addSetLoggerMiddleware(stack, options); err != nil { 67 return err 68 } 69 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 70 return err 71 } 72 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 73 return err 74 } 75 if err = addResolveEndpointMiddleware(stack, options); err != nil { 76 return err 77 } 78 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 79 return err 80 } 81 if err = addRetryMiddlewares(stack, options); err != nil { 82 return err 83 } 84 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 85 return err 86 } 87 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 88 return err 89 } 90 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 91 return err 92 } 93 if err = addClientUserAgent(stack); err != nil { 94 return err 95 } 96 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 97 return err 98 } 99 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 100 return err 101 } 102 if err = addOpListSmartHomeAppliancesValidationMiddleware(stack); err != nil { 103 return err 104 } 105 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListSmartHomeAppliances(options.Region), middleware.Before); err != nil { 106 return err 107 } 108 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 109 return err 110 } 111 if err = addResponseErrorMiddleware(stack); err != nil { 112 return err 113 } 114 if err = addRequestResponseLogging(stack, options); err != nil { 115 return err 116 } 117 return nil 118} 119 120// ListSmartHomeAppliancesAPIClient is a client that implements the 121// ListSmartHomeAppliances operation. 122type ListSmartHomeAppliancesAPIClient interface { 123 ListSmartHomeAppliances(context.Context, *ListSmartHomeAppliancesInput, ...func(*Options)) (*ListSmartHomeAppliancesOutput, error) 124} 125 126var _ ListSmartHomeAppliancesAPIClient = (*Client)(nil) 127 128// ListSmartHomeAppliancesPaginatorOptions is the paginator options for 129// ListSmartHomeAppliances 130type ListSmartHomeAppliancesPaginatorOptions struct { 131 // The maximum number of appliances to be returned, per paginated calls. 132 Limit int32 133 134 // Set to true if pagination should stop if the service returns a pagination token 135 // that matches the most recent token provided to the service. 136 StopOnDuplicateToken bool 137} 138 139// ListSmartHomeAppliancesPaginator is a paginator for ListSmartHomeAppliances 140type ListSmartHomeAppliancesPaginator struct { 141 options ListSmartHomeAppliancesPaginatorOptions 142 client ListSmartHomeAppliancesAPIClient 143 params *ListSmartHomeAppliancesInput 144 nextToken *string 145 firstPage bool 146} 147 148// NewListSmartHomeAppliancesPaginator returns a new 149// ListSmartHomeAppliancesPaginator 150func NewListSmartHomeAppliancesPaginator(client ListSmartHomeAppliancesAPIClient, params *ListSmartHomeAppliancesInput, optFns ...func(*ListSmartHomeAppliancesPaginatorOptions)) *ListSmartHomeAppliancesPaginator { 151 if params == nil { 152 params = &ListSmartHomeAppliancesInput{} 153 } 154 155 options := ListSmartHomeAppliancesPaginatorOptions{} 156 if params.MaxResults != nil { 157 options.Limit = *params.MaxResults 158 } 159 160 for _, fn := range optFns { 161 fn(&options) 162 } 163 164 return &ListSmartHomeAppliancesPaginator{ 165 options: options, 166 client: client, 167 params: params, 168 firstPage: true, 169 } 170} 171 172// HasMorePages returns a boolean indicating whether more pages are available 173func (p *ListSmartHomeAppliancesPaginator) HasMorePages() bool { 174 return p.firstPage || p.nextToken != nil 175} 176 177// NextPage retrieves the next ListSmartHomeAppliances page. 178func (p *ListSmartHomeAppliancesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListSmartHomeAppliancesOutput, error) { 179 if !p.HasMorePages() { 180 return nil, fmt.Errorf("no more pages available") 181 } 182 183 params := *p.params 184 params.NextToken = p.nextToken 185 186 var limit *int32 187 if p.options.Limit > 0 { 188 limit = &p.options.Limit 189 } 190 params.MaxResults = limit 191 192 result, err := p.client.ListSmartHomeAppliances(ctx, ¶ms, optFns...) 193 if err != nil { 194 return nil, err 195 } 196 p.firstPage = false 197 198 prevToken := p.nextToken 199 p.nextToken = result.NextToken 200 201 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 202 p.nextToken = nil 203 } 204 205 return result, nil 206} 207 208func newServiceMetadataMiddleware_opListSmartHomeAppliances(region string) *awsmiddleware.RegisterServiceMetadata { 209 return &awsmiddleware.RegisterServiceMetadata{ 210 Region: region, 211 ServiceID: ServiceID, 212 SigningName: "a4b", 213 OperationName: "ListSmartHomeAppliances", 214 } 215} 216