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// Gets a list of FileSystemAssociationSummary objects. Each object contains a 16// summary of a file system association. This operation is only supported for 17// Amazon FSx file gateways. 18func (c *Client) ListFileSystemAssociations(ctx context.Context, params *ListFileSystemAssociationsInput, optFns ...func(*Options)) (*ListFileSystemAssociationsOutput, error) { 19 if params == nil { 20 params = &ListFileSystemAssociationsInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "ListFileSystemAssociations", params, optFns, addOperationListFileSystemAssociationsMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*ListFileSystemAssociationsOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type ListFileSystemAssociationsInput struct { 34 35 // The Amazon Resource Name (ARN) of the gateway. Use the ListGateways operation to 36 // return a list of gateways for your account and AWS Region. 37 GatewayARN *string 38 39 // The maximum number of file system associations to return in the response. If 40 // present, Limit must be an integer with a value greater than zero. Optional. 41 Limit *int32 42 43 // Opaque pagination token returned from a previous ListFileSystemAssociations 44 // operation. If present, Marker specifies where to continue the list from after a 45 // previous call to ListFileSystemAssociations. Optional. 46 Marker *string 47} 48 49type ListFileSystemAssociationsOutput struct { 50 51 // An array of information about the Amazon FSx gateway's file system associations. 52 FileSystemAssociationSummaryList []types.FileSystemAssociationSummary 53 54 // If the request includes Marker, the response returns that value in this field. 55 Marker *string 56 57 // If a value is present, there are more file system associations to return. In a 58 // subsequent request, use NextMarker as the value for Marker to retrieve the next 59 // set of file system associations. 60 NextMarker *string 61 62 // Metadata pertaining to the operation's result. 63 ResultMetadata middleware.Metadata 64} 65 66func addOperationListFileSystemAssociationsMiddlewares(stack *middleware.Stack, options Options) (err error) { 67 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListFileSystemAssociations{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListFileSystemAssociations{}, middleware.After) 72 if err != nil { 73 return err 74 } 75 if err = addSetLoggerMiddleware(stack, options); err != nil { 76 return err 77 } 78 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 79 return err 80 } 81 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 82 return err 83 } 84 if err = addResolveEndpointMiddleware(stack, options); err != nil { 85 return err 86 } 87 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 88 return err 89 } 90 if err = addRetryMiddlewares(stack, options); err != nil { 91 return err 92 } 93 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 94 return err 95 } 96 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 100 return err 101 } 102 if err = addClientUserAgent(stack); err != nil { 103 return err 104 } 105 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 106 return err 107 } 108 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 109 return err 110 } 111 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListFileSystemAssociations(options.Region), middleware.Before); err != nil { 112 return err 113 } 114 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 115 return err 116 } 117 if err = addResponseErrorMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addRequestResponseLogging(stack, options); err != nil { 121 return err 122 } 123 return nil 124} 125 126// ListFileSystemAssociationsAPIClient is a client that implements the 127// ListFileSystemAssociations operation. 128type ListFileSystemAssociationsAPIClient interface { 129 ListFileSystemAssociations(context.Context, *ListFileSystemAssociationsInput, ...func(*Options)) (*ListFileSystemAssociationsOutput, error) 130} 131 132var _ ListFileSystemAssociationsAPIClient = (*Client)(nil) 133 134// ListFileSystemAssociationsPaginatorOptions is the paginator options for 135// ListFileSystemAssociations 136type ListFileSystemAssociationsPaginatorOptions struct { 137 // The maximum number of file system associations to return in the response. If 138 // present, Limit must be an integer with a value greater than zero. Optional. 139 Limit int32 140 141 // Set to true if pagination should stop if the service returns a pagination token 142 // that matches the most recent token provided to the service. 143 StopOnDuplicateToken bool 144} 145 146// ListFileSystemAssociationsPaginator is a paginator for 147// ListFileSystemAssociations 148type ListFileSystemAssociationsPaginator struct { 149 options ListFileSystemAssociationsPaginatorOptions 150 client ListFileSystemAssociationsAPIClient 151 params *ListFileSystemAssociationsInput 152 nextToken *string 153 firstPage bool 154} 155 156// NewListFileSystemAssociationsPaginator returns a new 157// ListFileSystemAssociationsPaginator 158func NewListFileSystemAssociationsPaginator(client ListFileSystemAssociationsAPIClient, params *ListFileSystemAssociationsInput, optFns ...func(*ListFileSystemAssociationsPaginatorOptions)) *ListFileSystemAssociationsPaginator { 159 if params == nil { 160 params = &ListFileSystemAssociationsInput{} 161 } 162 163 options := ListFileSystemAssociationsPaginatorOptions{} 164 if params.Limit != nil { 165 options.Limit = *params.Limit 166 } 167 168 for _, fn := range optFns { 169 fn(&options) 170 } 171 172 return &ListFileSystemAssociationsPaginator{ 173 options: options, 174 client: client, 175 params: params, 176 firstPage: true, 177 } 178} 179 180// HasMorePages returns a boolean indicating whether more pages are available 181func (p *ListFileSystemAssociationsPaginator) HasMorePages() bool { 182 return p.firstPage || p.nextToken != nil 183} 184 185// NextPage retrieves the next ListFileSystemAssociations page. 186func (p *ListFileSystemAssociationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListFileSystemAssociationsOutput, error) { 187 if !p.HasMorePages() { 188 return nil, fmt.Errorf("no more pages available") 189 } 190 191 params := *p.params 192 params.Marker = p.nextToken 193 194 var limit *int32 195 if p.options.Limit > 0 { 196 limit = &p.options.Limit 197 } 198 params.Limit = limit 199 200 result, err := p.client.ListFileSystemAssociations(ctx, ¶ms, optFns...) 201 if err != nil { 202 return nil, err 203 } 204 p.firstPage = false 205 206 prevToken := p.nextToken 207 p.nextToken = result.NextMarker 208 209 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 210 p.nextToken = nil 211 } 212 213 return result, nil 214} 215 216func newServiceMetadataMiddleware_opListFileSystemAssociations(region string) *awsmiddleware.RegisterServiceMetadata { 217 return &awsmiddleware.RegisterServiceMetadata{ 218 Region: region, 219 ServiceID: ServiceID, 220 SigningName: "storagegateway", 221 OperationName: "ListFileSystemAssociations", 222 } 223} 224