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// Lists the iSCSI stored volumes of a gateway. Results are sorted by volume ARN. 16// The response includes only the volume ARNs. If you want additional volume 17// information, use the DescribeStorediSCSIVolumes or the 18// DescribeCachediSCSIVolumes API. The operation supports pagination. By default, 19// the operation returns a maximum of up to 100 volumes. You can optionally specify 20// the Limit field in the body to limit the number of volumes in the response. If 21// the number of volumes returned in the response is truncated, the response 22// includes a Marker field. You can use this Marker value in your subsequent 23// request to retrieve the next set of volumes. This operation is only supported in 24// the cached volume and stored volume gateway types. 25func (c *Client) ListVolumes(ctx context.Context, params *ListVolumesInput, optFns ...func(*Options)) (*ListVolumesOutput, error) { 26 if params == nil { 27 params = &ListVolumesInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "ListVolumes", params, optFns, c.addOperationListVolumesMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*ListVolumesOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40// A JSON object that contains one or more of the following fields: 41// 42// * 43// ListVolumesInput$Limit 44// 45// * ListVolumesInput$Marker 46type ListVolumesInput struct { 47 48 // The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to 49 // return a list of gateways for your account and Region. 50 GatewayARN *string 51 52 // Specifies that the list of volumes returned be limited to the specified number 53 // of items. 54 Limit *int32 55 56 // A string that indicates the position at which to begin the returned list of 57 // volumes. Obtain the marker from the response of a previous List iSCSI Volumes 58 // request. 59 Marker *string 60 61 noSmithyDocumentSerde 62} 63 64// A JSON object containing the following fields: 65// 66// * ListVolumesOutput$Marker 67// 68// * 69// ListVolumesOutput$VolumeInfos 70type ListVolumesOutput struct { 71 72 // The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to 73 // return a list of gateways for your account and Region. 74 GatewayARN *string 75 76 // Use the marker in your next request to continue pagination of iSCSI volumes. If 77 // there are no more volumes to list, this field does not appear in the response 78 // body. 79 Marker *string 80 81 // An array of VolumeInfo objects, where each object describes an iSCSI volume. If 82 // no volumes are defined for the gateway, then VolumeInfos is an empty array "[]". 83 VolumeInfos []types.VolumeInfo 84 85 // Metadata pertaining to the operation's result. 86 ResultMetadata middleware.Metadata 87 88 noSmithyDocumentSerde 89} 90 91func (c *Client) addOperationListVolumesMiddlewares(stack *middleware.Stack, options Options) (err error) { 92 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListVolumes{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListVolumes{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 if err = addSetLoggerMiddleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addResolveEndpointMiddleware(stack, options); err != nil { 110 return err 111 } 112 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 113 return err 114 } 115 if err = addRetryMiddlewares(stack, options); err != nil { 116 return err 117 } 118 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 125 return err 126 } 127 if err = addClientUserAgent(stack); err != nil { 128 return err 129 } 130 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 134 return err 135 } 136 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListVolumes(options.Region), middleware.Before); err != nil { 137 return err 138 } 139 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 140 return err 141 } 142 if err = addResponseErrorMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addRequestResponseLogging(stack, options); err != nil { 146 return err 147 } 148 return nil 149} 150 151// ListVolumesAPIClient is a client that implements the ListVolumes operation. 152type ListVolumesAPIClient interface { 153 ListVolumes(context.Context, *ListVolumesInput, ...func(*Options)) (*ListVolumesOutput, error) 154} 155 156var _ ListVolumesAPIClient = (*Client)(nil) 157 158// ListVolumesPaginatorOptions is the paginator options for ListVolumes 159type ListVolumesPaginatorOptions struct { 160 // Specifies that the list of volumes returned be limited to the specified number 161 // of items. 162 Limit int32 163 164 // Set to true if pagination should stop if the service returns a pagination token 165 // that matches the most recent token provided to the service. 166 StopOnDuplicateToken bool 167} 168 169// ListVolumesPaginator is a paginator for ListVolumes 170type ListVolumesPaginator struct { 171 options ListVolumesPaginatorOptions 172 client ListVolumesAPIClient 173 params *ListVolumesInput 174 nextToken *string 175 firstPage bool 176} 177 178// NewListVolumesPaginator returns a new ListVolumesPaginator 179func NewListVolumesPaginator(client ListVolumesAPIClient, params *ListVolumesInput, optFns ...func(*ListVolumesPaginatorOptions)) *ListVolumesPaginator { 180 if params == nil { 181 params = &ListVolumesInput{} 182 } 183 184 options := ListVolumesPaginatorOptions{} 185 if params.Limit != nil { 186 options.Limit = *params.Limit 187 } 188 189 for _, fn := range optFns { 190 fn(&options) 191 } 192 193 return &ListVolumesPaginator{ 194 options: options, 195 client: client, 196 params: params, 197 firstPage: true, 198 } 199} 200 201// HasMorePages returns a boolean indicating whether more pages are available 202func (p *ListVolumesPaginator) HasMorePages() bool { 203 return p.firstPage || p.nextToken != nil 204} 205 206// NextPage retrieves the next ListVolumes page. 207func (p *ListVolumesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListVolumesOutput, error) { 208 if !p.HasMorePages() { 209 return nil, fmt.Errorf("no more pages available") 210 } 211 212 params := *p.params 213 params.Marker = p.nextToken 214 215 var limit *int32 216 if p.options.Limit > 0 { 217 limit = &p.options.Limit 218 } 219 params.Limit = limit 220 221 result, err := p.client.ListVolumes(ctx, ¶ms, optFns...) 222 if err != nil { 223 return nil, err 224 } 225 p.firstPage = false 226 227 prevToken := p.nextToken 228 p.nextToken = result.Marker 229 230 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 231 p.nextToken = nil 232 } 233 234 return result, nil 235} 236 237func newServiceMetadataMiddleware_opListVolumes(region string) *awsmiddleware.RegisterServiceMetadata { 238 return &awsmiddleware.RegisterServiceMetadata{ 239 Region: region, 240 ServiceID: ServiceID, 241 SigningName: "storagegateway", 242 OperationName: "ListVolumes", 243 } 244} 245