| 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 | // SetServicePropertiesSender sends the SetServiceProperties request. The method will close the |
| 14 | // http.Response Body if it receives an error. |
| 15 | func (client Client) SetServicePropertiesSender(req *http.Request) (*http.Response, error) { |
| 16 | return autorest.SendWithSender(client, req, |
| 17 | azure.DoRetryWithRegistration(client.Client)) |
| 18 | } |
| 19 | |
| 20 | // SetServicePropertiesPreparer prepares the SetServiceProperties request. |
| 21 | func (client Client) SetServicePropertiesPreparer(ctx context.Context, accountName string, input StorageServiceProperties) (*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.AsPut(), |
| 33 | autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), |
| 34 | autorest.WithHeaders(headers), |
| 35 | autorest.WithXML(input), |
| 36 | autorest.WithQueryParameters(queryParameters)) |
| 37 | return preparer.Prepare((&http.Request{}).WithContext(ctx)) |
| 38 | } |
| 39 | |
| 40 | // SetServicePropertiesResponder handles the response to the SetServiceProperties request. The method always |
| 41 | // closes the http.Response Body. |
| 42 | func (client Client) SetServicePropertiesResponder(resp *http.Response) (result SetServicePropertiesResult, err error) { |
| 43 | err = autorest.Respond( |
| 44 | resp, |
| 45 | client.ByInspecting(), |
| 46 | azure.WithErrorUnlessStatusCode(http.StatusAccepted), |
| 47 | autorest.ByClosing()) |
| 48 | result.Response = autorest.Response{Response: resp} |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | func (client Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (result SetServicePropertiesResult, err error) { |
| 53 | if accountName == "" { |
| 54 | return result, validation.NewError("accounts.Client", "SetServiceProperties", "`accountName` cannot be an empty string.") |
| 55 | } |
| 56 | |
| 57 | req, err := client.SetServicePropertiesPreparer(ctx, accountName, input) |
| 58 | if err != nil { |
| 59 | err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", nil, "Failure preparing request") |
| 60 | return |
| 61 | } |
| 62 | |
| 63 | resp, err := client.SetServicePropertiesSender(req) |
| 64 | if err != nil { |
| 65 | result.Response = autorest.Response{Response: resp} |
| 66 | err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", resp, "Failure sending request") |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | result, err = client.SetServicePropertiesResponder(resp) |
| 71 | if err != nil { |
| 72 | err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", resp, "Failure responding to request") |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | return |
| 77 | } |