1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package elasticinference 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/elasticinference/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes information over a provided set of accelerators belonging to an 16// account. 17func (c *Client) DescribeAccelerators(ctx context.Context, params *DescribeAcceleratorsInput, optFns ...func(*Options)) (*DescribeAcceleratorsOutput, error) { 18 if params == nil { 19 params = &DescribeAcceleratorsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "DescribeAccelerators", params, optFns, addOperationDescribeAcceleratorsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*DescribeAcceleratorsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type DescribeAcceleratorsInput struct { 33 34 // The IDs of the accelerators to describe. 35 AcceleratorIds []string 36 37 // One or more filters. Filter names and values are case-sensitive. Valid filter 38 // names are: accelerator-types: can provide a list of accelerator type names to 39 // filter for. instance-id: can provide a list of EC2 instance ids to filter for. 40 Filters []types.Filter 41 42 // The total number of items to return in the command's output. If the total number 43 // of items available is more than the value specified, a NextToken is provided in 44 // the command's output. To resume pagination, provide the NextToken value in the 45 // starting-token argument of a subsequent command. Do not use the NextToken 46 // response element directly outside of the AWS CLI. 47 MaxResults int32 48 49 // A token to specify where to start paginating. This is the NextToken from a 50 // previously truncated response. 51 NextToken *string 52} 53 54type DescribeAcceleratorsOutput struct { 55 56 // The details of the Elastic Inference Accelerators. 57 AcceleratorSet []types.ElasticInferenceAccelerator 58 59 // A token to specify where to start paginating. This is the NextToken from a 60 // previously truncated response. 61 NextToken *string 62 63 // Metadata pertaining to the operation's result. 64 ResultMetadata middleware.Metadata 65} 66 67func addOperationDescribeAcceleratorsMiddlewares(stack *middleware.Stack, options Options) (err error) { 68 err = stack.Serialize.Add(&awsRestjson1_serializeOpDescribeAccelerators{}, middleware.After) 69 if err != nil { 70 return err 71 } 72 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpDescribeAccelerators{}, middleware.After) 73 if err != nil { 74 return err 75 } 76 if err = addSetLoggerMiddleware(stack, options); err != nil { 77 return err 78 } 79 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 80 return err 81 } 82 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 83 return err 84 } 85 if err = addResolveEndpointMiddleware(stack, options); err != nil { 86 return err 87 } 88 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 89 return err 90 } 91 if err = addRetryMiddlewares(stack, options); err != nil { 92 return err 93 } 94 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 95 return err 96 } 97 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 98 return err 99 } 100 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 101 return err 102 } 103 if err = addClientUserAgent(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 107 return err 108 } 109 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 110 return err 111 } 112 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeAccelerators(options.Region), middleware.Before); err != nil { 113 return err 114 } 115 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addResponseErrorMiddleware(stack); err != nil { 119 return err 120 } 121 if err = addRequestResponseLogging(stack, options); err != nil { 122 return err 123 } 124 return nil 125} 126 127// DescribeAcceleratorsAPIClient is a client that implements the 128// DescribeAccelerators operation. 129type DescribeAcceleratorsAPIClient interface { 130 DescribeAccelerators(context.Context, *DescribeAcceleratorsInput, ...func(*Options)) (*DescribeAcceleratorsOutput, error) 131} 132 133var _ DescribeAcceleratorsAPIClient = (*Client)(nil) 134 135// DescribeAcceleratorsPaginatorOptions is the paginator options for 136// DescribeAccelerators 137type DescribeAcceleratorsPaginatorOptions struct { 138 // The total number of items to return in the command's output. If the total number 139 // of items available is more than the value specified, a NextToken is provided in 140 // the command's output. To resume pagination, provide the NextToken value in the 141 // starting-token argument of a subsequent command. Do not use the NextToken 142 // response element directly outside of the AWS CLI. 143 Limit int32 144 145 // Set to true if pagination should stop if the service returns a pagination token 146 // that matches the most recent token provided to the service. 147 StopOnDuplicateToken bool 148} 149 150// DescribeAcceleratorsPaginator is a paginator for DescribeAccelerators 151type DescribeAcceleratorsPaginator struct { 152 options DescribeAcceleratorsPaginatorOptions 153 client DescribeAcceleratorsAPIClient 154 params *DescribeAcceleratorsInput 155 nextToken *string 156 firstPage bool 157} 158 159// NewDescribeAcceleratorsPaginator returns a new DescribeAcceleratorsPaginator 160func NewDescribeAcceleratorsPaginator(client DescribeAcceleratorsAPIClient, params *DescribeAcceleratorsInput, optFns ...func(*DescribeAcceleratorsPaginatorOptions)) *DescribeAcceleratorsPaginator { 161 options := DescribeAcceleratorsPaginatorOptions{} 162 if params.MaxResults != 0 { 163 options.Limit = params.MaxResults 164 } 165 166 for _, fn := range optFns { 167 fn(&options) 168 } 169 170 if params == nil { 171 params = &DescribeAcceleratorsInput{} 172 } 173 174 return &DescribeAcceleratorsPaginator{ 175 options: options, 176 client: client, 177 params: params, 178 firstPage: true, 179 } 180} 181 182// HasMorePages returns a boolean indicating whether more pages are available 183func (p *DescribeAcceleratorsPaginator) HasMorePages() bool { 184 return p.firstPage || p.nextToken != nil 185} 186 187// NextPage retrieves the next DescribeAccelerators page. 188func (p *DescribeAcceleratorsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeAcceleratorsOutput, error) { 189 if !p.HasMorePages() { 190 return nil, fmt.Errorf("no more pages available") 191 } 192 193 params := *p.params 194 params.NextToken = p.nextToken 195 196 params.MaxResults = p.options.Limit 197 198 result, err := p.client.DescribeAccelerators(ctx, ¶ms, optFns...) 199 if err != nil { 200 return nil, err 201 } 202 p.firstPage = false 203 204 prevToken := p.nextToken 205 p.nextToken = result.NextToken 206 207 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 208 p.nextToken = nil 209 } 210 211 return result, nil 212} 213 214func newServiceMetadataMiddleware_opDescribeAccelerators(region string) *awsmiddleware.RegisterServiceMetadata { 215 return &awsmiddleware.RegisterServiceMetadata{ 216 Region: region, 217 ServiceID: ServiceID, 218 SigningName: "elastic-inference", 219 OperationName: "DescribeAccelerators", 220 } 221} 222