From 4c3dd2288369ac9cc72426a1ad112f0e1cb53288 Mon Sep 17 00:00:00 2001 From: Emily Gerner Date: Fri, 2 Oct 2015 16:35:45 -0700 Subject: [PATCH 1/2] SRP GA --- .../storage/StorageAccountOperations.java | 76 +++--- .../storage/StorageAccountOperationsImpl.java | 255 +++++++++++------- .../storage/StorageManagementClient.java | 7 +- .../storage/StorageManagementClientImpl.java | 98 ++++--- .../management/storage/UsageOperations.java | 57 ++++ .../storage/UsageOperationsImpl.java | 245 +++++++++++++++++ .../management/storage/models/Endpoints.java | 18 ++ .../storage/models/StorageAccount.java | 1 - .../StorageAccountCreateParameters.java | 1 - .../models/StorageAccountListResponse.java | 32 +-- .../StorageAccountUpdateParameters.java | 1 - .../management/storage/models/Usage.java | 105 ++++++++ .../storage/models/UsageListResponse.java | 69 +++++ .../management/storage/models/UsageName.java | 65 +++++ .../management/storage/models/UsageUnit.java | 59 ++++ 15 files changed, 872 insertions(+), 217 deletions(-) create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperations.java create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Usage.java create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageListResponse.java create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageName.java create mode 100644 resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageUnit.java diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperations.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperations.java index e03932d8573f..c1098a93b5d2 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperations.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperations.java @@ -24,7 +24,6 @@ package com.microsoft.azure.management.storage; import com.microsoft.azure.management.storage.models.CheckNameAvailabilityResponse; -import com.microsoft.azure.management.storage.models.KeyName; import com.microsoft.azure.management.storage.models.StorageAccountCreateParameters; import com.microsoft.azure.management.storage.models.StorageAccountCreateResponse; import com.microsoft.azure.management.storage.models.StorageAccountGetPropertiesResponse; @@ -35,7 +34,6 @@ import com.microsoft.azure.management.storage.models.StorageAccountUpdateResponse; import com.microsoft.windowsazure.core.OperationResponse; import com.microsoft.windowsazure.exception.ServiceException; - import java.io.IOException; import java.net.URISyntaxException; import java.util.concurrent.ExecutionException; @@ -53,7 +51,7 @@ public interface StorageAccountOperations { * properties, then HTTP 200 would be returned. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -77,7 +75,7 @@ public interface StorageAccountOperations { * properties, then HTTP 200 would be returned. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -117,10 +115,10 @@ public interface StorageAccountOperations { * instead use the Update Storage Account API. If an account is already * created and subsequent create request is issued with exact same set of * properties, the request succeeds.The max number of storage accounts that - * can be created per subscription is limited to 20. + * can be created per subscription is limited to 100. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -146,10 +144,10 @@ public interface StorageAccountOperations { * instead use the Update Storage Account API. If an account is already * created and subsequent create request is issued with exact same set of * properties, the request succeeds.The max number of storage accounts that - * can be created per subscription is limited to 20. + * can be created per subscription is limited to 100. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -163,7 +161,7 @@ public interface StorageAccountOperations { * Deletes a storage account in Microsoft Azure. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -180,7 +178,7 @@ public interface StorageAccountOperations { * Deletes a storage account in Microsoft Azure. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -195,7 +193,7 @@ public interface StorageAccountOperations { * ListKeys operation should be used to retrieve storage keys. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -215,7 +213,7 @@ public interface StorageAccountOperations { * ListKeys operation should be used to retrieve storage keys. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -251,7 +249,7 @@ public interface StorageAccountOperations { * this. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. @@ -268,7 +266,7 @@ public interface StorageAccountOperations { * this. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @return The list storage accounts operation response. */ Future listByResourceGroupAsync(String resourceGroupName); @@ -299,48 +297,51 @@ public interface StorageAccountOperations { * Regenerates the access keys for the specified storage account. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. * @param regenerateKey Required. Specifies name of the key which should be - * regenerated. + * regenerated. key1 or key2 for the default keys * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return The RegenerateKey operation response. */ - StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupName, String accountName, KeyName regenerateKey) throws IOException, ServiceException; + StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupName, String accountName, String regenerateKey) throws IOException, ServiceException; /** * Regenerates the access keys for the specified storage account. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. * @param regenerateKey Required. Specifies name of the key which should be - * regenerated. + * regenerated. key1 or key2 for the default keys * @return The RegenerateKey operation response. */ - Future regenerateKeyAsync(String resourceGroupName, String accountName, KeyName regenerateKey); + Future regenerateKeyAsync(String resourceGroupName, String accountName, String regenerateKey); /** * Updates the account type or tags for a storage account. It can also be * used to add a custom domain (note that custom domains cannot be added * via the Create operation). Only one custom domain is supported per - * storage account. This API can only be used to update one of tags, - * accountType, or customDomain per call. To update multiple of these - * properties, call the API multiple times with one change per call. This - * call does not change the storage keys for the account. If you want to - * change storage account keys, use the RegenerateKey operation. The - * location and name of the storage account cannot be changed after - * creation. + * storage account. In order to replace a custom domain, the old value must + * be cleared before a new value may be set. To clear a custom domain, + * simply update the custom domain with empty string. Then call update + * again with the new cutsom domain name. The update API can only be used + * to update one of tags, accountType, or customDomain per call. To update + * multiple of these properties, call the API multiple times with one + * change per call. This call does not change the storage keys for the + * account. If you want to change storage account keys, use the + * RegenerateKey operation. The location and name of the storage account + * cannot be changed after creation. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -360,16 +361,19 @@ public interface StorageAccountOperations { * Updates the account type or tags for a storage account. It can also be * used to add a custom domain (note that custom domains cannot be added * via the Create operation). Only one custom domain is supported per - * storage account. This API can only be used to update one of tags, - * accountType, or customDomain per call. To update multiple of these - * properties, call the API multiple times with one change per call. This - * call does not change the storage keys for the account. If you want to - * change storage account keys, use the RegenerateKey operation. The - * location and name of the storage account cannot be changed after - * creation. + * storage account. In order to replace a custom domain, the old value must + * be cleared before a new value may be set. To clear a custom domain, + * simply update the custom domain with empty string. Then call update + * again with the new cutsom domain name. The update API can only be used + * to update one of tags, accountType, or customDomain per call. To update + * multiple of these properties, call the API multiple times with one + * change per call. This call does not change the storage keys for the + * account. If you want to change storage account keys, use the + * RegenerateKey operation. The location and name of the storage account + * cannot be changed after creation. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java index 51d193419ca0..4e1689e9ee2d 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java @@ -28,7 +28,6 @@ import com.microsoft.azure.management.storage.models.CheckNameAvailabilityResponse; import com.microsoft.azure.management.storage.models.CustomDomain; import com.microsoft.azure.management.storage.models.Endpoints; -import com.microsoft.azure.management.storage.models.KeyName; import com.microsoft.azure.management.storage.models.ProvisioningState; import com.microsoft.azure.management.storage.models.Reason; import com.microsoft.azure.management.storage.models.StorageAccount; @@ -50,21 +49,6 @@ import com.microsoft.windowsazure.exception.ServiceException; import com.microsoft.windowsazure.tracing.ClientRequestTrackingHandler; import com.microsoft.windowsazure.tracing.CloudTracing; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.entity.StringEntity; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.node.ArrayNode; -import org.codehaus.jackson.node.NullNode; -import org.codehaus.jackson.node.ObjectNode; - -import javax.xml.bind.DatatypeConverter; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; @@ -80,6 +64,19 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import javax.xml.bind.DatatypeConverter; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPatch; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.entity.StringEntity; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.node.ArrayNode; +import org.codehaus.jackson.node.NullNode; +import org.codehaus.jackson.node.ObjectNode; /** * Operations for managing storage accounts. @@ -113,7 +110,7 @@ public StorageManagementClientImpl getClient() { * properties, then HTTP 200 would be returned. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -139,7 +136,7 @@ public StorageAccountCreateResponse call() throws Exception { * properties, then HTTP 200 would be returned. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -206,7 +203,7 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String url = url + "/providers/Microsoft.Storage/storageAccounts/"; url = url + URLEncoder.encode(accountName, "UTF-8"); ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -288,9 +285,8 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountCreateResponse(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -377,6 +373,13 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue2.get("primaryLocation"); @@ -466,6 +469,13 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } @@ -475,8 +485,8 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String if (httpResponse.getHeaders("Location").length > 0) { result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue()); } - if (httpResponse.getHeaders("RetryAfter").length > 0) { - result.setRetryAfter(DatatypeConverter.parseInt(httpResponse.getFirstHeader("RetryAfter").getValue())); + if (httpResponse.getHeaders("Retry-After").length > 0) { + result.setRetryAfter(DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue())); } if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); @@ -554,7 +564,7 @@ public CheckNameAvailabilityResponse checkNameAvailability(String accountName) t } url = url + "/providers/Microsoft.Storage/checkNameAvailability"; ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -621,9 +631,8 @@ public CheckNameAvailabilityResponse checkNameAvailability(String accountName) t InputStream responseContent = httpResponse.getEntity().getContent(); result = new CheckNameAvailabilityResponse(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -672,10 +681,10 @@ public CheckNameAvailabilityResponse checkNameAvailability(String accountName) t * instead use the Update Storage Account API. If an account is already * created and subsequent create request is issued with exact same set of * properties, the request succeeds.The max number of storage accounts that - * can be created per subscription is limited to 20. + * can be created per subscription is limited to 100. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -699,10 +708,10 @@ public StorageAccountCreateResponse call() throws Exception { * instead use the Update Storage Account API. If an account is already * created and subsequent create request is issued with exact same set of * properties, the request succeeds.The max number of storage accounts that - * can be created per subscription is limited to 20. + * can be created per subscription is limited to 100. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -739,7 +748,7 @@ public StorageAccountCreateResponse create(String resourceGroupName, String acco } StorageAccountCreateResponse response = client2.getStorageAccountsOperations().beginCreateAsync(resourceGroupName, accountName, parameters).get(); - if (response.getStatus() == OperationStatus.Succeeded) { + if (response.getStatus() == OperationStatus.SUCCEEDED) { return response; } StorageAccountCreateResponse result = client2.getCreateOperationStatusAsync(response.getOperationStatusLink()).get(); @@ -750,7 +759,7 @@ public StorageAccountCreateResponse create(String resourceGroupName, String acco if (client2.getLongRunningOperationInitialTimeout() >= 0) { delayInSeconds = client2.getLongRunningOperationInitialTimeout(); } - while (result.getStatus() != null && result.getStatus().equals(OperationStatus.InProgress)) { + while (result.getStatus() != null && result.getStatus().equals(OperationStatus.INPROGRESS)) { Thread.sleep(delayInSeconds * 1000); result = client2.getCreateOperationStatusAsync(response.getOperationStatusLink()).get(); delayInSeconds = result.getRetryAfter(); @@ -778,7 +787,7 @@ public StorageAccountCreateResponse create(String resourceGroupName, String acco * Deletes a storage account in Microsoft Azure. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -799,7 +808,7 @@ public OperationResponse call() throws Exception { * Deletes a storage account in Microsoft Azure. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -853,7 +862,7 @@ public OperationResponse delete(String resourceGroupName, String accountName) th url = url + "/providers/Microsoft.Storage/storageAccounts/"; url = url + URLEncoder.encode(accountName, "UTF-8"); ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -919,7 +928,7 @@ public OperationResponse delete(String resourceGroupName, String accountName) th * ListKeys operation should be used to retrieve storage keys. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -941,7 +950,7 @@ public StorageAccountGetPropertiesResponse call() throws Exception { * ListKeys operation should be used to retrieve storage keys. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -996,7 +1005,7 @@ public StorageAccountGetPropertiesResponse getProperties(String resourceGroupNam url = url + "/providers/Microsoft.Storage/storageAccounts/"; url = url + URLEncoder.encode(accountName, "UTF-8"); ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -1044,9 +1053,8 @@ public StorageAccountGetPropertiesResponse getProperties(String resourceGroupNam result = new StorageAccountGetPropertiesResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -1133,6 +1141,13 @@ public StorageAccountGetPropertiesResponse getProperties(String resourceGroupNam tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue.get("primaryLocation"); @@ -1222,6 +1237,13 @@ public StorageAccountGetPropertiesResponse getProperties(String resourceGroupNam tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } @@ -1292,7 +1314,7 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U } url = url + "/providers/Microsoft.Storage/storageAccounts"; ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -1340,9 +1362,8 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U result = new StorageAccountListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -1432,6 +1453,13 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue.get("primaryLocation"); @@ -1521,17 +1549,17 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } } - - JsonNode nextLinkValue = responseDoc.get("nextLink"); - if (nextLinkValue != null && nextLinkValue instanceof NullNode == false) { - String nextLinkInstance; - nextLinkInstance = nextLinkValue.getTextValue(); - result.setNextLink(nextLinkInstance); - } } } @@ -1557,7 +1585,7 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U * this. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @return The list storage accounts operation response. */ @Override @@ -1576,7 +1604,7 @@ public StorageAccountListResponse call() throws Exception { * this. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. @@ -1612,7 +1640,7 @@ public StorageAccountListResponse listByResourceGroup(String resourceGroupName) url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/Microsoft.Storage/storageAccounts"; ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -1660,9 +1688,8 @@ public StorageAccountListResponse listByResourceGroup(String resourceGroupName) result = new StorageAccountListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -1752,6 +1779,13 @@ public StorageAccountListResponse listByResourceGroup(String resourceGroupName) tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue.get("primaryLocation"); @@ -1841,17 +1875,17 @@ public StorageAccountListResponse listByResourceGroup(String resourceGroupName) tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } } - - JsonNode nextLinkValue = responseDoc.get("nextLink"); - if (nextLinkValue != null && nextLinkValue instanceof NullNode == false) { - String nextLinkInstance; - nextLinkInstance = nextLinkValue.getTextValue(); - result.setNextLink(nextLinkInstance); - } } } @@ -1943,7 +1977,7 @@ public StorageAccountListKeysResponse listKeys(String resourceGroupName, String url = url + URLEncoder.encode(accountName, "UTF-8"); url = url + "/listKeys"; ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -1991,9 +2025,8 @@ public StorageAccountListKeysResponse listKeys(String resourceGroupName, String result = new StorageAccountListKeysResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2036,16 +2069,16 @@ public StorageAccountListKeysResponse listKeys(String resourceGroupName, String * Regenerates the access keys for the specified storage account. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. * @param regenerateKey Required. Specifies name of the key which should be - * regenerated. + * regenerated. key1 or key2 for the default keys * @return The RegenerateKey operation response. */ @Override - public Future regenerateKeyAsync(final String resourceGroupName, final String accountName, final KeyName regenerateKey) { + public Future regenerateKeyAsync(final String resourceGroupName, final String accountName, final String regenerateKey) { return this.getClient().getExecutorService().submit(new Callable() { @Override public StorageAccountRegenerateKeyResponse call() throws Exception { @@ -2058,12 +2091,12 @@ public StorageAccountRegenerateKeyResponse call() throws Exception { * Regenerates the access keys for the specified storage account. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. * @param regenerateKey Required. Specifies name of the key which should be - * regenerated. + * regenerated. key1 or key2 for the default keys * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. @@ -2071,7 +2104,7 @@ public StorageAccountRegenerateKeyResponse call() throws Exception { * @return The RegenerateKey operation response. */ @Override - public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupName, String accountName, KeyName regenerateKey) throws IOException, ServiceException { + public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupName, String accountName, String regenerateKey) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); @@ -2118,7 +2151,7 @@ public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupNam url = url + URLEncoder.encode(accountName, "UTF-8"); url = url + "/regenerateKey"; ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -2148,7 +2181,7 @@ public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupNam ObjectNode storageAccountRegenerateKeyParametersValue = objectMapper.createObjectNode(); requestDoc = storageAccountRegenerateKeyParametersValue; - ((ObjectNode) storageAccountRegenerateKeyParametersValue).put("keyName", StorageManagementClientImpl.keyNameToString(regenerateKey)); + ((ObjectNode) storageAccountRegenerateKeyParametersValue).put("keyName", regenerateKey); StringWriter stringWriter = new StringWriter(); objectMapper.writeValue(stringWriter, requestDoc); @@ -2183,9 +2216,8 @@ public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupNam InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountRegenerateKeyResponse(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2228,16 +2260,19 @@ public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupNam * Updates the account type or tags for a storage account. It can also be * used to add a custom domain (note that custom domains cannot be added * via the Create operation). Only one custom domain is supported per - * storage account. This API can only be used to update one of tags, - * accountType, or customDomain per call. To update multiple of these - * properties, call the API multiple times with one change per call. This - * call does not change the storage keys for the account. If you want to - * change storage account keys, use the RegenerateKey operation. The - * location and name of the storage account cannot be changed after - * creation. + * storage account. In order to replace a custom domain, the old value must + * be cleared before a new value may be set. To clear a custom domain, + * simply update the custom domain with empty string. Then call update + * again with the new cutsom domain name. The update API can only be used + * to update one of tags, accountType, or customDomain per call. To update + * multiple of these properties, call the API multiple times with one + * change per call. This call does not change the storage keys for the + * account. If you want to change storage account keys, use the + * RegenerateKey operation. The location and name of the storage account + * cannot be changed after creation. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -2259,16 +2294,19 @@ public StorageAccountUpdateResponse call() throws Exception { * Updates the account type or tags for a storage account. It can also be * used to add a custom domain (note that custom domains cannot be added * via the Create operation). Only one custom domain is supported per - * storage account. This API can only be used to update one of tags, - * accountType, or customDomain per call. To update multiple of these - * properties, call the API multiple times with one change per call. This - * call does not change the storage keys for the account. If you want to - * change storage account keys, use the RegenerateKey operation. The - * location and name of the storage account cannot be changed after - * creation. + * storage account. In order to replace a custom domain, the old value must + * be cleared before a new value may be set. To clear a custom domain, + * simply update the custom domain with empty string. Then call update + * again with the new cutsom domain name. The update API can only be used + * to update one of tags, accountType, or customDomain per call. To update + * multiple of these properties, call the API multiple times with one + * change per call. This call does not change the storage keys for the + * account. If you want to change storage account keys, use the + * RegenerateKey operation. The location and name of the storage account + * cannot be changed after creation. * * @param resourceGroupName Required. The name of the resource group within - * the user’s subscription. + * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. @@ -2334,7 +2372,7 @@ public StorageAccountUpdateResponse update(String resourceGroupName, String acco url = url + "/providers/Microsoft.Storage/storageAccounts/"; url = url + URLEncoder.encode(accountName, "UTF-8"); ArrayList queryParameters = new ArrayList(); - queryParameters.add("api-version=" + "2015-05-01-preview"); + queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } @@ -2427,9 +2465,8 @@ public StorageAccountUpdateResponse update(String resourceGroupName, String acco InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountUpdateResponse(); JsonNode responseDoc = null; - String responseDocContent = IOUtils.toString(responseContent); - if (responseDocContent == null == false && responseDocContent.length() > 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2516,6 +2553,13 @@ public StorageAccountUpdateResponse update(String resourceGroupName, String acco tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue2.get("primaryLocation"); @@ -2605,6 +2649,13 @@ public StorageAccountUpdateResponse update(String resourceGroupName, String acco tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClient.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClient.java index d6db3b2b3b01..f8cbeea2ba5c 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClient.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClient.java @@ -27,7 +27,6 @@ import com.microsoft.windowsazure.core.FilterableService; import com.microsoft.windowsazure.credentials.SubscriptionCloudCredentials; import com.microsoft.windowsazure.exception.ServiceException; - import java.io.Closeable; import java.io.IOException; import java.net.URI; @@ -88,6 +87,12 @@ public interface StorageManagementClient extends Closeable, FilterableService 0) { - responseDoc = objectMapper.readTree(responseDocContent); + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -507,6 +482,13 @@ public StorageAccountCreateResponse getCreateOperationStatus(String operationSta tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } + + JsonNode fileValue = primaryEndpointsValue.get("file"); + if (fileValue != null && fileValue instanceof NullNode == false) { + URI fileInstance; + fileInstance = new URI(fileValue.getTextValue()); + primaryEndpointsInstance.setFile(fileInstance); + } } JsonNode primaryLocationValue = propertiesValue.get("primaryLocation"); @@ -596,14 +578,24 @@ public StorageAccountCreateResponse getCreateOperationStatus(String operationSta tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } + + JsonNode fileValue2 = secondaryEndpointsValue.get("file"); + if (fileValue2 != null && fileValue2 instanceof NullNode == false) { + URI fileInstance2; + fileInstance2 = new URI(fileValue2.getTextValue()); + secondaryEndpointsInstance.setFile(fileInstance2); + } } } } } result.setStatusCode(statusCode); - if (httpResponse.getHeaders("RetryAfter").length > 0) { - result.setRetryAfter(DatatypeConverter.parseInt(httpResponse.getFirstHeader("RetryAfter").getValue())); + if (httpResponse.getHeaders("Location").length > 0) { + result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue()); + } + if (httpResponse.getHeaders("Retry-After").length > 0) { + result.setRetryAfter(DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue())); } if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); @@ -611,10 +603,10 @@ public StorageAccountCreateResponse getCreateOperationStatus(String operationSta if (statusCode == HttpStatus.SC_CONFLICT) { result.setStatus(OperationStatus.Failed); } - if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) { + if (statusCode == HttpStatus.SC_ACCEPTED) { result.setStatus(OperationStatus.InProgress); } - if (statusCode == HttpStatus.SC_ACCEPTED) { + if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) { result.setStatus(OperationStatus.InProgress); } if (statusCode == HttpStatus.SC_OK) { diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperations.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperations.java new file mode 100644 index 000000000000..3b40af02fb91 --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperations.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage; + +import com.microsoft.azure.management.storage.models.UsageListResponse; +import com.microsoft.windowsazure.exception.ServiceException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.concurrent.Future; + +/** +* Operations for listing usage. +*/ +public interface UsageOperations { + /** + * Gets the current usage count and the limit for the resources under the + * subscription. + * + * @throws IOException Signals that an I/O exception of some sort has + * occurred. This class is the general class of exceptions produced by + * failed or interrupted I/O operations. + * @throws ServiceException Thrown if an unexpected response is found. + * @throws URISyntaxException Thrown if there was an error parsing a URI in + * the response. + * @return The List Usages operation response. + */ + UsageListResponse list() throws IOException, ServiceException, URISyntaxException; + + /** + * Gets the current usage count and the limit for the resources under the + * subscription. + * + * @return The List Usages operation response. + */ + Future listAsync(); +} diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java new file mode 100644 index 000000000000..a0c2479da0a5 --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java @@ -0,0 +1,245 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage; + +import com.microsoft.azure.management.storage.models.Usage; +import com.microsoft.azure.management.storage.models.UsageListResponse; +import com.microsoft.azure.management.storage.models.UsageName; +import com.microsoft.azure.management.storage.models.UsageUnit; +import com.microsoft.windowsazure.core.ServiceOperations; +import com.microsoft.windowsazure.core.utils.CollectionStringBuilder; +import com.microsoft.windowsazure.exception.ServiceException; +import com.microsoft.windowsazure.tracing.CloudTracing; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.node.ArrayNode; +import org.codehaus.jackson.node.NullNode; + +/** +* Operations for listing usage. +*/ +public class UsageOperationsImpl implements ServiceOperations, UsageOperations { + /** + * Initializes a new instance of the UsageOperationsImpl class. + * + * @param client Reference to the service client. + */ + UsageOperationsImpl(StorageManagementClientImpl client) { + this.client = client; + } + + private StorageManagementClientImpl client; + + /** + * Gets a reference to the + * microsoft.azure.management.storage.StorageManagementClientImpl. + * @return The Client value. + */ + public StorageManagementClientImpl getClient() { + return this.client; + } + + /** + * Gets the current usage count and the limit for the resources under the + * subscription. + * + * @return The List Usages operation response. + */ + @Override + public Future listAsync() { + return this.getClient().getExecutorService().submit(new Callable() { + @Override + public UsageListResponse call() throws Exception { + return list(); + } + }); + } + + /** + * Gets the current usage count and the limit for the resources under the + * subscription. + * + * @throws IOException Signals that an I/O exception of some sort has + * occurred. This class is the general class of exceptions produced by + * failed or interrupted I/O operations. + * @throws ServiceException Thrown if an unexpected response is found. + * @throws URISyntaxException Thrown if there was an error parsing a URI in + * the response. + * @return The List Usages operation response. + */ + @Override + public UsageListResponse list() throws IOException, ServiceException, URISyntaxException { + // Validate + + // Tracing + boolean shouldTrace = CloudTracing.getIsEnabled(); + String invocationId = null; + if (shouldTrace) { + invocationId = Long.toString(CloudTracing.getNextInvocationId()); + HashMap tracingParameters = new HashMap(); + CloudTracing.enter(invocationId, this, "listAsync", tracingParameters); + } + + // Construct URL + String url = ""; + url = url + "/subscriptions/"; + if (this.getClient().getCredentials().getSubscriptionId() != null) { + url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); + } + url = url + "/providers/Microsoft.Storage/usages"; + ArrayList queryParameters = new ArrayList(); + if (this.getClient().getApiVersion() != null) { + queryParameters.add("api-version=" + URLEncoder.encode(this.getClient().getApiVersion(), "UTF-8")); + } + if (queryParameters.size() > 0) { + url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); + } + String baseUrl = this.getClient().getBaseUri().toString(); + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl.charAt(baseUrl.length() - 1) == '/') { + baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); + } + if (url.charAt(0) == '/') { + url = url.substring(1); + } + url = baseUrl + "/" + url; + url = url.replace(" ", "%20"); + + // Create HTTP transport objects + HttpGet httpRequest = new HttpGet(url); + + // Set Headers + httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString()); + + // Send Request + HttpResponse httpResponse = null; + try { + if (shouldTrace) { + CloudTracing.sendRequest(invocationId, httpRequest); + } + httpResponse = this.getClient().getHttpClient().execute(httpRequest); + if (shouldTrace) { + CloudTracing.receiveResponse(invocationId, httpResponse); + } + int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode != HttpStatus.SC_OK) { + ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); + if (shouldTrace) { + CloudTracing.error(invocationId, ex); + } + throw ex; + } + + // Create Result + UsageListResponse result = null; + // Deserialize Response + if (statusCode == HttpStatus.SC_OK) { + InputStream responseContent = httpResponse.getEntity().getContent(); + result = new UsageListResponse(); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode responseDoc = null; + if (responseContent == null == false) { + responseDoc = objectMapper.readTree(responseContent); + } + + if (responseDoc != null && responseDoc instanceof NullNode == false) { + JsonNode valueArray = responseDoc.get("value"); + if (valueArray != null && valueArray instanceof NullNode == false) { + for (JsonNode valueValue : ((ArrayNode) valueArray)) { + Usage usageInstance = new Usage(); + result.getUsages().add(usageInstance); + + JsonNode unitValue = valueValue.get("unit"); + if (unitValue != null && unitValue instanceof NullNode == false) { + UsageUnit unitInstance; + unitInstance = Enum.valueOf(UsageUnit.class, unitValue.getTextValue()); + usageInstance.setUnit(unitInstance); + } + + JsonNode currentValueValue = valueValue.get("currentValue"); + if (currentValueValue != null && currentValueValue instanceof NullNode == false) { + int currentValueInstance; + currentValueInstance = currentValueValue.getIntValue(); + usageInstance.setCurrentValue(currentValueInstance); + } + + JsonNode limitValue = valueValue.get("limit"); + if (limitValue != null && limitValue instanceof NullNode == false) { + int limitInstance; + limitInstance = limitValue.getIntValue(); + usageInstance.setLimit(limitInstance); + } + + JsonNode nameValue = valueValue.get("name"); + if (nameValue != null && nameValue instanceof NullNode == false) { + UsageName nameInstance = new UsageName(); + usageInstance.setName(nameInstance); + + JsonNode valueValue2 = nameValue.get("value"); + if (valueValue2 != null && valueValue2 instanceof NullNode == false) { + String valueInstance; + valueInstance = valueValue2.getTextValue(); + nameInstance.setValue(valueInstance); + } + + JsonNode localizedValueValue = nameValue.get("localizedValue"); + if (localizedValueValue != null && localizedValueValue instanceof NullNode == false) { + String localizedValueInstance; + localizedValueInstance = localizedValueValue.getTextValue(); + nameInstance.setLocalizedValue(localizedValueInstance); + } + } + } + } + } + + } + result.setStatusCode(statusCode); + if (httpResponse.getHeaders("x-ms-request-id").length > 0) { + result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); + } + + if (shouldTrace) { + CloudTracing.exit(invocationId, result); + } + return result; + } finally { + if (httpResponse != null && httpResponse.getEntity() != null) { + httpResponse.getEntity().getContent().close(); + } + } + } +} diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Endpoints.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Endpoints.java index c43f927389f7..893f136e03a0 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Endpoints.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Endpoints.java @@ -48,6 +48,24 @@ public void setBlob(final URI blobValue) { this.blob = blobValue; } + private URI file; + + /** + * Optional. Gets the file endpoint. + * @return The File value. + */ + public URI getFile() { + return this.file; + } + + /** + * Optional. Gets the file endpoint. + * @param fileValue The File value. + */ + public void setFile(final URI fileValue) { + this.file = fileValue; + } + private URI queue; /** diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccount.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccount.java index 39701dd8a492..21b75f3c757d 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccount.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccount.java @@ -24,7 +24,6 @@ package com.microsoft.azure.management.storage.models; import com.microsoft.windowsazure.core.ResourceBaseExtended; - import java.util.Calendar; /** diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountCreateParameters.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountCreateParameters.java index 6b269e9400c4..50f483a96dd4 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountCreateParameters.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountCreateParameters.java @@ -24,7 +24,6 @@ package com.microsoft.azure.management.storage.models; import com.microsoft.windowsazure.core.LazyHashMap; - import java.util.HashMap; /** diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountListResponse.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountListResponse.java index f0124d323efe..9e5ce932e31b 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountListResponse.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountListResponse.java @@ -25,33 +25,13 @@ import com.microsoft.windowsazure.core.LazyArrayList; import com.microsoft.windowsazure.core.OperationResponse; - import java.util.ArrayList; +import java.util.Iterator; /** * The list storage accounts operation response. */ -public class StorageAccountListResponse extends OperationResponse { - private String nextLink; - - /** - * Optional. Gets the link to the next set of results. Currently this will - * always be empty as the API does not support pagination. - * @return The NextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * Optional. Gets the link to the next set of results. Currently this will - * always be empty as the API does not support pagination. - * @param nextLinkValue The NextLink value. - */ - public void setNextLink(final String nextLinkValue) { - this.nextLink = nextLinkValue; - } - +public class StorageAccountListResponse extends OperationResponse implements Iterable { private ArrayList storageAccounts; /** @@ -78,4 +58,12 @@ public StorageAccountListResponse() { super(); this.setStorageAccounts(new LazyArrayList()); } + + /** + * Gets the sequence of StorageAccounts. + * + */ + public Iterator iterator() { + return this.getStorageAccounts().iterator(); + } } diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountUpdateParameters.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountUpdateParameters.java index a87259bece88..b399b99e8cbf 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountUpdateParameters.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/StorageAccountUpdateParameters.java @@ -24,7 +24,6 @@ package com.microsoft.azure.management.storage.models; import com.microsoft.windowsazure.core.LazyHashMap; - import java.util.HashMap; /** diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Usage.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Usage.java new file mode 100644 index 000000000000..42ccb792504c --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/Usage.java @@ -0,0 +1,105 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage.models; + +/** +* Describes Storage Resource Usage. +*/ +public class Usage { + private int currentValue; + + /** + * Required. Gets the current count of the allocated resources in the + * subscription. + * @return The CurrentValue value. + */ + public int getCurrentValue() { + return this.currentValue; + } + + /** + * Required. Gets the current count of the allocated resources in the + * subscription. + * @param currentValueValue The CurrentValue value. + */ + public void setCurrentValue(final int currentValueValue) { + this.currentValue = currentValueValue; + } + + private int limit; + + /** + * Required. Gets the maximum count of the resources that can be allocated + * in the subscription. + * @return The Limit value. + */ + public int getLimit() { + return this.limit; + } + + /** + * Required. Gets the maximum count of the resources that can be allocated + * in the subscription. + * @param limitValue The Limit value. + */ + public void setLimit(final int limitValue) { + this.limit = limitValue; + } + + private UsageName name; + + /** + * Required. Gets the name of the type of usage. + * @return The Name value. + */ + public UsageName getName() { + return this.name; + } + + /** + * Required. Gets the name of the type of usage. + * @param nameValue The Name value. + */ + public void setName(final UsageName nameValue) { + this.name = nameValue; + } + + private UsageUnit unit; + + /** + * Required. Gets the unit of measurement. + * @return The Unit value. + */ + public UsageUnit getUnit() { + return this.unit; + } + + /** + * Required. Gets the unit of measurement. + * @param unitValue The Unit value. + */ + public void setUnit(final UsageUnit unitValue) { + this.unit = unitValue; + } +} diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageListResponse.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageListResponse.java new file mode 100644 index 000000000000..21cf1b6ce778 --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageListResponse.java @@ -0,0 +1,69 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage.models; + +import com.microsoft.windowsazure.core.LazyArrayList; +import com.microsoft.windowsazure.core.OperationResponse; +import java.util.ArrayList; +import java.util.Iterator; + +/** +* The List Usages operation response. +*/ +public class UsageListResponse extends OperationResponse implements Iterable { + private ArrayList usages; + + /** + * Optional. Gets or sets the list Storage Resource Usages. + * @return The Usages value. + */ + public ArrayList getUsages() { + return this.usages; + } + + /** + * Optional. Gets or sets the list Storage Resource Usages. + * @param usagesValue The Usages value. + */ + public void setUsages(final ArrayList usagesValue) { + this.usages = usagesValue; + } + + /** + * Initializes a new instance of the UsageListResponse class. + * + */ + public UsageListResponse() { + super(); + this.setUsages(new LazyArrayList()); + } + + /** + * Gets the sequence of Usages. + * + */ + public Iterator iterator() { + return this.getUsages().iterator(); + } +} diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageName.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageName.java new file mode 100644 index 000000000000..37e8910f7047 --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageName.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage.models; + +/** +* The Usage Names. +*/ +public class UsageName { + private String localizedValue; + + /** + * Optional. Gets a localized string describing the resource name. + * @return The LocalizedValue value. + */ + public String getLocalizedValue() { + return this.localizedValue; + } + + /** + * Optional. Gets a localized string describing the resource name. + * @param localizedValueValue The LocalizedValue value. + */ + public void setLocalizedValue(final String localizedValueValue) { + this.localizedValue = localizedValueValue; + } + + private String value; + + /** + * Optional. Gets a string describing the resource name. + * @return The Value value. + */ + public String getValue() { + return this.value; + } + + /** + * Optional. Gets a string describing the resource name. + * @param valueValue The Value value. + */ + public void setValue(final String valueValue) { + this.value = valueValue; + } +} diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageUnit.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageUnit.java new file mode 100644 index 000000000000..03c65adfdf90 --- /dev/null +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/models/UsageUnit.java @@ -0,0 +1,59 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +package com.microsoft.azure.management.storage.models; + +/** +* The usage unit. +*/ +public enum UsageUnit { + /** + * The count usage unit. + */ + Count, + + /** + * The bytes usage unit. + */ + Bytes, + + /** + * The seconds usage unit. + */ + Seconds, + + /** + * The percent usage unit. + */ + Percent, + + /** + * The counts per second usage unit. + */ + CountsPerSecond, + + /** + * The bytes per second usage unit. + */ + BytesPerSecond, +} From bc1b0cc3519f1d66deda5db9bfaf12bf717d34ce Mon Sep 17 00:00:00 2001 From: Emily Gerner Date: Mon, 5 Oct 2015 10:16:46 -0700 Subject: [PATCH 2/2] SRP GA utility and samples fixes --- .../storage/StorageAccountExample.java | 19 ++------ .../storage/StorageAccountOperationsImpl.java | 45 +++++++++++-------- .../storage/StorageManagementClientImpl.java | 6 ++- .../storage/UsageOperationsImpl.java | 6 ++- .../azure/utility/StorageHelper.java | 5 +-- 5 files changed, 41 insertions(+), 40 deletions(-) diff --git a/azure-mgmt-samples/src/main/java/com/microsoft/azure/samples/storage/StorageAccountExample.java b/azure-mgmt-samples/src/main/java/com/microsoft/azure/samples/storage/StorageAccountExample.java index 83e800647cd9..9209cb9208db 100644 --- a/azure-mgmt-samples/src/main/java/com/microsoft/azure/samples/storage/StorageAccountExample.java +++ b/azure-mgmt-samples/src/main/java/com/microsoft/azure/samples/storage/StorageAccountExample.java @@ -19,7 +19,6 @@ import com.microsoft.azure.management.storage.StorageManagementClient; import com.microsoft.azure.management.storage.StorageManagementService; import com.microsoft.azure.management.storage.models.AccountType; -import com.microsoft.azure.management.storage.models.KeyName; import com.microsoft.azure.management.storage.models.StorageAccount; import com.microsoft.azure.management.storage.models.StorageAccountCreateParameters; import com.microsoft.azure.management.storage.models.StorageAccountKeys; @@ -130,17 +129,7 @@ public static void main(String[] args) throws Exception { if (args.length != 4) { result = -1; } else { - KeyName keyName = null; - if (args[3].toLowerCase().equals("primary")) { - keyName = KeyName.Key1; - } else if (args[3].toLowerCase().equals("secondary")) { - keyName = KeyName.Key2; - } - if (keyName == null) { - result = -1; - } else { - result = regenerateStorageAccountKey(storageManagementClient, args[1], args[2], keyName); - } + result = regenerateStorageAccountKey(storageManagementClient, args[1], args[2], args[3]); } } else if(args[0].equals("listAccounts")) { if (args.length > 2) { @@ -330,7 +319,7 @@ private static int retrieveStorageAccount(StorageManagementClient client, */ private static int regenerateStorageAccountKey(StorageManagementClient client, String resourceGroup, String accountName, - KeyName keyName) + String keyName) throws Exception { ResourceContext context = new ResourceContext(null, resourceGroup, getPropertyElseEnvironment(ManagementConfiguration.SUBSCRIPTION_ID), @@ -339,9 +328,9 @@ private static int regenerateStorageAccountKey(StorageManagementClient client, StorageAccountRegenerateKeyResponse response = StorageHelper.regenerateStorageAccountKey(client, context, keyName); if(response != null) { - System.out.println("Key " + (keyName == KeyName.Key1 ? "Primary" : "Secondary") + " regenerated."); + System.out.println("Key " + keyName + " regenerated."); StorageAccountKeys keys = response.getStorageAccountKeys(); - System.out.println("Key Value: " + (keyName == KeyName.Key1 ? keys.getKey1() : keys.getKey2())); + System.out.println("Key Value: " + (keyName.equals("key1") ? keys.getKey1() : keys.getKey2())); } return (response == null ? 1 : 0); diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java index 4e1689e9ee2d..a452e89888b2 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccountOperationsImpl.java @@ -65,6 +65,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import javax.xml.bind.DatatypeConverter; +import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; @@ -285,8 +286,9 @@ public StorageAccountCreateResponse beginCreate(String resourceGroupName, String InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountCreateResponse(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -631,8 +633,9 @@ public CheckNameAvailabilityResponse checkNameAvailability(String accountName) t InputStream responseContent = httpResponse.getEntity().getContent(); result = new CheckNameAvailabilityResponse(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -748,7 +751,7 @@ public StorageAccountCreateResponse create(String resourceGroupName, String acco } StorageAccountCreateResponse response = client2.getStorageAccountsOperations().beginCreateAsync(resourceGroupName, accountName, parameters).get(); - if (response.getStatus() == OperationStatus.SUCCEEDED) { + if (response.getStatus() == OperationStatus.Succeeded) { return response; } StorageAccountCreateResponse result = client2.getCreateOperationStatusAsync(response.getOperationStatusLink()).get(); @@ -759,7 +762,7 @@ public StorageAccountCreateResponse create(String resourceGroupName, String acco if (client2.getLongRunningOperationInitialTimeout() >= 0) { delayInSeconds = client2.getLongRunningOperationInitialTimeout(); } - while (result.getStatus() != null && result.getStatus().equals(OperationStatus.INPROGRESS)) { + while (result.getStatus() != null && result.getStatus().equals(OperationStatus.InProgress)) { Thread.sleep(delayInSeconds * 1000); result = client2.getCreateOperationStatusAsync(response.getOperationStatusLink()).get(); delayInSeconds = result.getRetryAfter(); @@ -1053,8 +1056,9 @@ public StorageAccountGetPropertiesResponse getProperties(String resourceGroupNam result = new StorageAccountGetPropertiesResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -1362,8 +1366,9 @@ public StorageAccountListResponse list() throws IOException, ServiceException, U result = new StorageAccountListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -1688,8 +1693,9 @@ public StorageAccountListResponse listByResourceGroup(String resourceGroupName) result = new StorageAccountListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2025,8 +2031,9 @@ public StorageAccountListKeysResponse listKeys(String resourceGroupName, String result = new StorageAccountListKeysResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2216,8 +2223,9 @@ public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupNam InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountRegenerateKeyResponse(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { @@ -2465,8 +2473,9 @@ public StorageAccountUpdateResponse update(String resourceGroupName, String acco InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountUpdateResponse(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClientImpl.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClientImpl.java index 4576ef6d9a15..b74d46157c93 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClientImpl.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageManagementClientImpl.java @@ -51,6 +51,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.xml.bind.DatatypeConverter; +import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; @@ -394,8 +395,9 @@ public StorageAccountCreateResponse getCreateOperationStatus(String operationSta result = new StorageAccountCreateResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { diff --git a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java index a0c2479da0a5..d576f948470a 100644 --- a/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java +++ b/resource-management/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/UsageOperationsImpl.java @@ -40,6 +40,7 @@ import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future; +import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; @@ -171,8 +172,9 @@ public UsageListResponse list() throws IOException, ServiceException, URISyntaxE result = new UsageListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; - if (responseContent == null == false) { - responseDoc = objectMapper.readTree(responseContent); + String responseDocContent = IOUtils.toString(responseContent); + if (responseDocContent == null == false && responseDocContent.length() > 0) { + responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { diff --git a/resource-management/azure-mgmt-utility/src/main/java/com/microsoft/azure/utility/StorageHelper.java b/resource-management/azure-mgmt-utility/src/main/java/com/microsoft/azure/utility/StorageHelper.java index 35beca0b32ea..69f68b5c9e59 100644 --- a/resource-management/azure-mgmt-utility/src/main/java/com/microsoft/azure/utility/StorageHelper.java +++ b/resource-management/azure-mgmt-utility/src/main/java/com/microsoft/azure/utility/StorageHelper.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.storage.StorageManagementClient; import com.microsoft.azure.management.storage.models.AccountType; -import com.microsoft.azure.management.storage.models.KeyName; import com.microsoft.azure.management.storage.models.StorageAccount; import com.microsoft.azure.management.storage.models.StorageAccountCreateParameters; import com.microsoft.azure.management.storage.models.StorageAccountListResponse; @@ -203,12 +202,12 @@ public static List listStorageAccounts( * * @param storageManagementClient the storage management client object on which operations are performed * @param context information necessary for creating the storage account - * @param keyName storage account specific parameters + * @param keyName string identifying which key to regenerate * @return StorageAccount the storage account created, null if operation failed * @throws Exception in the advent of a problem, the exception is thrown */ public static StorageAccountRegenerateKeyResponse regenerateStorageAccountKey( - StorageManagementClient storageManagementClient, ResourceContext context, KeyName keyName) throws Exception { + StorageManagementClient storageManagementClient, ResourceContext context, String keyName) throws Exception { String storageAccountName = context.getStorageAccountName(); StorageAccountRegenerateKeyResponse response = null;