ListBuckets list all buckets owned by this authenticated user. This call requires explicit authentication, no anonymous requests are allowed for listing buckets. api := client.New(....) for message := range api.ListBuckets(context.Background()) { fmt.Println(message) }
(ctx context.Context)
| 39 | // fmt.Println(message) |
| 40 | // } |
| 41 | func (c *Client) ListBuckets(ctx context.Context) ([]BucketInfo, error) { |
| 42 | // Execute GET on service. |
| 43 | resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{contentSHA256Hex: emptySHA256Hex}) |
| 44 | defer closeResponse(resp) |
| 45 | if err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | if resp != nil { |
| 49 | if resp.StatusCode != http.StatusOK { |
| 50 | return nil, httpRespToErrorResponse(resp, "", "") |
| 51 | } |
| 52 | } |
| 53 | listAllMyBucketsResult := listAllMyBucketsResult{} |
| 54 | err = xmlDecoder(resp.Body, &listAllMyBucketsResult) |
| 55 | if err != nil { |
| 56 | return nil, err |
| 57 | } |
| 58 | return listAllMyBucketsResult.Buckets.Bucket, nil |
| 59 | } |
| 60 | |
| 61 | // ListDirectoryBuckets list all buckets owned by this authenticated user. |
| 62 | // |
no test coverage detected