| 1 |
package accounts |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"net/http" |
| 6 |
|
| 7 |
"github.com/Azure/go-autorest/autorest" |
| 8 |
"github.com/Azure/go-autorest/autorest/azure" |
| 9 |
"github.com/Azure/go-autorest/autorest/validation" |
| 10 |
"github.com/tombuildsstuff/giovanni/storage/internal/endpoints" |
| 11 |
) |
| 12 |
|
| 13 |
type GetServicePropertiesResult struct { |
| 14 |
autorest.Response |
| 15 |
|
| 16 |
ContentType string |
| 17 |
StorageServiceProperties *StorageServiceProperties |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
func (client Client) GetServicePropertiesPreparer(ctx context.Context, accountName string) (*http.Request, error) { |
| 22 |
queryParameters := map[string]interface{}{ |
| 23 |
"restype": "service", |
| 24 |
"comp": "properties", |
| 25 |
} |
| 26 |
|
| 27 |
headers := map[string]interface{}{ |
| 28 |
"x-ms-version": APIVersion, |
| 29 |
} |
| 30 |
|
| 31 |
preparer := autorest.CreatePreparer( |
| 32 |
autorest.AsGet(), |
| 33 |
autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), |
| 34 |
autorest.WithHeaders(headers), |
| 35 |
autorest.WithQueryParameters(queryParameters)) |
| 36 |
return preparer.Prepare((&http.Request{}).WithContext(ctx)) |
| 37 |
} |
| 38 |
|
| 39 |
func (client Client) GetServicePropertiesSender(req *http.Request) (*http.Response, error) { |
| 40 |
return autorest.SendWithSender(client, req, |
| 41 |
azure.DoRetryWithRegistration(client.Client)) |
| 42 |
} |
| 43 |
|
| 44 |
func (client Client) GetServicePropertiesResponder(resp *http.Response) (result GetServicePropertiesResult, err error) { |
| 45 |
if resp != nil && resp.Header != nil { |
| 46 |
result.ContentType = resp.Header.Get("Content-Type") |
| 47 |
} |
| 48 |
|
| 49 |
err = autorest.Respond( |
| 50 |
resp, |
| 51 |
client.ByInspecting(), |
| 52 |
azure.WithErrorUnlessStatusCode(http.StatusOK), |
| 53 |
autorest.ByUnmarshallingXML(&result.StorageServiceProperties), |
| 54 |
autorest.ByClosing()) |
| 55 |
result.Response = autorest.Response{Response: resp} |
| 56 |
return |
| 57 |
} |
| 58 |
|
| 59 |
func (client Client) GetServiceProperties(ctx context.Context, accountName string) (result GetServicePropertiesResult, err error) { |
| 60 |
if accountName == "" { |
| 61 |
return result, validation.NewError("accounts.Client", "GetServiceProperties", "`accountName` cannot be an empty string.") |
| 62 |
} |
| 63 |
|
| 64 |
req, err := client.GetServicePropertiesPreparer(ctx, accountName) |
| 65 |
if err != nil { |
| 66 |
err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", nil, "Failure preparing request") |
| 67 |
return |
| 68 |
} |
| 69 |
|
| 70 |
resp, err := client.GetServicePropertiesSender(req) |
| 71 |
if err != nil { |
| 72 |
result.Response = autorest.Response{Response: resp} |
| 73 |
err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", resp, "Failure sending request") |
| 74 |
return |
| 75 |
} |
| 76 |
|
| 77 |
result, err = client.GetServicePropertiesResponder(resp) |
| 78 |
if err != nil { |
| 79 |
err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", resp, "Failure responding to request") |
| 80 |
return |
| 81 |
} |
| 82 |
|
| 83 |
return |
| 84 |
} |