1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package storagegateway 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/storagegateway/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a description of virtual tape library (VTL) devices for the specified 16// tape gateway. In the response, AWS Storage Gateway returns VTL device 17// information. This operation is only supported in the tape gateway type. 18func (c *Client) DescribeVTLDevices(ctx context.Context, params *DescribeVTLDevicesInput, optFns ...func(*Options)) (*DescribeVTLDevicesOutput, error) { 19 if params == nil { 20 params = &DescribeVTLDevicesInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "DescribeVTLDevices", params, optFns, addOperationDescribeVTLDevicesMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*DescribeVTLDevicesOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33// DescribeVTLDevicesInput 34type DescribeVTLDevicesInput struct { 35 36 // The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to 37 // return a list of gateways for your account and AWS Region. 38 // 39 // This member is required. 40 GatewayARN *string 41 42 // Specifies that the number of VTL devices described be limited to the specified 43 // number. 44 Limit *int32 45 46 // An opaque string that indicates the position at which to begin describing the 47 // VTL devices. 48 Marker *string 49 50 // An array of strings, where each string represents the Amazon Resource Name (ARN) 51 // of a VTL device. All of the specified VTL devices must be from the same gateway. 52 // If no VTL devices are specified, the result will contain all devices on the 53 // specified gateway. 54 VTLDeviceARNs []string 55} 56 57// DescribeVTLDevicesOutput 58type DescribeVTLDevicesOutput struct { 59 60 // The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to 61 // return a list of gateways for your account and AWS Region. 62 GatewayARN *string 63 64 // An opaque string that indicates the position at which the VTL devices that were 65 // fetched for description ended. Use the marker in your next request to fetch the 66 // next set of VTL devices in the list. If there are no more VTL devices to 67 // describe, this field does not appear in the response. 68 Marker *string 69 70 // An array of VTL device objects composed of the Amazon Resource Name (ARN) of the 71 // VTL devices. 72 VTLDevices []types.VTLDevice 73 74 // Metadata pertaining to the operation's result. 75 ResultMetadata middleware.Metadata 76} 77 78func addOperationDescribeVTLDevicesMiddlewares(stack *middleware.Stack, options Options) (err error) { 79 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeVTLDevices{}, middleware.After) 80 if err != nil { 81 return err 82 } 83 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeVTLDevices{}, middleware.After) 84 if err != nil { 85 return err 86 } 87 if err = addSetLoggerMiddleware(stack, options); err != nil { 88 return err 89 } 90 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 91 return err 92 } 93 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 94 return err 95 } 96 if err = addResolveEndpointMiddleware(stack, options); err != nil { 97 return err 98 } 99 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 100 return err 101 } 102 if err = addRetryMiddlewares(stack, options); err != nil { 103 return err 104 } 105 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 112 return err 113 } 114 if err = addClientUserAgent(stack); err != nil { 115 return err 116 } 117 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addOpDescribeVTLDevicesValidationMiddleware(stack); err != nil { 124 return err 125 } 126 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeVTLDevices(options.Region), middleware.Before); err != nil { 127 return err 128 } 129 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addResponseErrorMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addRequestResponseLogging(stack, options); err != nil { 136 return err 137 } 138 return nil 139} 140 141// DescribeVTLDevicesAPIClient is a client that implements the DescribeVTLDevices 142// operation. 143type DescribeVTLDevicesAPIClient interface { 144 DescribeVTLDevices(context.Context, *DescribeVTLDevicesInput, ...func(*Options)) (*DescribeVTLDevicesOutput, error) 145} 146 147var _ DescribeVTLDevicesAPIClient = (*Client)(nil) 148 149// DescribeVTLDevicesPaginatorOptions is the paginator options for 150// DescribeVTLDevices 151type DescribeVTLDevicesPaginatorOptions struct { 152 // Specifies that the number of VTL devices described be limited to the specified 153 // number. 154 Limit int32 155 156 // Set to true if pagination should stop if the service returns a pagination token 157 // that matches the most recent token provided to the service. 158 StopOnDuplicateToken bool 159} 160 161// DescribeVTLDevicesPaginator is a paginator for DescribeVTLDevices 162type DescribeVTLDevicesPaginator struct { 163 options DescribeVTLDevicesPaginatorOptions 164 client DescribeVTLDevicesAPIClient 165 params *DescribeVTLDevicesInput 166 nextToken *string 167 firstPage bool 168} 169 170// NewDescribeVTLDevicesPaginator returns a new DescribeVTLDevicesPaginator 171func NewDescribeVTLDevicesPaginator(client DescribeVTLDevicesAPIClient, params *DescribeVTLDevicesInput, optFns ...func(*DescribeVTLDevicesPaginatorOptions)) *DescribeVTLDevicesPaginator { 172 options := DescribeVTLDevicesPaginatorOptions{} 173 if params.Limit != nil { 174 options.Limit = *params.Limit 175 } 176 177 for _, fn := range optFns { 178 fn(&options) 179 } 180 181 if params == nil { 182 params = &DescribeVTLDevicesInput{} 183 } 184 185 return &DescribeVTLDevicesPaginator{ 186 options: options, 187 client: client, 188 params: params, 189 firstPage: true, 190 } 191} 192 193// HasMorePages returns a boolean indicating whether more pages are available 194func (p *DescribeVTLDevicesPaginator) HasMorePages() bool { 195 return p.firstPage || p.nextToken != nil 196} 197 198// NextPage retrieves the next DescribeVTLDevices page. 199func (p *DescribeVTLDevicesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeVTLDevicesOutput, error) { 200 if !p.HasMorePages() { 201 return nil, fmt.Errorf("no more pages available") 202 } 203 204 params := *p.params 205 params.Marker = p.nextToken 206 207 var limit *int32 208 if p.options.Limit > 0 { 209 limit = &p.options.Limit 210 } 211 params.Limit = limit 212 213 result, err := p.client.DescribeVTLDevices(ctx, ¶ms, optFns...) 214 if err != nil { 215 return nil, err 216 } 217 p.firstPage = false 218 219 prevToken := p.nextToken 220 p.nextToken = result.Marker 221 222 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 223 p.nextToken = nil 224 } 225 226 return result, nil 227} 228 229func newServiceMetadataMiddleware_opDescribeVTLDevices(region string) *awsmiddleware.RegisterServiceMetadata { 230 return &awsmiddleware.RegisterServiceMetadata{ 231 Region: region, 232 ServiceID: ServiceID, 233 SigningName: "storagegateway", 234 OperationName: "DescribeVTLDevices", 235 } 236} 237