From 9ad163b5250d88238f18d950fffc230758d76c9d Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 19 Aug 2016 12:00:44 -0700 Subject: [PATCH 01/47] Fixed to the key vault certificate feature and tests. 1) getObjests is changed to listObjects 2) Removed getObjectsNext as this is controlled by the library 3) Changes the request parameters for some update* operations to reflect mandatory and optional parameters. 4) Added tests for Async and some additional tests --- .../azure/keyvault/KeyVaultClient.java | 285 +-- .../azure/keyvault/KeyVaultClientImpl.java | 350 ++- .../keyvault/models/CertificateBundle.java | 4 +- .../CertificateIssuerSetParameters.java | 121 + .../CertificateIssuerUpdateParameters.java | 121 + .../keyvault/models/CertificateOperation.java | 4 +- .../CertificateOperationUpdateParameter.java | 45 + .../models/CertificateUpdateParameters.java | 26 + .../azure/keyvault/models/IssuerBundle.java | 4 +- .../azure/keyvault/models/JsonWebKey.java | 5 +- .../azure/keyvault/models/KeyBundle.java | 4 +- .../models/KeyVaultErrorException.java | 11 + .../azure/keyvault/models/SecretBundle.java | 4 +- .../requests/SetCertificateIssuerRequest.java | 110 +- .../UpdateCertificateIssuerRequest.java | 107 +- .../UpdateCertificateOperationRequest.java | 32 +- .../UpdateCertificatePolicyRequest.java | 2 +- .../requests/UpdateCertificateRequest.java | 69 + .../keyvault/test/AsyncOperationsTest.java | 242 ++ .../test/CertificateOperationsTest.java | 2141 ++++++++--------- .../keyvault/test/KeyOperationsTest.java | 166 +- .../KeyVaultClientIntegrationTestBase.java | 12 +- .../keyvault/test/SecretOperationsTest.java | 172 +- 23 files changed, 2383 insertions(+), 1654 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 52cbba1b6abbe..1c1d45cab33d3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -26,7 +26,6 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; -import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; @@ -425,7 +424,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) + public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -438,7 +437,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -452,7 +451,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -466,7 +465,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); } @@ -479,7 +478,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl) + public ServiceResponse> listKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -491,7 +490,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl) * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); } /** @@ -504,7 +503,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -517,7 +516,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl, fi * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -962,7 +961,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) + public ServiceResponse> listSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -974,7 +973,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); } /** @@ -987,7 +986,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } @@ -1000,7 +999,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1014,7 +1013,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) + public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1027,7 +1026,7 @@ public ServiceResponse> getSecretVersions(final String vau * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); } /** @@ -1041,7 +1040,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1055,7 +1054,7 @@ public ServiceResponse> getSecretVersions(final String vau * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); } @@ -1068,7 +1067,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl) + public ServiceResponse> listCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl); } @@ -1080,7 +1079,7 @@ public ServiceResponse> getCertificates(final String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); } /** @@ -1093,7 +1092,7 @@ public ServiceCall> getCertificatesAsync(final String vaul * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } @@ -1106,7 +1105,7 @@ public ServiceResponse> getCertificates(final String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1223,7 +1222,7 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) + public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1235,7 +1234,7 @@ public ServiceResponse> getCertificateIssuers(f * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); } /** @@ -1248,7 +1247,7 @@ public ServiceCall> getCertificateIssuersAsync(final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1261,7 +1260,7 @@ public ServiceResponse> getCertificateIssuers(f * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1279,8 +1278,11 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer()); + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.provider(), + setCertificateIssuerRequest.credentials(), + setCertificateIssuerRequest.organizationDetails(), + setCertificateIssuerRequest.attributes()); } /** @@ -1295,7 +1297,10 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR return innerKeyVaultClient.setCertificateIssuerAsync( setCertificateIssuerRequest.vaultBaseUrl(), setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer(), + setCertificateIssuerRequest.provider(), + setCertificateIssuerRequest.credentials(), + setCertificateIssuerRequest.organizationDetails(), + setCertificateIssuerRequest.attributes(), serviceCallback); } @@ -1313,8 +1318,11 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer()); + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.provider(), + updateCertificateIssuerRequest.credentials(), + updateCertificateIssuerRequest.organizationDetails(), + updateCertificateIssuerRequest.attributes()); } /** @@ -1329,8 +1337,11 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.provider(), + updateCertificateIssuerRequest.credentials(), + updateCertificateIssuerRequest.organizationDetails(), + updateCertificateIssuerRequest.attributes(), serviceCallback); } @@ -1478,7 +1489,7 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) + public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1491,7 +1502,7 @@ public ServiceResponse> getCertificateVersions(final * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1505,7 +1516,7 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) + public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } @@ -1519,7 +1530,7 @@ public ServiceResponse> getCertificateVersions(final * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); } @@ -1576,7 +1587,7 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificatePolicyAsync(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( updateCertificatePolicyRequest.vaultBaseUrl(), updateCertificatePolicyRequest.certificateName(), @@ -1598,8 +1609,9 @@ public ServiceResponse updateCertificate(UpdateCertificateReq throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificatePolicy(), updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags()); } @@ -1616,7 +1628,8 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe return innerKeyVaultClient.updateCertificateAsync( updateCertificateRequest.vaultBaseUrl(), updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificatePolicy(), updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags(), serviceCallback); @@ -1720,7 +1733,7 @@ public ServiceResponse updateCertificateOperation(UpdateCe return innerKeyVaultClient.updateCertificateOperation( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation()); + updateCertificateOperationRequest.cancellationRequested()); } /** @@ -1735,7 +1748,7 @@ public ServiceCall updateCertificateOperationAsync(UpdateC return innerKeyVaultClient.updateCertificateOperationAsync( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation(), + updateCertificateOperationRequest.cancellationRequested(), serviceCallback); } @@ -1789,7 +1802,7 @@ public ServiceResponse deleteCertificateOperation(String v * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1868,9 +1881,6 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1901,187 +1911,4 @@ public void onResponse(Call call, Response response) }); return serviceCall; } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getKeyVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); - } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getKeysNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeysNext(nextPageLink); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getSecretsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretsNext(nextPageLink); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getSecretVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificatesNext(nextPageLink); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 5d3610adf8074..8b5c045ede14a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. @@ -17,13 +21,18 @@ import com.microsoft.azure.keyvault.models.CertificateCreateParameters; import com.microsoft.azure.keyvault.models.CertificateImportParameters; import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateIssuerSetParameters; +import com.microsoft.azure.keyvault.models.CertificateIssuerUpdateParameters; import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.CertificateMergeParameters; import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificateOperationUpdateParameter; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.CertificateUpdateParameters; import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; @@ -38,6 +47,7 @@ import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyParameters; import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.OrganizationDetails; import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; @@ -342,11 +352,11 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") @@ -386,7 +396,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") @@ -1647,7 +1657,7 @@ private ServiceResponse restoreKeyDelegate(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -1687,7 +1697,7 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1750,7 +1760,7 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1853,7 +1863,7 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1956,7 +1966,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -2001,7 +2011,7 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -2069,7 +2079,7 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -2109,7 +2119,7 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -2172,7 +2182,7 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -3712,28 +3722,35 @@ private ServiceResponse> getCertificateIssuersDe * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); return setCertificateIssuerDelegate(call.execute()); } @@ -3742,26 +3759,129 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + return setCertificateIssuerDelegate(call.execute()); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object + */ + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override @@ -3795,28 +3915,35 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); return updateCertificateIssuerDelegate(call.execute()); } @@ -3825,26 +3952,129 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + return updateCertificateIssuerDelegate(call.execute()); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object + */ + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override @@ -4742,9 +4972,11 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4774,9 +5006,11 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4808,6 +5042,7 @@ public void onResponse(Call call, Response response) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -4815,7 +5050,7 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4828,9 +5063,11 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4844,12 +5081,13 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4862,9 +5100,11 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4983,28 +5223,26 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } - if (certificateOperation == null) { - throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateOperation); + CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); + certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); return updateCertificateOperationDelegate(call.execute()); } @@ -5013,26 +5251,24 @@ public ServiceResponse updateCertificateOperation(String v * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param certificateOperation The certificate operation response. + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } - if (certificateOperation == null) { - throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateOperation); + CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); + certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index eda7dfbc9da3a..44417b1eea285 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -13,6 +13,7 @@ import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.Base64Url; import java.io.IOException; @@ -239,7 +240,8 @@ public KeyIdentifier keyIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java new file mode 100644 index 0000000000000..f9daf44e44fda --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The certificate issuer set parameters. + */ +public class CertificateIssuerSetParameters { + /** + * The name of the issuer. + */ + @JsonProperty(required = true) + private String provider; + + /** + * The credentials to be used for the issuer. + */ + private IssuerCredentials credentials; + + /** + * Details of the organization as provided to the issuer. + */ + @JsonProperty(value = "org_details") + private OrganizationDetails organizationDetails; + + /** + * Attributes of the issuer object. + */ + private IssuerAttributes attributes; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the credentials value. + * + * @return the credentials value + */ + public IssuerCredentials credentials() { + return this.credentials; + } + + /** + * Set the credentials value. + * + * @param credentials the credentials value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get the organizationDetails value. + * + * @return the organizationDetails value + */ + public OrganizationDetails organizationDetails() { + return this.organizationDetails; + } + + /** + * Set the organizationDetails value. + * + * @param organizationDetails the organizationDetails value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public IssuerAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java new file mode 100644 index 0000000000000..7af311457b0ea --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The certificate issuer set parameters. + */ +public class CertificateIssuerUpdateParameters { + /** + * The name of the issuer. + */ + @JsonProperty(required = true) + private String provider; + + /** + * The credentials to be used for the issuer. + */ + private IssuerCredentials credentials; + + /** + * Details of the organization as provided to the issuer. + */ + @JsonProperty(value = "org_details") + private OrganizationDetails organizationDetails; + + /** + * Attributes of the issuer object. + */ + private IssuerAttributes attributes; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the credentials value. + * + * @return the credentials value + */ + public IssuerCredentials credentials() { + return this.credentials; + } + + /** + * Set the credentials value. + * + * @param credentials the credentials value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get the organizationDetails value. + * + * @return the organizationDetails value + */ + public OrganizationDetails organizationDetails() { + return this.organizationDetails; + } + + /** + * Set the organizationDetails value. + * + * @param organizationDetails the organizationDetails value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public IssuerAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index c8aea174e4bf3..02fd132ae9754 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.CertificateOperationIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A certificate operation is returned in case of async requests. @@ -255,7 +256,8 @@ public CertificateOperationIdentifier certificateOperationIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java new file mode 100644 index 0000000000000..dd7c42a5f4ac0 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A certificate operation is returned in case of async requests. + */ +public class CertificateOperationUpdateParameter { + /** + * Indicates if cancellation was requested on the certificate operation. + */ + @JsonProperty(value = "cancellation_requested", required = true) + private boolean cancellationRequested; + + /** + * Get the cancellationRequested value. + * + * @return the cancellationRequested value + */ + public boolean cancellationRequested() { + return this.cancellationRequested; + } + + /** + * Set the cancellationRequested value. + * + * @param cancellationRequested the cancellationRequested value to set + * @return the CertificateOperationUpdateParameter object itself. + */ + public CertificateOperationUpdateParameter withCancellationRequested(boolean cancellationRequested) { + this.cancellationRequested = cancellationRequested; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index 0e3d426eed6cf..e3e899ff572c6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -17,6 +17,12 @@ * The certificate update parameters. */ public class CertificateUpdateParameters { + /** + * The management policy for the certificate. + */ + @JsonProperty(value = "policy") + private CertificatePolicy certificatePolicy; + /** * The attributes of the certificate (optional). */ @@ -28,6 +34,26 @@ public class CertificateUpdateParameters { */ private Map tags; + /** + * Get the certificatePolicy value. + * + * @return the certificatePolicy value + */ + public CertificatePolicy certificatePolicy() { + return this.certificatePolicy; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy the certificatePolicy value to set + * @return the CertificateUpdateParameters object itself. + */ + public CertificateUpdateParameters withCertificatePolicy(CertificatePolicy certificatePolicy) { + this.certificatePolicy = certificatePolicy; + return this; + } + /** * Get the certificateAttributes value. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 3dd318e5139f8..e30c98684da69 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.IssuerIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * The issuer for Key Vault certificate. @@ -151,7 +152,8 @@ public IssuerIdentifier issuerIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index ed9bb700c1543..ef267481ebba1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.Base64Url; /** @@ -95,7 +96,6 @@ public class JsonWebKey { /** * Symmetric key. */ - @JsonProperty(value = "K") private Base64Url k; /** @@ -436,7 +436,8 @@ public JsonWebKey withT(byte[] t) { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 4c13b1490a64d..453e5177fab2b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A KeyBundle consisting of a WebKey plus its Attributes. @@ -110,7 +111,8 @@ public KeyIdentifier keyIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index bdcfc617fc14c..43b6a45e162db 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -29,6 +29,17 @@ public class KeyVaultErrorException extends RestException { * Initializes a new instance of the KeyVaultErrorException class. */ public KeyVaultErrorException() { } + + @Override + public String getMessage() + { + if(body != null && body.error() != null + && body.error().message() != null + && !body.error().message().isEmpty()) { + return body.error().message(); + } + return getMessage(); + } /** * Initializes a new instance of the KeyVaultErrorException class. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 52d7e736fb451..c52baf76b82f9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A Secret consisting of a value, id and its attributes. @@ -185,7 +186,8 @@ public SecretIdentifier secretIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 5c2d00f4d82e6..23201a4a26f4a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -1,7 +1,11 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; + +import com.microsoft.azure.keyvault.models.AdministratorDetails; import com.microsoft.azure.keyvault.models.IssuerAttributes; -import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; +import com.microsoft.azure.keyvault.models.OrganizationDetails; /** * The set certificate issuer request class. @@ -10,7 +14,10 @@ public final class SetCertificateIssuerRequest { private final String vaultBaseUrl; private final String issuerName; - private final IssuerBundle issuer; + private final String provider; + private final IssuerCredentials credentials; + private final OrganizationDetails organizationDetails; + private final IssuerAttributes attributes; /** * The {@link SetCertificateIssuerRequest} builder. @@ -20,9 +27,12 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; + private final String provider; // Optional parameters - private IssuerBundle issuer; + private IssuerCredentials credentials; + private OrganizationDetails organizationDetails; + private IssuerAttributes attributes; /** * The builder for constructing {@link SetCertificateIssuerRequest} @@ -32,24 +42,50 @@ public static class Builder { * The vault name, e.g. https://myvault.vault.azure.net. * @param issuerName * The name of the issuer. + * @param provider The name of the issuer. */ - public Builder(String vaultBaseUrl, String issuerName) { + public Builder(String vaultBaseUrl, String issuerName, String provider) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; + this.provider = provider; } /** - * Set the issuer value. + * Set issuer credentials. * - * @param issuer - * The issuer bundle. + * @param credentials + * The issuer credentials. * @return the Builder object itself. */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; + public Builder withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; return this; } - + + /** + * Set issuer organization details. + * + * @param organizationDetails + * The issuer organization details. + * @return the Builder object itself. + */ + public Builder withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Set issuer attributes. + * + * @param organizationDetails + * The issuer attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + /** * builds the {@link SetCertificateIssuerRequest} object. * @@ -63,15 +99,25 @@ public SetCertificateIssuerRequest build() { private SetCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; - if (builder.issuer != null) { - issuer = new IssuerBundle().withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); - } + provider = builder.provider; + if(builder.organizationDetails != null) { + organizationDetails = new OrganizationDetails() + .withId(builder.organizationDetails.id()) + .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { - issuer = null; + organizationDetails = null; + } + if(builder.credentials != null) { + credentials = new IssuerCredentials() + .withAccountId(builder.credentials.accountId()) + .withPassword(builder.credentials.password()); + } else { + credentials = null; + } + if (builder.attributes != null) { + attributes = new IssuerAttributes().withEnabled(builder.attributes.enabled()); + } else { + attributes = null; } } @@ -90,10 +136,30 @@ public String issuerName() { } /** - * @return the issuer + * @return the issuer provider name */ - public IssuerBundle issuer() { - return issuer; + public String provider() { + return provider; + } + + /** + * @return the issuer credentials + */ + public IssuerCredentials credentials() { + return credentials; + } + + /** + * @return the organization details + */ + public OrganizationDetails organizationDetails() { + return organizationDetails; + } + + /** + * @return the issuer attributes + */ + public IssuerAttributes attributes() { + return attributes; } - } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index 633d16a2e7a70..37d1048673aea 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -1,7 +1,11 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; + +import com.microsoft.azure.keyvault.models.AdministratorDetails; import com.microsoft.azure.keyvault.models.IssuerAttributes; -import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; +import com.microsoft.azure.keyvault.models.OrganizationDetails; /** * The update certificate issuer request class. @@ -9,7 +13,10 @@ public final class UpdateCertificateIssuerRequest { private final String vaultBaseUrl; private final String issuerName; - private final IssuerBundle issuer; + private final String provider; + private final IssuerCredentials credentials; + private final OrganizationDetails organizationDetails; + private final IssuerAttributes attributes; /** * The {@link UpdateCertificateIssuerRequest} builder. @@ -19,9 +26,12 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; + private final String provider; // Optional parameters - private IssuerBundle issuer; + private IssuerCredentials credentials; + private OrganizationDetails organizationDetails; + private IssuerAttributes attributes; /** * The builder for constructing {@link UpdateCertificateIssuerRequest} @@ -32,20 +42,45 @@ public static class Builder { * @param issuerName * The name of the issuer in the given vault. */ - public Builder(String vaultBaseUrl, String issuerName) { + public Builder(String vaultBaseUrl, String issuerName, String provider) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; + this.provider = provider; } /** - * Set the issuer value. + * Set issuer credentials. + * + * @param credentials + * The issuer credentials. + * @return the Builder object itself. + */ + public Builder withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Set issuer organization details. * - * @param issuer - * The issuer bundle. + * @param organizationDetails + * The issuer organization details. * @return the Builder object itself. */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; + public Builder withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Set issuer attributes. + * + * @param organizationDetails + * The issuer attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; return this; } @@ -62,16 +97,25 @@ public UpdateCertificateIssuerRequest build() { private UpdateCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; - - if (builder.issuer != null) { - issuer = new IssuerBundle().withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); - } + provider = builder.provider; + if(builder.organizationDetails != null) { + organizationDetails = new OrganizationDetails() + .withId(builder.organizationDetails.id()) + .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { - issuer = null; + organizationDetails = null; + } + if(builder.credentials != null) { + credentials = new IssuerCredentials() + .withAccountId(builder.credentials.accountId()) + .withPassword(builder.credentials.password()); + } else { + credentials = null; + } + if (builder.attributes != null) { + attributes = new IssuerAttributes().withEnabled(builder.attributes.enabled()); + } else { + attributes = null; } } @@ -90,9 +134,30 @@ public String issuerName() { } /** - * @return the issuer + * @return the issuer provider name + */ + public String provider() { + return provider; + } + + /** + * @return the issuer credentials + */ + public IssuerCredentials credentials() { + return credentials; + } + + /** + * @return the organization details + */ + public OrganizationDetails organizationDetails() { + return organizationDetails; + } + + /** + * @return the issuer attributes */ - public IssuerBundle issuer() { - return issuer; + public IssuerAttributes attributes() { + return attributes; } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java index 95bd2af87a2e7..24f68899e111c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java @@ -1,14 +1,12 @@ package com.microsoft.azure.keyvault.requests; -import com.microsoft.azure.keyvault.models.CertificateOperation; - /** * The update certificate operation request class. */ public final class UpdateCertificateOperationRequest { private final String vaultBaseUrl; private final String certificateName; - private final CertificateOperation certificateOperation; + private final Boolean cancellationRequested; /** * The {@link UpdateCertificateOperationRequest} builder. @@ -18,9 +16,9 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String certificateName; + private final Boolean cancellationRequested; // Optional parameters - private Boolean cancellationRequested; /** * The builder for constructing {@link CreateCertificateRequest} object. @@ -29,23 +27,13 @@ public static class Builder { * The vault name, e.g. https://myvault.vault.azure.net. * @param certificateName * The name of the certificate in the given vault. + * @param cancellationRequested + * Indicates if cancellation was requested on the certificate operation. */ - public Builder(String vaultBaseUrl, String certificateName) { + public Builder(String vaultBaseUrl, String certificateName, Boolean cancellationRequested) { this.vaultBaseUrl = vaultBaseUrl; this.certificateName = certificateName; - } - - /** - * Set the cancellationRequested value. - * - * @param cancellationRequested - * Indicates if cancellation was requested on the certificate - * operation. - * @return the Builder object itself. - */ - public Builder withCancellationRequested(Boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; - return this; } /** @@ -61,11 +49,7 @@ public UpdateCertificateOperationRequest build() { private UpdateCertificateOperationRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; certificateName = builder.certificateName; - if (builder.cancellationRequested != null) { - certificateOperation = new CertificateOperation().withCancellationRequested(builder.cancellationRequested); - } else { - certificateOperation = null; - } + cancellationRequested = builder.cancellationRequested; } /** @@ -85,7 +69,7 @@ public String certificateName() { /** * @return the certificate policy */ - public CertificateOperation certificateOperation() { - return certificateOperation; + public Boolean cancellationRequested() { + return cancellationRequested; } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java index da062e1ca5220..ea155328ece75 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java @@ -106,7 +106,7 @@ private UpdateCertificatePolicyRequest(Builder builder) { new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); } } else { - certificatePolicy = null; + certificatePolicy = new CertificatePolicy(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index 009caeded6ce7..407b4c1407d27 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -1,9 +1,17 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; import java.util.Collections; import java.util.Map; import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyProperties; +import com.microsoft.azure.keyvault.models.LifetimeAction; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest.Builder; /** * The update certificate request class. @@ -12,6 +20,7 @@ public final class UpdateCertificateRequest { private final String vaultBaseUrl; private final String certificateName; private final String certificateVersion; + private final CertificatePolicy certificatePolicy; private final CertificateAttributes certificateAttributes; private final Map tags; @@ -28,6 +37,7 @@ public static class Builder { private String certificateVersion; private CertificateAttributes attributes; private Map tags; + private CertificatePolicy policy; /** * The builder for constructing {@link UpdateCertificateRequest} object. @@ -53,6 +63,19 @@ public Builder withCertificateVersion(String version) { this.certificateVersion = version; return this; } + + /** + * Set the certificatePolicy value. Mandatory if sending the create + * request for the first time. + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } /** * Set the attributes value. @@ -107,6 +130,45 @@ private UpdateCertificateRequest(Builder builder) { } else { tags = null; } + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy + .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames( + builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties( + new KeyProperties().withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = new CertificatePolicy(); + } } /** @@ -130,6 +192,13 @@ public String certificateVersion() { return certificateVersion; } + /** + * @return the certificate policy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; + } + /** * @return the certificate attributes */ diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java new file mode 100644 index 0000000000000..86410c9ab946f --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -0,0 +1,242 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.test; + +import java.security.MessageDigest; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.azure.keyvault.models.BackupKeyResult; +import com.microsoft.azure.keyvault.models.CertificateBundle; +import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateItem; +import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.KeyItem; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; +import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; + + +public class AsyncOperationsTest extends KeyVaultClientIntegrationTestBase { + + @Test + public void keyAsync() throws Exception { + + String vault = getVaultUri(); + String keyname = "mykey"; + + CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, "RSA").build(); + KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); + Assert.assertNotNull(keyBundle); + + UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest.Builder(keyBundle.key().kid()).build(); + keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get().getBody(); + Assert.assertNotNull(keyBundle); + + keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get().getBody(); + Assert.assertNotNull(keyBundle); + + List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get().getBody(); + Assert.assertNotNull(keyItems); + + List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get().getBody(); + Assert.assertNotNull(keyVersionItems); + + BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get().getBody(); + Assert.assertNotNull(backupResult); + + keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); + + KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); + Assert.assertNotNull(restoreResult); + + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + Assert.assertNotNull(encryptResult); + + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, encryptResult.result(), null).get().getBody(); + Assert.assertNotNull(decryptResult); + + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + Assert.assertNotNull(wrapResult); + + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, wrapResult.result(), null).get().getBody(); + Assert.assertNotNull(unwrapResult); + + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(plainText); + byte[] digest = md.digest(); + KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get().getBody(); + Assert.assertNotNull(signResult); + + KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get().getBody(); + Assert.assertTrue(verifypResult.value()); + + keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); + Assert.assertNotNull(keyBundle); + } + + @Test + public void secretAsync() throws Exception { + + String vault = getVaultUri(); + String secretname = "mySecret"; + String password = "password"; + + SetSecretRequest setSecretRequest = new SetSecretRequest.Builder(vault, secretname, password).build(); + SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get().getBody(); + Assert.assertNotNull(secretBundle); + + UpdateSecretRequest updateSecretRequest = new UpdateSecretRequest.Builder(secretBundle.id()).build(); + secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get().getBody(); + Assert.assertNotNull(secretBundle); + + secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get().getBody(); + Assert.assertNotNull(secretBundle); + + List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get().getBody(); + Assert.assertNotNull(secretItems); + + List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get().getBody(); + Assert.assertNotNull(secretVersionItems); + + secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); + Assert.assertNotNull(secretBundle); + } + + @Test + public void certificateAsync() throws Exception { + + String vault = getVaultUri(); + String certificateName = "myCertificate"; + + CreateCertificateRequest createCertificateRequest = + new CreateCertificateRequest + .Builder(vault, certificateName) + .withPolicy(new CertificatePolicy() + .withSecretProperties(new SecretProperties().withContentType("application/x-pkcs12")) + .withIssuerReference(new IssuerReference().withName("Self")) + .withX509CertificateProperties(new X509CertificateProperties() + .withSubject("CN=SelfSignedJavaPkcs12") + .withValidityInMonths(12))) + .build(); + CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + UpdateCertificateOperationRequest updateCertificateOperationRequest = new UpdateCertificateOperationRequest.Builder(vault, certificateName, false).build(); + certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + Map tags = new HashMap(); + tags.put("tag1", "foo"); + UpdateCertificateRequest updateCertificateRequest = new UpdateCertificateRequest.Builder(vault, certificateName).withTags(tags).build(); + CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get().getBody(); + Assert.assertNotNull(certificateBundle); + + UpdateCertificatePolicyRequest updateCertificatePolicyRequest = new UpdateCertificatePolicyRequest.Builder(vault, certificateName).build(); + CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get().getBody(); + Assert.assertNotNull(certificatePolicy); + + certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificatePolicy); + + certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateBundle); + + String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get().getBody(); + Assert.assertTrue(!cert.isEmpty()); + + List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get().getBody(); + Assert.assertNotNull(certificateItem); + + List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateVersionItem); + + + keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + } + + @Test + public void issuerAsync() throws Exception { + + String vault = getVaultUri(); + String issuerName = "myIssuer"; + + SetCertificateIssuerRequest setCertificateIssuerRequest = new SetCertificateIssuerRequest.Builder(vault, issuerName, "Test").build(); + IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName, "SslAdmin").build(); + certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get().getBody(); + Assert.assertNotNull(issuers); + + keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + } + + + @Test + public void certificateContactsAsync() throws Exception { + + String vault = getVaultUri(); + + Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get().getBody(); + Assert.assertNotNull(contacts); + + contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get().getBody(); + Assert.assertNotNull(contacts); + + keyVaultClient.deleteCertificateContactsAsync(vault, null).get(); + } +} diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index daa3f644c3ca6..85839d816a2aa 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -20,14 +20,15 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.Key; import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyStore; +import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; +import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; @@ -35,8 +36,10 @@ import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; @@ -48,6 +51,7 @@ import javax.crypto.NoSuchPaddingException; import org.apache.commons.codec.binary.Base64; +import org.joda.time.DateTime; import org.junit.Assert; import org.junit.Test; @@ -55,6 +59,7 @@ import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.AdministratorDetails; +import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.Contact; import com.microsoft.azure.keyvault.models.Contacts; @@ -73,814 +78,589 @@ import com.microsoft.azure.keyvault.requests.ImportCertificateRequest; import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; public class CertificateOperationsTest extends KeyVaultClientIntegrationTestBase { - static final String ALGO_RSA = "RSA"; + static final String ALGO_RSA = "RSA"; - static final String X509 = "X.509"; + static final String X509 = "X.509"; - static final String PKCS12 = "PKCS12"; + static final String PKCS12 = "PKCS12"; - static final String MIME_PKCS12 = "application/x-pkcs12"; + static final String MIME_PKCS12 = "application/x-pkcs12"; - static final String MIME_PEM = "application/x-pem-file"; + static final String MIME_PEM = "application/x-pem-file"; - static final String ISSUER_SELF = "Self"; + static final String ISSUER_SELF = "Self"; - static final String ISSUER_TEST = "Test"; - - static final String ISSUER_UNKNOWN = "Unknown"; - - static final String STATUS_IN_PROGRESS = "inProgress"; + static final String ISSUER_TEST = "Test"; + + static final String ISSUER_UNKNOWN = "Unknown"; + + static final String STATUS_IN_PROGRESS = "inProgress"; - static final String STATUS_COMPLETED = "Completed"; + static final String STATUS_COMPLETED = "Completed"; - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 _base64 = new Base64(-1, null, true); - static final Pattern _privateKey = Pattern.compile("-{5}BEGIN PRIVATE KEY-{5}(?:\\s|\\r|\\n)+" - + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END PRIVATE KEY-{5}(?:\\s|\\r|\\n)+"); + static final Pattern _privateKey = Pattern.compile("-{5}BEGIN PRIVATE KEY-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END PRIVATE KEY-{5}(?:\\s|\\r|\\n)+"); - static final Pattern _certificate = Pattern.compile("-{5}BEGIN CERTIFICATE-{5}(?:\\s|\\r|\\n)+" - + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END CERTIFICATE-{5}(?:\\s|\\r|\\n)+"); + static final Pattern _certificate = Pattern.compile("-{5}BEGIN CERTIFICATE-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END CERTIFICATE-{5}(?:\\s|\\r|\\n)+"); - private static final int MAX_CERTS = 4; + private static final int MAX_CERTS = 4; private static final int PAGELIST_MAX_CERTS = 3; - /** - * Create a self-signed certificate in PKCS12 format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createSelfSignedCertificatePkcs12() throws Exception { - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=SelfSignedJavaPkcs12"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_SELF); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createSelfSignedJavaPkcs12"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.keyIdentifier()); - Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a self-signed certificate in PEM format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createSelfSignedCertificatePem() throws Exception { - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=SelfSignedJavaPem"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_SELF); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "SelfSignedJavaPem"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - String secretValue = secret.value(); - - // Extract private key from PEM - PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); - Assert.assertNotNull(secretPrivateKey); - - // Extract certificates from PEM - List certificates = extractCertificatesFromPemContents(secretValue); - Assert.assertNotNull(certificates); - Assert.assertTrue(certificates.size() == 1); - - // has the public key corresponding to the private key. - X509Certificate secretCertificate = certificates.get(0); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a test-issuer issued certificate in PKCS12 format (which includes - * the private key) certificate. - * - * @throws Exception - */ - @Test - public void createCertificatePkcs12() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - String certificateIssuerName = "createCertificateJavaPkcs12Issuer01"; - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(),certificateIssuerName) - .withIssuer(certificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); - Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=TestJavaPkcs12"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createTestJavaPkcs12"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.keyIdentifier()); - Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertNotNull(certificateBundle.policy()); - Assert.assertNotNull(certificateBundle.policy().issuerReference()); - Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); - Assert.assertTrue( - certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a test-issuer certificate in PEM format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createCertificatePem() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - String certificateIssuerName = "createCertificateJavaPemIssuer01"; - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName) - .withIssuer(certificateIssuer) - .build()).getBody(); - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); - Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); - - // Set content type to indicate the certificate is PEM format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=TestJavaPem"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createTestJavaPem"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertNotNull(certificateBundle.policy()); - Assert.assertNotNull(certificateBundle.policy().issuerReference()); - Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); - Assert.assertTrue( - certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - String secretValue = secret.value(); - - // Extract private key from PEM - PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); - Assert.assertNotNull(secretPrivateKey); - - // Extract certificates from PEM - List certificates = extractCertificatesFromPemContents(secretValue); - Assert.assertNotNull(certificates); - Assert.assertTrue(certificates.size() == 1); - - // has the public key corresponding to the private key. - X509Certificate secretCertificate = certificates.get(0); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } - catch(KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a certificate signing request with key in Key Vault. - * @throws ExecutionException - * @throws InterruptedException - * @throws IOException - * @throws IllegalArgumentException - * @throws KeyVaultErrorException - * - * @throws Exception - */ - @Test - public void createCsr() throws InterruptedException, ExecutionException, KeyVaultErrorException, IllegalArgumentException, IOException { - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=ManualEnrollmentJava"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Unknown" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_UNKNOWN); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createManualEnrollmentJava"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - Assert.assertNotNull(certificateOperation.csr()); - - String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); - Assert.assertNotNull(csr); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - /** - * Import a PKCS12 format (which includes the private key) certificate. - */ - @Test - public void importCertificatePkcs12() throws Exception { - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - String vaultUri = getVaultUri(); - String certificateName = "importCertPkcs"; - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(vaultUri, certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - - // Validate the certificate bundle created - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest")); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency")); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Import a PEM format (which includes a encrypted private key) certificate. - * TODO: Server can't handle this yet. - */ - // @Test - public void importCertificatePem() throws Exception { - String certificateContent = "-----BEGIN ENCRYPTED PRIVATE KEY-----\n" - + "MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI+mprWsX8IMICAggA\n" - + "MBQGCCqGSIb3DQMHBAgu4FUBoWBbGgSCBMhjsFyDgeqAVrMRXKaGpdstAHttWxGw\n" - + "JfkthRr8eULwldl2sYZdxwZaHOWjhhwp3LHZ7M5+6augyo1WxIJ456hPlZQ0nlXO\n" - + "y9pFBXEFSIeemd7JdVPjZ3HWVrkXapcKh12hqhzskdXlBermc5uS5NScOFJhnGFT\n" - + "68Va9KHglOmX2T0fUIagWnxQuP2gu3w3PIbbMt8tB0fN5H2xfd6xjKiTlb+3jHP2\n" - + "kZzAcPCzqgNlCK09fOqD9x+fFO2Zn6SqzPt66E8IMZ/7s41mF5IU8H0rIkA9vOZM\n" - + "oM41r0S+N1nhn1MV52aHcqQETV/odKq968dnLRiSIRLfSI9HQWubXu3jWeDHh3GC\n" - + "gaJbafDZWYjN42xIamm5xv3JEycED3Cqk4ibSJgw72uEIGZmhxzo8cXCelOezCBT\n" - + "aj3IkLfUej9p9UhIZJ6DX3kWFh7Ab5T4c23ZzV1WeDtLSANqh1FHFnWMxAcTOgY0\n" - + "0uPGKW03uz3RQdypI8GbrYlT0QiLAaCT6dijFyGNk8W1eAcFJQS4Vtp7PBG+o1qn\n" - + "+xdXVEiQxpZbiFeSMaydfxWAbin4gr98I55gf2VXq9VOFsRY2LxeNzmmEVt1HjuJ\n" - + "rCl4KB/d7VrB+Ev/zjUHDtD22f/Gca7VRET7FaG9Mdj4trtngKFc3B82Q98a3F2w\n" - + "l7ppYQMwdOFUrDRCCDdmatVJwtg/MAXxaIxwGAow+po0dQx2xyqz/8aIPoSg604d\n" - + "+Z5AEmpyLC7369+OZUtJfQ5bCmFbBLne9YvoDAKXuJ07fx+Sq7Hzrbb3uPQo6vgi\n" - + "QrLJhY8KgCFMMWzsfiVPOIGkWIR2KRiyX2HMbsYGRdhRsGl4xco8mmCv4C9WjR9A\n" - + "AT5mVi6U9/zMG1wJMrnVoPQ1E+pi+nuviWZWKZ8uqYOAOEwewHpuTrdmgPe1yoJ/\n" - + "beIYzTOEt9BemnuQge9/zdhH3U5667xWb08hV5dv1Z9ubLKbZx3Yea/J+EbfNW3B\n" - + "OxuacDsaMSSj1wiKKgeSkusrAikCvlsCJumTRAbu/uR6HgmqIlBpB3JTJHoCx90F\n" - + "BsIcwf73aFs/rQQJ6aZRi/fFgHpxWgtEQ9aTKXmhgbfTjjHYGYGkHvDNdzKaXu46\n" - + "6WliF9G0WAeotaGrRESvqVDswaM0F27KjtSdcmtdUQOtbtVVd84VClZqhbyd6tFh\n" - + "lqFsHO9oN+mQQJNhemqiL/Tdo+BQwGxeWjlstd7HlwUsc1sp0OLA8h8QlteBAnNb\n" - + "KpOQYblZbCZX4uZR5KJYDeCuDmWp/Qg7gcKyRLC9I+PrzYockl375RuK60Lws8B+\n" - + "kW49wYHzJFf7DOwuV/2TwkOwP0jcr9nWkjS1uwryuYbp9zPuqddHWggt2rDIlBIG\n" - + "aCU46hS1cGJmzLcIF8TAg8hPQgSikr1AIseyDnWK96OnrTRVK8TbVWOHwvJWr92g\n" - + "ZLwgAve79qgG4LPCOF1HZSeU9sq81FbzPz+BGdVLn5xkoZ1gyjclR78W6jeeTGH3\n" - + "efiw9atBkAiUKaODMXbtHm93JcSQ5sK0r66J7uAQVjLIMu757V0paJNjfF5WoisC\n" - + "3nwuSbg71YHNgvlx/OYWRBRreT/zDgApvnrYqUsUPSQaybMc/9Pbjj76T4AWmjVa\n" - + "JHA=\n" - + "-----END ENCRYPTED PRIVATE KEY-----\n" - + "-----BEGIN CERTIFICATE-----\n" - + "MIIDozCCAougAwIBAgIJAIvNGnmenqgjMA0GCSqGSIb3DQEBCwUAMGgxCzAJBgNV\n" - + "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwO\n" - + "TWljcm9zb2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVs\n" - + "dDAeFw0xNjA0MDEyMzAwMjlaFw0xNjA1MzEyMzAwMjlaMGgxCzAJBgNVBAYTAlVT\n" - + "MQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwOTWljcm9z\n" - + "b2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVsdDCCASIw\n" - + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN1udkhsWIwmua3SFJWxS9AJoKK5\n" - + "o7RAHwsQUWWNkSsPiWrzDYXarfUEs1HBEsAjOJDabK1L0ahw4Manx0NXDOmw8kuD\n" - + "lNMs4yTZNxvECvKpq37Z6Q3D9ts4sVSeFbXtOYr81P+8DOOH3Ibk3sldoJBMXJ5h\n" - + "pw4R72988m9CZ9KjcdaKFk3L1baCehpwkJLZD2XD7MzV9YBKNnd15DPCkVZHul1t\n" - + "bW0E7kf7vUOPIfRuNZeN6QvqsKTA+RoGh3CVu9QV+XG/AsHDoHUwGUlJPvOCm3U5\n" - + "tDrrbXAP+Wa/kE/fGAJkZQLPcbappUI4Swtt9u7+CpyQ96H7BY1yHvmBzBUCAwEA\n" - + "AaNQME4wHQYDVR0OBBYEFJ9DSIY/4ODmWY7oIQkGDD7KlQnAMB8GA1UdIwQYMBaA\n" - + "FJ9DSIY/4ODmWY7oIQkGDD7KlQnAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEL\n" - + "BQADggEBAGV3fTAVWd1tdgcaogBirn1LF8d3H45bdDtjD98933dsOCYlXHKNdB62\n" - + "6Qwg6XF9a+p1vuHI1I8MKBu//q+pLJce+bi2jmge64zlz/iO3sLSOFo/q1EWzhal\n" - + "TRglNkvqWr7OvJXdUznQI3AzjB8tbFB2YerSbmD6FxAAihEq8ZoJ1BsMq5vknpPB\n" - + "iETENaNSjdgPEsiapYNALgY4AVxtSS5GJDZ9zpc5Q6HCPmUozLbQheNZf3+D75cy\n" - + "gB2odtfwhKCuIfuMan51UqjupK0JVJuNV4MXRXH0mFPEBxI4pYolFuV8960jGXqE\n" - + "m/26LtCJLW5QaedtCCKpn9fat5VHgso=\n" - + "-----END CERTIFICATE-----\n"; - - String certificatePassword = "1234"; - - // Set content type to indicate the certificate is PEM format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - String vaultUri = getVaultUri(); - String certificateName = "importCertPem"; - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(vaultUri, certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - - // Validate the certificate bundle created - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("d86db6736c335f08ef39aa27ef83836e8eba95b9")); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName() - .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName() - .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * List certificates in a vault. - */ - @Test - public void listCertificates() throws Exception { - String certificateName = "listCertificate"; - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - HashSet certificates = new HashSet(); - for (int i = 0; i < MAX_CERTS; ++i) { - int failureCount = 0; - for (;;) { - try { - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(getVaultUri(), certificateName + i, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - CertificateIdentifier id = certificateBundle.certificateIdentifier(); - certificates.add(id.baseIdentifier()); - break; + private static final Map sTags = new HashMap(); + + /** + * Create a self-signed certificate in PKCS12 format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePkcs12() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=SelfSignedJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() + .withEnabled(false) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + String vaultUri = getVaultUri(); + String certificateName = "createSelfSignedJavaPkcs12"; + + CreateCertificateRequest createCertificateRequest = + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .withAttributes(attribute) + .withTags(sTags) + .build(); + + CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + compareAttributes(attribute, createCertificateRequest.certificateAttributes()); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a self-signed certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePem() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PEM); + + String subjectName = "CN=SelfSignedJavaPem"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "SelfSignedJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + validatePem(certificateBundle, subjectName); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer issued certificate in PKCS12 format (which includes + * the private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePkcs12() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + OrganizationDetails organizationDetails = new OrganizationDetails() + .withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + String certificateIssuerName = "createCertificateJavaPkcs12Issuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(),certificateIssuerName, ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails) + .build()).getBody(); + + validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=TestJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPkcs12"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePem() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + String certificateIssuerName = "createCertificateJavaPemIssuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails) + .build()).getBody(); + validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); + + // Set content type to indicate the certificate is PEM format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PEM); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=TestJavaPem"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + validatePem(certificateBundle, subjectName); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } + catch(KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a certificate signing request with key in Key Vault. + * @throws ExecutionException + * @throws InterruptedException + * @throws IOException + * @throws IllegalArgumentException + * @throws KeyVaultErrorException + * + * @throws Exception + */ + @Test + public void createCsr() throws InterruptedException, ExecutionException, KeyVaultErrorException, IllegalArgumentException, IOException { + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=ManualEnrollmentJava"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer to "Unknown" + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(ISSUER_UNKNOWN); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createManualEnrollmentJava"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + Assert.assertNotNull(certificateOperation.csr()); + + String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); + Assert.assertNotNull(csr); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Cancel the certificate create asynchronously + * @throws IOException + * @throws IllegalArgumentException + * @throws KeyVaultErrorException + * + */ + @Test + public void certificateAsyncRequestCancellation() throws KeyVaultErrorException, IllegalArgumentException, IOException { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=SelfSignedJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "cancellationRequestedCertJava"; + keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + CertificateOperation cancelledCertificateOperation = keyVaultClient.updateCertificateOperation( + new UpdateCertificateOperationRequest + .Builder(vaultUri, certificateName, true) + .build()).getBody(); + + Assert.assertNotNull(cancelledCertificateOperation); + Assert.assertTrue(cancelledCertificateOperation.cancellationRequested()); + + keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName).getBody(); + keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + } + + /** + * Import a PKCS12 format (which includes the private key) certificate. + */ + @Test + public void importCertificatePkcs12() throws Exception { + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes().withEnabled(true); + + String vaultUri = getVaultUri(); + String certificateName = "importCertPkcs"; + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .withAttributes(attribute) + .withTags(sTags) + .build()).getBody(); + + // Validate the certificate bundle created + validateCertificateBundle(certificateBundle, certificatePolicy); + Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); + Assert.assertEquals(attribute.enabled(), certificateBundle.attributes().enabled()); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest")); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency")); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Import a PKCS12 format (which includes the private key) certificate. + */ + @Test + public void certificateUpdate() throws Exception { + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); + + String vaultUri = getVaultUri(); + String certificateName = "updateCertJava"; + keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + + + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() + .withEnabled(false) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + CertificateBundle updatedCertBundle = keyVaultClient.updateCertificate( + new UpdateCertificateRequest + .Builder(vaultUri, certificateName) + .withAttributes((CertificateAttributes) attribute.withEnabled(false)) + .withTags(sTags) + .build()).getBody(); + Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); + Assert.assertEquals(sTags.toString(), updatedCertBundle.tags().toString()); + + CertificatePolicy certificatePolicyUpdate = certificatePolicy.withIssuerReference(new IssuerReference().withName(ISSUER_SELF)); + CertificatePolicy updatedCertificatePolicy = keyVaultClient.updateCertificatePolicy( + new UpdateCertificatePolicyRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicyUpdate) + .build()).getBody(); + Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), updatedCertificatePolicy.issuerReference().name()); + + CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName).getBody(); + Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), policy.issuerReference().name()); + + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); + } + + /** + * List certificates in a vault. + */ + @Test + public void listCertificates() throws Exception { + String certificateName = "listCertificate"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName + i, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.baseIdentifier()); + break; } catch (KeyVaultErrorException e) { ++failureCount; if (e.getBody().error().code().equals("Throttled")) { @@ -890,13 +670,13 @@ public void listCertificates() throws Exception { } throw e; } - } - } + } + } - PagedList listResult = keyVaultClient.getCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); - Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - HashSet toDelete = new HashSet(); + HashSet toDelete = new HashSet(); for (CertificateItem item : listResult) { CertificateIdentifier id = new CertificateIdentifier(item.id()); @@ -904,42 +684,42 @@ public void listCertificates() throws Exception { certificates.remove(item.id()); } - Assert.assertEquals(0, certificates.size()); - - for (String toDeleteCertificateName : toDelete) { - keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName); - } - } - - /** - * List versions of a certificate in a vault. - */ - @Test - public void listCertificateVersions() throws Exception { - String certificateName = "listCertificateVersions"; - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - HashSet certificates = new HashSet(); - for (int i = 0; i < MAX_CERTS; ++i) { - int failureCount = 0; - for (;;) { - try { - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(getVaultUri(), certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - CertificateIdentifier id = certificateBundle.certificateIdentifier(); - certificates.add(id.identifier()); - break; + Assert.assertEquals(0, certificates.size()); + + for (String toDeleteCertificateName : toDelete) { + keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName); + } + } + + /** + * List versions of a certificate in a vault. + */ + @Test + public void listCertificateVersions() throws Exception { + String certificateName = "listCertificateVersions"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.identifier()); + break; } catch (KeyVaultErrorException e) { ++failureCount; if (e.getBody().error().code().equals("Throttled")) { @@ -949,320 +729,399 @@ public void listCertificateVersions() throws Exception { } throw e; } - } - } + } + } - PagedList listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName).getBody(); - for (;;) { - for (CertificateItem item : listResult) { - certificates.remove(item.id()); + listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); + + for (CertificateItem item : listResult) { + certificates.remove(item.id()); + } + + Assert.assertEquals(0, certificates.size()); + + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); + } + + /** + * CRUD for Certificate issuers + */ + @Test + public void issuerCrudOperations() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + IssuerBundle certificateIssuer = new IssuerBundle() + .withProvider(ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails); + + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), "issuer1", certificateIssuer.provider()) + .withCredentials(certificateIssuer.credentials()) + .withOrganizationDetails(certificateIssuer.organizationDetails()) + .build()).getBody(); + + validateCertificateIssuer(certificateIssuer, createdCertificateIssuer); + + String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); + IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), + certificateIssuerName).getBody(); + + validateCertificateIssuer(certificateIssuer, retrievedCertificateIssuer); + + IssuerCredentials updatedCredentials = new IssuerCredentials() + .withAccountId("account2") + .withPassword("Secur!Ty"); + + retrievedCertificateIssuer.withCredentials(updatedCredentials); + IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( + new UpdateCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .withCredentials(updatedCredentials) + .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) + .withAttributes(retrievedCertificateIssuer.attributes()) + .build()).getBody(); + + validateCertificateIssuer(retrievedCertificateIssuer, updatedCertificateIssuer); + + Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); + + IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); + + validateCertificateIssuer(updatedCertificateIssuer, deletedCertificateIssuer); + + try { + keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); + } + } + + /** + * CRUD for Certificate contacts + * @throws Exception + */ + @Test + public void contactsCrudOperations() throws Exception { + // Create + Contact contact1 = new Contact(); + contact1.withName("James"); + contact1.withEmailAddress("james@contoso.com"); + contact1.withPhone("7777777777"); + + Contact contact2 = new Contact(); + contact2.withName("Ethan"); + contact2.withEmailAddress("ethan@contoso.com"); + contact2.withPhone("8888888888"); + + List contacts = new ArrayList(); + contacts.add(contact1); + contacts.add(contact2); + + Contacts certificateContacts = new Contacts(); + certificateContacts.withContactList(contacts); + Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); + Assert.assertNotNull(createdCertificateContacts); + Assert.assertNotNull(createdCertificateContacts.contactList()); + Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); + Contact[] createContacts = createdCertificateContacts.contactList().toArray(new Contact[createdCertificateContacts.contactList().size()]); + Assert.assertTrue(createContacts[0].name().equalsIgnoreCase("James")); + Assert.assertTrue(createContacts[0].emailAddress().equalsIgnoreCase("james@contoso.com")); + Assert.assertTrue(createContacts[0].phone().equalsIgnoreCase("7777777777")); + Assert.assertTrue(createContacts[1].name().equalsIgnoreCase("Ethan")); + Assert.assertTrue(createContacts[1].emailAddress().equalsIgnoreCase("ethan@contoso.com")); + Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); + + // Get + Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(retrievedCertificateContacts); + Assert.assertNotNull(retrievedCertificateContacts.contactList()); + Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); + + // Delete + Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(deletedCertificateContacts); + Assert.assertNotNull(deletedCertificateContacts.contactList()); + Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); + + // Get after delete + try { + keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); + } + } + + /** + * Polls on a certificate operation for completion. + * + * @throws Exception + */ + private static CertificateBundle pollOnCertificateOperation(CertificateOperation certificateOperation) + throws Exception { + + // Wait for enrollment to complete. We will wait for 200 seconds + int pendingPollCount = 0; + while (pendingPollCount < 21) { + String certificateName = certificateOperation.certificateOperationIdentifier().name(); + CertificateOperation pendingCertificateOperation = keyVaultClient + .getCertificateOperation(getVaultUri(), certificateName).getBody(); + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { + Thread.sleep(10000); + pendingPollCount += 1; + continue; } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { + + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { + return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); + } + + throw new Exception(String.format( + "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", + pendingCertificateOperation.error().code(), + pendingCertificateOperation.error().message())); + } + + throw new Exception("Pending certificate processing delayed"); + } + + /** + * Extracts private key from PEM contents + * + * @throws InvalidKeySpecException + * @throws NoSuchAlgorithmException + */ + private static PrivateKey extractPrivateKeyFromPemContents(String pemContents) + throws InvalidKeySpecException, NoSuchAlgorithmException { + Matcher matcher = _privateKey.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No private key found in PEM contents."); + } + + byte[] privateKeyBytes = _base64.decode(matcher.group(1)); + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); + KeyFactory keyFactory = KeyFactory.getInstance(ALGO_RSA); + PrivateKey privateKey = keyFactory.generatePrivate(keySpec); + return privateKey; + } + + /** + * Extracts certificates from PEM contents + * + * @throws CertificateException + * @throws IOException + */ + private static List extractCertificatesFromPemContents(String pemContents) + throws CertificateException, IOException { + Matcher matcher = _certificate.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No certificate found in PEM contents."); + } + + List result = new ArrayList(); + int offset = 0; + while (true) { + if (!matcher.find(offset)) { break; } - keyVaultClient.getCertificateVersionsNext(nextLink).getBody(); + byte[] certBytes = _base64.decode(matcher.group(1)); + ByteArrayInputStream certStream = new ByteArrayInputStream(certBytes); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certStream); + certStream.close(); + + result.add(x509Certificate); + offset = matcher.end(); } - Assert.assertEquals(0, certificates.size()); + return result; + } + + /** + * Verify a RSA key pair with a simple encrypt/decrypt test. + * + * @throws NoSuchPaddingException + * @throws NoSuchAlgorithmException + * @throws InvalidKeyException + * @throws BadPaddingException + * @throws IllegalBlockSizeException + */ + private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmException, NoSuchPaddingException, + InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + // Validate algorithm is RSA + Assert.assertTrue(keyPair.getPublic().getAlgorithm().equals(ALGO_RSA)); + Assert.assertTrue(keyPair.getPrivate().getAlgorithm().equals(ALGO_RSA)); + + // Generate an array of 10 random bytes + byte[] plainData = new byte[10]; + Random random = new Random(); + random.nextBytes(plainData); + + // Encrypt using the public key + Cipher encryptCipher = Cipher.getInstance(ALGO_RSA); + encryptCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); + byte[] encryptedData = encryptCipher.doFinal(plainData); + + // Decrypt using the private key + Cipher decryptCipher = Cipher.getInstance(ALGO_RSA); + decryptCipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + byte[] decryptedData = decryptCipher.doFinal(encryptedData); + + // Validate plainData is equal to decryptedData + Assert.assertArrayEquals(plainData, decryptedData); + } + + private String toHexString(byte[] x5t) { + + if(x5t == null) + return ""; + + StringBuilder hexString = new StringBuilder(); + for (int i = 0; i < x5t.length; i++) { + String hex = Integer.toHexString(0xFF & x5t[i]); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); + } - keyVaultClient.deleteCertificate(getVaultUri(), certificateName); - } - - /** - * CRUD for Certificate issuers - */ - @Test - public void issuerCrudOperations() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(), "issuer1") - .withIssuer(certificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.provider()); - Assert.assertTrue(createdCertificateIssuer.provider().equals("Test")); - - Assert.assertNotNull(createdCertificateIssuer.credentials()); - Assert.assertNotNull(createdCertificateIssuer.credentials().accountId()); - Assert.assertTrue(createdCertificateIssuer.credentials().accountId().equals("account1")); - Assert.assertNull(createdCertificateIssuer.credentials().password()); - - Assert.assertNotNull(createdCertificateIssuer.organizationDetails()); - - String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); - IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), - certificateIssuerName).getBody(); - - Assert.assertNotNull(retrievedCertificateIssuer); - Assert.assertNotNull(retrievedCertificateIssuer.provider()); - Assert.assertTrue(retrievedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(retrievedCertificateIssuer.credentials()); - Assert.assertNotNull(retrievedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(retrievedCertificateIssuer.credentials().accountId().equals("account1")); - Assert.assertNull(retrievedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(retrievedCertificateIssuer.organizationDetails()); - - IssuerCredentials updatedCredentials = new IssuerCredentials(); - updatedCredentials.withAccountId("account2"); - updatedCredentials.withPassword("Secur!Ty"); - retrievedCertificateIssuer.withCredentials(updatedCredentials); - IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( - new UpdateCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName) - .withIssuer(retrievedCertificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(updatedCertificateIssuer); - Assert.assertNotNull(updatedCertificateIssuer.provider()); - Assert.assertTrue(updatedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(updatedCertificateIssuer.credentials()); - Assert.assertNotNull(updatedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(updatedCertificateIssuer.credentials().accountId().equals("account2")); - Assert.assertNull(updatedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); - - IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); - - Assert.assertNotNull(deletedCertificateIssuer); - Assert.assertNotNull(deletedCertificateIssuer.provider()); - Assert.assertTrue(deletedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(deletedCertificateIssuer.credentials()); - Assert.assertNotNull(deletedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(deletedCertificateIssuer.credentials().accountId().equals("account2")); - Assert.assertNull(deletedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(deletedCertificateIssuer.organizationDetails()); - - try { - keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); - } - } - - /** - * CRUD for Certificate contacts - * @throws Exception - */ - @Test - public void contactsCrudOperations() throws Exception { - // Create - Contact contact1 = new Contact(); - contact1.withName("James"); - contact1.withEmailAddress("james@contoso.com"); - contact1.withPhone("7777777777"); - - Contact contact2 = new Contact(); - contact2.withName("Ethan"); - contact2.withEmailAddress("ethan@contoso.com"); - contact2.withPhone("8888888888"); - - List contacts = new ArrayList(); - contacts.add(contact1); - contacts.add(contact2); - - Contacts certificateContacts = new Contacts(); - certificateContacts.withContactList(contacts); - Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); - Assert.assertNotNull(createdCertificateContacts); - Assert.assertNotNull(createdCertificateContacts.contactList()); - Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); - Contact[] createContacts = createdCertificateContacts.contactList().toArray(new Contact[createdCertificateContacts.contactList().size()]); - Assert.assertTrue(createContacts[0].name().equalsIgnoreCase("James")); - Assert.assertTrue(createContacts[0].emailAddress().equalsIgnoreCase("james@contoso.com")); - Assert.assertTrue(createContacts[0].phone().equalsIgnoreCase("7777777777")); - Assert.assertTrue(createContacts[1].name().equalsIgnoreCase("Ethan")); - Assert.assertTrue(createContacts[1].emailAddress().equalsIgnoreCase("ethan@contoso.com")); - Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); - - // Get - Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); - Assert.assertNotNull(retrievedCertificateContacts); - Assert.assertNotNull(retrievedCertificateContacts.contactList()); - Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); - - // Delete - Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); - Assert.assertNotNull(deletedCertificateContacts); - Assert.assertNotNull(deletedCertificateContacts.contactList()); - Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); - - // Get after delete - try { - keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); - } - } - - /** - * Polls on a certificate operation for completion. - * - * @throws Exception - */ - private static CertificateBundle pollOnCertificateOperation(CertificateOperation certificateOperation) - throws Exception { - - // Wait for enrollment to complete. We will wait for 200 seconds - int pendingPollCount = 0; - while (pendingPollCount < 21) { - String certificateName = certificateOperation.certificateOperationIdentifier().name(); - CertificateOperation pendingCertificateOperation = keyVaultClient - .getCertificateOperation(getVaultUri(), certificateName).getBody(); - if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { - Thread.sleep(10000); - pendingPollCount += 1; - continue; - } - - if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { - return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); - } - - throw new Exception(String.format( - "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", - pendingCertificateOperation.error().code(), - pendingCertificateOperation.error().message())); - } - - throw new Exception("Pending certificate processing delayed"); - } - - /** - * Extracts private key from PEM contents - * - * @throws InvalidKeySpecException - * @throws NoSuchAlgorithmException - */ - private static PrivateKey extractPrivateKeyFromPemContents(String pemContents) - throws InvalidKeySpecException, NoSuchAlgorithmException { - Matcher matcher = _privateKey.matcher(pemContents); - if (!matcher.find()) { - throw new IllegalArgumentException("No private key found in PEM contents."); - } - - byte[] privateKeyBytes = _base64.decode(matcher.group(1)); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); - KeyFactory keyFactory = KeyFactory.getInstance(ALGO_RSA); - PrivateKey privateKey = keyFactory.generatePrivate(keySpec); - return privateKey; - } - - /** - * Extracts certificates from PEM contents - * - * @throws CertificateException - * @throws IOException - */ - private static List extractCertificatesFromPemContents(String pemContents) - throws CertificateException, IOException { - Matcher matcher = _certificate.matcher(pemContents); - if (!matcher.find()) { - throw new IllegalArgumentException("No certificate found in PEM contents."); - } - - List result = new ArrayList(); - int offset = 0; - while (true) { - if (!matcher.find(offset)) { - break; - } - byte[] certBytes = _base64.decode(matcher.group(1)); - ByteArrayInputStream certStream = new ByteArrayInputStream(certBytes); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certStream); - certStream.close(); - - result.add(x509Certificate); - offset = matcher.end(); - } - - return result; - } - - /** - * Verify a RSA key pair with a simple encrypt/decrypt test. - * - * @throws NoSuchPaddingException - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws BadPaddingException - * @throws IllegalBlockSizeException - */ - private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmException, NoSuchPaddingException, - InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - // Validate algorithm is RSA - Assert.assertTrue(keyPair.getPublic().getAlgorithm().equals(ALGO_RSA)); - Assert.assertTrue(keyPair.getPrivate().getAlgorithm().equals(ALGO_RSA)); - - // Generate an array of 10 random bytes - byte[] plainData = new byte[10]; - Random random = new Random(); - random.nextBytes(plainData); - - // Encrypt using the public key - Cipher encryptCipher = Cipher.getInstance(ALGO_RSA); - encryptCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); - byte[] encryptedData = encryptCipher.doFinal(plainData); - - // Decrypt using the private key - Cipher decryptCipher = Cipher.getInstance(ALGO_RSA); - decryptCipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); - byte[] decryptedData = decryptCipher.doFinal(encryptedData); - - // Validate plainData is equal to decryptedData - Assert.assertArrayEquals(plainData, decryptedData); - } - - private String toHexString(byte[] x5t) { - - if(x5t == null) - return ""; - - StringBuilder hexString = new StringBuilder(); - for (int i = 0; i < x5t.length; i++) { - String hex = Integer.toHexString(0xFF & x5t[i]); - if (hex.length() == 1) { - hexString.append('0'); - } - hexString.append(hex); - } - - return hexString.toString().replace("-", ""); - } + return hexString.toString().replace("-", ""); + } + + private void validateCertificateBundle(CertificateBundle certificateBundle, CertificatePolicy certificatePolicy) { + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.keyIdentifier()); + Assert.assertNotNull(certificateBundle.secretIdentifier()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); + + if (certificatePolicy != null) { + Assert.assertNotNull(certificateBundle.policy()); + Assert.assertNotNull(certificateBundle.policy().issuerReference()); + Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); + if(certificatePolicy.issuerReference() != null) { + Assert.assertTrue(certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificatePolicy.issuerReference().name())); + } + } + } + + private X509Certificate loadCerToX509Certificate(CertificateBundle certificateBundle) throws CertificateException, IOException { + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + return x509Certificate; + } + + private void validateCertificateIssuer(IssuerBundle expecred, IssuerBundle actual) { + Assert.assertNotNull(actual); + Assert.assertNotNull(actual.provider()); + Assert.assertTrue(actual.provider().equals(expecred.provider())); + + Assert.assertNotNull(actual.credentials()); + Assert.assertNotNull(actual.credentials().accountId()); + Assert.assertTrue(actual.credentials().accountId().equals(expecred.credentials().accountId())); + Assert.assertNull(actual.credentials().password()); + + Assert.assertNotNull(actual.organizationDetails()); + } + + private void validateCertificateKeyInKeyStore(KeyStore keyStore, X509Certificate x509Certificate, String secretPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + } + + private void validateCertificateIssuer(IssuerBundle issuer, String issuerName) { + Assert.assertNotNull(issuer); + Assert.assertNotNull(issuer.issuerIdentifier()); + Assert.assertNotNull(issuer.issuerIdentifier().name()); + Assert.assertTrue(issuer.issuerIdentifier().name().equalsIgnoreCase(issuerName)); + } + + private KeyStore loadSecretToKeyStore(SecretBundle secret, String secretPassword) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + return keyStore; + } + + private void validatePem(CertificateBundle certificateBundle, String subjectName) throws CertificateException, IOException, KeyVaultErrorException, IllegalArgumentException, InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + String secretValue = secret.value(); + + // Extract private key from PEM + PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); + Assert.assertNotNull(secretPrivateKey); + + // Extract certificates from PEM + List certificates = extractCertificatesFromPemContents(secretValue); + Assert.assertNotNull(certificates); + Assert.assertTrue(certificates.size() == 1); + + // has the public key corresponding to the private key. + X509Certificate secretCertificate = certificates.get(0); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 08ff519858b73..f227d9f5ca3cb 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -48,6 +48,7 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; @@ -64,15 +65,30 @@ public void transparentAuthentication() throws Exception { // Create a key on a vault. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", null); + Map tags = new HashMap(); + tags.put("foo", "baz"); + List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); + KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest + .Builder(getVaultUri(), KEY_NAME, "RSA") + .withAttributes(attribute) + .withKeyOperations(keyOps) + .withKeySize(2048) + .withTags(tags) + .build()).getBody(); + + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", keyOps, attribute); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null, null); } } @@ -92,13 +108,24 @@ public void importKeyOperation() throws Exception { } private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) throws Exception { + KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + Map tags = new HashMap(); + tags.put("foo", "baz"); + JsonWebKey importedJwk = keyBundle.key(); KeyBundle importResultBundle = keyVaultClient.importKey( - new ImportKeyRequest - .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) - .withHsm(importToHardware) - .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps()); + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) + .withHsm(importToHardware) + .withAttributes(attribute) + .withTags(tags) + .build()).getBody(); + + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -151,7 +178,7 @@ public void crudOperations() throws Exception { { // Create key createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); } // Key identifier. @@ -192,9 +219,9 @@ public void crudOperations() throws Exception { // First we create a bundle with the modified attributes. createdBundle.attributes().withExpires(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2050)); + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); List key_ops = Arrays.asList("encrypt", "decrypt"); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -203,12 +230,12 @@ public void crudOperations() throws Exception { // Perform the operation. KeyBundle updatedBundle = keyVaultClient.updateKey( - new UpdateKeyRequest - .Builder(createdBundle.key().kid()) - .withKeyOperations(key_ops) - .withAttributes(createdBundle.attributes()) - .withTags(createdBundle.tags()) - .build()).getBody(); + new UpdateKeyRequest + .Builder(createdBundle.key().kid()) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); compareKeyBundles(createdBundle, updatedBundle); @@ -220,24 +247,24 @@ public void crudOperations() throws Exception { // Update key using vault and key name. // First we create a bundle with the modified attributes. - createdBundle.attributes().withNotBefore(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2000)); + createdBundle.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); List key_ops = Arrays.asList("sign", "verify"); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.withTags(tags); - // Perform the operation. + // Perform the operation. KeyBundle updatedBundle = keyVaultClient.updateKey( - new UpdateKeyRequest - .Builder(getVaultUri(), KEY_NAME) - .withKeyOperations(key_ops) - .withAttributes(createdBundle.attributes()) - .withTags(createdBundle.tags()) - .build()).getBody(); + new UpdateKeyRequest + .Builder(getVaultUri(), KEY_NAME) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); compareKeyBundles(createdBundle, updatedBundle); } @@ -251,7 +278,7 @@ public void crudOperations() throws Exception { { // Expects a key not found try { - keyVaultClient.getKey(keyId.baseIdentifier()); + keyVaultClient.getKey(keyId.baseIdentifier()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error()); Assert.assertEquals("KeyNotFound", e.getBody().error().code()); @@ -268,9 +295,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") - .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + .build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); } // Creates a backup of key. @@ -316,7 +343,7 @@ public void listKeys() throws Exception { } } - PagedList listResult = keyVaultClient.getKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -330,14 +357,14 @@ public void listKeys() throws Exception { Assert.assertEquals(0, keys.size()); for (String name : toDelete) { - try{ - keyVaultClient.deleteKey(getVaultUri(), name); - } - catch(KeyVaultErrorException e){ - // Ignore forbidden exception for certificate keys that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) - throw e; - } + try{ + keyVaultClient.deleteKey(getVaultUri(), name); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate keys that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } } } @@ -364,20 +391,13 @@ public void listKeyVersions() throws Exception { } } - PagedList listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); //TODO bug: Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME).getBody(); + listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); - for (;;) { - for (KeyItem item : listResult) { - keys.remove(item.kid()); - } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { - break; - } - keyVaultClient.getKeyVersionsNext(nextLink).getBody(); + for (KeyItem item : listResult) { + keys.remove(item.kid()); } Assert.assertEquals(0, keys.size()); @@ -400,7 +420,7 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -409,7 +429,7 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -432,7 +452,7 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -441,7 +461,7 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -468,7 +488,7 @@ public void signVerifyOperations() throws Exception { // Using kid WO version { - result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); signature = result.result(); verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); @@ -495,18 +515,18 @@ private static JsonWebKey importTestKey() throws Exception { key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); keyBundle = keyVaultClient.importKey( - new ImportKeyRequest - .Builder(getVaultUri(), KEY_NAME, key) - .withHsm(false) - .build()).getBody(); + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, key) + .withHsm(false) + .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null, null); return keyBundle.key(); } private static KeyPair getTestKeyMaterial() throws Exception { - return getWellKnownKey(); + return getWellKnownKey(); } private static KeyPair getWellKnownKey() throws Exception { @@ -526,7 +546,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, KeyAttributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( @@ -540,16 +560,18 @@ private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String } Assert.assertNotNull("\"created\" should not be null.", bundle.attributes().created()); Assert.assertNotNull("\"updated\" should not be null.", bundle.attributes().updated()); + + compareAttributes(attributes, bundle.attributes()); } private void compareKeyBundles(KeyBundle expected, KeyBundle actual) { - Assert.assertTrue(expected.key().toString().equals(actual.key().toString())); - Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); - Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); - Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); - if(expected.tags() != null || actual.tags() != null) - Assert.assertTrue(expected.tags().equals(actual.tags())); - } + Assert.assertTrue(expected.key().toString().equals(actual.key().toString())); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java index be6906865cd25..2ebb0c791a977 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -25,6 +25,7 @@ import org.junit.After; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -37,6 +38,7 @@ import com.microsoft.aad.adal4j.ClientCredential; import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; +import com.microsoft.azure.keyvault.models.Attributes; public class KeyVaultClientIntegrationTestBase { @@ -95,7 +97,7 @@ public String doAuthenticate(String authorization, String resource, String scope private static AuthenticationResult getAccessToken(String authorization, String resource) throws Exception { String clientId = System.getenv("arm.clientid"); - + if (clientId == null) { throw new Exception("Please inform arm.clientid in the environment settings."); } @@ -136,6 +138,14 @@ private static AuthenticationResult getAccessToken(String authorization, String return result; } + protected static void compareAttributes(Attributes expectedAttributes, Attributes actualAttribute) { + if(expectedAttributes != null) { + Assert.assertEquals(expectedAttributes.enabled(), actualAttribute.enabled()); + Assert.assertEquals(expectedAttributes.expires(), actualAttribute.expires()); + Assert.assertEquals(expectedAttributes.notBefore(), actualAttribute.notBefore()); + } + } + protected static ObjectWriter jsonWriter; protected static ObjectReader jsonReader; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index aac73d56cf5c1..7378e9ebc9bee 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.SecretIdentifier; @@ -45,17 +46,30 @@ public void transparentAuthentication() throws Exception { // Create a secret on a vault. { - SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + SecretAttributes attributes = (SecretAttributes) new SecretAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + Map tags = new HashMap(); + tags.put("foo", "baz"); + String contentType = "contentType"; + + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest + .Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE) + .withAttributes(attributes) + .withContentType(contentType) + .withTags(tags) + .build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, contentType, attributes); } // Create a secret on a different vault. Secret Vault Data Plane returns // 401, which must be transparently handled by KeyVaultCredentials. { - SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null); + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } } @@ -63,12 +77,12 @@ public void transparentAuthentication() throws Exception { @Test public void crudOperations() throws Exception { - SecretBundle secret; + SecretBundle secret; { // Create secret - secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } // Secret identifier. @@ -76,47 +90,47 @@ public void crudOperations() throws Exception { { // Get secret using kid WO version - SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); compareSecrets(secret, readBundle); } { // Get secret using full kid as defined in the bundle - SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); compareSecrets(secret, readBundle); } { // Get secret using vault and secret name. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); compareSecrets(secret, readBundle); } { // Get secret using vault, secret name and version. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); compareSecrets(secret, readBundle); } { - secret.attributes().withExpires(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2050)); - Map tags = new HashMap(); - tags.put("foo", "baz"); - secret.withTags(tags) - .withContentType("application/html") - .withValue(null); // The value doesn't get updated - + secret.attributes().withExpires(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); + Map tags = new HashMap(); + tags.put("foo", "baz"); + secret.withTags(tags) + .withContentType("application/html") + .withValue(null); // The value doesn't get updated + // Update secret using the kid as defined in the bundle SecretBundle updatedSecret = keyVaultClient.updateSecret( - new UpdateSecretRequest - .Builder(secret.id()) - .withContentType(secret.contentType()) - .withAttributes(secret.attributes()) - .withTags(secret.tags()) - .build()).getBody(); + new UpdateSecretRequest + .Builder(secret.id()) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); compareSecrets(secret, updatedSecret); // Subsequent operations must use the updated bundle for comparison. @@ -126,37 +140,42 @@ public void crudOperations() throws Exception { { // Update secret using vault and secret name. - secret.attributes().withNotBefore(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2000)); - Map tags = new HashMap(); - tags.put("rex", "woof"); - secret.withTags(tags) - .withContentType("application/html"); + secret.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); + Map tags = new HashMap(); + tags.put("rex", "woof"); + secret.withTags(tags) + .withContentType("application/html"); // Perform the operation. SecretBundle updatedSecret = keyVaultClient.updateSecret( - new UpdateSecretRequest - .Builder(getVaultUri(), SECRET_NAME) - .withContentType(secret.contentType()) - .withAttributes(secret.attributes()) - .withTags(secret.tags()) - .build()).getBody(); + new UpdateSecretRequest + .Builder(getVaultUri(), SECRET_NAME) + .withVersion(secret.secretIdentifier().version()) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); compareSecrets(secret, updatedSecret); + validateSecret(updatedSecret, + secret.secretIdentifier().vault(), + secret.secretIdentifier().name(), + null, secret.contentType(), secret.attributes()); } { // Delete secret - SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); compareSecrets(secret, deleteBundle); } { // Expects a secret not found try { - keyVaultClient.getSecret(secretId.baseIdentifier()); + keyVaultClient.getSecret(secretId.baseIdentifier()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error().code()); Assert.assertEquals("SecretNotFound", e.getBody().error().code()); @@ -165,7 +184,7 @@ public void crudOperations() throws Exception { } - @Test + @Test public void listSecrets() throws Exception { HashSet secrets = new HashSet(); @@ -174,7 +193,7 @@ public void listSecrets() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); SecretIdentifier id = new SecretIdentifier(secret.id()); secrets.add(id.baseIdentifier()); break; @@ -190,7 +209,7 @@ public void listSecrets() throws Exception { } } - PagedList listResult = keyVaultClient.getSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -204,14 +223,14 @@ public void listSecrets() throws Exception { Assert.assertEquals(0, secrets.size()); for (String secretName : toDelete) { - try{ - keyVaultClient.deleteSecret(getVaultUri(), secretName); - } - catch(KeyVaultErrorException e){ - // Ignore forbidden exception for certificate secrets that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) - throw e; - } + try{ + keyVaultClient.deleteSecret(getVaultUri(), secretName); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate secrets that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } } } @@ -224,7 +243,7 @@ public void listSecretVersions() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); secrets.add(secret.id()); break; } catch (KeyVaultErrorException e) { @@ -239,19 +258,12 @@ public void listSecretVersions() throws Exception { } } - PagedList listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME).getBody(); - for (;;) { - for (SecretItem item : listResult) { - secrets.remove(item.id()); - } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { - break; - } - keyVaultClient.getSecretVersionsNext(nextLink).getBody(); + listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); + for (SecretItem item : listResult) { + secrets.remove(item.id()); } Assert.assertEquals(0, secrets.size()); @@ -259,7 +271,7 @@ public void listSecretVersions() throws Exception { keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); } - private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType) throws Exception { + private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, SecretAttributes attributes) throws Exception { String prefix = vault + "/secrets/" + name + "/"; String id = secret.id(); Assert.assertTrue( // @@ -271,17 +283,19 @@ private static void validateSecret(SecretBundle secret, String vault, String nam } Assert.assertNotNull("\"created\" should not be null.", secret.attributes().created()); Assert.assertNotNull("\"updated\" should not be null.", secret.attributes().updated()); + + compareAttributes(attributes, secret.attributes()); } private void compareSecrets(SecretBundle expected, SecretBundle actual) { - Assert.assertEquals(expected.contentType(), actual.contentType()); - Assert.assertEquals(expected.id(), actual.id()); - Assert.assertEquals(expected.value(), actual.value()); - Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); - Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); - Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); - if(expected.tags() != null || actual.tags() != null) - Assert.assertTrue(expected.tags().equals(actual.tags())); - } + Assert.assertEquals(expected.contentType(), actual.contentType()); + Assert.assertEquals(expected.id(), actual.id()); + Assert.assertEquals(expected.value(), actual.value()); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } } From 764c5909f7d6ad7ec47fa387cac7b16d5e06dbe2 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 15 Aug 2016 16:35:42 -0700 Subject: [PATCH 02/47] Java Cryptography Test Case update --- .../azure/keyvault/cryptography/RsaKey.java | 19 + .../test/AesCbcBCProviderTest.java | 120 +---- .../test/AesCbcHmacShaBCProviderTest.java | 17 + .../cryptography/test/AesCbcHmacShaTest.java | 59 +-- ...faultProviderTest.java => AesCbcTest.java} | 61 +-- .../test/AesKwBCProviderTest.java | 261 +---------- ...efaultProviderTest.java => AesKwTest.java} | 135 ++---- .../test/RsaKeyBCProviderTest.java | 16 + .../cryptography/test/RsaKeyTest.java | 30 +- .../test/SymmetricKeyBCProviderTest.java | 326 +------------- .../test/SymmetricKeyBaseTest.java | 423 ++++++++++++++++++ .../test/SymmetricKeyDefaultProviderTest.java | 399 +---------------- 12 files changed, 576 insertions(+), 1290 deletions(-) create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{AesCbcDefaultProviderTest.java => AesCbcTest.java} (61%) rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{AesKwDefaultProviderTest.java => AesKwTest.java} (60%) create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index d8fe513c31c7b..b56511a99205d 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -22,6 +22,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import java.security.interfaces.RSAPublicKey; import org.apache.commons.lang3.NotImplementedException; @@ -52,6 +53,8 @@ public RsaKey(String kid) throws NoSuchAlgorithmException { public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { + this(kid, keySize, null); + /* if (Strings.isNullOrWhiteSpace(kid)) { throw new IllegalArgumentException("kid"); } @@ -62,6 +65,22 @@ public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { _keyPair = generator.generateKeyPair(); _kid = kid; + */ + } + + public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithmException { + + if (Strings.isNullOrWhiteSpace(kid)) { + throw new IllegalArgumentException("kid"); + } + + final KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", provider); + + generator.initialize(keySize); + + _keyPair = generator.generateKeyPair(); + _kid = kid; + } public RsaKey(String kid, KeyPair keyPair) { diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java index c7d9c96b36702..043b2b54808be 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java @@ -1,132 +1,18 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; -import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; - -public class AesCbcBCProviderTest { - private Provider _provider = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class AesCbcBCProviderTest extends AesCbcTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } } - @After - public void tearDown() throws Exception { - } - - @Test - public void testAes128Cbc() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at - // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we - // actually take the realCEK from the second half of the CEK data below - // in order - // that the encrypted result will match the ED value from the example. - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; - - Aes128Cbc algo = new Aes128Cbc(); - byte[] realCEK = new byte[128 >> 3]; - byte[] encrypted = null; - - // Take the second half of CEK as the AES key - System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); - - ICryptoTransform encryptor = null; - try { - encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); - } - - try { - encrypted = encryptor.doFinal(PLAIN); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - ICryptoTransform decryptor = null; - try { - decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(PLAIN, decrypted); - assertArrayEquals(ED, encrypted); - } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java new file mode 100644 index 0000000000000..5c7e07a273474 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java @@ -0,0 +1,17 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import java.security.Provider; + +import org.junit.Before; + +public class AesCbcHmacShaBCProviderTest extends AesCbcHmacShaTest { + + @Before + public void setUp() throws Exception { + try { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java index 211f3116bd0bc..4783152229b1d 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -3,13 +3,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; +import java.security.Provider; import org.junit.After; import org.junit.AfterClass; @@ -22,6 +16,8 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; public class AesCbcHmacShaTest { + + private Provider _provider = null; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -33,11 +29,16 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { + setProvider(null); } @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = null; + } @Test public void testAes128CbcHmacSha256() { @@ -59,15 +60,9 @@ public void testAes128CbcHmacSha256() { byte[] tag = null; try { - transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH, _provider); + } catch (Exception e) { + fail(e.getMessage()); } try { @@ -77,41 +72,23 @@ public void testAes128CbcHmacSha256() { assertArrayEquals(ED, encrypted); assertArrayEquals(TAG, tag); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, AUTH); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + decryptor = algo.CreateDecryptor(CEK, IV, AUTH, _provider); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java similarity index 61% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 947ef7cddfc74..53286b5471690 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -3,13 +3,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; +import java.security.Provider; import org.junit.After; import org.junit.AfterClass; @@ -20,8 +14,10 @@ import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; -public class AesCbcDefaultProviderTest { +public class AesCbcTest { + private Provider _provider = null; + @BeforeClass public static void setUpBeforeClass() throws Exception { } @@ -32,11 +28,16 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { + setProvider(null); } @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void testAes128Cbc() { @@ -63,54 +64,30 @@ public void testAes128Cbc() { ICryptoTransform encryptor = null; try { - encryptor = algo.CreateEncryptor(realCEK, IV, null); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); } try { encrypted = encryptor.doFinal(PLAIN); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(realCEK, IV, null); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java index e1e7ce50c53f7..480db6f2e8966 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java @@ -18,272 +18,17 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; - -public class AesKwBCProviderTest { - - private Provider _provider = null; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class AesKwBCProviderTest extends AesKwTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } } - - @After - public void tearDown() throws Exception { - } - - @Test - public void KeyVault_AesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - AesKw kw = new AesKw128(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - @Test - public void KeyVault_AesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - AesKw kw = new AesKw192(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - @Test - public void KeyVault_AesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - AesKw kw = new AesKw256(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java similarity index 60% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java index a9b4495e9313a..d22e2107ce6ef 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java @@ -21,15 +21,10 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -42,7 +37,10 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; -public class AesKwDefaultProviderTest { +public class AesKwTest { + + // Always null for the default provider + private Provider _provider = null; private static boolean hasUnlimitedCrypto() { try { @@ -68,8 +66,9 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - // Always null for the default provider - private Provider _provider = null; + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void KeyVault_AesKw128() { @@ -84,28 +83,16 @@ public void KeyVault_AesKw128() { try { encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } byte[] encrypted = null; try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -115,28 +102,16 @@ public void KeyVault_AesKw128() { try { decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -161,17 +136,13 @@ public void KeyVault_AesKw192() { ICryptoTransform encryptor = null; try { - encryptor = kw.CreateEncryptor(KEK); + encryptor = kw.CreateEncryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -179,14 +150,8 @@ public void KeyVault_AesKw192() { try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -196,16 +161,12 @@ public void KeyVault_AesKw192() { ICryptoTransform decryptor = null; try { - decryptor = kw.CreateDecryptor(KEK); + decryptor = kw.CreateDecryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -213,14 +174,8 @@ public void KeyVault_AesKw192() { try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -246,16 +201,12 @@ public void KeyVault_AesKw256() { ICryptoTransform encryptor = null; try { - encryptor = kw.CreateEncryptor(KEK); + encryptor = kw.CreateEncryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -263,14 +214,8 @@ public void KeyVault_AesKw256() { try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -280,17 +225,13 @@ public void KeyVault_AesKw256() { ICryptoTransform decryptor = null; try { - decryptor = kw.CreateDecryptor(KEK); + decryptor = kw.CreateDecryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -298,14 +239,8 @@ public void KeyVault_AesKw256() { try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java new file mode 100644 index 0000000000000..c9a9c70acaeb3 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java @@ -0,0 +1,16 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import java.security.Provider; +import org.junit.Before; + +public class RsaKeyBCProviderTest extends RsaKeyTest { + + @Before + public void setUp() throws Exception { + try { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index e41ceaa460ab6..0d9fafb68ebbf 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -5,7 +5,7 @@ import java.math.BigInteger; import java.security.KeyFactory; import java.security.KeyPair; -import java.security.KeyPairGenerator; +import java.security.Provider; import java.security.spec.KeySpec; import java.security.spec.RSAPrivateCrtKeySpec; import java.security.spec.RSAPublicKeySpec; @@ -24,6 +24,8 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; public class RsaKeyTest { + + private Provider _provider = null; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -40,6 +42,10 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void testEncryptDecryptRsa15() throws Exception { @@ -179,24 +185,24 @@ public void testWrapUnwrapDefaultAlgorithm() throws Exception { assertArrayEquals(plaintext, decrypted); } - private static KeyPair getTestKeyMaterial() throws Exception { + private KeyPair getTestKeyMaterial() throws Exception { return getWellKnownKey(); } - private static KeyPair getWellKnownKey() throws Exception { - BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); - BigInteger publicExponent = new BigInteger("65537"); + private KeyPair getWellKnownKey() throws Exception { + BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); + BigInteger publicExponent = new BigInteger("65537"); BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); - BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); - BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); - BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); - BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); - BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); + BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); + BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); + BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); + BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); + BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); - KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); + KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + KeyFactory keyFactory = _provider == null ? KeyFactory.getInstance("RSA") : KeyFactory.getInstance("RSA", _provider); return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java index ba86f68eeff90..a6a7936c9fa65 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java @@ -18,337 +18,17 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import java.util.concurrent.ExecutionException; - -import org.apache.commons.lang3.tuple.Pair; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.SymmetricKey; - -public class SymmetricKeyBCProviderTest { - - private Provider _provider = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class SymmetricKeyBCProviderTest extends SymmetricKeyBaseTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { - throw new RuntimeException(ex.getMessage()); - } - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSymmetricKeyAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); } } - - @Test - public void testSymmetricKeyAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A128KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals( "A192KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A256KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java new file mode 100644 index 0000000000000..36b6bf464aa16 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java @@ -0,0 +1,423 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.util.concurrent.ExecutionException; + +import javax.crypto.Cipher; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; + +public abstract class SymmetricKeyBaseTest { + + private Provider _provider = null; + + private static boolean hasUnlimitedCrypto() { + try { + return Cipher.getMaxAllowedKeyLength("RC5") >= 256; + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public abstract void setUp() throws Exception; + + @After + public void tearDown() throws Exception { + } + + protected void setProvider(Provider provider) { + _provider = provider; + } + + @Test + public void testSymmetricKeyAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals("A128KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals( "A192KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals("A256KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java index 9365b416988e3..384961ad2e643 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java @@ -18,407 +18,12 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.concurrent.ExecutionException; - -import javax.crypto.Cipher; - -import org.apache.commons.lang3.tuple.Pair; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.SymmetricKey; -public class SymmetricKeyDefaultProviderTest { - - private static boolean hasUnlimitedCrypto() { - try { - return Cipher.getMaxAllowedKeyLength("RC5") >= 256; - } catch (NoSuchAlgorithmException e) { - return false; - } - } - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class SymmetricKeyDefaultProviderTest extends SymmetricKeyBaseTest { @Before public void setUp() throws Exception { + super.setProvider(null); } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSymmetricKeyAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw192() { - - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A128KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - - encrypted = result.getLeft(); - algorithm = result.getRight(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertEquals( "A192KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertEquals("A256KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - } From 1d817fc767cf0f65dfeea35e0945f913f8818819 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Fri, 19 Aug 2016 14:11:52 -0700 Subject: [PATCH 03/47] RS256 Signature support. --- .../microsoft/azure/keyvault/core/IKey.java | 2 +- azure-keyvault-cryptography/pom.xml | 10 + .../keyvault/cryptography/Algorithm.java | 2 +- .../cryptography/AlgorithmResolver.java | 30 +- .../azure/keyvault/cryptography/RsaKey.java | 106 ++++-- .../azure/keyvault/cryptography/Strings.java | 20 +- .../cryptography/algorithms/Rs256.java | 126 +++++++ .../cryptography/algorithms/RsaSignature.java | 215 +++++++++++ .../test/Base64UrlDeserializer.java | 43 +++ .../test/Base64UrlSerializer.java | 47 +++ .../cryptography/test/JsonWebKey.java | 346 ++++++++++++++++++ .../cryptography/test/JsonWebKeyType.java | 40 ++ .../cryptography/test/RsaKeyTest.java | 207 ++++------- .../keyvault/extensions/KeyVaultKey.java | 3 +- .../azure/keyvault/extensions/Strings.java | 8 +- 15 files changed, 1020 insertions(+), 185 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index 264024d42b153..6cf69f7002aa9 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -153,7 +153,7 @@ public interface IKey extends Closeable { * The signature to verify * @param algorithm * The algorithm to use, must be provided - * @return A ListenableFuture containing a boolean result + * @return A ListenableFuture containing the signature and the algorithm used. * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException; diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 17b3766ef8184..5b7688e30a0db 100644 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -59,5 +59,15 @@ azure-keyvault-core ${project.version} + + com.fasterxml.jackson.core + jackson-databind + test + + + commons-codec + commons-codec + test + diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index 810a6dfa4fb51..bfdcf9e54e790 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -23,7 +23,7 @@ public abstract class Algorithm { private final String _name; protected Algorithm(String name) { - if (Strings.isNullOrEmpty(name)) { + if (Strings.isNullOrWhiteSpace(name)) { throw new IllegalArgumentException("name"); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index 1eacaad75e0c3..c794b02867779 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -30,6 +30,7 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; @@ -53,31 +54,38 @@ public class AlgorithmResolver { Default.put(Rsa15.AlgorithmName, new Rsa15()); Default.put(RsaOaep.AlgorithmName, new RsaOaep()); - // Default.put( Rs256.AlgorithmName, new Rs256() ); + Default.put( Rs256.AlgorithmName, new Rs256() ); // Default.put( RsNull.AlgorithmName, new RsNull() ); } private final ConcurrentMap _algorithms = new ConcurrentHashMap(); - /// - /// Returns the implementation for an algorithm name - /// - /// The algorithm name - /// + /** + * Returns the implementation for an algorithm name. + * + * @param algorithmName The algorithm name. + * @return The implementation for the algorithm or null. + */ public Algorithm get(String algorithmName) { return _algorithms.get(algorithmName); } + /** + * Add/Update a named algorithm implementation. + * + * @param algorithmName The algorithm name. + * @param provider The implementation of the algorithm. + */ public void put(String algorithmName, Algorithm provider) { _algorithms.put(algorithmName, provider); } - /// - /// Removes an algorithm from the resolver - /// - /// The algorithm name + /** + * Remove a named algorithm implementation. + * + * @param algorithmName The algorithm name + */ public void remove(String algorithmName) { _algorithms.remove(algorithmName); } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index b56511a99205d..4548a883c17fd 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -25,13 +25,13 @@ import java.security.Provider; import java.security.interfaces.RSAPublicKey; -import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; import com.microsoft.azure.keyvault.cryptography.Strings; @@ -44,28 +44,16 @@ public static int getDefaultKeySize() { return RsaKey.KeySize2048; } - private final String _kid; - private final KeyPair _keyPair; + private final String _kid; + private final KeyPair _keyPair; + private final Provider _provider; public RsaKey(String kid) throws NoSuchAlgorithmException { this(kid, getDefaultKeySize()); } public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { - this(kid, keySize, null); - /* - if (Strings.isNullOrWhiteSpace(kid)) { - throw new IllegalArgumentException("kid"); - } - - final KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); - - generator.initialize(keySize); - - _keyPair = generator.generateKeyPair(); - _kid = kid; - */ } public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithmException { @@ -78,12 +66,16 @@ public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithm generator.initialize(keySize); - _keyPair = generator.generateKeyPair(); - _kid = kid; - + _kid = kid; + _keyPair = generator.generateKeyPair(); + _provider = provider; } public RsaKey(String kid, KeyPair keyPair) { + this(kid, keyPair, null); + } + + public RsaKey(String kid, KeyPair keyPair, Provider provider) { if (Strings.isNullOrWhiteSpace(kid)) { throw new IllegalArgumentException("kid"); @@ -96,9 +88,10 @@ public RsaKey(String kid, KeyPair keyPair) { if (keyPair.getPublic() == null || !(keyPair.getPublic() instanceof RSAPublicKey)) { throw new IllegalArgumentException("keyPair"); } - - _keyPair = keyPair; - _kid = kid; + + _kid = kid; + _keyPair = keyPair; + _provider = provider; } @Override @@ -113,8 +106,7 @@ public String getDefaultKeyWrapAlgorithm() { @Override public String getDefaultSignatureAlgorithm() { - // TODO: Signature Processing - return null; + return Rs256.AlgorithmName; } @Override @@ -146,7 +138,7 @@ public ListenableFuture decryptAsync(final byte[] ciphertext, final byte ListenableFuture result; try { - transform = algo.CreateDecryptor(_keyPair); + transform = algo.CreateDecryptor(_keyPair, _provider); result = Futures.immediateFuture(transform.doFinal(ciphertext)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -176,7 +168,7 @@ public ListenableFuture> encryptAsync(final byte[ ListenableFuture> result; try { - transform = algo.CreateEncryptor(_keyPair); + transform = algo.CreateEncryptor(_keyPair, _provider); result = Futures.immediateFuture(Triple.of(transform.doFinal(plaintext), (byte[]) null, algorithmName)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -206,7 +198,7 @@ public ListenableFuture> wrapKeyAsync(final byte[] key, fin ListenableFuture> result; try { - transform = algo.CreateEncryptor(_keyPair); + transform = algo.CreateEncryptor(_keyPair, _provider); result = Futures.immediateFuture(Pair.of(transform.doFinal(key), algorithmName)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -240,7 +232,7 @@ public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final ListenableFuture result; try { - transform = algo.CreateDecryptor(_keyPair); + transform = algo.CreateDecryptor(_keyPair, _provider); result = Futures.immediateFuture(transform.doFinal(encryptedKey)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -250,13 +242,63 @@ public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final } @Override - public ListenableFuture> signAsync(final byte[] digest, final String algorithm) { - return Futures.immediateFailedFuture(new NotImplementedException("signAsync is not currently supported")); + public ListenableFuture> signAsync(final byte[] digest, final String algorithm) throws NoSuchAlgorithmException { + + if (digest == null) { + throw new IllegalArgumentException("encryptedKey "); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + // Interpret the requested algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricSignatureAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + Rs256 algo = (Rs256)baseAlgorithm; + + Rs256.Rs256Signer signer = algo.createSigner(_keyPair); + + try { + return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); + } catch (Exception e) { + return Futures.immediateFailedFuture(e); + } } @Override - public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { - return Futures.immediateFailedFuture(new NotImplementedException("verifyAsync is not currently supported")); + public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException { + + if (digest == null) { + throw new IllegalArgumentException("encryptedKey "); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + // Interpret the requested algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricSignatureAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + Rs256 algo = (Rs256)baseAlgorithm; + + Rs256.Rs256Verifier signer = algo.createVerifier(_keyPair); + + try { + return Futures.immediateFuture(signer.verify(signature, digest)); + } catch (Exception e) { + return Futures.immediateFailedFuture(e); + } } @Override diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java index c948e8e3453ab..c6cf7244a1532 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java @@ -18,19 +18,29 @@ package com.microsoft.azure.keyvault.cryptography; -import com.microsoft.azure.keyvault.cryptography.Strings; - -public class Strings { - +public final class Strings { + + /** + * Determines whether the parameter string is either null or empty. + * + * @param arg The string to be checked. + * @return true if the string is null or empty. + */ public static boolean isNullOrEmpty(String arg) { - if (arg == null || arg.isEmpty()) { + if (arg == null || arg.length() == 0) { return true; } return false; } + /** + * Determines whether the parameter string is null, empty or whitespace. + * + * @param arg The string to be checked. + * @return true if the string is null, empty or whitespace. + */ public static boolean isNullOrWhiteSpace(String arg) { if (Strings.isNullOrEmpty(arg) || arg.trim().isEmpty()) { diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java new file mode 100644 index 0000000000000..750a02f529ea7 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -0,0 +1,126 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +/** + * + */ +public class Rs256 extends RsaSignature { + + static final String RsaNone = "RSA/ECB/PKCS1Padding"; + + public class Rs256Signer { + + private final KeyPair _keyPair; + private final int _emLen; + + private final BigInteger _n; + + Rs256Signer(KeyPair keyPair) { + + _keyPair = keyPair; + _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + + _emLen = getOctetLength( _n.bitLength() ); + } + + public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // Signing isn't just a case of encrypting the digest, there is much more to do. + // For details of the algorithm, see https://tools.ietf.org/html/rfc3447#section-8.2 + + // Construct the encoded message + byte[] EM = EMSA_PKCS1_V1_5_ENCODE(digest, _emLen, "SHA-256"); + + // Convert to integer message + BigInteger s = OS2IP(EM); + + // RSASP1(s) + s = RSASP1((RSAPrivateKey)_keyPair.getPrivate(), s); + + // Convert to octet sequence + return I2OSP(s, getOctetLength( _n.bitLength() ) ); + } + } + + public class Rs256Verifier { + + private final KeyPair _keyPair; + private final BigInteger _n; + private final int _emLength; + + Rs256Verifier(KeyPair keyPair) { + _keyPair = keyPair; + _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + _emLength = getOctetLength( _n.bitLength() ); + } + + public boolean verify(final byte[] signature, final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + if ( signature.length != getOctetLength( _n.bitLength() ) ) { + throw new IllegalBlockSizeException(); + } + + // Convert to integer signature + BigInteger s = OS2IP(signature); + + // Convert integer message + BigInteger m = RSAVP1((RSAPublicKey)_keyPair.getPublic(), s); + + + byte[] EM = I2OSP(m, getOctetLength( _n.bitLength() ) ); + byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE(digest, _emLength, "SHA-256"); + + // TODO: Need constant time compare + if ( EM.length != EM2.length ) + return false; + + for ( int i = 0; i < digest.length; i++ ) { + if ( EM[i] != EM2[i] ) + return false; + } + + return true; + } + } + + public final static String AlgorithmName = "RS256"; + + public Rs256() { + super(AlgorithmName); + } + + public Rs256Signer createSigner(KeyPair keyPair) { + + return new Rs256Signer(keyPair); + } + + public Rs256Verifier createVerifier(KeyPair keyPair) { + return new Rs256Verifier(keyPair); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java new file mode 100644 index 0000000000000..a9ac4d4559cbb --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -0,0 +1,215 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.Arrays; + +import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; +import com.microsoft.azure.keyvault.cryptography.Strings; + +public abstract class RsaSignature extends AsymmetricSignatureAlgorithm { + + private static final BigInteger twoFiveSix = new BigInteger("256"); + private static final byte[] sha256Prefix = new byte[] { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, (byte) 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 }; + + protected RsaSignature(String name) { + super(name); + } + + protected static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + protected static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + protected int getOctetLength(int bits) { + return ( bits % 8 > 0 ) ? bits >> 3 + 1 : bits >> 3; + } + + + /* + * See https://tools.ietf.org/html/rfc3447#section-4.2 + */ + protected BigInteger OS2IP(byte[] x) { + + if ( x == null || x.length == 0 ) { + throw new IllegalArgumentException("x"); + } + + return new BigInteger(1,x); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-4.1 + */ + protected byte[] I2OSP(BigInteger x, int xLen) { + + if ( x == null ) { + throw new IllegalArgumentException("x"); + } + + if ( xLen <= 0 ) { + throw new IllegalArgumentException("xLen"); + } + + if ( x.compareTo( twoFiveSix.pow(xLen) ) == 1 ) { + throw new IllegalArgumentException("integer too large"); + } + + byte[] bytes = x.toByteArray(); + + if ( bytes.length > xLen ) { + throw new IllegalArgumentException("integer too large"); + } + + byte[] result = new byte[xLen]; + + System.arraycopy(bytes, 0, result, xLen - bytes.length, bytes.length); + + return result; + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-5.2.1 + */ + protected BigInteger RSASP1(RSAPrivateKey K, BigInteger m) { + + if ( K == null ) { + throw new IllegalArgumentException("K"); + } + + if ( m == null ) { + throw new IllegalArgumentException("m"); + } + + BigInteger n = K.getModulus(); + BigInteger d = K.getPrivateExponent(); + + if ( m.compareTo(BigInteger.ONE) == -1 || m.compareTo(n) != -1 ) { + throw new IllegalArgumentException("message representative out of range"); + } + + return m.modPow(d, n); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-5.2.2 + */ + protected BigInteger RSAVP1(RSAPublicKey K, BigInteger s) { + + if ( K == null ) { + throw new IllegalArgumentException("K"); + } + + if ( s == null ) { + throw new IllegalArgumentException("s"); + } + BigInteger n = K.getModulus(); + BigInteger e = K.getPublicExponent(); + + if ( s.compareTo(BigInteger.ONE) == -1 || s.compareTo(n) != -1 ) { + throw new IllegalArgumentException("message representative out of range"); + } + + return s.modPow(e, n); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-9.2 + */ + protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) throws NoSuchAlgorithmException { + + // Check m + if ( m == null || m.length == 0 ) { + throw new IllegalArgumentException("m"); + } + + byte[] algorithmPrefix = null; + MessageDigest messageDigest = null; + + // Check algorithm + if ( Strings.isNullOrWhiteSpace(algorithm) ) { + throw new IllegalArgumentException("algorithm"); + } + + // Only supported algorithms + if ( algorithm.equals("SHA-256") ) { + + // Initialize prefix and digest + algorithmPrefix = sha256Prefix; + messageDigest = MessageDigest.getInstance("SHA-256"); + } else { + throw new IllegalArgumentException("algorithm"); + } + + if ( algorithmPrefix == null || messageDigest == null ) { + throw new IllegalArgumentException("initialization with arguments failed"); + } + + // Hash the message + byte[] digest = messageDigest.digest(m); + + // Construct T, the DER encoded DigestInfo structure + byte[] T = new byte[algorithmPrefix.length + digest.length]; + + System.arraycopy(algorithmPrefix, 0, T, 0, algorithmPrefix.length); + System.arraycopy(digest, 0, T, algorithmPrefix.length, digest.length); + + if ( emLen < T.length + 11 ) { + throw new IllegalArgumentException("intended encoded message length too short"); + } + + // Construct PS + byte[] PS = new byte[emLen - T.length - 3]; + + for ( int i = 0; i < PS.length; i++ ) PS[i] = (byte) 0xff; + + // Construct EM + byte[] EM = new byte[PS.length + T.length + 3]; + + EM[0] = 0x00; EM[1] = 0x01; EM[PS.length + 2] = 0x00; + + System.arraycopy(PS, 0, EM, 2, PS.length); + System.arraycopy(T, 0, EM, PS.length + 3, T.length); + + return EM; + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java new file mode 100644 index 0000000000000..8f54e8cdece21 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java @@ -0,0 +1,43 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +public class Base64UrlDeserializer extends JsonDeserializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + String text = jp.getText(); + if (text != null) { + return _base64.decode(text); + } + return null; + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java new file mode 100644 index 0000000000000..3cf15e392863d --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java @@ -0,0 +1,47 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class Base64UrlSerializer extends JsonSerializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + String text; + if (value == null) { + text = null; + } else if (value.length == 0) { + text = ""; + } else { + text = _base64.encodeAsString(value); + } + jgen.writeString(text); + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java new file mode 100644 index 0000000000000..ec65f0d6fea55 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java @@ -0,0 +1,346 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.PublicKey; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) +public class JsonWebKey { + + private String kid; + + @JsonProperty("kid") + public String getKid() { + return kid; + } + + public void setKid(String kid) { + this.kid = kid; + } + + private String kty; + + @JsonProperty("kty") + public String getKty() { + return kty; + } + + public void setKty(String kty) { + this.kty = kty; + } + + private String[] keyOps; + + @JsonProperty("key_ops") + public String[] getKeyOps() { + return keyOps; + } + + public void setKeyOps(String[] keyOps) { + this.keyOps = keyOps; + } + + private byte[] n; + + @JsonProperty("n") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getN() { + return n; + } + + public void setN(byte[] n) { + this.n = n; + } + + private byte[] e; + + @JsonProperty("e") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getE() { + return e; + } + + public void setE(byte[] e) { + this.e = e; + } + + private byte[] d; + + @JsonProperty("d") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getD() { + return d; + } + + public void setD(byte[] d) { + this.d = d; + } + + private byte[] dp; + + @JsonProperty("dp") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getDP() { + return dp; + } + + public void setDP(byte[] dp) { + this.dp = dp; + } + + private byte[] dq; + + @JsonProperty("dq") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getDQ() { + return dq; + } + + public void setDQ(byte[] dq) { + this.dq = dq; + } + + private byte[] qi; + + @JsonProperty("qi") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getQI() { + return qi; + } + + public void setQI(byte[] qi) { + this.qi = qi; + } + + private byte[] p; + + @JsonProperty("p") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getP() { + return p; + } + + public void setP(byte[] p) { + this.p = p; + } + + private byte[] q; + + @JsonProperty("q") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getQ() { + return q; + } + + public void setQ(byte[] q) { + this.q = q; + } + + private byte[] k; + + @JsonProperty("k") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getk() { + return k; + } + + public void setK(byte[] k) { + this.k = k; + } + + private byte[] t; + + @JsonProperty("key_hsm") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getT() { + return t; + } + + public void setT(byte[] t) { + this.t = t; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private RSAPublicKeySpec getRSAPublicKeySpec() { + + return new RSAPublicKeySpec(toBigInteger(n), toBigInteger(e)); + } + + private RSAPrivateKeySpec getRSAPrivateKeySpec() { + + return new RSAPrivateCrtKeySpec(toBigInteger(n), toBigInteger(e), toBigInteger(d), toBigInteger(p), toBigInteger(q), toBigInteger(dp), toBigInteger(dq), toBigInteger(qi)); + } + + private PublicKey getRSAPublicKey(Provider provider) { + + try { + RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); + + return factory.generatePublic(publicKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private PrivateKey getRSAPrivateKey(Provider provider) { + + try { + RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); + + return factory.generatePrivate(privateKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private void checkRSACompatible() { + if (!JsonWebKeyType.RSA.equals(kty) && !JsonWebKeyType.RSAHSM.equals(kty)) { + throw new UnsupportedOperationException("Not an RSA key"); + } + } + + private static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + private static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + public static JsonWebKey fromRSA(KeyPair keyPair) { + + RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); + JsonWebKey key = null; + + if (privateKey != null) { + + key = new JsonWebKey(); + + key.setKty(JsonWebKeyType.RSA); + + key.setN(toByteArray(privateKey.getModulus())); + key.setE(toByteArray(privateKey.getPublicExponent())); + key.setD(toByteArray(privateKey.getPrivateExponent())); + key.setP(toByteArray(privateKey.getPrimeP())); + key.setQ(toByteArray(privateKey.getPrimeQ())); + key.setDP(toByteArray(privateKey.getPrimeExponentP())); + key.setDQ(toByteArray(privateKey.getPrimeExponentQ())); + key.setQI(toByteArray(privateKey.getCrtCoefficient())); + } else { + + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + + key = new JsonWebKey(); + + key.setKty(JsonWebKeyType.RSA); + + key.setN(toByteArray(publicKey.getModulus())); + key.setE(toByteArray(publicKey.getPublicExponent())); + key.setD(null); + key.setP(null); + key.setQ(null); + key.setDP(null); + key.setDQ(null); + key.setQI(null); + } + + return key; + } + + public KeyPair toRSA() { + return this.toRSA(false); + } + + public KeyPair toRSA(boolean includePrivateParameters) { + + return toRSA(includePrivateParameters, null); + } + + public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { + + // Must be RSA + checkRSACompatible(); + + if (includePrivateParameters) { + return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); + } else { + return new KeyPair(getRSAPublicKey(provider), null); + } + } +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java new file mode 100644 index 0000000000000..f3b1760652637 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java @@ -0,0 +1,40 @@ +/** + * + * 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. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey key types (kty) + */ +public final class JsonWebKeyType { + + public static final String EC = "EC"; + public static final String RSA = "RSA"; + public static final String RSAHSM = "RSA-HSM"; + public static final String OCT = "oct"; + + public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); + + private JsonWebKeyType() { + // not instantiable + } +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 0d9fafb68ebbf..7c9b29b956bd5 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -2,15 +2,10 @@ import static org.junit.Assert.*; -import java.math.BigInteger; -import java.security.KeyFactory; -import java.security.KeyPair; +import java.security.MessageDigest; import java.security.Provider; -import java.security.spec.KeySpec; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.util.concurrent.Future; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import org.junit.After; @@ -19,12 +14,19 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.cryptography.RsaKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; public class RsaKeyTest { + // A Content Encryption Key, or Message. This value is kept consistent with the .NET + // unit test cases to enable cross platform testing. + static final byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + static final String CrossPlatformSignature = "RaNc+8WcWxplS8I7ynJLSoLJKz+dgBvrZhIGH3VFlTTyzu7b9d+lpaV9IKhzCNBsgSysKhgL7EZwVCOTBZ4m6xvKSXqVFXYaBPyBTD7VoKPMYMW6ai5x6xV5XAMaZPfMkff3Deg/RXcc8xQ28FhYuUa8yly01GySY4Hk55anEvb2wBxSy1UGun/0LE1lYH3C3XEgSry4cEkJHDJl1hp+wB4J/noXOqn5ECGU+/4ehBJOyW1gtUH0/gRe8yXnDH0AXepHRyH8iBHLWlKX1r+1/OrMulqOoi82RZzJlTyEz9X+bsQhllqGF6n3hdLS6toH9o7wUtwYNqSx82JuQT6iMg=="; + private Provider _provider = null; @BeforeClass @@ -48,163 +50,110 @@ protected void setProvider(Provider provider) { } @Test - public void testEncryptDecryptRsa15() throws Exception { + public void testRsa15() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, Rsa15.AlgorithmName).get(); - - byte[] ciphertext = result.getLeft(); + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.AlgorithmName).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - assertEquals(Rsa15.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); - - key.close(); - - assertArrayEquals(plaintext, decrypted); - } - - @Test - public void testEncryptDecryptRsaOaep() throws Exception { - - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + // Assert + assertEquals(Rsa15.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, RsaOaep.AlgorithmName).get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.AlgorithmName).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(RsaOaep.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Assert + assertEquals(Rsa15.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } @Test - public void testWrapUnwrapRsa15() throws Exception { + public void testRsaOaep() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, Rsa15.AlgorithmName).get(); + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.AlgorithmName).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(Rsa15.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); - - key.close(); - - assertArrayEquals(plaintext, decrypted); - } + // Assert + assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - @Test - public void testWrapUnwrapRsaOaep() throws Exception { - - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); - - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, RsaOaep.AlgorithmName).get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.AlgorithmName).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(RsaOaep.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Assert + assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } @Test - public void testEncryptDecryptDefaultAlgorithm() throws Exception { + public void testDefaultAlgorithm() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, null).get(); - - byte[] ciphertext = result.getLeft(); + assertEquals(RsaOaep.AlgorithmName, key.getDefaultEncryptionAlgorithm()); + assertEquals(RsaOaep.AlgorithmName, key.getDefaultKeyWrapAlgorithm()); + assertEquals(Rs256.AlgorithmName, key.getDefaultSignatureAlgorithm()); + + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, key.getDefaultKeyWrapAlgorithm()).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - assertEquals(RsaOaep.AlgorithmName, result.getRight()); + // Assert + assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, key.getDefaultEncryptionAlgorithm()).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); + + // Assert + assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } - + @Test - public void testWrapUnwrapDefaultAlgorithm() throws Exception { + public void testSignVerify() throws Exception { + + RsaKey key = getTestRsaKey(); - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] hash = digest.digest(CEK); + + Pair signature = key.signAsync(hash, "RS256").get(); + boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, null).get(); - - byte[] ciphertext = result.getLeft(); + assertTrue(result); - assertEquals(RsaOaep.AlgorithmName, result.getRight()); + // Now prove we can verify the cross platform signature + result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); + assertTrue(result); key.close(); - - assertArrayEquals(plaintext, decrypted); } - - private KeyPair getTestKeyMaterial() throws Exception { - - return getWellKnownKey(); - } - - private KeyPair getWellKnownKey() throws Exception { - BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); - BigInteger publicExponent = new BigInteger("65537"); - BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); - BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); - BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); - BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); - BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); - BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); - - KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); - KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = _provider == null ? KeyFactory.getInstance("RSA") : KeyFactory.getInstance("RSA", _provider); - - return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); + + private RsaKey getTestRsaKey() throws Exception { + String jwkString = "{\"kty\":\"RSA\",\"n\":\"rZ8pnmXkhfmmgNWVVdtNcYy2q0OAcCGIpeFzsN9URqJsiBEiWQfxlUxFTbM4kVWPqjauKt6byvApBGEeMA7Qs8kxwRVP-BD4orXRe9VPgliM92rH0UxQWHmCHUe7G7uUAFPwbiDVhWuFzELxNa6Kljg6Z9DuUKoddmQvlYWj8uSunofCtDi_zzlZKGYTOYJma5IYScHNww1yjLp8-b-Be2UdHbrPkCv6Nuwi6MVIKjPpEeRQgfefRmxDBJQKY3OfydMXZmEwukYXVkUcdIP8XwG2OxnfdRK0oAo0NDebNNVuT89k_3AyZLTr1KbDmx1nnjwa8uB8k-uLtcOC9igbTw\",\"e\":\"AQAB\",\"d\":\"H-z7hy_vVJ9yeZBMtIvt8qpQUK_J51STPwV085otcgud72tPKJXoW2658664ASl9kGwbnLBwb2G3-SEunuGqiNS_PGUB3niob6sFSUMRKsPDsB9HfPoOcCZvwZiWFGRqs6C7vlR1TuJVqRjKJ_ffbf4K51oo6FZPspx7j4AShLAwLUSQ60Ld5QPuxYMYZIMpdVbMVIVHJ26pR4Y18e_0GYmEGnbF5N0HkwqQmfmTiIK5aoGnD3GGgqHeHmWBwh6_WAq90ITLcX_zBeqQUgBSj-Z5v61SroO9Eang36T9mMoYrcPpYwemtAOb4HhQYDj8dCCfbeOcVmvZ9UJKWCX2oQ\",\"dp\":\"HW87UpwPoj3lPI9B9K1hJFeuGgarpakvtHuk1HpZ5hXWFGAJiXoWRV-jvYyjoM2k7RpSxPyuuFFmYHcIxiGFp2ES4HnP0BIhKVa2DyugUxIEcMK53C43Ub4mboJPZTSC3sapKgAmA2ue624sapWmshTPpx9qnUP2Oj3cSMkgMGE\",\"dq\":\"RhwEwb5FYio0GS2tmul8FAYsNH7JDehwI1yUApnTiakhSenFetml4PYyVkKR4csgLZEi3RY6J3R8Tg-36zrZuF7hxhVJn80L5_KETSpfEI3jcrXMVg4SRaMsWLY9Ahxflt2FJgUnHOmWRLmP6_hmaTcxxSACjbyUd_HhwNavD5E\",\"qi\":\"wYPZ4lKIslA1w3FaAzQifnNLABYXXUZ_KAA3a8T8fuxkdE4OP3xIFX7WHhnmBd6uOFiEcGoeq2jNQqDg91rV5661-5muQKcvp4uUsNId5rQw9EZw-kdDcwMtVFTEBfvVuyp83X974xYAHn1Jd8wWohSwrpi1QuH5cQMR5Fm6I1A\",\"p\":\"74Ot7MgxRu4euB31UWnGtrqYPjJmvbjYESS43jfDfo-s62ggV5a39P_YPg6oosgtGHNw0QDxunUOXNu9iriaYPf_imptRk69bKN8Nrl727Y-AaBYdLf1UZuwz8X07FqHAH5ghYpk79djld8QvkUUJLpx6rzcW8BJLTOi46DtzZE\",\"q\":\"uZJu-qenARIt28oj_Jlsk-p_KLnqdczczZfbRDd7XNp6csGLa8R0EyYqUB4xLWELQZsX4tAu9SaAO62tuuEy5wbOAmOVrq2ntoia1mGQSJdoeVq6OqtN300xVnaBc3us0rm8C6-824fEQ1PWXoulXLKcSqBhFT-hQahsYi-kat8\"}"; + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey jwk = null; + + jwk = mapper.readValue(jwkString, JsonWebKey.class); + + return new RsaKey("foo", jwk.toRSA(true, _provider) ); } } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 485fa3a0b797f..c33fb8eefbabe 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -29,10 +29,9 @@ import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; -import com.microsoft.azure.keyvault.cryptography.Strings; +import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java index 3b4d8ad3b1afb..52ef356b78e3b 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java @@ -24,13 +24,13 @@ public class Strings { /** - * Verifier if the string is empty or null. + * Determines whether the parameter string is either null or empty. * @param arg the string to verify - * @return true if the string is empty or null and false otherwise + * @return true if the string is empty or null and false otherwise. */ public static boolean isNullOrEmpty(String arg) { - if (arg == null || arg.isEmpty()) { + if (arg == null || arg.length() == 0) { return true; } @@ -38,7 +38,7 @@ public static boolean isNullOrEmpty(String arg) { } /** - * Verifier if the string is empty, contains only whitespace or is null. + * Determines whether the parameter string is null, empty or whitespace. * @param arg the string to verify * @return true if the string is empty, contains only whitespace or is null and false otherwise */ From 46af04b30b206cbfe706fbeb8e237679b4a2d493 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Mon, 22 Aug 2016 09:38:56 -0700 Subject: [PATCH 04/47] Adding managed field for certifciates and use base class of attributes in request classes. --- .../azure/keyvault/models/KeyBundle.java | 25 +++++++++++++++++ .../azure/keyvault/models/KeyItem.java | 25 +++++++++++++++++ .../azure/keyvault/models/SecretBundle.java | 25 +++++++++++++++++ .../azure/keyvault/models/SecretItem.java | 25 +++++++++++++++++ .../requests/CreateCertificateRequest.java | 5 ++-- .../keyvault/requests/CreateKeyRequest.java | 5 ++-- .../requests/ImportCertificateRequest.java | 5 ++-- .../keyvault/requests/ImportKeyRequest.java | 5 ++-- .../requests/MergeCertificateRequest.java | 5 ++-- .../keyvault/requests/SetSecretRequest.java | 5 ++-- .../requests/UpdateCertificateRequest.java | 6 ++--- .../keyvault/requests/UpdateKeyRequest.java | 5 ++-- .../requests/UpdateSecretRequest.java | 5 ++-- .../test/CertificateOperationsTest.java | 27 +++++++++++++------ .../keyvault/test/KeyOperationsTest.java | 9 ++++--- .../keyvault/test/SecretOperationsTest.java | 8 ++++-- 16 files changed, 158 insertions(+), 32 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 453e5177fab2b..ae4a62b7cbacc 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -38,6 +38,11 @@ public class KeyBundle { */ private Map tags; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the key value. * @@ -98,6 +103,26 @@ public KeyBundle withTags(Map tags) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the KeyBundle object itself. + */ + public KeyBundle withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * The key identifier. * @return identifier for the key diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 05584de30f1ac..4dea299b81d8c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -33,6 +33,11 @@ public class KeyItem { */ private Map tags; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the kid value. * @@ -93,6 +98,26 @@ public KeyItem withTags(Map tags) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the KeyItem object itself. + */ + public KeyItem withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * The key identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index c52baf76b82f9..6dea046e03cc5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -53,6 +53,11 @@ public class SecretBundle { */ private String kid; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the value value. * @@ -173,6 +178,26 @@ public SecretBundle withKid(String kid) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the SecretBundle object itself. + */ + public SecretBundle withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 5359f9cba67ca..db383c7f7f0fb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -38,6 +38,11 @@ public class SecretItem { */ private String contentType; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the id value. * @@ -118,6 +123,26 @@ public SecretItem withContentType(String contentType) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the SecretItem object itself. + */ + public SecretItem withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java index fb9a8e5db704b..84900c5ae2143 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -69,8 +70,8 @@ public Builder withPolicy(CertificatePolicy certificatePolicy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index 96f416bb9cf36..e197baa16c33b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -84,8 +85,8 @@ public Builder withKeyOperations(List keyOperations) { * the key management attributes value to set. * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java index 56f04bd98a454..431c595ca9709 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -89,8 +90,8 @@ public Builder withPolicy(CertificatePolicy policy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 8fb02162ff3da..b644554936253 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; @@ -71,8 +72,8 @@ public Builder withHsm(boolean isHsm) { * the key management attributes value to set * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java index 9ad223c6a4816..1a1569e41d97c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; /** @@ -54,8 +55,8 @@ public Builder(String vaultBaseUrl, String certificateName, List x509Cer * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java index a34c08d296f73..2bfa1cc3c6bc4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java @@ -3,6 +3,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.SecretAttributes; /** @@ -66,8 +67,8 @@ public Builder withContentType(String contentType) { * The secret management attributes. * @return the Builder object itself. */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (SecretAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index 407b4c1407d27..b1403613b462d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -11,7 +12,6 @@ import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; -import com.microsoft.azure.keyvault.requests.CreateCertificateRequest.Builder; /** * The update certificate request class. @@ -84,8 +84,8 @@ public Builder withPolicy(CertificatePolicy certificatePolicy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index d87b8c798c583..bad0b37d43b75 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -6,6 +6,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -94,8 +95,8 @@ public Builder withKeyOperations(List keyOperations) { * the key management attributes value to set * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java index 732aa8843ae33..e56f9f7713e28 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java @@ -4,6 +4,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.SecretAttributes; /** @@ -89,8 +90,8 @@ public Builder withContentType(String contentType) { * The secret management attributes. * @return the Builder object itself. */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (SecretAttributes) attributes; return this; } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 85839d816a2aa..18a13e9423e9b 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -57,8 +57,10 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.CertificateIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.AdministratorDetails; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.Contact; @@ -66,6 +68,7 @@ import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.IssuerCredentials; import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.OrganizationDetails; import com.microsoft.azure.keyvault.models.CertificateItem; @@ -143,8 +146,8 @@ public void createSelfSignedCertificatePkcs12() throws Exception { .withIssuerReference(issuerReference) .withX509CertificateProperties(x509Properties); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() - .withEnabled(false) + Attributes attribute = new CertificateAttributes() + .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -177,7 +180,13 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(secret.managed()); + // Retrieve the key backing the certificate + KeyIdentifier keyIdentifier = certificateBundle.keyIdentifier(); + KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(keyBundle.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -325,7 +334,8 @@ public void createCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - + Assert.assertTrue(secret.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -538,7 +548,7 @@ public void importCertificatePkcs12() throws Exception { // Set content type to indicate the certificate is PKCS12 format. SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes().withEnabled(true); + Attributes attribute = new CertificateAttributes().withEnabled(true); String vaultUri = getVaultUri(); String certificateName = "importCertPkcs"; @@ -565,7 +575,8 @@ public void importCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - + Assert.assertTrue(secret.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -605,14 +616,13 @@ public void certificateUpdate() throws Exception { .build()).getBody(); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() - .withEnabled(false) + Attributes attribute = new CertificateAttributes() .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); CertificateBundle updatedCertBundle = keyVaultClient.updateCertificate( new UpdateCertificateRequest .Builder(vaultUri, certificateName) - .withAttributes((CertificateAttributes) attribute.withEnabled(false)) + .withAttributes(attribute.withEnabled(false)) .withTags(sTags) .build()).getBody(); Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); @@ -1098,6 +1108,7 @@ private void validatePem(CertificateBundle certificateBundle, String subjectName // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(secret.managed()); String secretValue = secret.value(); // Extract private key from PEM diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index f227d9f5ca3cb..c4fd3b4d6209f 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -47,6 +47,7 @@ import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; @@ -68,7 +69,7 @@ public void transparentAuthentication() throws Exception { Map tags = new HashMap(); tags.put("foo", "baz"); List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); - KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -108,7 +109,7 @@ public void importKeyOperation() throws Exception { } private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) throws Exception { - KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -546,7 +547,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, KeyAttributes attributes) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, Attributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( @@ -562,6 +563,8 @@ private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String Assert.assertNotNull("\"updated\" should not be null.", bundle.attributes().updated()); compareAttributes(attributes, bundle.attributes()); + + Assert.assertTrue(bundle.managed() == null || bundle.managed() == false); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 7378e9ebc9bee..1673ded8ff130 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -25,6 +25,7 @@ import org.junit.Assert; import org.junit.Test; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; @@ -46,7 +47,7 @@ public void transparentAuthentication() throws Exception { // Create a secret on a vault. { - SecretAttributes attributes = (SecretAttributes) new SecretAttributes() + Attributes attributes = new SecretAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -271,7 +272,7 @@ public void listSecretVersions() throws Exception { keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); } - private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, SecretAttributes attributes) throws Exception { + private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, Attributes attributes) throws Exception { String prefix = vault + "/secrets/" + name + "/"; String id = secret.id(); Assert.assertTrue( // @@ -285,6 +286,8 @@ private static void validateSecret(SecretBundle secret, String vault, String nam Assert.assertNotNull("\"updated\" should not be null.", secret.attributes().updated()); compareAttributes(attributes, secret.attributes()); + + Assert.assertTrue(secret.managed() == null || secret.managed() == false); } private void compareSecrets(SecretBundle expected, SecretBundle actual) { @@ -296,6 +299,7 @@ private void compareSecrets(SecretBundle expected, SecretBundle actual) { Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); if(expected.tags() != null || actual.tags() != null) Assert.assertTrue(expected.tags().equals(actual.tags())); + } } From 4f601147a8bd652ffba506eb5c6cd59a0315ed94 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 22 Aug 2016 13:46:46 -0700 Subject: [PATCH 05/47] Crypto test cases for excess key material support to match .NET --- .../keyvault/cryptography/Algorithm.java | 25 +++ .../cryptography/algorithms/Aes128Cbc.java | 50 +++++ .../cryptography/algorithms/Aes192Cbc.java | 51 +++++ .../cryptography/algorithms/Aes256Cbc.java | 51 +++++ .../cryptography/algorithms/AesKw128.java | 19 +- .../cryptography/algorithms/AesKw192.java | 19 +- .../cryptography/algorithms/AesKw256.java | 19 +- .../cryptography/test/AesCbcTest.java | 185 +++++++++++++++--- .../keyvault/cryptography/test/AesKwTest.java | 178 +++++++++++++++++ .../test/SymmetricKeyBCProviderTest.java | 2 +- .../test/SymmetricKeyDefaultProviderTest.java | 29 --- ...KeyBaseTest.java => SymmetricKeyTest.java} | 173 +++++++++++++++- 12 files changed, 719 insertions(+), 82 deletions(-) delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{SymmetricKeyBaseTest.java => SymmetricKeyTest.java} (69%) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index bfdcf9e54e790..127521c7d4373 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -33,4 +33,29 @@ protected Algorithm(String name) { public String getName() { return _name; } + + /* + * Takes the first count bytes from the source and + * returns a new array containing those bytes. + * + * @param count The number of bytes to take. + * @param source The source of the bytes. + * @return count bytes from the source as a new array. + */ + public static byte[] Take(int count, byte[] source) + { + if ( source == null ) { + throw new IllegalArgumentException("source"); + } + + if ( count <= 0 || count > source.length ) { + throw new IllegalArgumentException("count"); + } + + byte[] target = new byte[count]; + + System.arraycopy(source, 0, target, 0, count); + + return target; + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index 206a463d5b7ef..c0a5630e8df6b 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -18,12 +18,62 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes128Cbc extends AesCbc { public static final String AlgorithmName = "A128CBC"; + + static final int KeySizeInBytes = 128 >> 3; public Aes128Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 2cb0fc22b4d96..96b03caf970e0 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -18,12 +18,63 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes192Cbc extends AesCbc { public static final String AlgorithmName = "A192CBC"; + + static final int KeySizeInBytes = 192 >> 3; public Aes192Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 91fb58e09c932..88abe788ee757 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -18,12 +18,63 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes256Cbc extends AesCbc { public static final String AlgorithmName = "A256CBC"; + + static final int KeySizeInBytes = 256 >> 3; public Aes256Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 5d7a15605aea6..2044f10895867 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw128 extends AesKw { public static final String AlgorithmName = "A128KW"; + + static final int KeySizeInBytes = 128 >> 3; public AesKw128() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 128) { - throw new IllegalArgumentException("key must be 128 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 128) { - throw new IllegalArgumentException("key must be 128 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index f20f5ec7ee22c..bb652553ff83e 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw192 extends AesKw { public static final String AlgorithmName = "A192KW"; + + static final int KeySizeInBytes = 192 >> 3; public AesKw192() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 192) { - throw new IllegalArgumentException("key must be 192 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 192) { - throw new IllegalArgumentException("key must be 192 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index c4b23a572c222..b2ed7dd4815f7 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw256 extends AesKw { public static final String AlgorithmName = "A256KW"; + + static final int KeySizeInBytes = 256 >> 3; public AesKw256() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 256) { - throw new IllegalArgumentException("key must be 256 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 256) { - throw new IllegalArgumentException("key must be 256 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 53286b5471690..6498b9508dff6 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -11,6 +11,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.microsoft.azure.keyvault.cryptography.Algorithm; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -40,44 +41,130 @@ protected void setProvider(Provider provider) { } @Test - public void testAes128Cbc() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at - // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we - // actually take the realCEK from the second half of the CEK data below - // in order - // that the encrypted result will match the ED value from the example. - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; - - Aes128Cbc algo = new Aes128Cbc(); - byte[] realCEK = new byte[128 >> 3]; - byte[] encrypted = null; - - // Take the second half of CEK as the AES key - System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); + public void testAes128CbcOneBlock() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors from RFC3602 do not use padding. + byte[] CEK = { 0x06, (byte)0xa9, 0x21, 0x40, 0x36, (byte)0xb8, (byte)0xa1, 0x5b, 0x51, 0x2e, 0x03, (byte)0xd5, 0x34, 0x12, 0x00, 0x06 }; + byte[] PLAIN = "Single block msg".getBytes(); + byte[] IV = { 0x3d, (byte)0xaf, (byte)0xba, 0x42, (byte)0x9d, (byte)0x9e, (byte)0xb4, 0x30, (byte)0xb4, 0x22, (byte)0xda, (byte)0x80, 0x2c, (byte)0x9f, (byte)0xac, 0x41 }; + byte[] ED = { (byte)0xe3, 0x53, 0x77, (byte)0x9c, 0x10, 0x79, (byte)0xae, (byte)0xb8, 0x27, 0x08, (byte)0x94, 0x2d, (byte)0xbe, 0x77, 0x18, 0x1a }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testAes128CbcTwoBlock() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors do not use padding. + byte[] CEK = { (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; + byte[] IV = { 0x56, 0x2e, 0x17, (byte)0x99, 0x6d, 0x09, 0x3d, 0x28, (byte)0xdd, (byte)0xb3, (byte)0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }; + byte[] ED = { (byte)0xd2, (byte)0x96, (byte)0xcd, (byte)0x94, (byte)0xc2, (byte)0xcc, (byte)0xcf, (byte)0x8a, 0x3a, (byte)0x86, 0x30, 0x28, (byte)0xb5, (byte)0xe1, (byte)0xdc, 0x0a, 0x75, (byte)0x86, 0x60, 0x2d, 0x25, 0x3c, (byte)0xff, (byte)0xf9, 0x1b, (byte)0x82, 0x66, (byte)0xbe, (byte)0xa6, (byte)0xd6, 0x1a, (byte)0xb1 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testAes128CbcOneBlock_ExcessKeyMaterial() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors from RFC3602 do not use padding. + byte[] CEK = { 0x06, (byte)0xa9, 0x21, 0x40, 0x36, (byte)0xb8, (byte)0xa1, 0x5b, 0x51, 0x2e, 0x03, (byte)0xd5, 0x34, 0x12, 0x00, 0x06, (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = "Single block msg".getBytes(); + byte[] IV = { 0x3d, (byte)0xaf, (byte)0xba, 0x42, (byte)0x9d, (byte)0x9e, (byte)0xb4, 0x30, (byte)0xb4, 0x22, (byte)0xda, (byte)0x80, 0x2c, (byte)0x9f, (byte)0xac, 0x41 }; + byte[] ED = { (byte)0xe3, 0x53, 0x77, (byte)0x9c, 0x10, 0x79, (byte)0xae, (byte)0xb8, 0x27, 0x08, (byte)0x94, 0x2d, (byte)0xbe, 0x77, 0x18, 0x1a }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; ICryptoTransform encryptor = null; try { - encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); } catch (Exception e) { fail(e.getMessage()); } try { encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16,encrypted),ED); } catch (Exception e) { fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -86,12 +173,58 @@ public void testAes128Cbc() { try { decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); } catch (Exception e) { fail(e.getMessage()); } + } - // Assert - assertArrayEquals(PLAIN, decrypted); - assertArrayEquals(ED, encrypted); + @Test + public void testAes128CbcTwoBlock_ExcessKeyMaterial() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors do not use padding. + byte[] CEK = { (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a, (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; + byte[] IV = { 0x56, 0x2e, 0x17, (byte)0x99, 0x6d, 0x09, 0x3d, 0x28, (byte)0xdd, (byte)0xb3, (byte)0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }; + byte[] ED = { (byte)0xd2, (byte)0x96, (byte)0xcd, (byte)0x94, (byte)0xc2, (byte)0xcc, (byte)0xcf, (byte)0x8a, 0x3a, (byte)0x86, 0x30, 0x28, (byte)0xb5, (byte)0xe1, (byte)0xdc, 0x0a, 0x75, (byte)0x86, 0x60, 0x2d, 0x25, 0x3c, (byte)0xff, (byte)0xf9, 0x1b, (byte)0x82, 0x66, (byte)0xbe, (byte)0xa6, (byte)0xd6, 0x1a, (byte)0xb1 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java index d22e2107ce6ef..e79e5569fe71c 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java @@ -248,4 +248,182 @@ public void KeyVault_AesKw256() { } } + @Test + public void KeyVault_AesKw128_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { 0x1F, (byte)0xA6, (byte)0x8B, 0x0A, (byte)0x81, 0x12, (byte)0xB4, 0x47, (byte)0xAE, (byte)0xF3, 0x4B, (byte)0xD8, (byte)0xFB, 0x5A, 0x7B, (byte)0x82, (byte)0x9D, 0x3E, (byte)0x86, 0x23, 0x71, (byte)0xD2, (byte)0xCF, (byte)0xE5 }; + + AesKw kw = new AesKw128(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + @Test + public void KeyVault_AesKw192_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw192(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + + @Test + public void KeyVault_AesKw256_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw256(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java index a6a7936c9fa65..2954df416105f 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java @@ -21,7 +21,7 @@ import java.security.Provider; import org.junit.Before; -public class SymmetricKeyBCProviderTest extends SymmetricKeyBaseTest { +public class SymmetricKeyBCProviderTest extends SymmetricKeyTest { @Before public void setUp() throws Exception { diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java deleted file mode 100644 index 384961ad2e643..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - * 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. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import org.junit.Before; - -public class SymmetricKeyDefaultProviderTest extends SymmetricKeyBaseTest { - - @Before - public void setUp() throws Exception { - super.setProvider(null); - } -} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java similarity index 69% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java index 36b6bf464aa16..b6d3194cae058 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java @@ -37,7 +37,7 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; -public abstract class SymmetricKeyBaseTest { +public class SymmetricKeyTest { private Provider _provider = null; @@ -58,7 +58,9 @@ public static void tearDownAfterClass() throws Exception { } @Before - public abstract void setUp() throws Exception; + public void setUp() throws Exception { + setProvider(null); + } @After public void tearDown() throws Exception { @@ -420,4 +422,171 @@ public void testSymmetricKeyDefaultAlgorithmAesKw256() { } } + @Test + public void testSymmetricKeyAesKw128_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { 0x1F, (byte)0xA6, (byte)0x8B, 0x0A, (byte)0x81, 0x12, (byte)0xB4, 0x47, (byte)0xAE, (byte)0xF3, 0x4B, (byte)0xD8, (byte)0xFB, 0x5A, 0x7B, (byte)0x82, (byte)0x9D, 0x3E, (byte)0x86, 0x23, 0x71, (byte)0xD2, (byte)0xCF, (byte)0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { (byte)0x96, 0x77, (byte)0x8B, 0x25, (byte)0xAE, 0x6C, (byte)0xA4, 0x35, (byte)0xF9, 0x2B, 0x5B, (byte)0x97, (byte)0xC0, 0x50, (byte)0xAE, (byte)0xD2, 0x46, (byte)0x8A, (byte)0xB8, (byte)0xA1, 0x7A, (byte)0xD8, 0x4E, 0x5D }; + + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte)0xE8, (byte)0xC3, (byte)0xF9, (byte)0xCE, 0x0F, 0x5B, (byte)0xA2, 0x63, (byte)0xE9, 0x77, 0x79, 0x05, (byte)0x81, (byte)0x8A, 0x2A, (byte)0x93, (byte)0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte)0x8A, (byte)0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } } From 666ab1748184ebf2e5044803611c3fc45575b811 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 23 Aug 2016 11:25:18 -0700 Subject: [PATCH 06/47] Refactoring JSON web key to KV webkey project --- azure-keyvault-cryptography/pom.xml | 61 ++- .../test/Base64UrlDeserializer.java | 43 --- .../cryptography/test/JsonWebKey.java | 346 ------------------ .../cryptography/test/JsonWebKeyType.java | 40 -- .../cryptography/test/RsaKeyTest.java | 1 + azure-keyvault-extensions/pom.xml | 5 + .../keyvault/extensions/KeyVaultKey.java | 2 +- azure-keyvault-webkey/pom.xml | 104 ++++++ .../webkey/Base64UrlJsonDeserializer.java | 34 ++ .../webkey/Base64UrlJsonSerializer.java | 25 +- .../azure/keyvault/webkey}/JsonWebKey.java | 337 ++++++++--------- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 18 +- .../keyvault/webkey/JsonWebKeyOperation.java | 18 +- .../webkey/JsonWebKeySignatureAlgorithm.java | 18 +- .../azure/keyvault/webkey/JsonWebKeyType.java | 18 +- .../azure/keyvault/webkey/package-info.java | 3 +- azure-keyvault/pom.xml | 5 + .../azure/keyvault/KeyVaultClientImpl.java | 4 +- .../azure/keyvault/models/KeyBundle.java | 1 + .../keyvault/models/KeyImportParameters.java | 1 + .../keyvault/requests/ImportKeyRequest.java | 2 +- .../keyvault/test/AsyncOperationsTest.java | 44 ++- .../keyvault/test/KeyOperationsTest.java | 2 +- pom.xml | 1 + 24 files changed, 396 insertions(+), 737 deletions(-) delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java create mode 100644 azure-keyvault-webkey/pom.xml create mode 100644 azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java => azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java (50%) rename {azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models => azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey}/JsonWebKey.java (60%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java (54%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java (63%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java (59%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java (58%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java (58%) diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 5b7688e30a0db..b3e1236542df2 100644 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -34,40 +34,35 @@ HEAD - - UTF-8 - - - true - + + UTF-8 + + + true + - - - junit - junit - test - - - org.bouncycastle - bcprov-jdk15on - test - 1.54 - - + + + junit + junit + test + + + org.bouncycastle + bcprov-jdk15on + test + 1.54 + + ${project.groupId} - azure-keyvault-core - ${project.version} - - - com.fasterxml.jackson.core - jackson-databind - test - - - commons-codec - commons-codec - test - - + azure-keyvault-core + ${project.version} + + + ${project.groupId} + azure-keyvault-webkey + ${project.version} + + diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java deleted file mode 100644 index 8f54e8cdece21..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * 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. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.io.IOException; - -import org.apache.commons.codec.binary.Base64; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -public class Base64UrlDeserializer extends JsonDeserializer { - - static final Base64 _base64 = new Base64(-1, null, true); - - @Override - public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - String text = jp.getText(); - if (text != null) { - return _base64.decode(text); - } - return null; - } - -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java deleted file mode 100644 index ec65f0d6fea55..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java +++ /dev/null @@ -1,346 +0,0 @@ -/** - * - * 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. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.Provider; -import java.security.PublicKey; -import java.security.interfaces.RSAPrivateCrtKey; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPrivateKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.util.Arrays; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) -public class JsonWebKey { - - private String kid; - - @JsonProperty("kid") - public String getKid() { - return kid; - } - - public void setKid(String kid) { - this.kid = kid; - } - - private String kty; - - @JsonProperty("kty") - public String getKty() { - return kty; - } - - public void setKty(String kty) { - this.kty = kty; - } - - private String[] keyOps; - - @JsonProperty("key_ops") - public String[] getKeyOps() { - return keyOps; - } - - public void setKeyOps(String[] keyOps) { - this.keyOps = keyOps; - } - - private byte[] n; - - @JsonProperty("n") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getN() { - return n; - } - - public void setN(byte[] n) { - this.n = n; - } - - private byte[] e; - - @JsonProperty("e") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getE() { - return e; - } - - public void setE(byte[] e) { - this.e = e; - } - - private byte[] d; - - @JsonProperty("d") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getD() { - return d; - } - - public void setD(byte[] d) { - this.d = d; - } - - private byte[] dp; - - @JsonProperty("dp") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getDP() { - return dp; - } - - public void setDP(byte[] dp) { - this.dp = dp; - } - - private byte[] dq; - - @JsonProperty("dq") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getDQ() { - return dq; - } - - public void setDQ(byte[] dq) { - this.dq = dq; - } - - private byte[] qi; - - @JsonProperty("qi") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getQI() { - return qi; - } - - public void setQI(byte[] qi) { - this.qi = qi; - } - - private byte[] p; - - @JsonProperty("p") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getP() { - return p; - } - - public void setP(byte[] p) { - this.p = p; - } - - private byte[] q; - - @JsonProperty("q") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getQ() { - return q; - } - - public void setQ(byte[] q) { - this.q = q; - } - - private byte[] k; - - @JsonProperty("k") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getk() { - return k; - } - - public void setK(byte[] k) { - this.k = k; - } - - private byte[] t; - - @JsonProperty("key_hsm") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getT() { - return t; - } - - public void setT(byte[] t) { - this.t = t; - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private RSAPublicKeySpec getRSAPublicKeySpec() { - - return new RSAPublicKeySpec(toBigInteger(n), toBigInteger(e)); - } - - private RSAPrivateKeySpec getRSAPrivateKeySpec() { - - return new RSAPrivateCrtKeySpec(toBigInteger(n), toBigInteger(e), toBigInteger(d), toBigInteger(p), toBigInteger(q), toBigInteger(dp), toBigInteger(dq), toBigInteger(qi)); - } - - private PublicKey getRSAPublicKey(Provider provider) { - - try { - RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); - KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); - - return factory.generatePublic(publicKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - private PrivateKey getRSAPrivateKey(Provider provider) { - - try { - RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); - KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); - - return factory.generatePrivate(privateKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty) && !JsonWebKeyType.RSAHSM.equals(kty)) { - throw new UnsupportedOperationException("Not an RSA key"); - } - } - - private static byte[] toByteArray(BigInteger n) { - byte[] result = n.toByteArray(); - if (result[0] == 0) { - // The leading zero is used to let the number positive. Since RSA - // parameters are always positive, we remove it. - return Arrays.copyOfRange(result, 1, result.length); - } - return result; - } - - private static BigInteger toBigInteger(byte[] b) { - if (b[0] < 0) { - // RSA parameters are always positive numbers, so if the first byte - // is negative, we need to add a leading zero - // to make the entire BigInteger positive. - byte[] temp = new byte[1 + b.length]; - System.arraycopy(b, 0, temp, 1, b.length); - b = temp; - } - return new BigInteger(b); - } - - public static JsonWebKey fromRSA(KeyPair keyPair) { - - RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); - JsonWebKey key = null; - - if (privateKey != null) { - - key = new JsonWebKey(); - - key.setKty(JsonWebKeyType.RSA); - - key.setN(toByteArray(privateKey.getModulus())); - key.setE(toByteArray(privateKey.getPublicExponent())); - key.setD(toByteArray(privateKey.getPrivateExponent())); - key.setP(toByteArray(privateKey.getPrimeP())); - key.setQ(toByteArray(privateKey.getPrimeQ())); - key.setDP(toByteArray(privateKey.getPrimeExponentP())); - key.setDQ(toByteArray(privateKey.getPrimeExponentQ())); - key.setQI(toByteArray(privateKey.getCrtCoefficient())); - } else { - - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - - key = new JsonWebKey(); - - key.setKty(JsonWebKeyType.RSA); - - key.setN(toByteArray(publicKey.getModulus())); - key.setE(toByteArray(publicKey.getPublicExponent())); - key.setD(null); - key.setP(null); - key.setQ(null); - key.setDP(null); - key.setDQ(null); - key.setQI(null); - } - - return key; - } - - public KeyPair toRSA() { - return this.toRSA(false); - } - - public KeyPair toRSA(boolean includePrivateParameters) { - - return toRSA(includePrivateParameters, null); - } - - public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { - - // Must be RSA - checkRSACompatible(); - - if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); - } else { - return new KeyPair(getRSAPublicKey(provider), null); - } - } -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java deleted file mode 100644 index f3b1760652637..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - * 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. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey key types (kty) - */ -public final class JsonWebKeyType { - - public static final String EC = "EC"; - public static final String RSA = "RSA"; - public static final String RSAHSM = "RSA-HSM"; - public static final String OCT = "oct"; - - public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); - - private JsonWebKeyType() { - // not instantiable - } -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 7c9b29b956bd5..454752d7bac8b 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -19,6 +19,7 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; public class RsaKeyTest { diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 3c9f92ea238a1..36d1dc3668e0a 100644 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -81,6 +81,11 @@ azure-keyvault ${project.version} + + ${project.groupId} + azure-keyvault-webkey + ${project.version} + org.mockito mockito-core diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index c33fb8eefbabe..2ef3291cfca3a 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -29,7 +29,7 @@ import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; -import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml new file mode 100644 index 0000000000000..698622c6d1fe0 --- /dev/null +++ b/azure-keyvault-webkey/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault-webkey + jar + + Microsoft Azure SDK for Key Vault WebKey + This package contains Microsoft Azure Key Vault WebKey library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + + com.fasterxml.jackson.core + jackson-databind + + + commons-codec + commons-codec + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + com.microsoft.schemas._2003._10.serialization; + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java new file mode 100644 index 0000000000000..18967a8863809 --- /dev/null +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +/** + * The base64 URL JSON deserializer. + */ +public class Base64UrlJsonDeserializer extends JsonDeserializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + String text = jp.getText(); + if (text != null) { + return _base64.decode(text); + } + return null; + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java similarity index 50% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java index 3cf15e392863d..3613a1aa79199 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java @@ -1,22 +1,10 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ -package com.microsoft.azure.keyvault.cryptography.test; +package com.microsoft.azure.keyvault.webkey; import java.io.IOException; @@ -27,7 +15,10 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -public class Base64UrlSerializer extends JsonSerializer { +/** + * The base64 URL JSON serializer. + */ +public class Base64UrlJsonSerializer extends JsonSerializer { static final Base64 _base64 = new Base64(-1, null, true); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java similarity index 60% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index ef267481ebba1..e6670116cf5e4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -1,14 +1,10 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * license information. */ -package com.microsoft.azure.keyvault.models; +package com.microsoft.azure.keyvault.webkey; import java.io.IOException; import java.math.BigInteger; @@ -16,6 +12,7 @@ import java.security.KeyFactory; import java.security.KeyPair; import java.security.PrivateKey; +import java.security.Provider; import java.security.PublicKey; import java.security.interfaces.RSAPrivateCrtKey; import java.security.interfaces.RSAPublicKey; @@ -24,18 +21,21 @@ import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; import java.util.List; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; -import com.microsoft.rest.Base64Url; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. */ +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) public class JsonWebKey { + /** * Key Identifier. */ @@ -50,73 +50,72 @@ public class JsonWebKey { /** * The keyOps property. */ - @JsonProperty(value = "key_ops") private List keyOps; /** * RSA modulus. */ - private Base64Url n; + private byte[] n; /** * RSA public exponent. */ - private Base64Url e; + private byte[] e; /** * RSA private exponent. */ - private Base64Url d; + private byte[] d; /** * RSA Private Key Parameter. */ - private Base64Url dp; + private byte[] dp; /** * RSA Private Key Parameter. */ - private Base64Url dq; + private byte[] dq; /** * RSA Private Key Parameter. */ - private Base64Url qi; + private byte[] qi; /** * RSA secret prime. */ - private Base64Url p; + private byte[] p; /** * RSA secret prime, with p < q. */ - private Base64Url q; + private byte[] q; /** * Symmetric key. */ - private Base64Url k; + private byte[] k; /** * HSM Token, used with Bring Your Own Key. */ - @JsonProperty(value = "key_hsm") - private Base64Url t; + private byte[] t; /** - * Get the kid value. + * Key Identifier. * - * @return the kid value + * @return the kid value. */ + @JsonProperty("kid") public String kid() { return this.kid; } /** - * Set the kid value. + * Set the key identifier value. * - * @param kid the kid value to set + * @param kid the key identifier * @return the JsonWebKey object itself. */ public JsonWebKey withKid(String kid) { @@ -125,18 +124,20 @@ public JsonWebKey withKid(String kid) { } /** - * Get the kty value. + * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', + * 'oct'. * - * @return the kty value + * @return the key type. */ + @JsonProperty("kty") public String kty() { return this.kty; } /** - * Set the kty value. + * Set the key type value. * - * @param kty the kty value to set + * @param kty the key type * @return the JsonWebKey object itself. */ public JsonWebKey withKty(String kty) { @@ -145,18 +146,19 @@ public JsonWebKey withKty(String kty) { } /** - * Get the keyOps value. + * Get the key operations. * - * @return the keyOps value + * @return the key operations. */ + @JsonProperty("key_ops") public List keyOps() { return this.keyOps; } /** - * Set the keyOps value. + * Set the key operations value. * - * @param keyOps the keyOps value to set + * @param keyOps the key operations value to set * @return the JsonWebKey object itself. */ public JsonWebKey withKeyOps(List keyOps) { @@ -165,279 +167,222 @@ public JsonWebKey withKeyOps(List keyOps) { } /** - * Get the n value. + * Get the RSA modulus value. * - * @return the n value + * @return the RSA modulus value. */ + @JsonProperty("n") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] n() { - if (this.n == null) { - return null; - } - return this.n.getDecodedBytes(); + return this.n; } /** - * Set the n value. + * Set the RSA modulus value. * - * @param n the n value to set + * @param n the RSA modulus value to set * @return the JsonWebKey object itself. */ public JsonWebKey withN(byte[] n) { - if (n == null) { - this.n = null; - } else { - this.n = Base64Url.encode(n); - } + this.n = n; return this; } /** - * Get the e value. - * - * @return the e value + * Get the RSA public exponent value. + * @return the RSA public exponent value. */ + @JsonProperty("e") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] e() { - if (this.e == null) { - return null; - } - return this.e.getDecodedBytes(); + return this.e; } /** - * Set the e value. - * - * @param e the e value to set + * Set the RSA public exponent value. + * + * @param e RSA public exponent value to set * @return the JsonWebKey object itself. */ public JsonWebKey withE(byte[] e) { - if (e == null) { - this.e = null; - } else { - this.e = Base64Url.encode(e); - } + this.e = e; return this; } /** - * Get the d value. - * - * @return the d value + * Get the RSA private exponent value. + * @return the RSA private exponent value. */ + @JsonProperty("d") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] d() { - if (this.d == null) { - return null; - } - return this.d.getDecodedBytes(); + return this.d; } /** - * Set the d value. - * - * @param d the d value to set + * Set RSA private exponent value. + * + * @param d the RSA private exponent value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withD(byte[] d) { - if (d == null) { - this.d = null; - } else { - this.d = Base64Url.encode(d); - } + this.d = d; return this; } /** - * Get the dp value. - * - * @return the dp value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("dp") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] dp() { - if (this.dp == null) { - return null; - } - return this.dp.getDecodedBytes(); + return this.dp; } /** - * Set the dp value. - * - * @param dp the dp value to set + * Set RSA Private Key Parameter value + * @param dp the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withDp(byte[] dp) { - if (dp == null) { - this.dp = null; - } else { - this.dp = Base64Url.encode(dp); - } + this.dp = dp; return this; } /** - * Get the dq value. - * - * @return the dq value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("dq") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] dq() { - if (this.dq == null) { - return null; - } - return this.dq.getDecodedBytes(); + return this.dq; } /** - * Set the dq value. - * - * @param dq the dq value to set + * Set RSA Private Key Parameter value . + * @param dq the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withDq(byte[] dq) { - if (dq == null) { - this.dq = null; - } else { - this.dq = Base64Url.encode(dq); - } + this.dq = dq; return this; } /** - * Get the qi value. - * - * @return the qi value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("qi") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] qi() { - if (this.qi == null) { - return null; - } - return this.qi.getDecodedBytes(); + return this.qi; } /** - * Set the qi value. - * - * @param qi the qi value to set + * Set RSA Private Key Parameter value. + * @param qi the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withQi(byte[] qi) { - if (qi == null) { - this.qi = null; - } else { - this.qi = Base64Url.encode(qi); - } + this.qi = qi; return this; } /** - * Get the p value. - * - * @return the p value + * Get the RSA secret prime value. + * @return the RSA secret prime value. */ + @JsonProperty("p") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] p() { - if (this.p == null) { - return null; - } - return this.p.getDecodedBytes(); + return this.p; } /** - * Set the p value. - * - * @param p the p value to set + * Set the RSA secret prime value. + * @param p the RSA secret prime value. * @return the JsonWebKey object itself. */ public JsonWebKey withP(byte[] p) { - if (p == null) { - this.p = null; - } else { - this.p = Base64Url.encode(p); - } + this.p = p; return this; } /** - * Get the q value. - * - * @return the q value + * Get RSA secret prime, with p < q value. + * @return the RSA secret prime, with p < q value. */ + @JsonProperty("q") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] q() { - if (this.q == null) { - return null; - } - return this.q.getDecodedBytes(); + return this.q; } /** - * Set the q value. - * - * @param q the q value to set + * Set the RSA secret prime, with p < q value. + * @param q the the RSA secret prime, with p < q value to be set. * @return the JsonWebKey object itself. */ public JsonWebKey withQ(byte[] q) { - if (q == null) { - this.q = null; - } else { - this.q = Base64Url.encode(q); - } + this.q = q; return this; } /** - * Get the k value. - * - * @return the k value + * Get Symmetric key value. + * @return the symmetric key value. */ + @JsonProperty("k") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] k() { - if (this.k == null) { - return null; - } - return this.k.getDecodedBytes(); + return this.k; } /** - * Set the k value. - * - * @param k the k value to set + * Set the Symmetric key value. + * @param k the symmetric key value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withK(byte[] k) { - if (k == null) { - this.k = null; - } else { - this.k = Base64Url.encode(k); - } + this.k = k; return this; } /** - * Get the t value. - * - * @return the t value + * Get HSM Token value, used with Bring Your Own Key. + * @return HSM Token, used with Bring Your Own Key. */ + @JsonProperty("key_hsm") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] t() { - if (this.t == null) { - return null; - } - return this.t.getDecodedBytes(); + return this.t; } /** - * Set the t value. - * - * @param t the t value to set + * Set HSM Token value, used with Bring Your Own Key. + * @param t HSM Token value to set, used with Bring Your Own Key * @return the JsonWebKey object itself. */ public JsonWebKey withT(byte[] t) { - if (t == null) { - this.t = null; - } else { - this.t = Base64Url.encode(t); - } + this.t = t; return this; } @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { @@ -473,13 +418,14 @@ private RSAPrivateKeySpec getRSAPrivateKeySpec() { /** * Get the RSA public key value. * + * @param provider the Java security provider. * @return the RSA public key value */ - private PublicKey getRSAPublicKey() { + private PublicKey getRSAPublicKey(Provider provider) { try { RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); return factory.generatePublic(publicKeySpec); } catch (GeneralSecurityException e) { @@ -490,13 +436,14 @@ private PublicKey getRSAPublicKey() { /** * Get the RSA private key value. * + * @param provider the Java security provider. * @return the RSA private key value */ - private PrivateKey getRSAPrivateKey() { + private PrivateKey getRSAPrivateKey(Provider provider) { try { RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); return factory.generatePrivate(privateKeySpec); } catch (GeneralSecurityException e) { @@ -590,14 +537,24 @@ public KeyPair toRSA() { * @return RSA key pair */ public KeyPair toRSA(boolean includePrivateParameters) { + return toRSA(includePrivateParameters, null); + } + + /** + * Converts JSON web key to RSA key pair and include the private key if set to true. + * @param provider the Java security provider. + * @param includePrivateParameters true if the RSA key pair should include the private key. False otherwise. + * @return RSA key pair + */ + public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { // Must be RSA checkRSACompatible(); if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(), getRSAPrivateKey()); + return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); } else { - return new KeyPair(getRSAPublicKey(), null); + return new KeyPair(getRSAPublicKey(provider), null); } } -} +} \ No newline at end of file diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java similarity index 54% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java index 96ee1a2d303e8..8eb412e21e412 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java similarity index 63% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java index 50360fee81496..aeacbc6655ace 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java similarity index 59% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java index fa9737305d268..0dc97946c274b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java similarity index 58% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java index a04d9b3c40540..c5bdf89410d9e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java similarity index 58% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java index 30b69d136c2b7..6768bb5045206 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java @@ -3,7 +3,6 @@ // license information. /** - * This package contains the classes for KeyVaultClient. Performs cryptographic - * key operations and vault operations against the Key Vault service. + * This package contains the classes for key vault JSON web key. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index a1a3830259410..66e34edb30b3e 100644 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -52,6 +52,11 @@ azure-client-runtime 1.0.0-SNAPSHOT
+ + ${project.groupId} + azure-keyvault-webkey + ${project.version} + diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 8b5c045ede14a..4c9e596423269 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -33,7 +33,6 @@ import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.IssuerCredentials; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyCreateParameters; @@ -54,6 +53,9 @@ import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; +import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index ae4a62b7cbacc..e7ce6cc2b0fb1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 0cd6eb0a956e5..457486131b8c7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -12,6 +12,7 @@ import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; /** * The key import parameters. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index b644554936253..91adae60c3ce8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -5,8 +5,8 @@ import java.util.Map; import com.microsoft.azure.keyvault.models.Attributes; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; /** * The import key request class. diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 86410c9ab946f..de8a167ee8eda 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Test; @@ -39,6 +40,7 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; @@ -115,7 +117,21 @@ public void keyAsync() throws Exception { Assert.assertTrue(verifypResult.value()); keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); - Assert.assertNotNull(keyBundle); + Assert.assertNotNull(keyBundle); + + //Get the unavailable key to throw exception -> it gets stuck + + try { + keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("KeyNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test @@ -144,6 +160,18 @@ public void secretAsync() throws Exception { secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); Assert.assertNotNull(secretBundle); + + try { + keyVaultClient.deleteSecretAsync(vault, secretname, null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("SecretNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test @@ -199,7 +227,19 @@ public void certificateAsync() throws Exception { keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); - keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + + try { + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("CertificateNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index c4fd3b4d6209f..219b2202eade1 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -48,8 +48,8 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.Attributes; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; diff --git a/pom.xml b/pom.xml index 13352a37a5d1d..76d0bed4340fc 100644 --- a/pom.xml +++ b/pom.xml @@ -239,6 +239,7 @@ ./azure-keyvault-core ./azure-keyvault-cryptography ./azure-keyvault-extensions + ./azure-keyvault-webkey ./azure-mgmt-compute ./azure-mgmt-resources ./azure-mgmt-storage From 3354595de1ed94029f1e3e2cb15ee60efabb9fe4 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Wed, 24 Aug 2016 09:56:30 -0700 Subject: [PATCH 07/47] License, documentation and byte array handling update. --- .../microsoft/azure/keyvault/core/IKey.java | 18 +-- .../keyvault/cryptography/Algorithm.java | 57 ++----- .../cryptography/AlgorithmResolver.java | 18 +-- .../AsymmetricEncryptionAlgorithm.java | 76 +++++++-- .../AsymmetricSignatureAlgorithm.java | 18 +-- .../keyvault/cryptography/ByteExtensions.java | 147 ++++++++++++++++++ .../cryptography/EncryptionAlgorithm.java | 26 ++-- .../IAuthenticatedCryptoTransform.java | 18 +-- .../cryptography/ICryptoTransform.java | 34 ++-- .../cryptography/KeyWrapAlgorithm.java | 133 ++++++++++++++-- .../cryptography/SignatureAlgorithm.java | 18 +-- .../azure/keyvault/cryptography/Strings.java | 18 +-- .../SymmetricEncryptionAlgorithm.java | 99 +++++++++--- .../keyvault/cryptography/SymmetricKey.java | 18 +-- .../cryptography/algorithms/Aes128Cbc.java | 27 +--- .../algorithms/Aes128CbcHmacSha256.java | 18 +-- .../cryptography/algorithms/Aes192Cbc.java | 27 +--- .../algorithms/Aes192CbcHmacSha384.java | 18 +-- .../cryptography/algorithms/Aes256Cbc.java | 27 +--- .../algorithms/Aes256CbcHmacSha512.java | 18 +-- .../cryptography/algorithms/AesCbc.java | 18 +-- .../algorithms/AesCbcHmacSha2.java | 18 +-- .../cryptography/algorithms/AesKw.java | 18 +-- .../cryptography/algorithms/AesKw128.java | 23 +-- .../cryptography/algorithms/AesKw192.java | 23 +-- .../cryptography/algorithms/AesKw256.java | 23 +-- .../cryptography/algorithms/Rsa15.java | 18 +-- .../algorithms/RsaEncryption.java | 18 +-- .../cryptography/algorithms/RsaOaep.java | 18 +-- .../cryptography/algorithms/package-info.java | 9 ++ .../cryptography/algorithms/package.html | 5 - .../keyvault/cryptography/package-info.java | 10 ++ .../azure/keyvault/cryptography/package.html | 5 - .../cryptography/test/AesCbcTest.java | 17 +- .../azure/keyvault/CertificateIdentifier.java | 18 +-- .../CertificateOperationIdentifier.java | 18 +-- .../azure/keyvault/IssuerIdentifier.java | 18 +-- .../azure/keyvault/KeyIdentifier.java | 18 +-- .../azure/keyvault/KeyVaultClient.java | 2 +- .../azure/keyvault/ObjectIdentifier.java | 18 +-- .../azure/keyvault/SecretIdentifier.java | 18 +-- .../authentication/ChallengeCache.java | 18 +-- .../authentication/KeyVaultCredentials.java | 18 +-- .../keyvault/test/AsyncOperationsTest.java | 18 +-- .../test/CertificateOperationsTest.java | 18 +-- .../keyvault/test/KeyOperationsTest.java | 18 +-- .../KeyVaultClientIntegrationTestBase.java | 18 +-- .../keyvault/test/SecretOperationsTest.java | 18 +-- 48 files changed, 610 insertions(+), 682 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java delete mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java delete mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index 6cf69f7002aa9..5eb18bd42677a 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.core; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index 127521c7d4373..e80ccaf5a76b0 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -1,27 +1,24 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; +/** + * Abstract base class for all Algorithm objects. + * + */ public abstract class Algorithm { private final String _name; + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected Algorithm(String name) { if (Strings.isNullOrWhiteSpace(name)) { throw new IllegalArgumentException("name"); @@ -30,32 +27,12 @@ protected Algorithm(String name) { _name = name; } - public String getName() { - return _name; - } - - /* - * Takes the first count bytes from the source and - * returns a new array containing those bytes. + /** + * Gets the name of the algorithm. * - * @param count The number of bytes to take. - * @param source The source of the bytes. - * @return count bytes from the source as a new array. + * @return The name of the algorithm. */ - public static byte[] Take(int count, byte[] source) - { - if ( source == null ) { - throw new IllegalArgumentException("source"); - } - - if ( count <= 0 || count > source.length ) { - throw new IllegalArgumentException("count"); - } - - byte[] target = new byte[count]; - - System.arraycopy(source, 0, target, 0, count); - - return target; + public String getName() { + return _name; } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index c794b02867779..6804aa055420d 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java index 6a01e0333b0f2..b239a41d8530c 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,18 +13,74 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all asymmetric encryption algorithms. + * + */ public abstract class AsymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected AsymmetricEncryptionAlgorithm(String name) { super(name); } + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider. + * + * @param keyPair + * The key pair to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}. + * + * @param keyPair + * The key pair to use. + * @param provider + * The provider to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider. + * + * @param keyPair + * The key pair to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}. + * + * @param keyPair + * The key pair to use. + * @param provider + * The provider to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java index 5232ab646ff4c..ff5e1417ba5c6 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java new file mode 100644 index 0000000000000..c76b4c507de6a --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java @@ -0,0 +1,147 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.cryptography; + +public final class ByteExtensions { + + public static boolean sequenceEqualConstantTime( byte[] self, byte[] other ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + // Constant time comparison of two byte arrays + long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); + + for ( int i = 0; i < self.length && i < other.length; i++ ) + { + difference |= ( self[i] ^ other[i] ) & 0xffffffffl; + } + + return difference == 0; + } + + public static byte[] or( byte[] self, byte[] other ) + { + return or( self, other, 0 ); + } + + public static byte[] or( byte[] self, byte[] other, int offset ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + if ( self.length > other.length - offset ) + throw new IllegalArgumentException( "self and other lengths do not match" ); + + byte[] result = new byte[self.length]; + + for ( int i = 0; i < self.length; i++ ) + { + result[i] = (byte)( self[i] | other[offset + i] ); + } + + return result; + } + + public static byte[] xor( byte[] self, byte[] other ) { + return xor( self, other, 0, false ); + } + + public static byte[] xor( byte[] self, byte[] other, boolean inPlace ) + { + return xor( self, other, 0, inPlace ); + } + + public static byte[] xor( byte[] self, byte[] other, int offset ) { + return xor( self, other, 0, false ); + } + + public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + if ( self.length > other.length - offset ) + throw new IllegalArgumentException( "self and other lengths do not match" ); + + if ( inPlace ) + { + for ( int i = 0; i < self.length; i++ ) + { + self[i] = (byte)( self[i] ^ other[offset + i] ); + } + + return self; + } + else + { + byte[] result = new byte[self.length]; + + for ( int i = 0; i < self.length; i++ ) + { + result[i] = (byte)( self[i] ^ other[offset + i] ); + } + + return result; + } + } + + public static byte[] take( byte[] self, int count ) + { + return ByteExtensions.take( self, 0, count ); + } + + + /** + * Takes the first count bytes from the source and + * returns a new array containing those bytes. + * + * @param self The source of the bytes. + * @param offset The starting offset. + * @param count The number of bytes to take. + * @return count bytes from the source as a new array. + */ + public static byte[] take( byte[] self, int offset, int count ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( offset < 0 ) + throw new IllegalArgumentException( "offset cannot be < 0" ); + + if ( count <= 0 ) + throw new IllegalArgumentException( "count cannot be <= 0" ); + + if ( offset + count > self.length ) + throw new IllegalArgumentException( "offset + count cannot be > self.Length" ); + + byte[] result = new byte[count]; + + System.arraycopy( self, offset, result, 0, count ); + + return result; + } + + public static void zero( byte[] self ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + for ( int i = 0; i < self.length; i++ ) { + self[i] = 0; + } + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java index 527b704d6db20..4d36c332b3beb 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java @@ -1,25 +1,21 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; +/** + * Abstract base class for all encryption algorithms. + * + */ public abstract class EncryptionAlgorithm extends Algorithm { + /** + * Constructor. + * @param name The name of the algorithm. + */ protected EncryptionAlgorithm(String name) { super(name); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java index 8145964666abf..113a14404cf4d 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java index 3e1c725b3f8b0..4787a9d11a0f4 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -24,7 +12,23 @@ import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; +/** + * Defines the basic operations of cryptographic transformations. + * + */ public interface ICryptoTransform { + /** + * Transforms the specified region of the specified byte array as a single operation. + * + * @param input + * The byte array to be transformed + * @return + * The transformed result. + * @throws IllegalBlockSizeException + * @throws BadPaddingException + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + */ public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException; } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java index fdc15bc1dad94..e0028d51a5073 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,25 +13,140 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all key wrap algorithms. + * + */ public abstract class KeyWrapAlgorithm extends Algorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected KeyWrapAlgorithm(String name) { super(name); } + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption. + * Uses the default AES-KW initialization vector. + * @param key + * The AES key material to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified provider for the Java Security API. Uses the default AES-KW initialization vector. + * + * @param key + * The AES key material to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption. + * Uses the default AES-KW initialization vector. + * @param key + * The AES key material to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified provider for the Java Security API. Uses the default AES-KW initialization vector. + * + * @param key + * The AES key material to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java index f0d8f2b953f88..53d7459b91363 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java index c6cf7244a1532..a1ead94749e65 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java index 4834485c31957..7c6e586fc09f8 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,18 +13,91 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all symmetric encryption algorithms. + * + */ public abstract class SymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected SymmetricEncryptionAlgorithm(String name) { super(name); } - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; - - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; - + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index f9900d592b3de..14e0797b46587 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index c0a5630e8df6b..14cf40023b7c8 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes128Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,6 +63,6 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java index eeb40fa3808b4..9e75131a3de84 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 96b03caf970e0..4ec8451b47901 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes192Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,7 +63,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java index 0e0e6758558a8..74f279eff8c72 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 88abe788ee757..629b647ec6b92 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes256Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,7 +63,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java index 495bc7bd69468..e038c808fec53 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java index 7c49fba06c6b2..49edaa57a71b5 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java index 882a21284d616..c2ccc2a88ab13 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java index 8f7fa07ae6f12..6bd7dfc28c639 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 2044f10895867..3c628688ef236 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw128 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index bb652553ff83e..dd24b0011a0c1 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw192 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index b2ed7dd4815f7..79398e292adc4 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw256 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java index 8161095756f88..4770183bb3ab8 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java index dd673f61ab416..83343057aa55a 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java index 424778e85f261..55b57b6acd633 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java new file mode 100644 index 0000000000000..f3101db3f04c0 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains cryptographic functions and implementations. + */ +package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html deleted file mode 100644 index 102a782ab4a86..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This package contains the Azure Key Vault Extension Cryptographic algorithm classes. - - diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java new file mode 100644 index 0000000000000..5492e8c677615 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains cryptographic functions and implementations + * of RSA and symmetric keys that conform with the IKey interface. + */ +package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html deleted file mode 100644 index 12edd05fd0bac..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This package contains the Azure Key Vault Extension classes. - - diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 6498b9508dff6..c35cfcdfc6c24 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import com.microsoft.azure.keyvault.cryptography.Algorithm; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -63,7 +64,7 @@ public void testAes128CbcOneBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 16), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -81,7 +82,7 @@ public void testAes128CbcOneBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -110,7 +111,7 @@ public void testAes128CbcTwoBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -128,7 +129,7 @@ public void testAes128CbcTwoBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -157,7 +158,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 16),ED); } catch (Exception e) { fail(e.getMessage()); } @@ -175,7 +176,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -204,7 +205,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -222,7 +223,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java index 334ad65b5f3d4..c78460edcfdec 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java index e902dad696565..ed88be41ab019 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java index 69b685c50ea40..6d50e9c6c049c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java index b28d4464449e2..67dcd6f35b83e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 1c1d45cab33d3..2aae9e82f23b3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java index 290a07c94003e..e026b82b7d9ae 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java index 60d3d927bcdee..c2564685eb822 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java index 7f0a1fbd287d0..07cd0a8dc49b7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.authentication; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java index ad1a3e8206271..9c184cb7cea5b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.authentication; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index de8a167ee8eda..44eb04f681b56 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 18a13e9423e9b..3af77cfca2625 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 219b2202eade1..54eb89cd3d444 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java index 2ebb0c791a977..d3deb5fcb23f5 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 1673ded8ff130..af27ec8973c2f 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; From 4759885c36c2658c4e29b584f2d773916a3ffed6 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Wed, 24 Aug 2016 15:22:19 -0700 Subject: [PATCH 08/47] Fix RSA256 signature --- .../cryptography/ISignatureTransform.java | 16 +++ .../azure/keyvault/cryptography/RsaKey.java | 24 ++--- .../cryptography/algorithms/Rs256.java | 102 ++++++------------ .../cryptography/algorithms/RsaSignature.java | 91 ++++++++-------- .../cryptography/test/AesCbcTest.java | 1 - .../cryptography/test/RsaKeyTest.java | 12 ++- 6 files changed, 112 insertions(+), 134 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java new file mode 100644 index 0000000000000..484b1448fb513 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java @@ -0,0 +1,16 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.GeneralSecurityException; + +public interface ISignatureTransform { + + public byte[] sign(final byte[] digest) throws GeneralSecurityException; + + public boolean verify(final byte[] digest, final byte[] signature) throws GeneralSecurityException; +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index 4548a883c17fd..4abfcfd8855a6 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -1,19 +1,7 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -262,7 +250,7 @@ public ListenableFuture> signAsync(final byte[] digest, fin Rs256 algo = (Rs256)baseAlgorithm; - Rs256.Rs256Signer signer = algo.createSigner(_keyPair); + ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); @@ -292,10 +280,10 @@ public ListenableFuture verifyAsync(final byte[] digest, final byte[] s Rs256 algo = (Rs256)baseAlgorithm; - Rs256.Rs256Verifier signer = algo.createVerifier(_keyPair); + ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { - return Futures.immediateFuture(signer.verify(signature, digest)); + return Futures.immediateFuture(signer.verify(digest, signature)); } catch (Exception e) { return Futures.immediateFailedFuture(e); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java index 750a02f529ea7..54a4fd4572361 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -1,32 +1,19 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; import java.math.BigInteger; -import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; +import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; /** * @@ -35,27 +22,31 @@ public class Rs256 extends RsaSignature { static final String RsaNone = "RSA/ECB/PKCS1Padding"; - public class Rs256Signer { - + class Rs256SignatureTransform implements ISignatureTransform { + private final KeyPair _keyPair; private final int _emLen; - private final BigInteger _n; - - Rs256Signer(KeyPair keyPair) { - + Rs256SignatureTransform(KeyPair keyPair) { _keyPair = keyPair; - _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); - _emLen = getOctetLength( _n.bitLength() ); + BigInteger modulus = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + + _emLen = getOctetLength( modulus.bitLength() ); + } - - public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + @Override + public byte[] sign(byte[] digest) throws NoSuchAlgorithmException { // Signing isn't just a case of encrypting the digest, there is much more to do. // For details of the algorithm, see https://tools.ietf.org/html/rfc3447#section-8.2 + if ( _keyPair.getPrivate() == null ) { + // TODO + } + // Construct the encoded message - byte[] EM = EMSA_PKCS1_V1_5_ENCODE(digest, _emLen, "SHA-256"); + byte[] EM = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); // Convert to integer message BigInteger s = OS2IP(EM); @@ -64,26 +55,14 @@ public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgori s = RSASP1((RSAPrivateKey)_keyPair.getPrivate(), s); // Convert to octet sequence - return I2OSP(s, getOctetLength( _n.bitLength() ) ); + return I2OSP(s, _emLen ); } - } - - public class Rs256Verifier { - - private final KeyPair _keyPair; - private final BigInteger _n; - private final int _emLength; - - Rs256Verifier(KeyPair keyPair) { - _keyPair = keyPair; - _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); - _emLength = getOctetLength( _n.bitLength() ); - } - - public boolean verify(final byte[] signature, final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + @Override + public boolean verify(byte[] digest, byte[] signature) throws NoSuchAlgorithmException { - if ( signature.length != getOctetLength( _n.bitLength() ) ) { - throw new IllegalBlockSizeException(); + if ( signature.length != _emLen ) { + throw new IllegalArgumentException( "invalid signature length"); } // Convert to integer signature @@ -92,21 +71,13 @@ public boolean verify(final byte[] signature, final byte[] digest) throws Invali // Convert integer message BigInteger m = RSAVP1((RSAPublicKey)_keyPair.getPublic(), s); + byte[] EM = I2OSP(m, _emLen ); + byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); - byte[] EM = I2OSP(m, getOctetLength( _n.bitLength() ) ); - byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE(digest, _emLength, "SHA-256"); - - // TODO: Need constant time compare - if ( EM.length != EM2.length ) - return false; - - for ( int i = 0; i < digest.length; i++ ) { - if ( EM[i] != EM2[i] ) - return false; - } - - return true; + // Use constant time compare + return ByteExtensions.sequenceEqualConstantTime(EM, EM2); } + } public final static String AlgorithmName = "RS256"; @@ -115,12 +86,9 @@ public Rs256() { super(AlgorithmName); } - public Rs256Signer createSigner(KeyPair keyPair) { + @Override + public ISignatureTransform createSignatureTransform(KeyPair keyPair) { - return new Rs256Signer(keyPair); - } - - public Rs256Verifier createVerifier(KeyPair keyPair) { - return new Rs256Verifier(keyPair); + return new Rs256SignatureTransform(keyPair); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java index a9ac4d4559cbb..e5248b47bfb52 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -1,24 +1,13 @@ /** - * - * 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. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; import java.math.BigInteger; +import java.security.KeyPair; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; @@ -26,6 +15,7 @@ import java.util.Arrays; import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; +import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; import com.microsoft.azure.keyvault.cryptography.Strings; public abstract class RsaSignature extends AsymmetricSignatureAlgorithm { @@ -37,33 +27,10 @@ protected RsaSignature(String name) { super(name); } - protected static byte[] toByteArray(BigInteger n) { - byte[] result = n.toByteArray(); - if (result[0] == 0) { - // The leading zero is used to let the number positive. Since RSA - // parameters are always positive, we remove it. - return Arrays.copyOfRange(result, 1, result.length); - } - return result; - } - - protected static BigInteger toBigInteger(byte[] b) { - if (b[0] < 0) { - // RSA parameters are always positive numbers, so if the first byte - // is negative, we need to add a leading zero - // to make the entire BigInteger positive. - byte[] temp = new byte[1 + b.length]; - System.arraycopy(b, 0, temp, 1, b.length); - b = temp; - } - return new BigInteger(b); - } - protected int getOctetLength(int bits) { return ( bits % 8 > 0 ) ? bits >> 3 + 1 : bits >> 3; } - /* * See https://tools.ietf.org/html/rfc3447#section-4.2 */ @@ -161,7 +128,6 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t throw new IllegalArgumentException("m"); } - byte[] algorithmPrefix = null; MessageDigest messageDigest = null; // Check algorithm @@ -172,25 +138,55 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t // Only supported algorithms if ( algorithm.equals("SHA-256") ) { - // Initialize prefix and digest - algorithmPrefix = sha256Prefix; + // Initialize digest messageDigest = MessageDigest.getInstance("SHA-256"); } else { throw new IllegalArgumentException("algorithm"); } - if ( algorithmPrefix == null || messageDigest == null ) { - throw new IllegalArgumentException("initialization with arguments failed"); - } - // Hash the message byte[] digest = messageDigest.digest(m); // Construct T, the DER encoded DigestInfo structure - byte[] T = new byte[algorithmPrefix.length + digest.length]; + return EMSA_PKCS1_V1_5_ENCODE_HASH(digest, emLen, algorithm); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-9.2 + */ + protected byte[] EMSA_PKCS1_V1_5_ENCODE_HASH(byte[] h, int emLen, String algorithm) throws NoSuchAlgorithmException { + + // Check m + if ( h == null || h.length == 0 ) { + throw new IllegalArgumentException("m"); + } + + byte[] algorithmPrefix = null; + + // Check algorithm + if ( Strings.isNullOrWhiteSpace(algorithm) ) { + throw new IllegalArgumentException("algorithm"); + } + + // Only supported algorithms + if ( algorithm.equals("SHA-256") ) { + + // Initialize prefix and digest + algorithmPrefix = sha256Prefix; + + if ( h.length != 32 ) { + throw new IllegalArgumentException("h is incorrect length for SHA-256"); + } + } else { + throw new IllegalArgumentException("algorithm"); + } + + + // Construct T, the DER encoded DigestInfo structure + byte[] T = new byte[algorithmPrefix.length + h.length]; System.arraycopy(algorithmPrefix, 0, T, 0, algorithmPrefix.length); - System.arraycopy(digest, 0, T, algorithmPrefix.length, digest.length); + System.arraycopy(h, 0, T, algorithmPrefix.length, h.length); if ( emLen < T.length + 11 ) { throw new IllegalArgumentException("intended encoded message length too short"); @@ -212,4 +208,5 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t return EM; } + public abstract ISignatureTransform createSignatureTransform(KeyPair keyPair); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index c35cfcdfc6c24..351f22a1ce993 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -11,7 +11,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.azure.keyvault.cryptography.Algorithm; import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 454752d7bac8b..2b181398ae859 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -25,7 +25,8 @@ public class RsaKeyTest { // A Content Encryption Key, or Message. This value is kept consistent with the .NET // unit test cases to enable cross platform testing. - static final byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + static final byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + static final String CrossPlatformHash = "qPrtarvzXBKksm5A9v6xnXNtkARcg7n5ox9jjTI+aBE="; static final String CrossPlatformSignature = "RaNc+8WcWxplS8I7ynJLSoLJKz+dgBvrZhIGH3VFlTTyzu7b9d+lpaV9IKhzCNBsgSysKhgL7EZwVCOTBZ4m6xvKSXqVFXYaBPyBTD7VoKPMYMW6ai5x6xV5XAMaZPfMkff3Deg/RXcc8xQ28FhYuUa8yly01GySY4Hk55anEvb2wBxSy1UGun/0LE1lYH3C3XEgSry4cEkJHDJl1hp+wB4J/noXOqn5ECGU+/4ehBJOyW1gtUH0/gRe8yXnDH0AXepHRyH8iBHLWlKX1r+1/OrMulqOoi82RZzJlTyEz9X+bsQhllqGF6n3hdLS6toH9o7wUtwYNqSx82JuQT6iMg=="; private Provider _provider = null; @@ -134,11 +135,20 @@ public void testSignVerify() throws Exception { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(CEK); + byte[] crossPlatformHash = Base64.decodeBase64(CrossPlatformHash); + byte[] crossPlatformSignature = Base64.decodeBase64(CrossPlatformSignature); + + assertNotNull( hash ); + assertEquals( 32, hash.length ); + assertArrayEquals(hash, crossPlatformHash); + Pair signature = key.signAsync(hash, "RS256").get(); boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); assertTrue(result); + //assertArrayEquals(crossPlatformSignature, signature.getLeft()); + // Now prove we can verify the cross platform signature result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); From d99d08b42fb6e03ec7025b6ef614f6251aba3397 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 29 Aug 2016 16:58:23 -0700 Subject: [PATCH 09/47] Minor signature code cleanup --- .../azure/keyvault/cryptography/algorithms/RsaSignature.java | 2 -- .../azure/keyvault/cryptography/test/RsaKeyTest.java | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java index e5248b47bfb52..84d2257ae2175 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -12,8 +12,6 @@ import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import java.util.Arrays; - import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; import com.microsoft.azure.keyvault.cryptography.Strings; diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 2b181398ae859..18cf7db616e18 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -138,6 +138,7 @@ public void testSignVerify() throws Exception { byte[] crossPlatformHash = Base64.decodeBase64(CrossPlatformHash); byte[] crossPlatformSignature = Base64.decodeBase64(CrossPlatformSignature); + // Check the hash assertNotNull( hash ); assertEquals( 32, hash.length ); assertArrayEquals(hash, crossPlatformHash); @@ -145,9 +146,9 @@ public void testSignVerify() throws Exception { Pair signature = key.signAsync(hash, "RS256").get(); boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); + // Check the signature assertTrue(result); - - //assertArrayEquals(crossPlatformSignature, signature.getLeft()); + assertArrayEquals(crossPlatformSignature, signature.getLeft()); // Now prove we can verify the cross platform signature result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); From 1551ec9ba62d0eb473d1735111d3fe822672a12c Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 2 Sep 2016 10:59:27 -0700 Subject: [PATCH 10/47] Adapting the observer model for Key Vault wrapped client, fixed build becaue incompatibility with runtime and instead of using constant string for JWK algorithms use static class representations --- .../keyvault/extensions/KeyVaultKey.java | 10 +- .../KeyVaultKeyResolverBCProviderTest.java | 3 +- ...eyVaultKeyResolverDefaultProviderTest.java | 3 +- .../azure/keyvault/webkey/JsonWebKey.java | 14 +- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 62 +- .../keyvault/webkey/JsonWebKeyOperation.java | 94 +- .../webkey/JsonWebKeySignatureAlgorithm.java | 79 +- .../azure/keyvault/webkey/JsonWebKeyType.java | 79 +- .../azure/keyvault/KeyVaultClient.java | 83 +- .../azure/keyvault/KeyVaultClientImpl.java | 4982 ++++++++--------- .../models/CertificateIssuerItem.java | 2 +- .../CertificateIssuerSetParameters.java | 2 +- .../CertificateIssuerUpdateParameters.java | 5 +- .../CertificateOperationUpdateParameter.java | 2 +- .../azure/keyvault/models/IssuerBundle.java | 2 +- .../keyvault/models/IssuerReference.java | 3 +- .../azure/keyvault/models/KeyBundle.java | 5 +- .../keyvault/models/KeyCreateParameters.java | 17 +- .../azure/keyvault/models/KeyItem.java | 5 +- .../models/KeyOperationsParameters.java | 7 +- .../azure/keyvault/models/KeyProperties.java | 2 +- .../keyvault/models/KeySignParameters.java | 7 +- .../keyvault/models/KeyUpdateParameters.java | 7 +- .../keyvault/models/KeyVerifyParameters.java | 7 +- .../azure/keyvault/models/SecretBundle.java | 9 +- .../azure/keyvault/models/SecretItem.java | 5 +- .../models/X509CertificateProperties.java | 4 +- .../keyvault/requests/CreateKeyRequest.java | 25 +- .../keyvault/requests/ImportKeyRequest.java | 3 +- .../keyvault/requests/UpdateKeyRequest.java | 11 +- .../keyvault/test/AsyncOperationsTest.java | 11 +- .../test/CertificateOperationsTest.java | 12 +- .../keyvault/test/KeyOperationsTest.java | 66 +- .../keyvault/test/SecretOperationsTest.java | 15 +- 34 files changed, 2768 insertions(+), 2875 deletions(-) diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 2ef3291cfca3a..f4afd66b74aaa 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -30,6 +30,8 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; @@ -96,7 +98,7 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { if (key.kty().equals(JsonWebKeyType.RSA)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); - } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { + } else if (key.kty().equals(JsonWebKeyType.RSA_HSM)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); } @@ -169,7 +171,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ ListenableFuture> futureCall = client.decryptAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -207,7 +209,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit ListenableFuture> futureCall = client.unwrapKeyAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -227,7 +229,7 @@ public ListenableFuture> signAsync(byte[] digest, String al ListenableFuture> futureCall = client.signAsync( implementation.getKid(), - algorithm, + new JsonWebKeySignatureAlgorithm(algorithm), digest, null); return Futures.transform(futureCall, new SignResultTransform(algorithm)); diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index 58948e52d9bb2..f7f16bb09ca29 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -38,6 +38,7 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); ServiceResponse response = keyVaultClient.createKey(request); KeyBundle bundle = response != null ? response.getBody() : null; diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index e6932d917cda1..63708e2b6a085 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -22,6 +22,7 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; // //Copyright © Microsoft Corporation, All Rights Reserved @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); try diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index e6670116cf5e4..868cab9204858 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -45,12 +45,12 @@ public class JsonWebKey { * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', * 'oct'. */ - private String kty; + private JsonWebKeyType kty; /** * The keyOps property. */ - private List keyOps; + private List keyOps; /** * RSA modulus. @@ -130,7 +130,7 @@ public JsonWebKey withKid(String kid) { * @return the key type. */ @JsonProperty("kty") - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -140,7 +140,7 @@ public String kty() { * @param kty the key type * @return the JsonWebKey object itself. */ - public JsonWebKey withKty(String kty) { + public JsonWebKey withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -151,7 +151,7 @@ public JsonWebKey withKty(String kty) { * @return the key operations. */ @JsonProperty("key_ops") - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -161,7 +161,7 @@ public List keyOps() { * @param keyOps the key operations value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKeyOps(List keyOps) { + public JsonWebKey withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -455,7 +455,7 @@ private PrivateKey getRSAPrivateKey(Provider provider) { * Verifies if the key is an RSA key. */ private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { + if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSA_HSM.equals(kty())) { throw new UnsupportedOperationException("Not an RSA key"); } } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java index 8eb412e21e412..67e5e99dd08c2 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,30 +10,58 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey Algorithms. + * Defines values for JsonWebKeyEncryptionAlgorithm. */ public final class JsonWebKeyEncryptionAlgorithm { + /** Static value RSA-OAEP for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP = new JsonWebKeyEncryptionAlgorithm("RSA-OAEP"); - /** - * The 'RSA-OAEP' algorithm. - */ - public static final String RSAOAEP = "RSA-OAEP"; - - /** - * The 'RSA1_5' algorithm. - */ - public static final String RSA15 = "RSA1_5"; + /** Static value RSA1_5 for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA1_5 = new JsonWebKeyEncryptionAlgorithm("RSA1_5"); + + private String value; /** - * All the JWK encryption algorithms. + * Creates a custom value for JsonWebKeyEncryptionAlgorithm. + * @param value the custom value */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RSA15, RSAOAEP})); + public JsonWebKeyEncryptionAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyEncryptionAlgorithm() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyEncryptionAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyEncryptionAlgorithm rhs = (JsonWebKeyEncryptionAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK encryption algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList(Arrays.asList(RSA_OAEP, RSA1_5)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java index aeacbc6655ace..9dbb9d30fce67 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,50 +10,70 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey operations. + * Defines values for JsonWebKeyOperation. */ public final class JsonWebKeyOperation { + /** Static value encrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation ENCRYPT = new JsonWebKeyOperation("encrypt"); - /** - * Encrypt operation. - */ - public static final String ENCRYPT = "encrypt"; - - /** - * Decrypt operation. - */ - public static final String DECRYPT = "decrypt"; - - /** - * Sign operation. - */ - public static final String SIGN = "sign"; - - /** - * Verify operation. - */ - public static final String VERIFY = "verify"; - - /** - * WrapKey operation. - */ - public static final String WRAP = "wrapKey"; - - /** - * UnwrapKey operation. - */ - public static final String UNWRAP = "unwrapKey"; + /** Static value decrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation DECRYPT = new JsonWebKeyOperation("decrypt"); + + /** Static value sign for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation SIGN = new JsonWebKeyOperation("sign"); + + /** Static value verify for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation VERIFY = new JsonWebKeyOperation("verify"); + + /** Static value wrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation WRAP_KEY = new JsonWebKeyOperation("wrapKey"); + + /** Static value unwrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation UNWRAP_KEY = new JsonWebKeyOperation("unwrapKey"); + + private String value; /** - * All JWK operations. + * Creates a custom value for JsonWebKeyOperation. + * @param value the custom value */ - public static final List ALL_OPERATIONS = - Collections.unmodifiableList( - Arrays.asList(new String[] {ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); + public JsonWebKeyOperation(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyOperation() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyOperation)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyOperation rhs = (JsonWebKeyOperation) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK operations. + */ + public static final List ALL_OPERATIONS = + Collections.unmodifiableList(Arrays.asList(ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP_KEY, UNWRAP_KEY)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java index 0dc97946c274b..5e532c10cd297 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,39 +10,64 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey Algorithms. + * Defines values for JsonWebKeySignatureAlgorithm. */ public final class JsonWebKeySignatureAlgorithm { + /** Static value RS256 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS256 = new JsonWebKeySignatureAlgorithm("RS256"); - /** - * The 'RS256' algorithm. - */ - public static final String RS256 = "RS256"; - - /** - * The 'RS384' algorithm. - */ - public static final String RS384 = "RS384"; - - /** - * The 'RS512' algorithm. - */ - public static final String RS512 = "RS512"; - - /** - * The 'RSNULL' algorithm. - */ - public static final String RSNULL = "RSNULL"; + /** Static value RS384 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS384 = new JsonWebKeySignatureAlgorithm("RS384"); + + /** Static value RS512 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS512 = new JsonWebKeySignatureAlgorithm("RS512"); + + /** Static value RSNULL for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RSNULL = new JsonWebKeySignatureAlgorithm("RSNULL"); + + private String value; /** - * All JWK algorithms. + * Creates a custom value for JsonWebKeySignatureAlgorithm. + * @param value the custom value */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RS256, RS384, RS512, RSNULL})); + public JsonWebKeySignatureAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeySignatureAlgorithm() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeySignatureAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeySignatureAlgorithm rhs = (JsonWebKeySignatureAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK signature algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList(Arrays.asList(RS256, RS384, RS512, RSNULL)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java index c5bdf89410d9e..8a7c9dbffbc8e 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,39 +10,64 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey key types (kty). + * Defines values for JsonWebKeyType. */ public final class JsonWebKeyType { + /** Static value EC for JsonWebKeyType. */ + public static final JsonWebKeyType EC = new JsonWebKeyType("EC"); - /** - * The Elliptic Curve 'EC' key type. - */ - public static final String EC = "EC"; - - /** - * The 'RSA' key type. - */ - public static final String RSA = "RSA"; - - /** - * The 'RSA-HSM' key type. - */ - public static final String RSAHSM = "RSA-HSM"; - - /** - * The Octet 'oct' key type. - */ - public static final String OCT = "oct"; + /** Static value RSA for JsonWebKeyType. */ + public static final JsonWebKeyType RSA = new JsonWebKeyType("RSA"); + + /** Static value RSA-HSM for JsonWebKeyType. */ + public static final JsonWebKeyType RSA_HSM = new JsonWebKeyType("RSA-HSM"); + + /** Static value oct for JsonWebKeyType. */ + public static final JsonWebKeyType OCT = new JsonWebKeyType("oct"); + + private String value; /** - * All JWK key types. + * Creates a custom value for JsonWebKeyType. + * @param value the custom value */ - public static final List ALL_TYPES = - Collections.unmodifiableList( - Arrays.asList(new String[] {EC, RSA, RSAHSM, OCT})); + public JsonWebKeyType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyType() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyType)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyType rhs = (JsonWebKeyType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK key types. + */ + public static final List ALL_TYPES = + Collections.unmodifiableList(Arrays.asList(EC, RSA, RSA_HSM, OCT)); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 2aae9e82f23b3..0dbb76b43010b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -41,11 +41,12 @@ import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; @@ -56,6 +57,8 @@ import retrofit2.http.Headers; import retrofit2.http.Path; import retrofit2.http.Query; +import rx.Observable; +import rx.functions.Func1; /** * Initializes a new instance of the KeyVaultClient class. @@ -179,7 +182,7 @@ private void initializeService() { interface KeyVaultClientService { @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) @GET("certificates/{certificate-name}/pending") - Call getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } /** @@ -585,7 +588,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -600,7 +603,7 @@ public ServiceResponse encrypt(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -616,7 +619,7 @@ public ServiceCall encryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -631,7 +634,7 @@ public ServiceResponse decrypt(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -647,7 +650,7 @@ public ServiceCall decryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -662,7 +665,7 @@ public ServiceResponse sign(String keyIdentifier, String alg * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -679,7 +682,7 @@ public ServiceCall signAsync(String keyIdentifier, String al * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) + public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -695,7 +698,7 @@ public ServiceResponse verify(String keyIdentifier, String algo * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -711,7 +714,7 @@ public ServiceCall verifyAsync(String keyIdentifier, String alg * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -726,7 +729,7 @@ public ServiceResponse wrapKey(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -742,7 +745,7 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -757,7 +760,7 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -1857,19 +1860,7 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ */ public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - Response response = call.execute(); - return new ServiceResponse(response.body().string(), response); + return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -1881,6 +1872,17 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the pending certificate signing request response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the String object + */ + private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1891,24 +1893,17 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - if (serviceCallback != null) { - serviceCallback.success(new ServiceResponse(response.body().string(), response)); - } - serviceCall.success(new ServiceResponse(response.body().string(), response)); - } catch (IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = new ServiceResponse(response.body().string(), response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 4c9e596423269..156945410742d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -13,6 +13,7 @@ import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.keyvault.models.BackupKeyResult; @@ -54,6 +55,10 @@ import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; @@ -61,16 +66,15 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.RestClient; import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.Validator; import java.io.IOException; import java.util.List; import java.util.Map; import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.Header; @@ -83,6 +87,8 @@ import retrofit2.http.Query; import retrofit2.http.Url; import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; /** * Initializes a new instance of the KeyVaultClientImpl class. @@ -246,199 +252,199 @@ private void initializeService() { interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/create") - Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("keys/{key-name}") - Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) - Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("keys/{key-name}/{key-version}") - Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/{key-version}") - Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/versions") - Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys") - Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/backup") - Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/restore") - Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/encrypt") - Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/decrypt") - Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") - Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/wrapkey") - Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/unwrapkey") - Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("secrets/{secret-name}") - Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) - Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("secrets/{secret-name}/{secret-version}") - Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/{secret-version}") - Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets") - Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/versions") - Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates") - Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) - Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Call setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") - Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) - Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers") - Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") - Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) - Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/create") - Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/import") - Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/versions") - Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/policy") - Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") - Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/{certificate-version}") - Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") - Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) - Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/pending/merge") - Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -447,38 +453,14 @@ interface KeyVaultClientService { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - final Integer keySize = null; - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(null); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); } /** @@ -486,11 +468,23 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -504,7 +498,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); @@ -514,26 +508,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -541,9 +527,9 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -551,31 +537,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(keySize); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -583,15 +546,31 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param keyOps the List<JsonWebKeyOperation> value + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -614,26 +593,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -655,30 +626,7 @@ private ServiceResponse createKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - final Boolean hsm = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(null); - parameters.withKey(key); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); } /** @@ -688,9 +636,21 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -713,26 +673,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -750,29 +702,7 @@ public void onResponse(Call call, Response response) * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(hsm); - parameters.withKey(key); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); } /** @@ -785,9 +715,24 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyAttributes The key management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -800,7 +745,6 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName if (key == null) { throw new IllegalArgumentException("Parameter key is required and cannot be null."); } - Validator.validate(key); Validator.validate(keyAttributes); Validator.validate(tags); KeyImportParameters parameters = new KeyImportParameters(); @@ -809,26 +753,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -849,18 +785,7 @@ private ServiceResponse importKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteKeyDelegate(call.execute()); + return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -869,9 +794,20 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the KeyBundle object + */ + public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -882,26 +818,18 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -923,28 +851,7 @@ private ServiceResponse deleteKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -954,9 +861,21 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -969,7 +888,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); @@ -977,26 +896,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1013,29 +924,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -1048,9 +938,24 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1071,26 +976,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1112,21 +1009,7 @@ private ServiceResponse updateKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getKeyDelegate(call.execute()); + return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -1136,9 +1019,21 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1152,26 +1047,18 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1192,26 +1079,14 @@ private ServiceResponse getKeyDelegate(Response respons * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1220,9 +1095,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1234,32 +1146,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1274,25 +1172,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1302,9 +1189,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param keyName The name of the key + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1315,32 +1241,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1360,23 +1272,14 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1384,9 +1287,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl) { + return getKeysSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1395,32 +1333,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1434,22 +1358,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1458,9 +1374,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + return getKeysSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1468,32 +1421,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1514,18 +1453,7 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return backupKeyDelegate(call.execute()); + return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -1534,9 +1462,20 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the BackupKeyResult object + */ + public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1547,26 +1486,18 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = backupKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = backupKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1587,20 +1518,7 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (keyBundleBackup == null) { - throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); - } - KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.withKeyBundleBackup(keyBundleBackup); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return restoreKeyDelegate(call.execute()); + return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); } /** @@ -1609,9 +1527,20 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { + return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @return the observable to the KeyBundle object + */ + public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1624,26 +1553,18 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun KeyRestoreParameters parameters = new KeyRestoreParameters(); parameters.withKeyBundleBackup(keyBundleBackup); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = restoreKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = restoreKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1666,31 +1587,8 @@ private ServiceResponse restoreKeyDelegate(Response res * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return encryptDelegate(call.execute()); + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1702,9 +1600,23 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1727,26 +1639,18 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = encryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = encryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1769,31 +1673,8 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return decryptDelegate(call.execute()); + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1805,9 +1686,23 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1830,26 +1725,18 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = decryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = decryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1872,7 +1759,36 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1895,64 +1811,18 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return signDelegate(call.execute()); - } - - /** - * Creates a signature from a digest using the specified key in the vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param value the Base64Url value - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object - */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeySignParameters parameters = new KeySignParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = signDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); - } - } - }); - return serviceCall; + return service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = signDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); } private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1976,35 +1846,8 @@ private ServiceResponse signDelegate(Response * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (digest == null) { - throw new IllegalArgumentException("Parameter digest is required and cannot be null."); - } - if (signature == null) { - throw new IllegalArgumentException("Parameter signature is required and cannot be null."); - } - KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.withAlgorithm(algorithm); - parameters.withDigest(digest); - parameters.withSignature(signature); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return verifyDelegate(call.execute()); + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); } /** @@ -2017,9 +1860,24 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param digest The digest used for signing + * @param signature The signature to be verified + * @return the observable to the KeyVerifyResult object + */ + public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2046,26 +1904,18 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyN parameters.withDigest(digest); parameters.withSignature(signature); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = verifyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2088,31 +1938,8 @@ private ServiceResponse verifyDelegate(Response r * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return wrapKeyDelegate(call.execute()); + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2124,9 +1951,23 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2149,26 +1990,18 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = wrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = wrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2191,31 +2024,8 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return unwrapKeyDelegate(call.execute()); + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2227,9 +2037,23 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2252,26 +2076,18 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, Strin parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = unwrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = unwrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2293,29 +2109,7 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - final Map tags = null; - final String contentType = null; - final SecretAttributes secretAttributes = null; - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(null); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); } /** @@ -2325,9 +2119,21 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param value The value of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2349,26 +2155,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(null); parameters.withSecretAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2386,28 +2184,7 @@ public void onResponse(Call call, Response response) * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - Validator.validate(tags); - Validator.validate(secretAttributes); - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(tags); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); } /** @@ -2420,9 +2197,24 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2443,26 +2235,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(contentType); parameters.withSecretAttributes(secretAttributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2483,18 +2267,7 @@ private ServiceResponse setSecretDelegate(Response r * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteSecretDelegate(call.execute()); + return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); } /** @@ -2503,9 +2276,20 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the SecretBundle object + */ + public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2516,26 +2300,18 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2557,28 +2333,7 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final String contentType = null; - final SecretAttributes secretAttributes = null; - final Map tags = null; - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); } /** @@ -2588,9 +2343,21 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2611,26 +2378,18 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s parameters.withSecretAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2648,27 +2407,7 @@ public void onResponse(Call call, Response response) * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(secretAttributes); - Validator.validate(tags); - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); } /** @@ -2681,9 +2420,24 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2703,26 +2457,18 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s parameters.withSecretAttributes(secretAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2744,21 +2490,7 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getSecretDelegate(call.execute()); + return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); } /** @@ -2768,9 +2500,21 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2784,26 +2528,18 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2823,23 +2559,14 @@ private ServiceResponse getSecretDelegate(Response r * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2847,9 +2574,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl) { + return getSecretsSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2858,32 +2620,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2897,22 +2645,14 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2921,9 +2661,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of secrets to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2931,32 +2708,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2977,26 +2740,14 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3005,9 +2756,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3019,32 +2807,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3059,25 +2833,35 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); } /** @@ -3086,10 +2870,28 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param secretName The name of the secret in the given vault + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3100,32 +2902,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3145,23 +2933,14 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3169,9 +2948,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl) { + return getCertificatesSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3180,32 +2994,18 @@ public ServiceCall> getCertificatesAsync(final String vaul } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3219,22 +3019,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3243,9 +3035,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3253,32 +3082,18 @@ public ServiceCall> getCertificatesAsync(final String vaul throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3299,18 +3114,7 @@ private ServiceResponse> getCertificatesDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateDelegate(call.execute()); + return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -3319,9 +3123,20 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @return the observable to the CertificateBundle object + */ + public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3332,26 +3147,18 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3372,19 +3179,7 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (contacts == null) { - throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(contacts); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return setCertificateContactsDelegate(call.execute()); + return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); } /** @@ -3393,9 +3188,20 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts The contacts for the vault certificates. + * @return the observable to the Contacts object + */ + public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3407,26 +3213,18 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co } Validator.validate(contacts); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3446,15 +3244,7 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateContactsDelegate(call.execute()); + return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3462,9 +3252,19 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> getCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3472,26 +3272,18 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3511,15 +3303,7 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateContactsDelegate(call.execute()); + return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3527,9 +3311,19 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3537,26 +3331,18 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3576,23 +3362,14 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3600,9 +3377,44 @@ public Page nextPage(String nextPageLink) throws KeyVault * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3611,32 +3423,18 @@ public ServiceCall> getCertificateIssuersAsync(final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3650,22 +3448,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3674,9 +3464,46 @@ public Page nextPage(String nextPageLink) throws KeyVault * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3684,32 +3511,18 @@ public ServiceCall> getCertificateIssuersAsync(final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3724,36 +3537,14 @@ private ServiceResponse> getCertificateIssuersDe * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - final IssuerCredentials credentials = null; - final OrganizationDetails organizationDetails = null; - final IssuerAttributes attributes = null; - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.withProvider(provider); - parameter.withCredentials(null); - parameter.withOrganizationDetails(null); - parameter.withAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return setCertificateIssuerDelegate(call.execute()); + return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider).toBlocking().single(); } /** @@ -3761,11 +3552,23 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @return the observable to the IssuerBundle object + */ + public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3787,26 +3590,18 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, parameter.withOrganizationDetails(null); parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3814,7 +3609,7 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. @@ -3823,30 +3618,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - Validator.validate(credentials); - Validator.validate(organizationDetails); - Validator.validate(attributes); - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.withProvider(provider); - parameter.withCredentials(credentials); - parameter.withOrganizationDetails(organizationDetails); - parameter.withAttributes(attributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return setCertificateIssuerDelegate(call.execute()); + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); } /** @@ -3854,14 +3627,29 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3883,26 +3671,18 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, parameter.withOrganizationDetails(organizationDetails); parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3917,36 +3697,13 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - final IssuerCredentials credentials = null; - final OrganizationDetails organizationDetails = null; - final IssuerAttributes attributes = null; - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); - parameter.withCredentials(null); - parameter.withOrganizationDetails(null); - parameter.withAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return updateCertificateIssuerDelegate(call.execute()); + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -3954,11 +3711,21 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3968,38 +3735,28 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } + final String provider = null; final IssuerCredentials credentials = null; final OrganizationDetails organizationDetails = null; final IssuerAttributes attributes = null; CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); + parameter.withProvider(null); parameter.withCredentials(null); parameter.withOrganizationDetails(null); parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4007,7 +3764,7 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. @@ -4017,29 +3774,7 @@ public void onResponse(Call call, Response response) * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - Validator.validate(credentials); - Validator.validate(organizationDetails); - Validator.validate(attributes); - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); - parameter.withCredentials(credentials); - parameter.withOrganizationDetails(organizationDetails); - parameter.withAttributes(attributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return updateCertificateIssuerDelegate(call.execute()); + return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); } /** @@ -4047,14 +3782,29 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4064,9 +3814,6 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } Validator.validate(credentials); Validator.validate(organizationDetails); Validator.validate(attributes); @@ -4076,26 +3823,18 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr parameter.withOrganizationDetails(organizationDetails); parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4116,18 +3855,7 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateIssuerDelegate(call.execute()); + return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -4136,9 +3864,20 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4149,26 +3888,18 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4189,18 +3920,7 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateIssuerDelegate(call.execute()); + return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -4209,9 +3929,20 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4222,26 +3953,18 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4262,25 +3985,7 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4289,9 +3994,20 @@ public ServiceResponse createCertificate(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4309,26 +4025,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4345,25 +4053,7 @@ public void onResponse(Call call, Response response) * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -4375,9 +4065,23 @@ public ServiceResponse createCertificate(String vaultBaseU * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4395,26 +4099,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4436,31 +4132,7 @@ private ServiceResponse createCertificateDelegate(Response * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - final String password = null; - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(null); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); } /** @@ -4470,9 +4142,21 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @return the observable to the CertificateBundle object + */ + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4496,26 +4180,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4534,30 +4210,24 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(password); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** @@ -4570,10 +4240,9 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the observable to the CertificateBundle object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4596,26 +4265,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4636,26 +4297,14 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4664,9 +4313,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4678,32 +4364,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4718,25 +4390,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4746,9 +4407,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param certificateName The name of the certificate + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4759,32 +4459,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4805,18 +4491,7 @@ private ServiceResponse> getCertificateVersionsDelegat * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificatePolicyDelegate(call.execute()); + return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4825,9 +4500,20 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @return the observable to the CertificatePolicy object + */ + public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4838,26 +4524,18 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4879,22 +4557,7 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return updateCertificatePolicyDelegate(call.execute()); + return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); } /** @@ -4904,9 +4567,21 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @return the observable to the CertificatePolicy object + */ + public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4921,26 +4596,18 @@ public ServiceCall updateCertificatePolicyAsync(String vaultB } Validator.validate(certificatePolicy); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4962,28 +4629,7 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -4993,9 +4639,21 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5016,26 +4674,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -5053,28 +4703,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -5087,9 +4716,24 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5110,26 +4754,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5151,21 +4787,7 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateDelegate(call.execute()); + return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -5175,9 +4797,21 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5191,26 +4825,18 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5232,20 +4858,7 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); - certificateOperation.withCancellationRequested(cancellationRequested); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); - return updateCertificateOperationDelegate(call.execute()); + return updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single(); } /** @@ -5255,9 +4868,21 @@ public ServiceResponse updateCertificateOperation(String v * @param certificateName The name of the certificate * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. + * @return the observable to the CertificateOperation object + */ + public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5270,26 +4895,18 @@ public ServiceCall updateCertificateOperationAsync(String CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5310,18 +4927,7 @@ private ServiceResponse updateCertificateOperationDelegate * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateOperationDelegate(call.execute()); + return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5330,9 +4936,20 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5343,26 +4960,18 @@ public ServiceCall getCertificateOperationAsync(String vau throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5383,18 +4992,7 @@ private ServiceResponse getCertificateOperationDelegate(Re * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateOperationDelegate(call.execute()); + return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5403,9 +5001,20 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5416,26 +5025,18 @@ public ServiceCall deleteCertificateOperationAsync(String throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5457,28 +5058,7 @@ private ServiceResponse deleteCertificateOperationDelegate * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); } /** @@ -5488,9 +5068,21 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5511,26 +5103,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -5547,28 +5131,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); } /** @@ -5580,9 +5143,23 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5603,26 +5180,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5641,12 +5210,15 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeyVersionsNextDelegate(call.execute()); + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5655,35 +5227,59 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5702,12 +5298,15 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeysNextDelegate(call.execute()); + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5716,35 +5315,59 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysNextAsync(final String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5763,12 +5386,15 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretsNextDelegate(call.execute()); + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5777,35 +5403,59 @@ public ServiceResponse> getSecretsNext(final String nextPag * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsNextAsync(final String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5824,12 +5474,15 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretVersionsNextDelegate(call.execute()); + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5838,35 +5491,59 @@ public ServiceResponse> getSecretVersionsNext(final String * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5885,12 +5562,15 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificatesNextDelegate(call.execute()); + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5899,35 +5579,59 @@ public ServiceResponse> getCertificatesNext(final Stri * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesNextAsync(final String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5946,12 +5650,15 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateIssuersNextDelegate(call.execute()); + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5960,35 +5667,59 @@ public ServiceResponse> getCertificateIssuersNex * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -6007,12 +5738,15 @@ private ServiceResponse> getCertificateIssuersNe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateVersionsNextDelegate(call.execute()); + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -6021,35 +5755,59 @@ public ServiceResponse> getCertificateVersionsNext(fin * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index f90e86cd39fdb..2edac49304f93 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -21,7 +21,7 @@ public class CertificateIssuerItem { private String id; /** - * The name of the issuer. + * The issuer provider. */ private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java index f9daf44e44fda..df352850dff30 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java @@ -17,7 +17,7 @@ */ public class CertificateIssuerSetParameters { /** - * The name of the issuer. + * The issuer provider. */ @JsonProperty(required = true) private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java index 7af311457b0ea..05d62b4ec54d9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java @@ -13,13 +13,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The certificate issuer set parameters. + * The certificate issuer update parameters. */ public class CertificateIssuerUpdateParameters { /** - * The name of the issuer. + * The issuer provider. */ - @JsonProperty(required = true) private String provider; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java index dd7c42a5f4ac0..b2cd7b05f1189 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * A certificate operation is returned in case of async requests. + * The certificate operation update parameters. */ public class CertificateOperationUpdateParameter { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index e30c98684da69..59b4d7f2afca1 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -30,7 +30,7 @@ public class IssuerBundle { private String id; /** - * The name of the issuer. + * The issuer provider. */ private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index 6f971897b7dbb..c2aa1dbe1f77e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -16,7 +16,8 @@ */ public class IssuerReference { /** - * Name of the referenced issuer object. + * Name of the referenced issuer object or reserved names e.g. 'Self', + * 'Unknown'. */ private String name; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index e7ce6cc2b0fb1..07fff30be2e88 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -19,6 +19,7 @@ import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.fasterxml.jackson.annotation.JsonProperty; /** * A KeyBundle consisting of a WebKey plus its Attributes. @@ -40,8 +41,10 @@ public class KeyBundle { private Map tags; /** - * True if the secret's lifetime is managed by key vault. + * True if the key's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index a799ee36fb6e7..9d61d685cee94 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; /** * The key create parameters. @@ -20,10 +22,11 @@ public class KeyCreateParameters { /** * The type of key to create. Valid key types, see JsonWebKeyType. - * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, + * Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ @JsonProperty(required = true) - private String kty; + private JsonWebKeyType kty; /** * The key size in bytes. e.g. 1024 or 2048. @@ -35,7 +38,7 @@ public class KeyCreateParameters { * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -53,7 +56,7 @@ public class KeyCreateParameters { * * @return the kty value */ - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -63,7 +66,7 @@ public String kty() { * @param kty the kty value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKty(String kty) { + public KeyCreateParameters withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -93,7 +96,7 @@ public KeyCreateParameters withKeySize(Integer keySize) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -103,7 +106,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKeyOps(List keyOps) { + public KeyCreateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 4dea299b81d8c..57f669af5a4b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -13,6 +13,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.fasterxml.jackson.annotation.JsonProperty; /** * The key item containing key metadata. @@ -34,8 +35,10 @@ public class KeyItem { private Map tags; /** - * True if the secret's lifetime is managed by key vault. + * True if the key's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 228a944624152..d65ddea14591e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -21,7 +22,7 @@ public class KeyOperationsParameters { * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeyEncryptionAlgorithm algorithm; /** * The value property. @@ -34,7 +35,7 @@ public class KeyOperationsParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeyEncryptionAlgorithm algorithm() { return this.algorithm; } @@ -44,7 +45,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters withAlgorithm(String algorithm) { + public KeyOperationsParameters withAlgorithm(JsonWebKeyEncryptionAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index 999ed545fd0be..a82bbe119d6b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -28,7 +28,7 @@ public class KeyProperties { private String keyType; /** - * The key size in bytes. e.g. 1024 or 2048. + * The key size in bytes. e.g. 2048. */ @JsonProperty(value = "key_size") private Integer keySize; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java index 1af4965c7b756..838b54f7a964a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -23,7 +24,7 @@ public class KeySignParameters { * values include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The value property. @@ -36,7 +37,7 @@ public class KeySignParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -46,7 +47,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeySignParameters object itself. */ - public KeySignParameters withAlgorithm(String algorithm) { + public KeySignParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 33c51dc4d697b..043fbe2d44fd3 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The key update parameters. @@ -23,7 +24,7 @@ public class KeyUpdateParameters { * operations, see JsonWebKeyOperation. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -41,7 +42,7 @@ public class KeyUpdateParameters { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -51,7 +52,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters withKeyOps(List keyOps) { + public KeyUpdateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 1f370f7494ed7..96fd4cb07f947 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -23,7 +24,7 @@ public class KeyVerifyParameters { * include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The digest used for signing. @@ -42,7 +43,7 @@ public class KeyVerifyParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -52,7 +53,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withAlgorithm(String algorithm) { + public KeyVerifyParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 6dea046e03cc5..2035765e09b95 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -49,13 +50,17 @@ public class SecretBundle { private Map tags; /** - * The key id for certificate. + * If this is a secret backing a KV certificate, then this field specifies + * the corresponding key backing the KV certificate. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String kid; /** - * True if the secret's lifetime is managed by key vault. + * True if the secret's lifetime is managed by key vault i.e. if this is a + * secret backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index db383c7f7f0fb..9c4c31e91d44a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -13,6 +13,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.fasterxml.jackson.annotation.JsonProperty; /** * The secret item containing secret metadata. @@ -39,8 +40,10 @@ public class SecretItem { private String contentType; /** - * True if the secret's lifetime is managed by key vault. + * True if the secret's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index ae9267dba24d6..34b1889e212ee 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -23,7 +23,7 @@ public class X509CertificateProperties { private String subject; /** - * The enhaunced key usage. + * The enhanced key usage. */ private List ekus; @@ -40,7 +40,7 @@ public class X509CertificateProperties { private List keyUsage; /** - * The subject alternate names. + * The duration that the ceritifcate is valid in months. */ @JsonProperty(value = "validity_months") private Integer validityInMonths; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index e197baa16c33b..8aee1468265fb 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -7,6 +7,8 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; /** * The create key request class. @@ -15,9 +17,9 @@ public final class CreateKeyRequest { private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; private final Integer keySize; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -29,11 +31,11 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; // Optional parameters private Integer keySize; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -45,10 +47,11 @@ public static class Builder { * @param keyName * The name of the key in the given vault * @param keyType - * The type of key to create. Possible values include: 'EC', - * 'RSA', 'RSA-HSM', 'oct' + * The type of key to create. Valid key types, see JsonWebKeyType. + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. + * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' */ - public Builder(String vaultBaseUrl, String keyName, String keyType) { + public Builder(String vaultBaseUrl, String keyName, JsonWebKeyType keyType) { this.vaultBaseUrl = vaultBaseUrl; this.keyName = keyName; this.keyType = keyType; @@ -73,7 +76,7 @@ public Builder withKeySize(Integer size) { * the key operation list. * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -120,7 +123,7 @@ private CreateKeyRequest(Builder builder) { keySize = builder.keySize; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -156,7 +159,7 @@ public String keyName() { /** * @return the key type */ - public String keyType() { + public JsonWebKeyType keyType() { return keyType; } @@ -170,7 +173,7 @@ public Integer keySize() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 91adae60c3ce8..908881d78bb92 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -7,6 +7,7 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The import key request class. @@ -110,7 +111,7 @@ private ImportKeyRequest(Builder builder) { .withD(builder.key.d()).withP(builder.key.p()).withQ(builder.key.q()).withDp(builder.key.dp()) .withDq(builder.key.dq()).withQi(builder.key.qi()).withK(builder.key.k()).withT(builder.key.t()); if (builder.key.keyOps() != null) { - key.withKeyOps(new ArrayList(builder.key.keyOps())); + key.withKeyOps(new ArrayList(builder.key.keyOps())); } } else { key = null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index bad0b37d43b75..6d62c41fc166f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -8,6 +8,7 @@ import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The key update request class. @@ -17,7 +18,7 @@ public final class UpdateKeyRequest { private final String vaultBaseUrl; private final String keyName; private final String keyVersion; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -32,7 +33,7 @@ public static class Builder { // Optional parameters private String keyVersion; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -83,7 +84,7 @@ public Builder withVersion(String keyVersion) { * the key operation list * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -129,7 +130,7 @@ private UpdateKeyRequest(Builder builder) { keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -172,7 +173,7 @@ public String keyVersion() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 44eb04f681b56..3fcd6787ce999 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -46,6 +46,7 @@ import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; public class AsyncOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -56,7 +57,7 @@ public void keyAsync() throws Exception { String vault = getVaultUri(); String keyname = "mykey"; - CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, "RSA").build(); + CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, JsonWebKeyType.RSA).build(); KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); Assert.assertNotNull(keyBundle); @@ -81,16 +82,16 @@ public void keyAsync() throws Exception { KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); Assert.assertNotNull(restoreResult); - KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); Assert.assertNotNull(encryptResult); - KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, encryptResult.result(), null).get().getBody(); + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get().getBody(); Assert.assertNotNull(decryptResult); - KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); Assert.assertNotNull(wrapResult); - KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, wrapResult.result(), null).get().getBody(); + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get().getBody(); Assert.assertNotNull(unwrapResult); byte[] plainText = new byte[100]; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 3af77cfca2625..c3dfd810293e3 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -677,9 +677,11 @@ public void listCertificates() throws Exception { HashSet toDelete = new HashSet(); for (CertificateItem item : listResult) { - CertificateIdentifier id = new CertificateIdentifier(item.id()); - toDelete.add(id.name()); - certificates.remove(item.id()); + if(item != null) { + CertificateIdentifier id = new CertificateIdentifier(item.id()); + toDelete.add(id.name()); + certificates.remove(item.id()); + } } Assert.assertEquals(0, certificates.size()); @@ -736,7 +738,9 @@ public void listCertificateVersions() throws Exception { listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); for (CertificateItem item : listResult) { - certificates.remove(item.id()); + if(item != null) { + certificates.remove(item.id()); + } } Assert.assertEquals(0, certificates.size()); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 54eb89cd3d444..92de113eb9f98 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -56,28 +56,28 @@ public void transparentAuthentication() throws Exception { { Map tags = new HashMap(); tags.put("foo", "baz"); - List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); + List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest - .Builder(getVaultUri(), KEY_NAME, "RSA") + .Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) .withAttributes(attribute) .withKeyOperations(keyOps) .withKeySize(2048) .withTags(tags) .build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", keyOps, attribute); + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, keyOps, attribute); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null, null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } } @@ -114,7 +114,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .withTags(tags) .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps(), attribute); + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -127,7 +127,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); } @@ -152,7 +152,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA15, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -166,8 +166,8 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Key identifier. @@ -211,7 +211,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2050)); - List key_ops = Arrays.asList("encrypt", "decrypt"); + List key_ops = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.key().withKeyOps(key_ops); @@ -240,7 +240,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2000)); - List key_ops = Arrays.asList("sign", "verify"); + List key_ops = Arrays.asList(JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -284,9 +284,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Creates a backup of key. @@ -316,7 +316,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -338,9 +338,11 @@ public void listKeys() throws Exception { HashSet toDelete = new HashSet(); for (KeyItem item : listResult) { - KeyIdentifier id = new KeyIdentifier(item.kid()); - toDelete.add(id.name()); - keys.remove(item.kid()); + if(item != null) { + KeyIdentifier id = new KeyIdentifier(item.kid()); + toDelete.add(id.name()); + keys.remove(item.kid()); + } } Assert.assertEquals(0, keys.size()); @@ -365,7 +367,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -386,7 +388,9 @@ public void listKeyVersions() throws Exception { listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); for (KeyItem item : listResult) { - keys.remove(item.kid()); + if(item != null) { + keys.remove(item.kid()); + } } Assert.assertEquals(0, keys.size()); @@ -409,19 +413,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -441,19 +445,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -501,7 +505,7 @@ private static JsonWebKey importTestKey() throws Exception { JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); key.withKty(JsonWebKeyType.RSA); - key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP_KEY, JsonWebKeyOperation.UNWRAP_KEY)); keyBundle = keyVaultClient.importKey( new ImportKeyRequest @@ -509,7 +513,7 @@ private static JsonWebKey importTestKey() throws Exception { .withHsm(false) .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); return keyBundle.key(); } @@ -535,7 +539,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, Attributes attributes) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, JsonWebKeyType kty, List key_ops, Attributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index af27ec8973c2f..ed6282decdf41 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -174,8 +174,7 @@ public void crudOperations() throws Exception { } @Test - public void listSecrets() throws Exception { - + public void listSecrets() throws Exception { HashSet secrets = new HashSet(); for (int i = 0; i < MAX_SECRETS; ++i) { int failureCount = 0; @@ -204,9 +203,11 @@ public void listSecrets() throws Exception { HashSet toDelete = new HashSet(); for (SecretItem item : listResult) { - SecretIdentifier id = new SecretIdentifier(item.id()); - toDelete.add(id.name()); - secrets.remove(item.id()); + if(item != null) { + SecretIdentifier id = new SecretIdentifier(item.id()); + toDelete.add(id.name()); + secrets.remove(item.id()); + } } Assert.assertEquals(0, secrets.size()); @@ -252,7 +253,9 @@ public void listSecretVersions() throws Exception { listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); for (SecretItem item : listResult) { - secrets.remove(item.id()); + if(item != null) { + secrets.remove(item.id()); + } } Assert.assertEquals(0, secrets.size()); From 9892e0643cd55066e660230ffba1535c77f7100b Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 2 Sep 2016 11:47:41 -0700 Subject: [PATCH 11/47] fix styling errors and addressed feedback. --- .../webkey/Base64UrlJsonDeserializer.java | 4 ++-- .../webkey/Base64UrlJsonSerializer.java | 4 ++-- .../azure/keyvault/webkey/JsonWebKey.java | 2 +- .../azure/keyvault/KeyVaultClient.java | 1 - .../azure/keyvault/KeyVaultClientImpl.java | 2 -- .../authentication/ChallengeCache.java | 5 +--- .../models/KeyVaultErrorException.java | 7 +++--- .../requests/SetCertificateIssuerRequest.java | 6 ++--- .../UpdateCertificateIssuerRequest.java | 23 ++++++++++++++----- .../keyvault/test/AsyncOperationsTest.java | 2 +- .../test/CertificateOperationsTest.java | 3 ++- 11 files changed, 32 insertions(+), 27 deletions(-) diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java index 18967a8863809..9418b15a96736 100644 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java @@ -20,13 +20,13 @@ */ public class Base64UrlJsonDeserializer extends JsonDeserializer { - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 BASE64 = new Base64(-1, null, true); @Override public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { - return _base64.decode(text); + return BASE64.decode(text); } return null; } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java index 3613a1aa79199..eac3d33e26c7b 100644 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java @@ -20,7 +20,7 @@ */ public class Base64UrlJsonSerializer extends JsonSerializer { - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 BASE64 = new Base64(-1, null, true); @Override public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { @@ -30,7 +30,7 @@ public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provi } else if (value.length == 0) { text = ""; } else { - text = _base64.encodeAsString(value); + text = BASE64.encodeAsString(value); } jgen.writeString(text); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index 868cab9204858..5d6dc8fe8b355 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -245,7 +245,7 @@ public byte[] dp() { } /** - * Set RSA Private Key Parameter value + * Set RSA Private Key Parameter value. * @param dp the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 0dbb76b43010b..95a998e02c63b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -50,7 +50,6 @@ import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.Response; import retrofit2.http.GET; import retrofit2.http.Header; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 156945410742d..ddeb203106bf6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -59,8 +59,6 @@ import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; -import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java index 07cd0a8dc49b7..a0700600afffe 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -10,13 +10,10 @@ import java.util.Locale; import java.util.Map; -import com.microsoft.rest.credentials.ServiceClientCredentials; - import okhttp3.HttpUrl; /** - * An implementation of {@link ServiceClientCredentials} that supports automatic bearer token refresh. - * + * Handles caching of the challenge. */ class ChallengeCache { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index 43b6a45e162db..796e35e8da3c6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -31,14 +31,13 @@ public class KeyVaultErrorException extends RestException { public KeyVaultErrorException() { } @Override - public String getMessage() - { - if(body != null && body.error() != null + public String getMessage() { + if (body != null && body.error() != null && body.error().message() != null && !body.error().message().isEmpty()) { return body.error().message(); } - return getMessage(); + return super.getMessage(); } /** * Initializes a new instance of the KeyVaultErrorException class. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 23201a4a26f4a..7d582e2f5bde6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -77,7 +77,7 @@ public Builder withOrganizationDetails(OrganizationDetails organizationDetails) /** * Set issuer attributes. * - * @param organizationDetails + * @param attributes * The issuer attributes. * @return the Builder object itself. */ @@ -100,14 +100,14 @@ private SetCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; provider = builder.provider; - if(builder.organizationDetails != null) { + if (builder.organizationDetails != null) { organizationDetails = new OrganizationDetails() .withId(builder.organizationDetails.id()) .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { organizationDetails = null; } - if(builder.credentials != null) { + if (builder.credentials != null) { credentials = new IssuerCredentials() .withAccountId(builder.credentials.accountId()) .withPassword(builder.credentials.password()); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index 37d1048673aea..d743f86cabe6c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -26,9 +26,9 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; - private final String provider; // Optional parameters + private String provider; private IssuerCredentials credentials; private OrganizationDetails organizationDetails; private IssuerAttributes attributes; @@ -42,12 +42,23 @@ public static class Builder { * @param issuerName * The name of the issuer in the given vault. */ - public Builder(String vaultBaseUrl, String issuerName, String provider) { + public Builder(String vaultBaseUrl, String issuerName) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; - this.provider = provider; } + /** + * Set issuer credentials. + * + * @param provider + * The issuer provider. + * @return the Builder object itself. + */ + public Builder withProvider(String provider) { + this.provider = provider; + return this; + } + /** * Set issuer credentials. * @@ -75,7 +86,7 @@ public Builder withOrganizationDetails(OrganizationDetails organizationDetails) /** * Set issuer attributes. * - * @param organizationDetails + * @param attributes * The issuer attributes. * @return the Builder object itself. */ @@ -98,14 +109,14 @@ private UpdateCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; provider = builder.provider; - if(builder.organizationDetails != null) { + if (builder.organizationDetails != null) { organizationDetails = new OrganizationDetails() .withId(builder.organizationDetails.id()) .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { organizationDetails = null; } - if(builder.credentials != null) { + if (builder.credentials != null) { credentials = new IssuerCredentials() .withAccountId(builder.credentials.accountId()) .withPassword(builder.credentials.password()); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 3fcd6787ce999..c2277e5bf2c5d 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -241,7 +241,7 @@ public void issuerAsync() throws Exception { IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); Assert.assertNotNull(certificateIssuer); - UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName, "SslAdmin").build(); + UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName).withProvider("SslAdmin").build(); certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); Assert.assertNotNull(certificateIssuer); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index c3dfd810293e3..8e4b7c7dced0f 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -798,7 +798,8 @@ public void issuerCrudOperations() throws Exception { retrievedCertificateIssuer.withCredentials(updatedCredentials); IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( new UpdateCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .Builder(getVaultUri(), certificateIssuerName) + .withProvider(ISSUER_TEST) .withCredentials(updatedCredentials) .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) .withAttributes(retrievedCertificateIssuer.attributes()) From 5cc125f4ddbfd5db65c8fba16297ef1c082001b5 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 9 Sep 2016 10:20:01 -0700 Subject: [PATCH 12/47] Remove .getBody for ListanableFuture to accomodate the recent breaking change --- .../keyvault/extensions/KeyVaultKey.java | 19 +++-- .../extensions/KeyVaultKeyResolver.java | 15 ++-- .../keyvault/test/AsyncOperationsTest.java | 78 +++++++++---------- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index f4afd66b74aaa..d3bf97abc148b 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -35,7 +35,6 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.rest.ServiceResponse; /** * The key vault key that performs cryptography operations. @@ -45,22 +44,22 @@ public class KeyVaultKey implements IKey { /** * Transforms the result of decrypt operation to byte array. */ - class DecryptResultTransform implements Function, byte[]> { + class DecryptResultTransform implements Function { DecryptResultTransform() { super(); } @Override - public byte[] apply(ServiceResponse result) { - return result.getBody().result(); + public byte[] apply(KeyOperationResult result) { + return result.result(); } } /** * Transforms the result of sign operation to byte array and algorithm pair. */ - class SignResultTransform implements Function, Pair> { + class SignResultTransform implements Function> { private final String algorithm; @@ -70,9 +69,9 @@ class SignResultTransform implements Function apply(ServiceResponse input) { + public Pair apply(KeyOperationResult input) { - return Pair.of(input.getBody().result(), algorithm); + return Pair.of(input.result(), algorithm); } } @@ -168,7 +167,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.decryptAsync( implementation.getKid(), new JsonWebKeyEncryptionAlgorithm(algorithm), @@ -206,7 +205,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.unwrapKeyAsync( implementation.getKid(), new JsonWebKeyEncryptionAlgorithm(algorithm), @@ -226,7 +225,7 @@ public ListenableFuture> signAsync(byte[] digest, String al } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.signAsync( implementation.getKid(), new JsonWebKeySignatureAlgorithm(algorithm), diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index 92f66ddba0c50..7f8e778ef0681 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -32,7 +32,6 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; -import com.microsoft.rest.ServiceResponse; /** * The key resolver class that handles resolving key id to type {@link IKey} @@ -45,16 +44,15 @@ public class KeyVaultKeyResolver implements IKeyResolver { /** * Transforms {@link KeyBundle} to {@link IKey}. */ - class FutureKeyFromKey implements Function, IKey> { + class FutureKeyFromKey implements Function { protected FutureKeyFromKey() { super(); } @Override - public IKey apply(ServiceResponse keyBundleResponse) { + public IKey apply(KeyBundle keyBundle) { - KeyBundle keyBundle = keyBundleResponse.getBody(); if (keyBundle != null) { return new KeyVaultKey(client, keyBundle); } @@ -66,16 +64,15 @@ public IKey apply(ServiceResponse keyBundleResponse) { /** * Transforms {@link SecretBundle} to {@link IKey}. */ - class FutureKeyFromSecret implements Function, IKey> { + class FutureKeyFromSecret implements Function { protected FutureKeyFromSecret() { super(); } @Override - public IKey apply(ServiceResponse secretBundleResponse) { + public IKey apply(SecretBundle secretBundle) { - SecretBundle secretBundle = secretBundleResponse.getBody(); if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { byte[] keyBytes = BASE64.decode(secretBundle.value()); @@ -112,13 +109,13 @@ public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { private ListenableFuture resolveKeyFromSecretAsync(String kid) { - ListenableFuture> futureCall = client.getSecretAsync(kid, null); + ListenableFuture futureCall = client.getSecretAsync(kid, null); return Futures.transform(futureCall, new FutureKeyFromSecret()); } private ListenableFuture resolveKeyFromKeyAsync(String kid) { - ListenableFuture> futureCall = client.getKeyAsync(kid, null); + ListenableFuture futureCall = client.getKeyAsync(kid, null); return Futures.transform(futureCall, new FutureKeyFromKey()); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index c2277e5bf2c5d..878603707842f 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -58,40 +58,40 @@ public void keyAsync() throws Exception { String keyname = "mykey"; CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, JsonWebKeyType.RSA).build(); - KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); + KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get(); Assert.assertNotNull(keyBundle); UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest.Builder(keyBundle.key().kid()).build(); - keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get().getBody(); + keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get(); Assert.assertNotNull(keyBundle); - keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get().getBody(); + keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get(); Assert.assertNotNull(keyBundle); - List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get().getBody(); + List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get(); Assert.assertNotNull(keyItems); - List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get().getBody(); + List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get(); Assert.assertNotNull(keyVersionItems); - BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get().getBody(); + BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get(); Assert.assertNotNull(backupResult); keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); - KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); + KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get(); Assert.assertNotNull(restoreResult); - KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get(); Assert.assertNotNull(encryptResult); - KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get().getBody(); + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get(); Assert.assertNotNull(decryptResult); - KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get(); Assert.assertNotNull(wrapResult); - KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get().getBody(); + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get(); Assert.assertNotNull(unwrapResult); byte[] plainText = new byte[100]; @@ -99,13 +99,13 @@ public void keyAsync() throws Exception { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(plainText); byte[] digest = md.digest(); - KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get().getBody(); + KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get(); Assert.assertNotNull(signResult); - KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get().getBody(); + KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get(); Assert.assertTrue(verifypResult.value()); - keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); + keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); Assert.assertNotNull(keyBundle); //Get the unavailable key to throw exception -> it gets stuck @@ -131,23 +131,23 @@ public void secretAsync() throws Exception { String password = "password"; SetSecretRequest setSecretRequest = new SetSecretRequest.Builder(vault, secretname, password).build(); - SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get().getBody(); + SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get(); Assert.assertNotNull(secretBundle); UpdateSecretRequest updateSecretRequest = new UpdateSecretRequest.Builder(secretBundle.id()).build(); - secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get().getBody(); + secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get(); Assert.assertNotNull(secretBundle); - secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get().getBody(); + secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get(); Assert.assertNotNull(secretBundle); - List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get().getBody(); + List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get(); Assert.assertNotNull(secretItems); - List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get().getBody(); + List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get(); Assert.assertNotNull(secretVersionItems); - secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); + secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get(); Assert.assertNotNull(secretBundle); try { @@ -179,44 +179,44 @@ public void certificateAsync() throws Exception { .withSubject("CN=SelfSignedJavaPkcs12") .withValidityInMonths(12))) .build(); - CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get().getBody(); + CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get(); Assert.assertNotNull(certificateOperation); UpdateCertificateOperationRequest updateCertificateOperationRequest = new UpdateCertificateOperationRequest.Builder(vault, certificateName, false).build(); - certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get().getBody(); + certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get(); Assert.assertNotNull(certificateOperation); Map tags = new HashMap(); tags.put("tag1", "foo"); UpdateCertificateRequest updateCertificateRequest = new UpdateCertificateRequest.Builder(vault, certificateName).withTags(tags).build(); - CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get().getBody(); + CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get(); Assert.assertNotNull(certificateBundle); UpdateCertificatePolicyRequest updateCertificatePolicyRequest = new UpdateCertificatePolicyRequest.Builder(vault, certificateName).build(); - CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get().getBody(); + CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get(); Assert.assertNotNull(certificatePolicy); - certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get().getBody(); + certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificatePolicy); - certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get().getBody(); + certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateOperation); - certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get().getBody(); + certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateBundle); - String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get().getBody(); + String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get(); Assert.assertTrue(!cert.isEmpty()); - List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get().getBody(); + List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get(); Assert.assertNotNull(certificateItem); - List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get().getBody(); + List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateVersionItem); - keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); - keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); try { keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); @@ -238,20 +238,20 @@ public void issuerAsync() throws Exception { String issuerName = "myIssuer"; SetCertificateIssuerRequest setCertificateIssuerRequest = new SetCertificateIssuerRequest.Builder(vault, issuerName, "Test").build(); - IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); + IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get(); Assert.assertNotNull(certificateIssuer); UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName).withProvider("SslAdmin").build(); - certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); + certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get(); Assert.assertNotNull(certificateIssuer); - certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get(); Assert.assertNotNull(certificateIssuer); - List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get().getBody(); + List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get(); Assert.assertNotNull(issuers); - keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get(); } @@ -260,10 +260,10 @@ public void certificateContactsAsync() throws Exception { String vault = getVaultUri(); - Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get().getBody(); + Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get(); Assert.assertNotNull(contacts); - contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get().getBody(); + contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get(); Assert.assertNotNull(contacts); keyVaultClient.deleteCertificateContactsAsync(vault, null).get(); From 63d5f7c24a495a1ae01b79a904b885dd2632fdb7 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Mon, 12 Sep 2016 10:30:25 -0700 Subject: [PATCH 13/47] key vault cryptography refactoring. Removing additional methods from ByteExtension and using Arrays extension methods where applicable. Changed static final names to all caps. --- .../cryptography/AlgorithmResolver.java | 26 ++--- .../keyvault/cryptography/ByteExtensions.java | 95 ++----------------- .../azure/keyvault/cryptography/RsaKey.java | 8 +- .../keyvault/cryptography/SymmetricKey.java | 20 ++-- .../cryptography/algorithms/Aes128Cbc.java | 57 +---------- .../algorithms/Aes128CbcHmacSha256.java | 4 +- .../cryptography/algorithms/Aes192Cbc.java | 58 +---------- .../algorithms/Aes192CbcHmacSha384.java | 4 +- .../cryptography/algorithms/Aes256Cbc.java | 58 +---------- .../algorithms/Aes256CbcHmacSha512.java | 4 +- .../cryptography/algorithms/AesCbc.java | 33 +++++-- .../algorithms/AesCbcHmacSha2.java | 6 +- .../cryptography/algorithms/AesKw128.java | 10 +- .../cryptography/algorithms/AesKw192.java | 10 +- .../cryptography/algorithms/AesKw256.java | 10 +- .../cryptography/algorithms/Rs256.java | 26 ++++- .../cryptography/algorithms/Rsa15.java | 4 +- .../cryptography/algorithms/RsaOaep.java | 4 +- .../cryptography/test/AesCbcTest.java | 18 ++-- .../cryptography/test/RsaKeyTest.java | 26 ++--- 20 files changed, 144 insertions(+), 337 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index 6804aa055420d..60930c8d1e3a7 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -27,23 +27,23 @@ public class AlgorithmResolver { public static final AlgorithmResolver Default = new AlgorithmResolver(); static { - Default.put(Aes128CbcHmacSha256.AlgorithmName, new Aes128CbcHmacSha256()); - Default.put(Aes192CbcHmacSha384.AlgorithmName, new Aes192CbcHmacSha384()); - Default.put(Aes256CbcHmacSha512.AlgorithmName, new Aes256CbcHmacSha512()); + Default.put(Aes128CbcHmacSha256.ALGORITHM_NAME, new Aes128CbcHmacSha256()); + Default.put(Aes192CbcHmacSha384.ALGORITHM_NAME, new Aes192CbcHmacSha384()); + Default.put(Aes256CbcHmacSha512.ALGORITHM_NAME, new Aes256CbcHmacSha512()); - Default.put(Aes128Cbc.AlgorithmName, new Aes128Cbc()); - Default.put(Aes192Cbc.AlgorithmName, new Aes192Cbc()); - Default.put(Aes256Cbc.AlgorithmName, new Aes256Cbc()); + Default.put(Aes128Cbc.ALGORITHM_NAME, new Aes128Cbc()); + Default.put(Aes192Cbc.ALGORITHM_NAME, new Aes192Cbc()); + Default.put(Aes256Cbc.ALGORITHM_NAME, new Aes256Cbc()); - Default.put(AesKw128.AlgorithmName, new AesKw128()); - Default.put(AesKw192.AlgorithmName, new AesKw192()); - Default.put(AesKw256.AlgorithmName, new AesKw256()); + Default.put(AesKw128.ALGORITHM_NAME, new AesKw128()); + Default.put(AesKw192.ALGORITHM_NAME, new AesKw192()); + Default.put(AesKw256.ALGORITHM_NAME, new AesKw256()); - Default.put(Rsa15.AlgorithmName, new Rsa15()); - Default.put(RsaOaep.AlgorithmName, new RsaOaep()); + Default.put(Rsa15.ALGORITHM_NAME, new Rsa15()); + Default.put(RsaOaep.ALGORITHM_NAME, new RsaOaep()); - Default.put( Rs256.AlgorithmName, new Rs256() ); - // Default.put( RsNull.AlgorithmName, new RsNull() ); + Default.put( Rs256.ALGORITHM_NAME, new Rs256() ); + // Default.put( RsNull.ALGORITHM_NAME, new RsNull() ); } private final ConcurrentMap _algorithms = new ConcurrentHashMap(); diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java index c76b4c507de6a..2c8af1810d836 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java @@ -6,26 +6,9 @@ package com.microsoft.azure.keyvault.cryptography; -public final class ByteExtensions { - - public static boolean sequenceEqualConstantTime( byte[] self, byte[] other ) - { - if ( self == null ) - throw new IllegalArgumentException( "self" ); +import java.util.Arrays; - if ( other == null ) - throw new IllegalArgumentException( "other" ); - - // Constant time comparison of two byte arrays - long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); - - for ( int i = 0; i < self.length && i < other.length; i++ ) - { - difference |= ( self[i] ^ other[i] ) & 0xffffffffl; - } - - return difference == 0; - } +public final class ByteExtensions { public static byte[] or( byte[] self, byte[] other ) { @@ -54,19 +37,10 @@ public static byte[] or( byte[] self, byte[] other, int offset ) } public static byte[] xor( byte[] self, byte[] other ) { - return xor( self, other, 0, false ); - } - - public static byte[] xor( byte[] self, byte[] other, boolean inPlace ) - { - return xor( self, other, 0, inPlace ); - } - - public static byte[] xor( byte[] self, byte[] other, int offset ) { - return xor( self, other, 0, false ); + return xor( self, other, 0 ); } - public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace ) + static byte[] xor( byte[] self, byte[] other, int offset ) { if ( self == null ) throw new IllegalArgumentException( "self" ); @@ -77,71 +51,20 @@ public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace if ( self.length > other.length - offset ) throw new IllegalArgumentException( "self and other lengths do not match" ); - if ( inPlace ) - { - for ( int i = 0; i < self.length; i++ ) - { - self[i] = (byte)( self[i] ^ other[offset + i] ); - } + byte[] result = new byte[self.length]; - return self; - } - else + for ( int i = 0; i < self.length; i++ ) { - byte[] result = new byte[self.length]; - - for ( int i = 0; i < self.length; i++ ) - { - result[i] = (byte)( self[i] ^ other[offset + i] ); - } - - return result; + result[i] = (byte)( self[i] ^ other[offset + i] ); } - } - - public static byte[] take( byte[] self, int count ) - { - return ByteExtensions.take( self, 0, count ); - } - - - /** - * Takes the first count bytes from the source and - * returns a new array containing those bytes. - * - * @param self The source of the bytes. - * @param offset The starting offset. - * @param count The number of bytes to take. - * @return count bytes from the source as a new array. - */ - public static byte[] take( byte[] self, int offset, int count ) - { - if ( self == null ) - throw new IllegalArgumentException( "self" ); - - if ( offset < 0 ) - throw new IllegalArgumentException( "offset cannot be < 0" ); - - if ( count <= 0 ) - throw new IllegalArgumentException( "count cannot be <= 0" ); - - if ( offset + count > self.length ) - throw new IllegalArgumentException( "offset + count cannot be > self.Length" ); - - byte[] result = new byte[count]; - - System.arraycopy( self, offset, result, 0, count ); return result; } public static void zero( byte[] self ) { - if ( self == null ) - throw new IllegalArgumentException( "self" ); - - for ( int i = 0; i < self.length; i++ ) { - self[i] = 0; + if ( self != null ) { + Arrays.fill(self, (byte)0); } } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index 4abfcfd8855a6..c8807fc29c49f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -84,17 +84,17 @@ public RsaKey(String kid, KeyPair keyPair, Provider provider) { @Override public String getDefaultEncryptionAlgorithm() { - return RsaOaep.AlgorithmName; + return RsaOaep.ALGORITHM_NAME; } @Override public String getDefaultKeyWrapAlgorithm() { - return RsaOaep.AlgorithmName; + return RsaOaep.ALGORITHM_NAME; } @Override public String getDefaultSignatureAlgorithm() { - return Rs256.AlgorithmName; + return Rs256.ALGORITHM_NAME; } @Override @@ -253,7 +253,7 @@ public ListenableFuture> signAsync(final byte[] digest, fin ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { - return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); + return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.ALGORITHM_NAME)); } catch (Exception e) { return Futures.immediateFailedFuture(e); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index 14e0797b46587..a5e333f092f3b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -66,19 +66,19 @@ public String getDefaultEncryptionAlgorithm() { switch (_key.length) { case KeySize128: - return Aes128Cbc.AlgorithmName; + return Aes128Cbc.ALGORITHM_NAME; case KeySize192: - return Aes192Cbc.AlgorithmName; + return Aes192Cbc.ALGORITHM_NAME; case KeySize256: - return Aes128CbcHmacSha256.AlgorithmName; + return Aes128CbcHmacSha256.ALGORITHM_NAME; case KeySize384: - return Aes192CbcHmacSha384.AlgorithmName; + return Aes192CbcHmacSha384.ALGORITHM_NAME; case KeySize512: - return Aes256CbcHmacSha512.AlgorithmName; + return Aes256CbcHmacSha512.ALGORITHM_NAME; } return null; @@ -89,21 +89,21 @@ public String getDefaultKeyWrapAlgorithm() { switch (_key.length) { case KeySize128: - return AesKw128.AlgorithmName; + return AesKw128.ALGORITHM_NAME; case KeySize192: - return AesKw192.AlgorithmName; + return AesKw192.ALGORITHM_NAME; case KeySize256: - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; case KeySize384: // Default to longest allowed key length for wrap - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; case KeySize512: // Default to longest allowed key length for wrap - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; } return null; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index 14cf40023b7c8..89a10584294dd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -6,63 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes128Cbc extends AesCbc { - public static final String AlgorithmName = "A128CBC"; - - static final int KeySizeInBytes = 128 >> 3; + private static final int KEY_SIZE = 128; + public static final String ALGORITHM_NAME = "A128CBC"; public Aes128Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java index 9e75131a3de84..f473aee20d11b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java @@ -8,9 +8,9 @@ public class Aes128CbcHmacSha256 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A128CBC-HS256"; + public static final String ALGORITHM_NAME = "A128CBC-HS256"; public Aes128CbcHmacSha256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 4ec8451b47901..fe6f3ff8f1f16 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -6,64 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes192Cbc extends AesCbc { - public static final String AlgorithmName = "A192CBC"; - - static final int KeySizeInBytes = 192 >> 3; + private static final int KEY_SIZE = 192; + public static final String ALGORITHM_NAME = "A192CBC"; public Aes192Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java index 74f279eff8c72..ecfc65f49ff69 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java @@ -8,9 +8,9 @@ public class Aes192CbcHmacSha384 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A192CBC-HS384"; + public static final String ALGORITHM_NAME = "A192CBC-HS384"; public Aes192CbcHmacSha384() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 629b647ec6b92..f198b9012b54c 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -6,64 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes256Cbc extends AesCbc { - public static final String AlgorithmName = "A256CBC"; - - static final int KeySizeInBytes = 256 >> 3; + private static final int KEY_SIZE = 256; + public static final String ALGORITHM_NAME = "A256CBC"; public Aes256Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java index e038c808fec53..61c1aead84b77 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java @@ -8,9 +8,9 @@ public class Aes256CbcHmacSha512 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A256CBC-HS512"; + public static final String ALGORITHM_NAME = "A256CBC-HS512"; public Aes256CbcHmacSha512() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java index 49edaa57a71b5..d2f891cc13094 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -10,6 +10,7 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -23,6 +24,8 @@ public abstract class AesCbc extends SymmetricEncryptionAlgorithm { + final int keySizeInBytes; + final int keySize; static class AesCbcDecryptor implements ICryptoTransform { private final Cipher _cipher; @@ -67,31 +70,49 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad } } - protected AesCbc(String name) { + protected AesCbc(String name, int size) { super(name); + keySize = size; + keySizeInBytes = size >> 3; } @Override public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - return new AesCbcEncryptor(key, iv, null); + + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcEncryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, null); } @Override public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcEncryptor(key, iv, provider); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcEncryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, provider); } @Override public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcDecryptor(key, iv, null); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcDecryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, null); } @Override public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcDecryptor(key, iv, provider); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcDecryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java index c2ccc2a88ab13..0372401e5a039 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -212,7 +212,7 @@ private static Triple GetAlgorithmParameters(String algorit byte[] hmac_key; Mac hmac; - if (algorithm.equalsIgnoreCase(Aes128CbcHmacSha256.AlgorithmName)) { + if (algorithm.equalsIgnoreCase(Aes128CbcHmacSha256.ALGORITHM_NAME)) { if ((key.length << 3) < 256) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 256", algorithm, key.length << 3)); } @@ -227,7 +227,7 @@ private static Triple GetAlgorithmParameters(String algorit hmac = Mac.getInstance("HmacSHA256"); hmac.init(new SecretKeySpec(hmac_key, "HmacSHA256")); - } else if (algorithm.equalsIgnoreCase(Aes192CbcHmacSha384.AlgorithmName)) { + } else if (algorithm.equalsIgnoreCase(Aes192CbcHmacSha384.ALGORITHM_NAME)) { if ((key.length << 3) < 384) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 384", algorithm, key.length << 3)); @@ -242,7 +242,7 @@ private static Triple GetAlgorithmParameters(String algorit hmac = Mac.getInstance("HmacSHA384"); hmac.init(new SecretKeySpec(hmac_key, "HmacSHA384")); - } else if (algorithm.equalsIgnoreCase(Aes256CbcHmacSha512.AlgorithmName)) { + } else if (algorithm.equalsIgnoreCase(Aes256CbcHmacSha512.ALGORITHM_NAME)) { if ((key.length << 3) < 512) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 512", algorithm, key.length << 3)); diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 3c628688ef236..d5696f5998f3f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw128 extends AesKw { - public static final String AlgorithmName = "A128KW"; + public static final String ALGORITHM_NAME = "A128KW"; static final int KeySizeInBytes = 128 >> 3; public AesKw128() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index dd24b0011a0c1..43225d8e080dd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw192 extends AesKw { - public static final String AlgorithmName = "A192KW"; + public static final String ALGORITHM_NAME = "A192KW"; static final int KeySizeInBytes = 192 >> 3; public AesKw192() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index 79398e292adc4..b2b514713c96f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw256 extends AesKw { - public static final String AlgorithmName = "A256KW"; + public static final String ALGORITHM_NAME = "A256KW"; static final int KeySizeInBytes = 256 >> 3; public AesKw256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java index 54a4fd4572361..eddafecac6b28 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -12,7 +12,6 @@ import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; /** @@ -75,15 +74,15 @@ public boolean verify(byte[] digest, byte[] signature) throws NoSuchAlgorithmExc byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); // Use constant time compare - return ByteExtensions.sequenceEqualConstantTime(EM, EM2); + return sequenceEqualConstantTime(EM, EM2); } } - public final static String AlgorithmName = "RS256"; + public final static String ALGORITHM_NAME = "RS256"; public Rs256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -91,4 +90,23 @@ public ISignatureTransform createSignatureTransform(KeyPair keyPair) { return new Rs256SignatureTransform(keyPair); } + + private boolean sequenceEqualConstantTime( byte[] self, byte[] other ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + // Constant time comparison of two byte arrays + long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); + + for ( int i = 0; i < self.length && i < other.length; i++ ) + { + difference |= ( self[i] ^ other[i] ) & 0xffffffffl; + } + + return difference == 0; + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java index 4770183bb3ab8..18ea8d28514fd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java @@ -72,10 +72,10 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad final static String RSA15 = "RSA/ECB/PKCS1Padding"; - public final static String AlgorithmName = "RSA1_5"; + public final static String ALGORITHM_NAME = "RSA1_5"; public Rsa15() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java index 55b57b6acd633..38c3e4131231b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java @@ -72,10 +72,10 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad final static String RSAOAEP = "RSA/ECB/OAEPWithSHA1AndMGF1Padding"; - public final static String AlgorithmName = "RSA-OAEP"; + public final static String ALGORITHM_NAME = "RSA-OAEP"; public RsaOaep() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 351f22a1ce993..b9bbf4a65e1e9 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.fail; import java.security.Provider; +import java.util.Arrays; import org.junit.After; import org.junit.AfterClass; @@ -11,7 +12,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -63,7 +63,7 @@ public void testAes128CbcOneBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 16), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 16), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -81,7 +81,7 @@ public void testAes128CbcOneBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -110,7 +110,7 @@ public void testAes128CbcTwoBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -128,7 +128,7 @@ public void testAes128CbcTwoBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -157,7 +157,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 16),ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 16),ED); } catch (Exception e) { fail(e.getMessage()); } @@ -175,7 +175,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -204,7 +204,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -222,7 +222,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 18cf7db616e18..799827bd349c5 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -57,19 +57,19 @@ public void testRsa15() throws Exception { RsaKey key = getTestRsaKey(); // Wrap and Unwrap - Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.AlgorithmName).get(); + Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.ALGORITHM_NAME).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(Rsa15.AlgorithmName, wrapped.getRight()); + assertEquals(Rsa15.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt - Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.AlgorithmName).get(); + Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.ALGORITHM_NAME).get(); byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(Rsa15.AlgorithmName, encrypted.getRight()); + assertEquals(Rsa15.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); @@ -81,19 +81,19 @@ public void testRsaOaep() throws Exception { RsaKey key = getTestRsaKey(); // Wrap and Unwrap - Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.AlgorithmName).get(); + Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.ALGORITHM_NAME).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt - Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.AlgorithmName).get(); + Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.ALGORITHM_NAME).get(); byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); @@ -104,16 +104,16 @@ public void testDefaultAlgorithm() throws Exception { RsaKey key = getTestRsaKey(); - assertEquals(RsaOaep.AlgorithmName, key.getDefaultEncryptionAlgorithm()); - assertEquals(RsaOaep.AlgorithmName, key.getDefaultKeyWrapAlgorithm()); - assertEquals(Rs256.AlgorithmName, key.getDefaultSignatureAlgorithm()); + assertEquals(RsaOaep.ALGORITHM_NAME, key.getDefaultEncryptionAlgorithm()); + assertEquals(RsaOaep.ALGORITHM_NAME, key.getDefaultKeyWrapAlgorithm()); + assertEquals(Rs256.ALGORITHM_NAME, key.getDefaultSignatureAlgorithm()); // Wrap and Unwrap Pair wrapped = key.wrapKeyAsync(CEK, key.getDefaultKeyWrapAlgorithm()).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt @@ -121,7 +121,7 @@ public void testDefaultAlgorithm() throws Exception { byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); From aaa9e00ddeb6149bb5305dbe2006ce1a246acd00 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 11:03:56 -0700 Subject: [PATCH 14/47] allowing to specify only NAT pools or NAT rule in the define flow, not mixing --- .../management/network/LoadBalancer.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java index 6fd254a211914..fa10dfa88c70a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java @@ -81,7 +81,10 @@ interface Definition extends DefinitionStages.WithProbe, DefinitionStages.WithProbeOrLoadBalancingRule, DefinitionStages.WithLoadBalancingRule, - DefinitionStages.WithLoadBalancingRuleOrCreate { + DefinitionStages.WithLoadBalancingRuleOrCreate, + DefinitionStages.WithCreateAndInboundNatPool, + DefinitionStages.WithCreateAndInboundNatRule, + DefinitionStages.WithCreateAndNatChoice { } /** @@ -338,7 +341,7 @@ interface WithLoadBalancingRule { /** * The stage of a load balancer definition allowing to create a load balancing rule or create the load balancer. */ - interface WithLoadBalancingRuleOrCreate extends WithLoadBalancingRule, WithCreate { + interface WithLoadBalancingRuleOrCreate extends WithLoadBalancingRule, WithCreateAndNatChoice { } /** @@ -348,9 +351,32 @@ interface WithLoadBalancingRuleOrCreate extends WithLoadBalancingRule, WithCreat */ interface WithCreate extends Creatable, - Resource.DefinitionWithTags, - DefinitionStages.WithInboundNatRule, - DefinitionStages.WithInboundNatPool { + Resource.DefinitionWithTags { + } + + /** + * The stage of a load balancer definition allowing to create the load balancer or start configuring optional inbound NAT rules or pools. + */ + interface WithCreateAndNatChoice extends + WithCreate, + WithInboundNatRule, + WithInboundNatPool { + } + + /** + * The stage of a load balancer definition allowing to create the load balancer or add an inbound NAT pool. + */ + interface WithCreateAndInboundNatPool extends + WithCreate, + WithInboundNatPool { + } + + /** + * The stage of a load balancer definition allowing to create the load balancer or add an inbound NAT rule. + */ + interface WithCreateAndInboundNatRule extends + WithCreate, + WithInboundNatRule { } /** @@ -364,7 +390,7 @@ interface WithInboundNatRule { * @param name the name of the inbound NAT rule * @return the first stage of the new inbound NAT rule definition */ - InboundNatRule.DefinitionStages.Blank defineInboundNatRule(String name); + InboundNatRule.DefinitionStages.Blank defineInboundNatRule(String name); } /** @@ -378,7 +404,7 @@ interface WithInboundNatPool { * @param name the name of the inbound NAT pool * @return the first stage of the new inbound NAT pool definition */ - InboundNatPool.DefinitionStages.Blank defineInboundNatPool(String name); + InboundNatPool.DefinitionStages.Blank defineInboundNatPool(String name); } } From 54f9a24f076b5b831ca721d9901657a9bc461fc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 11:09:25 -0700 Subject: [PATCH 15/47] impl correction --- .../management/network/implementation/InboundNatPoolImpl.java | 2 +- .../management/network/implementation/InboundNatRuleImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java index 585e0b03ceb3b..7a4a66dca6c7d 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java @@ -20,7 +20,7 @@ class InboundNatPoolImpl extends ChildResourceImpl implements InboundNatPool, - InboundNatPool.Definition, + InboundNatPool.Definition, InboundNatPool.UpdateDefinition, InboundNatPool.Update { diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java index 6050bc9f1138f..862d3915e4d2e 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java @@ -20,7 +20,7 @@ class InboundNatRuleImpl extends ChildResourceImpl implements InboundNatRule, - InboundNatRule.Definition, + InboundNatRule.Definition, InboundNatRule.UpdateDefinition, InboundNatRule.Update { From 053b4e8f9a87a86fb2631beb3062ce8110263153 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 11:50:43 -0700 Subject: [PATCH 16/47] adding .virtualMachineId() to NIC --- .../azure/management/network/NetworkInterface.java | 5 +++++ .../network/implementation/NetworkInterfaceImpl.java | 9 +++++++++ .../java/com/microsoft/azure/TestNetworkInterface.java | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java index 88f30cfec376c..d046ed18b41eb 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java @@ -138,6 +138,11 @@ public interface NetworkInterface extends */ NetworkSecurityGroup networkSecurityGroup() throws CloudException, IOException; + /** + * @return the resource ID of the associated virtual machine, or null if none. + */ + String virtualMachineId(); + // Setters (fluent) /** diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index fe4cdb84f90f2..899421bd322f0 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -240,6 +240,15 @@ public NetworkInterfaceImpl withInternalDnsNameLabel(String dnsNameLabel) { // Getters + @Override + public String virtualMachineId() { + if(this.inner().virtualMachine() != null) { + return this.inner().virtualMachine().id(); + } else { + return null; + } + } + @Override public boolean isIpForwardingEnabled() { return Utils.toPrimitiveBoolean(this.inner().enableIPForwarding()); diff --git a/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java b/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java index a5e022f643246..f289d149cb716 100644 --- a/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java +++ b/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java @@ -53,6 +53,7 @@ public void print(NetworkInterface resource) { .append("\n\tInternal DNS name label: ").append(resource.internalDnsNameLabel()) .append("\n\tInternal FQDN: ").append(resource.internalFqdn()) .append("\n\tInternal domain name suffix: ").append(resource.internalDomainNameSuffix()) + .append("\n\tVirtual machine ID: ").append(resource.virtualMachineId()) .append("\n\tApplied DNS servers: ").append(resource.appliedDnsServers().toString()) .append("\n\tDNS server IPs: "); @@ -61,7 +62,7 @@ public void print(NetworkInterface resource) { info.append("\n\t\t").append(dnsServerIp); } - info.append("\n\t IP forwarding enabled: ").append(resource.isIpForwardingEnabled()) + info.append("\n\tIP forwarding enabled: ").append(resource.isIpForwardingEnabled()) .append("\n\tMAC Address:").append(resource.macAddress()) .append("\n\tPrivate IP:").append(resource.primaryPrivateIp()) .append("\n\tPrivate allocation method:").append(resource.primaryPrivateIpAllocationMethod()) From 737f14a7e62dd26a202dd3985d9f75a1edd0179f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 11:54:47 -0700 Subject: [PATCH 17/47] renaming NIC#networkSecurityGroup() to getNetworkSecurityGroup() because it is a call to Azure, not a direct property of the NIC --- .../microsoft/azure/management/network/NetworkInterface.java | 2 +- .../management/network/implementation/NetworkInterfaceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java index d046ed18b41eb..a5a50497e8d1c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java @@ -136,7 +136,7 @@ public interface NetworkInterface extends * @throws CloudException exceptions thrown from the cloud. * @throws IOException exceptions thrown from serialization/deserialization. */ - NetworkSecurityGroup networkSecurityGroup() throws CloudException, IOException; + NetworkSecurityGroup getNetworkSecurityGroup() throws CloudException, IOException; /** * @return the resource ID of the associated virtual machine, or null if none. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index 899421bd322f0..3b99552963f2b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -329,7 +329,7 @@ public String networkSecurityGroupId() { } @Override - public NetworkSecurityGroup networkSecurityGroup() throws CloudException, IOException { + public NetworkSecurityGroup getNetworkSecurityGroup() throws CloudException, IOException { if (this.networkSecurityGroup == null && this.networkSecurityGroupId() != null) { String id = this.networkSecurityGroupId(); this.networkSecurityGroup = super.myManager From dd62054e48d6d1ecd456d035a7388905b31be2e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 13:08:19 -0700 Subject: [PATCH 18/47] exposing ability to list associated VM IDs from an LB backend --- .../azure/management/network/Backend.java | 6 ++++ .../network/implementation/BackendImpl.java | 29 +++++++++++++++++++ .../com/microsoft/azure/TestLoadBalancer.java | 13 +++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java index e78c82fb2c74a..f97d203631fc6 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java @@ -6,6 +6,7 @@ package com.microsoft.azure.management.network; import java.util.Map; +import java.util.Set; import com.microsoft.azure.management.network.implementation.BackendAddressPoolInner; import com.microsoft.azure.management.network.model.HasLoadBalancingRules; @@ -28,6 +29,11 @@ public interface Backend extends */ Map backendNicIpConfigurationNames(); + /** + * @return a list of the resource IDs of the virtual machines associated with this backend + */ + Set getVirtualMachineIds(); + /** * Grouping of backend definition stages. */ diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java index bc4c5148e763f..701c781d0ddbe 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java @@ -5,14 +5,19 @@ */ package com.microsoft.azure.management.network.implementation; +import java.io.IOException; import java.util.Collections; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.TreeMap; +import com.microsoft.azure.CloudException; import com.microsoft.azure.SubResource; import com.microsoft.azure.management.network.Backend; import com.microsoft.azure.management.network.LoadBalancer; import com.microsoft.azure.management.network.LoadBalancingRule; +import com.microsoft.azure.management.network.NetworkInterface; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ChildResourceImpl; @@ -70,6 +75,30 @@ public String name() { return this.inner().name(); } + @Override + public Set getVirtualMachineIds() { + Set vmIds = new HashSet<>(); + Map nicConfigs = this.backendNicIpConfigurationNames(); + if (nicConfigs != null) { + for (String nicId : nicConfigs.keySet()) { + try { + NetworkInterface nic = this.parent().manager().networkInterfaces().getById(nicId); + if (nic == null || nic.virtualMachineId() == null) { + continue; + } else { + vmIds.add(nic.virtualMachineId()); + } + } catch (CloudException | IllegalArgumentException | IOException e) { + continue; + } + } + } + + return vmIds; + } + + // Verbs + @Override public LoadBalancerImpl attach() { this.parent().withBackend(this); diff --git a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java index 6c8f9c9c1aec6..f0b001105bd56 100644 --- a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java +++ b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import java.util.Set; import org.junit.Assert; @@ -48,7 +49,7 @@ public class TestLoadBalancer { static final String[] PIP_NAMES = {"pipa" + TEST_ID, "pipb" + TEST_ID}; static final String[] VM_IDS = { "/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/marcinslbtest/providers/Microsoft.Compute/virtualMachines/marcinslbtest1", - "/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/marcinslbtest/providers/Microsoft.Compute/virtualMachines/marcinslbtest2" + "/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/marcinslbtest/providers/Microsoft.Compute/virtualMachines/marcinslbtest3" }; /** @@ -460,7 +461,7 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { // Frontend (default) .withExistingSubnet(network, "subnet1") // Backend (default) - //TODO .withExistingVirtualMachines(existingVMs) + .withExistingVirtualMachines(existingVMs) .defineBackend("foo") .attach() // Probe (default) @@ -780,6 +781,14 @@ static void printLB(LoadBalancer resource) { .append(" - IP Config: ").append(entry.getValue()); } + // Show assigned virtual machines + Set vmIds = backend.getVirtualMachineIds(); + info.append("\n\t\t\tReferenced virtual machine ids: ") + .append(vmIds.size()); + for (String vmId : vmIds) { + info.append("\n\t\t\t\tVM ID: ").append(vmId); + } + // Show assigned load balancing rules info.append("\n\t\t\tReferenced load balancing rules: ") .append(backend.loadBalancingRules().keySet().toArray(new String[0])); From d5525c549bd90721099c1179653ea1e8a275b1d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2016 13:36:02 -0700 Subject: [PATCH 19/47] checkstyle... --- .../management/network/implementation/NetworkInterfaceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index 3b99552963f2b..30024fcbcc6ef 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -242,7 +242,7 @@ public NetworkInterfaceImpl withInternalDnsNameLabel(String dnsNameLabel) { @Override public String virtualMachineId() { - if(this.inner().virtualMachine() != null) { + if (this.inner().virtualMachine() != null) { return this.inner().virtualMachine().id(); } else { return null; From 4f7829ce34b3cb2701bc4ceb132c7229d69ea12a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Sep 2016 15:23:41 -0700 Subject: [PATCH 20/47] enabling public IPs to be updated during LB update --- .../management/network/LoadBalancer.java | 45 +++++++++++++++++-- .../com/microsoft/azure/TestLoadBalancer.java | 22 ++++----- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java index fa10dfa88c70a..248b4a05e0ec7 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancer.java @@ -239,8 +239,7 @@ interface WithVirtualMachine { } /** - * The stage of a load balancer definition allowing to add a public ip address as one of the load - * balancer's public frontends. + * The stage of a load balancer definition allowing to add a public IP address as the default public frontend. * @param the next stage of the definition */ interface WithPublicIpAddress { @@ -552,7 +551,7 @@ interface WithLoadBalancingRule { /** * The stage of a load balancer update allowing to define, remove or edit Internet-facing frontends. */ - interface WithInternetFrontend { + interface WithInternetFrontend extends WithPublicIpAddress { /** * Begins the update of a load balancer frontend. *

@@ -577,6 +576,46 @@ interface WithInternetFrontend { PublicFrontend.Update updateInternetFrontend(String name); } + /** + * The stage of a load balancer update allowing to add a public IP address as the default public frontend. + */ + interface WithPublicIpAddress { + /** + * Assigns the provided public IP address to the default public frontend to the load balancer. + *

+ * This will create a new default frontend for the load balancer under the name "default", if one does not already exist. + * @param publicIpAddress an existing public IP address + * @return the next stage of the update + */ + Update withExistingPublicIpAddress(PublicIpAddress publicIpAddress); + + /** + * Creates a new public IP address as the default public frontend of the load balancer, + * using an automatically generated name and leaf DNS label + * derived from the load balancer's name, in the same resource group and region. + *

+ * This will create a new default frontend for the load balancer under the name "default", if one does not already exist. + * @return the next stage of the update + */ + Update withNewPublicIpAddress(); + + /** + * Adds a new public IP address as the default public frontend of the load balancer, + * using the specified DNS leaf label, an automatically generated frontend name derived from the DNS label, + * in the same resource group and region as the load balancer. + * @param dnsLeafLabel a DNS leaf label + * @return the next stage of the update + */ + Update withNewPublicIpAddress(String dnsLeafLabel); + + /** + * Adds a new public IP address to the default front end of the load balancer. + * @param creatablePublicIpAddress the creatable stage of a public IP address definition + * @return the next stage of the update + */ + Update withNewPublicIpAddress(Creatable creatablePublicIpAddress); + } + /** * The stage of a load balancer update allowing to define one or more private frontends. */ diff --git a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java index f0b001105bd56..0ebb8e1cc75e3 100644 --- a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java +++ b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java @@ -169,7 +169,6 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { @Override public LoadBalancer updateResource(LoadBalancer resource) throws Exception { resource = resource.update() - //TODO .withExistingPublicIpAddress(pip) .withoutFrontend("default") .withoutBackend("default") .withoutLoadBalancingRule("rule1") @@ -216,13 +215,11 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { .withExistingResourceGroup(TestLoadBalancer.GROUP_NAME) // Frontends - .withExistingPublicIpAddress(existingPips.get(0)) .definePublicFrontend("frontend1") - .withExistingPublicIpAddress(existingPips.get(1)) + .withExistingPublicIpAddress(existingPips.get(0)) .attach() // Backends - .withExistingVirtualMachines(existingVMs) .defineBackend("backend1") .attach() @@ -260,13 +257,11 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { // Verify frontends Assert.assertTrue(lb.frontends().containsKey("frontend1")); - Assert.assertTrue(lb.frontends().containsKey("default")); - Assert.assertTrue(lb.frontends().size() == 2); + Assert.assertTrue(lb.frontends().size() == 1); // Verify backends - Assert.assertTrue(lb.backends().containsKey("default")); Assert.assertTrue(lb.backends().containsKey("backend1")); - Assert.assertTrue(lb.backends().size() == 2); + Assert.assertTrue(lb.backends().size() == 1); // Verify probes Assert.assertTrue(lb.httpProbes().containsKey("httpProbe1")); @@ -296,8 +291,11 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { @Override public LoadBalancer updateResource(LoadBalancer resource) throws Exception { + List existingPips = ensurePIPs(pips); resource = resource.update() - //TODO .withExistingPublicIpAddress(pip) + .updateInternetFrontend("frontend1") + .withExistingPublicIpAddress(existingPips.get(1)) + .parent() .withoutFrontend("default") .withoutBackend("default") .withoutLoadBalancingRule("rule1") @@ -370,9 +368,7 @@ public LoadBalancer updateResource(LoadBalancer resource) throws Exception { List existingPips = ensurePIPs(pips); PublicIpAddress pip = existingPips.get(1); resource = resource.update() - .updateInternetFrontend("default") - .withExistingPublicIpAddress(pip) - .parent() + .withExistingPublicIpAddress(pip) .updateTcpProbe("default") .withPort(22) .parent() @@ -791,7 +787,7 @@ static void printLB(LoadBalancer resource) { // Show assigned load balancing rules info.append("\n\t\t\tReferenced load balancing rules: ") - .append(backend.loadBalancingRules().keySet().toArray(new String[0])); + .append(new ArrayList(backend.loadBalancingRules().keySet())); } System.out.println(info.toString()); From 9b801ef6bc585c252ed5072f00f17911b9a6b6e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Sep 2016 15:54:58 -0700 Subject: [PATCH 21/47] support for PublicIpAddress#version() --- .../azure/management/network/PublicIpAddress.java | 9 ++++++--- .../network/implementation/PublicIpAddressImpl.java | 6 ++++++ .../java/com/microsoft/azure/TestPublicIpAddress.java | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index cbb5b12a46412..89c11612bd3d4 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -23,9 +23,12 @@ public interface PublicIpAddress extends Wrapper, Updatable { - /*********************************************************** - * Getters - ***********************************************************/ + // Getters + + /** + * @return the IP version of the public IP address + */ + IPVersion version(); /** * @return the assigned IP address diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index 12925b6316636..8e9afd77e6c52 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -6,6 +6,7 @@ package com.microsoft.azure.management.network.implementation; import com.microsoft.azure.management.network.IPAllocationMethod; +import com.microsoft.azure.management.network.IPVersion; import com.microsoft.azure.management.network.PublicIPAddressDnsSettings; import com.microsoft.azure.management.network.PublicIpAddress; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; @@ -104,6 +105,11 @@ public IPAllocationMethod ipAllocationMethod() { return this.inner().publicIPAllocationMethod(); } + @Override + public IPVersion version() { + return this.inner().publicIPAddressVersion(); + } + @Override public String fqdn() { return this.inner().dnsSettings().fqdn(); diff --git a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java index d4e3f0818b6f9..d6d454cd763de 100644 --- a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java +++ b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java @@ -59,6 +59,7 @@ public void print(PublicIpAddress resource) { .append("\n\tReverse FQDN: ").append(resource.reverseFqdn()) .append("\n\tIdle timeout (minutes): ").append(resource.idleTimeoutInMinutes()) .append("\n\tIP allocation method: ").append(resource.ipAllocationMethod().toString()) + .append("\n\tIP version: ").append(resource.version().toString()) .toString()); } } From bf75d0f65682212590b235bd6cf501ce0fb00ed1 Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 13 Sep 2016 16:00:29 -0700 Subject: [PATCH 22/47] Moving external childresource to resources package --- .../azure/management/compute/VirtualMachineExtension.java | 1 + .../implementation/VirtualMachineExtensionImpl.java | 5 +++-- .../implementation/VirtualMachineExtensionsImpl.java | 8 +++++--- .../azure/management/compute/childresource/Pullet.java | 6 ------ .../implementation/ExternalChildResourcesImpl.java | 5 +++-- .../fluentcore/arm/models}/ExternalChildResource.java | 3 +-- .../models}/implementation/ExternalChildResourceImpl.java | 4 ++-- .../management/resources}/childresource/ChickenImpl.java | 2 +- .../childresource/ExternalChildResourceTests.java | 4 ++-- .../azure/management/resources/childresource/Pullet.java | 6 ++++++ .../management/resources}/childresource/PulletImpl.java | 4 ++-- .../management/resources}/childresource/PulletsImpl.java | 4 ++-- 12 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/Pullet.java rename {azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection}/implementation/ExternalChildResourcesImpl.java (98%) rename {azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models}/ExternalChildResource.java (73%) rename {azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models}/implementation/ExternalChildResourceImpl.java (95%) rename {azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources}/childresource/ChickenImpl.java (93%) rename {azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources}/childresource/ExternalChildResourceTests.java (97%) create mode 100644 azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/Pullet.java rename {azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources}/childresource/PulletImpl.java (92%) rename {azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute => azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources}/childresource/PulletsImpl.java (87%) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtension.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtension.java index 785562020270f..d2b320fcd3e2e 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtension.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtension.java @@ -1,6 +1,7 @@ package com.microsoft.azure.management.compute; import com.microsoft.azure.management.compute.implementation.VirtualMachineExtensionInner; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; import com.microsoft.azure.management.resources.fluentcore.model.Attachable; import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java index cd77a06ad65e7..13519bb0fa48d 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java @@ -4,6 +4,7 @@ import com.microsoft.azure.management.compute.VirtualMachineExtension; import com.microsoft.azure.management.compute.VirtualMachineExtensionImage; import com.microsoft.azure.management.compute.VirtualMachineExtensionInstanceView; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import rx.Observable; import rx.functions.Func1; @@ -18,8 +19,8 @@ */ class VirtualMachineExtensionImpl extends ExternalChildResourceImpl + VirtualMachineExtensionInner, + VirtualMachineImpl> implements VirtualMachineExtension, VirtualMachineExtension.Definition, VirtualMachineExtension.UpdateDefinition, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java index 42d8c0a7f7dba..37da115a015ea 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java @@ -1,5 +1,7 @@ package com.microsoft.azure.management.compute.implementation; import com.microsoft.azure.management.compute.VirtualMachineExtension; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -11,9 +13,9 @@ */ class VirtualMachineExtensionsImpl extends ExternalChildResourcesImpl { + VirtualMachineExtension, + VirtualMachineExtensionInner, + VirtualMachineImpl> { private final VirtualMachineExtensionsInner client; /** diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/Pullet.java b/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/Pullet.java deleted file mode 100644 index b0ea9f4a1686d..0000000000000 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/Pullet.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.microsoft.azure.management.compute.childresource; - -import com.microsoft.azure.management.compute.ExternalChildResource; - -interface Pullet extends ExternalChildResource { -} diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java similarity index 98% rename from azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourcesImpl.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java index 4db79da7e8f5e..5730e7695f4ce 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java @@ -1,6 +1,7 @@ -package com.microsoft.azure.management.compute.implementation; +package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; -import com.microsoft.azure.management.compute.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import rx.Observable; import rx.exceptions.CompositeException; import rx.functions.Action0; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ExternalChildResource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ExternalChildResource.java similarity index 73% rename from azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ExternalChildResource.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ExternalChildResource.java index 79cff6570e791..b83f6003a74a5 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/ExternalChildResource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ExternalChildResource.java @@ -1,6 +1,5 @@ -package com.microsoft.azure.management.compute; +package com.microsoft.azure.management.resources.fluentcore.arm.models; -import com.microsoft.azure.management.resources.fluentcore.arm.models.ChildResource; import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; /** diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java similarity index 95% rename from azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourceImpl.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java index e9386b2174f2f..d5e20ed24dcba 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ExternalChildResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.management.compute.implementation; +package com.microsoft.azure.management.resources.fluentcore.arm.models.implementation; -import com.microsoft.azure.management.compute.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableRefreshableWrapperImpl; import rx.Observable; diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ChickenImpl.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ChickenImpl.java similarity index 93% rename from azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ChickenImpl.java rename to azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ChickenImpl.java index 65a7b7cab15d0..00d28212e1938 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ChickenImpl.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ChickenImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.management.compute.childresource; +package com.microsoft.azure.management.resources.childresource; import rx.Observable; import rx.functions.Func1; diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ExternalChildResourceTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ExternalChildResourceTests.java similarity index 97% rename from azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ExternalChildResourceTests.java rename to azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ExternalChildResourceTests.java index 92eb380f0d098..e07636017688f 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/ExternalChildResourceTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/ExternalChildResourceTests.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.management.compute.childresource; +package com.microsoft.azure.management.resources.childresource; -import com.microsoft.azure.management.compute.implementation.ExternalChildResourceImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import org.junit.Assert; import org.junit.Test; import rx.Observer; diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/Pullet.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/Pullet.java new file mode 100644 index 0000000000000..96372524d1110 --- /dev/null +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/Pullet.java @@ -0,0 +1,6 @@ +package com.microsoft.azure.management.resources.childresource; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; + +interface Pullet extends ExternalChildResource { +} diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletImpl.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java similarity index 92% rename from azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletImpl.java rename to azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java index 9730dd90269ef..0a5dc17baf349 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletImpl.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.management.compute.childresource; +package com.microsoft.azure.management.resources.childresource; -import com.microsoft.azure.management.compute.implementation.ExternalChildResourceImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import rx.Observable; import rx.schedulers.Schedulers; diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletsImpl.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java similarity index 87% rename from azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletsImpl.java rename to azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java index 118263c3a0643..bcce414f55dbc 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/childresource/PulletsImpl.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.management.compute.childresource; +package com.microsoft.azure.management.resources.childresource; -import com.microsoft.azure.management.compute.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; import java.util.ArrayList; import java.util.List; From 57852905a27e9f0e97d0a5c93223e22b0532aa37 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 13 Sep 2016 22:34:23 -0700 Subject: [PATCH 23/47] Removing the ServiceResponse<> off return type and remove with*() for readonly objects. --- .../KeyVaultKeyResolverBCProviderTest.java | 10 +- ...eyVaultKeyResolverDefaultProviderTest.java | 8 +- .../azure/keyvault/KeyVaultClient.java | 258 +- .../azure/keyvault/KeyVaultClientImpl.java | 2066 +++++++++++++---- .../azure/keyvault/models/KeyBundle.java | 11 - .../azure/keyvault/models/KeyItem.java | 11 - .../azure/keyvault/models/SecretBundle.java | 22 - .../azure/keyvault/models/SecretItem.java | 11 - .../test/CertificateOperationsTest.java | 86 +- .../keyvault/test/KeyOperationsTest.java | 70 +- .../keyvault/test/SecretOperationsTest.java | 30 +- 11 files changed, 1864 insertions(+), 719 deletions(-) diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index f7f16bb09ca29..813b4c3ee5ad6 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -39,7 +39,6 @@ import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { @@ -81,8 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec try { // Create a key on a vault. CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); - ServiceResponse response = keyVaultClient.createKey(request); - KeyBundle bundle = response != null ? response.getBody() : null; + KeyBundle bundle = keyVaultClient.createKey(request); if ( bundle != null ) { @@ -126,7 +124,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -186,7 +184,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -246,7 +244,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index 63708e2b6a085..62777c9b26103 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -81,7 +81,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec try { // Create a key on a vault. CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); - KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); + KeyBundle keyBundle = keyVaultClient.createKey(request); try { @@ -116,7 +116,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret(request); if ( secretBundle != null ) { @@ -176,7 +176,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -249,7 +249,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 95a998e02c63b..c49e98428ee1c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -192,9 +192,9 @@ interface KeyVaultClientService { * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse createKey(CreateKeyRequest createKeyRequest) + public KeyBundle createKey(CreateKeyRequest createKeyRequest) throws KeyVaultErrorException, IllegalArgumentException, IOException { return innerKeyVaultClient.createKey( createKeyRequest.vaultBaseUrl(), @@ -234,9 +234,9 @@ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse importKey(ImportKeyRequest importKeyRequest) + public KeyBundle importKey(ImportKeyRequest importKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importKey( importKeyRequest.vaultBaseUrl(), @@ -274,9 +274,9 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } @@ -301,9 +301,9 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) + public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateKey( updateKeyRequest.vaultBaseUrl(), @@ -340,9 +340,9 @@ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String keyIdentifier) + public KeyBundle getKey(String keyIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null ? "" : id.version); @@ -368,9 +368,9 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName) + public KeyBundle getKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } @@ -396,9 +396,9 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } @@ -424,9 +424,9 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName) + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -447,13 +447,13 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -463,7 +463,7 @@ public ServiceResponse> listKeyVersions(final String vaultBas * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -478,9 +478,9 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeys(final String vaultBaseUrl) + public PagedList listKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -499,13 +499,13 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeys(final String vaultBaseUrl, final Integer maxresults) + public PagedList listKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -514,7 +514,7 @@ public ServiceResponse> listKeys(final String vaultBaseUrl, f * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -530,9 +530,9 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. + * @return the BackupKeyResult if successful. */ - public ServiceResponse backupKey(String vaultBaseUrl, String keyName) + public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } @@ -557,9 +557,9 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } @@ -585,9 +585,9 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -616,9 +616,9 @@ public ServiceCall encryptAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -647,9 +647,9 @@ public ServiceCall decryptAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) + public KeyOperationResult sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -679,9 +679,9 @@ public ServiceCall signAsync(String keyIdentifier, JsonWebKe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyVerifyResult if successful. */ - public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) + public KeyVerifyResult verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -711,9 +711,9 @@ public ServiceCall verifyAsync(String keyIdentifier, JsonWebKey * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -742,9 +742,9 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -772,9 +772,9 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Json * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse setSecret(SetSecretRequest setSecretRequest) + public SecretBundle setSecret(SetSecretRequest setSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setSecret( setSecretRequest.vaultBaseUrl(), @@ -812,9 +812,9 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } @@ -839,9 +839,9 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) + public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateSecret( updateSecretRequest.vaultBaseUrl(), @@ -878,9 +878,9 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String secretIdentifier) + public SecretBundle getSecret(String secretIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); @@ -906,9 +906,9 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName) + public SecretBundle getSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } @@ -934,9 +934,9 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } @@ -961,9 +961,9 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecrets(final String vaultBaseUrl) + public PagedList listSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -982,13 +982,13 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecrets(final String vaultBaseUrl, final Integer maxresults) + public PagedList listSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } @@ -997,7 +997,7 @@ public ServiceResponse> listSecrets(final String vaultBase * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1013,9 +1013,9 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName) + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1036,13 +1036,13 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1052,7 +1052,7 @@ public ServiceResponse> listSecretVersions(final String va * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1067,9 +1067,9 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificates(final String vaultBaseUrl) + public PagedList listCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl); } @@ -1088,13 +1088,13 @@ public ServiceCall> listCertificatesAsync(final String vau * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificates(final String vaultBaseUrl, final Integer maxresults) + public PagedList listCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } @@ -1103,7 +1103,7 @@ public ServiceResponse> listCertificates(final String * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1119,9 +1119,9 @@ public ServiceCall> listCertificatesAsync(final String vau * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } @@ -1146,9 +1146,9 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } @@ -1172,9 +1172,9 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse getCertificateContacts(String vaultBaseUrl) + public Contacts getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } @@ -1197,9 +1197,9 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) + public Contacts deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } @@ -1222,9 +1222,9 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> if successful. */ - public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl) + public PagedList listCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1243,13 +1243,13 @@ public ServiceCall> listCertificateIssuersAsync(fina * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> if successful. */ - public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public PagedList listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1258,7 +1258,7 @@ public ServiceResponse> listCertificateIssuers( * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1274,9 +1274,9 @@ public ServiceCall> listCertificateIssuersAsync(fina * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) + public IssuerBundle setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( setCertificateIssuerRequest.vaultBaseUrl(), @@ -1314,9 +1314,9 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) + public IssuerBundle updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( updateCertificateIssuerRequest.vaultBaseUrl(), @@ -1355,9 +1355,9 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1382,9 +1382,9 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) + public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1409,9 +1409,9 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) + public CertificateOperation createCertificate(CreateCertificateRequest createCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.createCertificate( createCertificateRequest.vaultBaseUrl(), @@ -1447,9 +1447,9 @@ public ServiceCall createCertificateAsync(CreateCertificat * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) + public CertificateBundle importCertificate(ImportCertificateRequest importCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importCertificate( importCertificateRequest.vaultBaseUrl(), @@ -1489,9 +1489,9 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName) + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1512,13 +1512,13 @@ public ServiceCall> listCertificateVersionsAsync(final Str * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } @@ -1528,7 +1528,7 @@ public ServiceResponse> listCertificateVersions(final * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1544,9 +1544,9 @@ public ServiceCall> listCertificateVersionsAsync(final Str * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } @@ -1571,9 +1571,9 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy if successful. */ - public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) + public CertificatePolicy updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificatePolicy( updateCertificatePolicyRequest.vaultBaseUrl(), @@ -1605,9 +1605,9 @@ public ServiceCall updateCertificatePolicyAsync(UpdateCertifi * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) + public CertificateBundle updateCertificate(UpdateCertificateRequest updateCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( updateCertificateRequest.vaultBaseUrl(), @@ -1644,9 +1644,9 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String certificateIdentifier) + public CertificateBundle getCertificate(String certificateIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); @@ -1672,9 +1672,9 @@ public ServiceCall getCertificateAsync(String certificateIden * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } @@ -1700,9 +1700,9 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } @@ -1728,9 +1728,9 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) + public CertificateOperation updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateOperation( updateCertificateOperationRequest.vaultBaseUrl(), @@ -1762,9 +1762,9 @@ public ServiceCall updateCertificateOperationAsync(UpdateC * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } @@ -1789,9 +1789,9 @@ public ServiceCall getCertificateOperationAsync(String vau * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } @@ -1816,9 +1816,9 @@ public ServiceCall deleteCertificateOperationAsync(String * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) + public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.mergeCertificate( mergeCertificateRequest.vaultBaseUrl(), @@ -1855,11 +1855,11 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the String object wrapped in {@link ServiceResponse} if successful. + * @return the String if successful. */ - public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) + public String getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); + return getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -1871,7 +1871,7 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -1881,7 +1881,7 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault * @param certificateName The name of the certificate * @return the observable to the String object */ - private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { + private Observable> getPendingCertificateSigningRequestWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index ddeb203106bf6..bfafedeedfcc8 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -455,10 +455,10 @@ interface KeyVaultClientService { * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().getBody(); } /** @@ -471,7 +471,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); + return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); } /** @@ -482,7 +482,24 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @return the observable to the KeyBundle object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @return the observable to the KeyBundle object + */ + public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -533,10 +550,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -553,7 +570,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); } /** @@ -568,7 +585,28 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param keyOps the List<JsonWebKeyOperation> value + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -621,10 +659,10 @@ private ServiceResponse createKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).toBlocking().single().getBody(); } /** @@ -637,7 +675,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); + return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); } /** @@ -648,7 +686,24 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName * @param key The Json web key * @return the observable to the KeyBundle object */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { + public Observable importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @return the observable to the KeyBundle object + */ + public Observable> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -697,10 +752,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -716,7 +771,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); } /** @@ -730,7 +785,27 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { + public Observable importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -780,10 +855,10 @@ private ServiceResponse importKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().getBody(); } /** @@ -795,7 +870,23 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.create(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the KeyBundle object + */ + public Observable deleteKeyAsync(String vaultBaseUrl, String keyName) { + return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -805,7 +896,7 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * @param keyName The name of the key * @return the observable to the KeyBundle object */ - public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { + public Observable> deleteKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -846,10 +937,10 @@ private ServiceResponse deleteKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); } /** @@ -862,7 +953,7 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** @@ -873,7 +964,24 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName * @param keyVersion The version of the key * @return the observable to the KeyBundle object */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -920,10 +1028,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -939,7 +1047,27 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -953,7 +1081,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1004,10 +1132,10 @@ private ServiceResponse updateKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); } /** @@ -1020,7 +1148,24 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.create(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1031,7 +1176,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @param keyVersion The version of the key * @return the observable to the KeyBundle object */ - public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + public Observable> getKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1074,17 +1219,16 @@ private ServiceResponse getKeyDelegate(Response respons * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1112,15 +1256,35 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + public Observable> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + return getKeyVersionsWithServiceResponseAsync(vaultBaseUrl, keyName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeyVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String keyName) { return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1130,7 +1294,7 @@ public Observable>> call(ServiceResponse>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { @@ -1163,21 +1327,20 @@ public Observable>> call(Response re * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1185,7 +1348,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1206,16 +1369,37 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + public Observable> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + return getKeyVersionsWithServiceResponseAsync(vaultBaseUrl, keyName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeyVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1225,8 +1409,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param keyName The name of the key - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -1267,17 +1451,16 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1303,15 +1486,34 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysAsync(final String vaultBaseUrl) { + public Observable> getKeysAsync(final String vaultBaseUrl) { + return getKeysWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeysWithServiceResponseAsync(final String vaultBaseUrl) { return getKeysSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1320,7 +1522,7 @@ public Observable>> call(ServiceResponse>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -1349,28 +1551,27 @@ public Observable>> call(Response re * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1390,16 +1591,36 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + return getKeysWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getKeysWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getKeysSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1408,8 +1629,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -1448,10 +1669,10 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().getBody(); } /** @@ -1463,7 +1684,7 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.create(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** @@ -1473,7 +1694,23 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @param keyName The name of the key * @return the observable to the BackupKeyResult object */ - public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { + public Observable backupKeyAsync(String vaultBaseUrl, String keyName) { + return backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, BackupKeyResult>() { + @Override + public BackupKeyResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the BackupKeyResult object + */ + public Observable> backupKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1513,10 +1750,10 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single().getBody(); } /** @@ -1528,7 +1765,7 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + return ServiceCall.create(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); } /** @@ -1538,7 +1775,23 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @param keyBundleBackup the backup blob associated with a key bundle * @return the observable to the KeyBundle object */ - public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { + public Observable restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { + return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @return the observable to the KeyBundle object + */ + public Observable> restoreKeyWithServiceResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1583,10 +1836,10 @@ private ServiceResponse restoreKeyDelegate(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult object if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1601,7 +1854,26 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1614,7 +1886,7 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable> encryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1669,10 +1941,10 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1687,7 +1959,7 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1700,7 +1972,26 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> decryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1755,10 +2046,10 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1773,7 +2064,7 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN * @return the {@link ServiceCall} object */ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1786,7 +2077,26 @@ public ServiceCall signAsync(String vaultBaseUrl, String key * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + public Observable signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> signWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1842,10 +2152,10 @@ private ServiceResponse signDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyVerifyResult object if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); + public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single().getBody(); } /** @@ -1861,7 +2171,27 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @return the {@link ServiceCall} object */ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + return ServiceCall.create(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param digest The digest used for signing + * @param signature The signature to be verified + * @return the observable to the KeyVerifyResult object + */ + public Observable verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).map(new Func1, KeyVerifyResult>() { + @Override + public KeyVerifyResult call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1875,7 +2205,7 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyN * @param signature The signature to be verified * @return the observable to the KeyVerifyResult object */ - public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + public Observable> verifyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1934,10 +2264,10 @@ private ServiceResponse verifyDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult object if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1952,7 +2282,7 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1965,7 +2295,26 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> wrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2020,10 +2369,10 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -2038,7 +2387,7 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @return the {@link ServiceCall} object */ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2051,7 +2400,26 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, Strin * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> unwrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2104,10 +2472,10 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).toBlocking().single().getBody(); } /** @@ -2120,7 +2488,7 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); + return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); } /** @@ -2131,7 +2499,24 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr * @param value The value of the secret * @return the observable to the SecretBundle object */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { + public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @return the observable to the SecretBundle object + */ + public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2179,10 +2564,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single().getBody(); } /** @@ -2198,7 +2583,27 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @return the observable to the SecretBundle object + */ + public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2212,7 +2617,7 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr * @param secretAttributes The secret management attributes * @return the observable to the SecretBundle object */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { + public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2262,10 +2667,10 @@ private ServiceResponse setSecretDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).toBlocking().single().getBody(); } /** @@ -2277,7 +2682,23 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); + return ServiceCall.create(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the SecretBundle object + */ + public Observable deleteSecretAsync(String vaultBaseUrl, String secretName) { + return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2287,7 +2708,7 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * @param secretName The name of the secret in the given vault * @return the observable to the SecretBundle object */ - public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { + public Observable> deleteSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2328,10 +2749,10 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); } /** @@ -2344,7 +2765,7 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2355,7 +2776,24 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s * @param secretVersion The version of the secret * @return the observable to the SecretBundle object */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2402,10 +2840,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single().getBody(); } /** @@ -2421,7 +2859,27 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the SecretBundle object + */ + public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2435,7 +2893,7 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the SecretBundle object */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2485,10 +2943,23 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2497,11 +2968,15 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the observable to the SecretBundle object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + public Observable getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2512,7 +2987,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @param secretVersion The version of the secret * @return the observable to the SecretBundle object */ - public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + public Observable> getSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2554,17 +3029,16 @@ private ServiceResponse getSecretDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2590,15 +3064,34 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsAsync(final String vaultBaseUrl) { + return getSecretsWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsAsync(final String vaultBaseUrl) { + public Observable>> getSecretsWithServiceResponseAsync(final String vaultBaseUrl) { return getSecretsSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2607,7 +3100,7 @@ public Observable>> call(ServiceResponse>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -2636,28 +3129,27 @@ public Observable>> call(Response * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -2677,16 +3169,36 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. - * @return the observable to the List<SecretItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + return getSecretsWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getSecretsWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2695,8 +3207,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of secrets to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -2735,17 +3247,16 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2773,15 +3284,35 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + return getSecretVersionsWithServiceResponseAsync(vaultBaseUrl, secretName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + public Observable>> getSecretVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String secretName) { return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2791,7 +3322,7 @@ public Observable>> call(ServiceResponse>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { @@ -2824,21 +3355,20 @@ public Observable>> call(Response * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2846,7 +3376,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -2867,16 +3397,37 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. - * @return the observable to the List<SecretItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + return getSecretVersionsWithServiceResponseAsync(vaultBaseUrl, secretName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + public Observable>> getSecretVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2886,8 +3437,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param secretName The name of the secret in the given vault - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -2928,17 +3479,16 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2964,15 +3514,34 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesAsync(final String vaultBaseUrl) { + return getCertificatesWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl) { + public Observable>> getCertificatesWithServiceResponseAsync(final String vaultBaseUrl) { return getCertificatesSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2981,7 +3550,7 @@ public Observable>> call(ServiceResponse

>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -3010,28 +3579,27 @@ public Observable>> call(Response> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -3051,16 +3619,36 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificatesWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getCertificatesWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3069,8 +3657,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -3109,10 +3697,10 @@ private ServiceResponse> getCertificatesDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -3124,7 +3712,7 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -3134,7 +3722,23 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @param certificateName The name of the certificate in the given vault * @return the observable to the CertificateBundle object */ - public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { + public Observable deleteCertificateAsync(String vaultBaseUrl, String certificateName) { + return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @return the observable to the CertificateBundle object + */ + public Observable> deleteCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3174,10 +3778,10 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).toBlocking().single().getBody(); } /** @@ -3189,7 +3793,23 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); + return ServiceCall.create(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts The contacts for the vault certificates. + * @return the observable to the Contacts object + */ + public Observable setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { + return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3199,7 +3819,7 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @param contacts The contacts for the vault certificates. * @return the observable to the Contacts object */ - public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { + public Observable> setCertificateContactsWithServiceResponseAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3239,10 +3859,10 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + public Contacts getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); } /** @@ -3253,7 +3873,22 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.create(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable getCertificateContactsAsync(String vaultBaseUrl) { + return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3262,7 +3897,7 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @return the observable to the Contacts object */ - public Observable> getCertificateContactsAsync(String vaultBaseUrl) { + public Observable> getCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3298,10 +3933,10 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + public Contacts deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); } /** @@ -3312,7 +3947,7 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.create(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** @@ -3321,7 +3956,22 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @return the observable to the Contacts object */ - public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { + public Observable deleteCertificateContactsAsync(String vaultBaseUrl) { + return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> deleteCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3357,17 +4007,16 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3393,15 +4042,34 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateIssuerItem> object + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersAsync(final String vaultBaseUrl) { + return getCertificateIssuersWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { + public Observable>> getCertificateIssuersWithServiceResponseAsync(final String vaultBaseUrl) { return getCertificateIssuersSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3410,7 +4078,7 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -3439,28 +4107,27 @@ public Observable>> call(Response> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -3480,16 +4147,36 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateIssuerItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificateIssuersWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getCertificateIssuersWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3498,8 +4185,8 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -3539,10 +4226,10 @@ private ServiceResponse> getCertificateIssuersDe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider).toBlocking().single(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).toBlocking().single().getBody(); } /** @@ -3555,7 +4242,24 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @return the observable to the IssuerBundle object + */ + public Observable setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3566,7 +4270,7 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, * @param provider The issuer provider. * @return the observable to the IssuerBundle object */ - public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { + public Observable> setCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3614,10 +4318,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); } /** @@ -3633,7 +4337,27 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3647,7 +4371,7 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, * @param attributes Attributes of the issuer object. * @return the observable to the IssuerBundle object */ - public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + public Observable> setCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3698,10 +4422,10 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3713,7 +4437,23 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3723,7 +4463,7 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> updateCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3769,10 +4509,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); + public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); } /** @@ -3788,7 +4528,27 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3802,7 +4562,7 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr * @param attributes Attributes of the issuer object. * @return the observable to the IssuerBundle object */ - public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + public Observable> updateCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3850,10 +4610,10 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3865,7 +4625,23 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3875,7 +4651,7 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> getCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3915,10 +4691,10 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3930,7 +4706,23 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3940,7 +4732,7 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> deleteCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3980,10 +4772,10 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -3995,7 +4787,23 @@ public ServiceResponse createCertificate(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable createCertificateAsync(String vaultBaseUrl, String certificateName) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4005,7 +4813,7 @@ public ServiceCall createCertificateAsync(String vaultBase * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { + public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4048,10 +4856,10 @@ public Observable> call(Response createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4066,7 +4874,26 @@ public ServiceResponse createCertificate(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateOperation object + */ + public Observable createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4079,7 +4906,7 @@ public ServiceCall createCertificateAsync(String vaultBase * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateOperation object */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4127,10 +4954,23 @@ private ServiceResponse createCertificateDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. + */ + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single().getBody(); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); } /** @@ -4139,11 +4979,15 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the observable to the CertificateBundle object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + public Observable importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4154,7 +4998,7 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @return the observable to the CertificateBundle object */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + public Observable> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4205,10 +5049,10 @@ public Observable> call(Response importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4225,7 +5069,28 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4240,7 +5105,7 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4292,17 +5157,16 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4330,15 +5194,35 @@ public Observable>> call(String nextPageLi * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + return getCertificateVersionsWithServiceResponseAsync(vaultBaseUrl, certificateName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + public Observable>> getCertificateVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String certificateName) { return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -4348,7 +5232,7 @@ public Observable>> call(ServiceResponse

>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { @@ -4381,21 +5265,20 @@ public Observable>> call(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4403,7 +5286,7 @@ public Page nextPage(String nextPageLink) throws RestException, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -4424,16 +5307,37 @@ public Observable>> call(String nextPageLi * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + return getCertificateVersionsWithServiceResponseAsync(vaultBaseUrl, certificateName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + public Observable>> getCertificateVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -4443,8 +5347,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param certificateName The name of the certificate - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -4486,10 +5390,10 @@ private ServiceResponse> getCertificateVersionsDelegat * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -4501,7 +5405,23 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @return the observable to the CertificatePolicy object + */ + public Observable getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { + return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificatePolicy>() { + @Override + public CertificatePolicy call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4511,7 +5431,7 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * @param certificateName The name of the certificate in the given vault. * @return the observable to the CertificatePolicy object */ - public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { + public Observable> getCertificatePolicyWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4552,10 +5472,10 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object if successful. */ - public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); + public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().getBody(); } /** @@ -4568,7 +5488,24 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + return ServiceCall.create(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @return the observable to the CertificatePolicy object + */ + public Observable updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { + return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).map(new Func1, CertificatePolicy>() { + @Override + public CertificatePolicy call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4579,7 +5516,7 @@ public ServiceCall updateCertificatePolicyAsync(String vaultB * @param certificatePolicy The policy for the certificate. * @return the observable to the CertificatePolicy object */ - public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { + public Observable> updateCertificatePolicyWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4624,10 +5561,10 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); } /** @@ -4640,7 +5577,24 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4651,7 +5605,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl * @param certificateVersion The version of the certificate * @return the observable to the CertificateBundle object */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4698,10 +5652,10 @@ public Observable> call(Response updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4717,7 +5671,27 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4731,7 +5705,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4782,10 +5756,10 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); } /** @@ -4798,7 +5772,24 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.create(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4809,7 +5800,7 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @param certificateVersion The version of the certificate * @return the observable to the CertificateBundle object */ - public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + public Observable> getCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4853,10 +5844,10 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single(); + public CertificateOperation updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single().getBody(); } /** @@ -4869,7 +5860,7 @@ public ServiceResponse updateCertificateOperation(String v * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + return ServiceCall.create(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); } /** @@ -4880,7 +5871,24 @@ public ServiceCall updateCertificateOperationAsync(String * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @return the observable to the CertificateOperation object */ - public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { + public Observable updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { + return updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. + * @return the observable to the CertificateOperation object + */ + public Observable> updateCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4922,10 +5930,10 @@ private ServiceResponse updateCertificateOperationDelegate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -4937,7 +5945,23 @@ public ServiceResponse getCertificateOperation(String vaul * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4947,7 +5971,7 @@ public ServiceCall getCertificateOperationAsync(String vau * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + public Observable> getCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4987,10 +6011,10 @@ private ServiceResponse getCertificateOperationDelegate(Re * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -5002,7 +6026,23 @@ public ServiceResponse deleteCertificateOperation(String v * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5012,7 +6052,7 @@ public ServiceCall deleteCertificateOperationAsync(String * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + public Observable> deleteCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5053,10 +6093,10 @@ private ServiceResponse deleteCertificateOperationDelegate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single().getBody(); } /** @@ -5069,7 +6109,24 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @return the observable to the CertificateBundle object + */ + public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5080,7 +6137,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, * @param x509Certificates The certificate or the certificate chain to merge * @return the observable to the CertificateBundle object */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { + public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5126,10 +6183,10 @@ public Observable> call(Response mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -5144,7 +6201,26 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5157,7 +6233,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { + public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5206,17 +6282,16 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5243,15 +6318,34 @@ public Observable>> call(String nextPageLink) { * List the versions of the specified key. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeyVersionsNextAsync(final String nextPageLink) { + return getKeyVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { + public Observable>> getKeyVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getKeyVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5260,7 +6354,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5294,17 +6388,16 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5331,15 +6424,34 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeysNextAsync(final String nextPageLink) { + return getKeysNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysNextAsync(final String nextPageLink) { + public Observable>> getKeysNextWithServiceResponseAsync(final String nextPageLink) { return getKeysNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5348,7 +6460,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5382,17 +6494,16 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5419,15 +6530,34 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsNextAsync(final String nextPageLink) { + return getSecretsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsNextAsync(final String nextPageLink) { + public Observable>> getSecretsNextWithServiceResponseAsync(final String nextPageLink) { return getSecretsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5436,7 +6566,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5470,17 +6600,16 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5507,15 +6636,34 @@ public Observable>> call(String nextPageLink) { * List the versions of the specified secret. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { + public Observable> getSecretVersionsNextAsync(final String nextPageLink) { + return getSecretVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable>> getSecretVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getSecretVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5524,7 +6672,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5558,17 +6706,16 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5595,15 +6742,34 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesNextAsync(final String nextPageLink) { + return getCertificatesNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesNextAsync(final String nextPageLink) { + public Observable>> getCertificatesNextWithServiceResponseAsync(final String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5612,7 +6778,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5646,17 +6812,16 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5683,15 +6848,34 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateIssuerItem> object + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersNextAsync(final String nextPageLink) { + return getCertificateIssuersNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { + public Observable>> getCertificateIssuersNextWithServiceResponseAsync(final String nextPageLink) { return getCertificateIssuersNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5700,7 +6884,7 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5734,17 +6918,16 @@ private ServiceResponse> getCertificateIssuersNe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5771,15 +6954,34 @@ public Observable>> call(String nextPageLi * List the versions of a certificate. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsNextAsync(final String nextPageLink) { + return getCertificateVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { + public Observable>> getCertificateVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getCertificateVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5788,7 +6990,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 07fff30be2e88..e8353e0708742 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -116,17 +116,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the KeyBundle object itself. - */ - public KeyBundle withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * The key identifier. * @return identifier for the key diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 57f669af5a4b7..f54b847cd02f7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -110,17 +110,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the KeyItem object itself. - */ - public KeyItem withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * The key identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 2035765e09b95..f5648ae67eb13 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -172,17 +172,6 @@ public String kid() { return this.kid; } - /** - * Set the kid value. - * - * @param kid the kid value to set - * @return the SecretBundle object itself. - */ - public SecretBundle withKid(String kid) { - this.kid = kid; - return this; - } - /** * Get the managed value. * @@ -192,17 +181,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the SecretBundle object itself. - */ - public SecretBundle withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 9c4c31e91d44a..00bd3528dc4a0 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -135,17 +135,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the SecretItem object itself. - */ - public SecretItem withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 8e4b7c7dced0f..833f167d399ff 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -150,7 +150,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { .withTags(sTags) .build(); - CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest).getBody(); + CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -167,12 +167,12 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Retrieve the key backing the certificate KeyIdentifier keyIdentifier = certificateBundle.keyIdentifier(); - KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()).getBody(); + KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()); Assert.assertTrue(keyBundle.managed()); // Load the secret into a KeyStore @@ -182,7 +182,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); @@ -224,7 +224,7 @@ public void createSelfSignedCertificatePem() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -234,7 +234,7 @@ public void createSelfSignedCertificatePem() throws Exception { validatePem(certificateBundle, subjectName); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -277,7 +277,7 @@ public void createCertificatePkcs12() throws Exception { .Builder(getVaultUri(),certificateIssuerName, ISSUER_TEST) .withCredentials(credentials) .withOrganizationDetails(organizationDetails) - .build()).getBody(); + .build()); validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); @@ -305,7 +305,7 @@ public void createCertificatePkcs12() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -321,7 +321,7 @@ public void createCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Load the secret into a KeyStore @@ -331,7 +331,7 @@ public void createCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -374,7 +374,7 @@ public void createCertificatePem() throws Exception { .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) .withCredentials(credentials) .withOrganizationDetails(organizationDetails) - .build()).getBody(); + .build()); validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); // Set content type to indicate the certificate is PEM format. @@ -401,7 +401,7 @@ public void createCertificatePem() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -411,7 +411,7 @@ public void createCertificatePem() throws Exception { validatePem(certificateBundle, subjectName); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -458,16 +458,16 @@ public void createCsr() throws InterruptedException, ExecutionException, KeyVaul new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); Assert.assertNotNull(certificateOperation.csr()); - String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); + String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName); Assert.assertNotNull(csr); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -511,18 +511,18 @@ public void certificateAsyncRequestCancellation() throws KeyVaultErrorException, new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateOperation cancelledCertificateOperation = keyVaultClient.updateCertificateOperation( new UpdateCertificateOperationRequest .Builder(vaultUri, certificateName, true) - .build()).getBody(); + .build()); Assert.assertNotNull(cancelledCertificateOperation); Assert.assertTrue(cancelledCertificateOperation.cancellationRequested()); - keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName).getBody(); - keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName); + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); } /** @@ -547,7 +547,7 @@ public void importCertificatePkcs12() throws Exception { .withPolicy(certificatePolicy) .withAttributes(attribute) .withTags(sTags) - .build()).getBody(); + .build()); // Validate the certificate bundle created validateCertificateBundle(certificateBundle, certificatePolicy); @@ -562,7 +562,7 @@ public void importCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Load the secret into a KeyStore @@ -572,7 +572,7 @@ public void importCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); @@ -601,7 +601,7 @@ public void certificateUpdate() throws Exception { .Builder(vaultUri, certificateName, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Attributes attribute = new CertificateAttributes() @@ -612,7 +612,7 @@ public void certificateUpdate() throws Exception { .Builder(vaultUri, certificateName) .withAttributes(attribute.withEnabled(false)) .withTags(sTags) - .build()).getBody(); + .build()); Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); Assert.assertEquals(sTags.toString(), updatedCertBundle.tags().toString()); @@ -621,10 +621,10 @@ public void certificateUpdate() throws Exception { new UpdateCertificatePolicyRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicyUpdate) - .build()).getBody(); + .build()); Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), updatedCertificatePolicy.issuerReference().name()); - CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName).getBody(); + CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName); Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), policy.issuerReference().name()); keyVaultClient.deleteCertificate(getVaultUri(), certificateName); @@ -655,7 +655,7 @@ public void listCertificates() throws Exception { .Builder(getVaultUri(), certificateName + i, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateIdentifier id = certificateBundle.certificateIdentifier(); certificates.add(id.baseIdentifier()); break; @@ -671,7 +671,7 @@ public void listCertificates() throws Exception { } } - PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -716,7 +716,7 @@ public void listCertificateVersions() throws Exception { .Builder(getVaultUri(), certificateName, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateIdentifier id = certificateBundle.certificateIdentifier(); certificates.add(id.identifier()); break; @@ -732,10 +732,10 @@ public void listCertificateVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); + listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName); for (CertificateItem item : listResult) { if(item != null) { @@ -781,13 +781,13 @@ public void issuerCrudOperations() throws Exception { .Builder(getVaultUri(), "issuer1", certificateIssuer.provider()) .withCredentials(certificateIssuer.credentials()) .withOrganizationDetails(certificateIssuer.organizationDetails()) - .build()).getBody(); + .build()); validateCertificateIssuer(certificateIssuer, createdCertificateIssuer); String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), - certificateIssuerName).getBody(); + certificateIssuerName); validateCertificateIssuer(certificateIssuer, retrievedCertificateIssuer); @@ -803,13 +803,13 @@ public void issuerCrudOperations() throws Exception { .withCredentials(updatedCredentials) .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) .withAttributes(retrievedCertificateIssuer.attributes()) - .build()).getBody(); + .build()); validateCertificateIssuer(retrievedCertificateIssuer, updatedCertificateIssuer); Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); - IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); + IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName); validateCertificateIssuer(updatedCertificateIssuer, deletedCertificateIssuer); @@ -844,7 +844,7 @@ public void contactsCrudOperations() throws Exception { Contacts certificateContacts = new Contacts(); certificateContacts.withContactList(contacts); - Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); + Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts); Assert.assertNotNull(createdCertificateContacts); Assert.assertNotNull(createdCertificateContacts.contactList()); Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); @@ -857,20 +857,20 @@ public void contactsCrudOperations() throws Exception { Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); // Get - Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()); Assert.assertNotNull(retrievedCertificateContacts); Assert.assertNotNull(retrievedCertificateContacts.contactList()); Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); // Delete - Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); + Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()); Assert.assertNotNull(deletedCertificateContacts); Assert.assertNotNull(deletedCertificateContacts.contactList()); Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); // Get after delete try { - keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + keyVaultClient.getCertificateContacts(getVaultUri()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error()); Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); @@ -890,7 +890,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation while (pendingPollCount < 21) { String certificateName = certificateOperation.certificateOperationIdentifier().name(); CertificateOperation pendingCertificateOperation = keyVaultClient - .getCertificateOperation(getVaultUri(), certificateName).getBody(); + .getCertificateOperation(getVaultUri(), certificateName); if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { Thread.sleep(10000); pendingPollCount += 1; @@ -898,7 +898,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation } if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { - return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); + return keyVaultClient.getCertificate(pendingCertificateOperation.target()); } throw new Exception(String.format( @@ -1100,7 +1100,7 @@ private void validatePem(CertificateBundle certificateBundle, String subjectName // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); String secretValue = secret.value(); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 92de113eb9f98..863b2f8a4166a 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -68,7 +68,7 @@ public void transparentAuthentication() throws Exception { .withKeyOperations(keyOps) .withKeySize(2048) .withTags(tags) - .build()).getBody(); + .build()); validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, keyOps, attribute); } @@ -76,7 +76,7 @@ public void transparentAuthentication() throws Exception { // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } @@ -112,7 +112,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .withHsm(importToHardware) .withAttributes(attribute) .withTags(tags) - .build()).getBody(); + .build()); validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); @@ -127,7 +127,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); } @@ -152,7 +152,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -166,7 +166,7 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } @@ -175,31 +175,31 @@ public void crudOperations() throws Exception { { // Get key using kid WO version - KeyBundle readBundle = keyVaultClient.getKey(keyId.baseIdentifier()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(keyId.baseIdentifier()); compareKeyBundles(createdBundle, readBundle); } { // Get key using full kid as defined in the bundle - KeyBundle readBundle = keyVaultClient.getKey(createdBundle.key().kid()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(createdBundle.key().kid()); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault and key name. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault, key name and version. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME, keyId.version()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME, keyId.version()); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault, key name and a null version. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, readBundle); } @@ -224,7 +224,7 @@ public void crudOperations() throws Exception { .withKeyOperations(key_ops) .withAttributes(createdBundle.attributes()) .withTags(createdBundle.tags()) - .build()).getBody(); + .build()); compareKeyBundles(createdBundle, updatedBundle); @@ -253,14 +253,14 @@ public void crudOperations() throws Exception { .withKeyOperations(key_ops) .withAttributes(createdBundle.attributes()) .withTags(createdBundle.tags()) - .build()).getBody(); + .build()); compareKeyBundles(createdBundle, updatedBundle); } { // Delete key - KeyBundle deleteBundle = keyVaultClient.deleteKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle deleteBundle = keyVaultClient.deleteKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, deleteBundle); } @@ -285,14 +285,14 @@ public void backupRestore() throws Exception { { createdBundle = keyVaultClient.createKey( new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) - .build()).getBody(); + .build()); validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Creates a backup of key. byte[] keyBackup; { - keyBackup = keyVaultClient.backupKey(getVaultUri(), KEY_NAME).getBody().value(); + keyBackup = keyVaultClient.backupKey(getVaultUri(), KEY_NAME).value(); } // Deletes the key. @@ -302,7 +302,7 @@ public void backupRestore() throws Exception { // Restores the key. { - KeyBundle restoredBundle = keyVaultClient.restoreKey(getVaultUri(), keyBackup).getBody(); + KeyBundle restoredBundle = keyVaultClient.restoreKey(getVaultUri(), keyBackup); compareKeyBundles(createdBundle, restoredBundle); } @@ -316,7 +316,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -332,7 +332,7 @@ public void listKeys() throws Exception { } } - PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS); Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -367,7 +367,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -382,10 +382,10 @@ public void listKeyVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS); //TODO bug: Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); + listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME); for (KeyItem item : listResult) { if(item != null) { @@ -413,19 +413,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } } @@ -445,19 +445,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } } @@ -481,19 +481,19 @@ public void signVerifyOperations() throws Exception { // Using kid WO version { - result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest); signature = result.result(); - verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature); Assert.assertEquals(new Boolean(true), verifyResult.value()); } // Using full kid { - result = keyVaultClient.sign(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest); signature = result.result(); - verifyResult = keyVaultClient.verify(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + verifyResult = keyVaultClient.verify(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signature); Assert.assertEquals(new Boolean(true), verifyResult.value()); } @@ -511,7 +511,7 @@ private static JsonWebKey importTestKey() throws Exception { new ImportKeyRequest .Builder(getVaultUri(), KEY_NAME, key) .withHsm(false) - .build()).getBody(); + .build()); validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index ed6282decdf41..08e6cd13de44e 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -49,7 +49,7 @@ public void transparentAuthentication() throws Exception { .withAttributes(attributes) .withContentType(contentType) .withTags(tags) - .build()).getBody(); + .build()); validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, contentType, attributes); } @@ -57,7 +57,7 @@ public void transparentAuthentication() throws Exception { // 401, which must be transparently handled by KeyVaultCredentials. { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()); validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } @@ -70,7 +70,7 @@ public void crudOperations() throws Exception { { // Create secret secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()); validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } @@ -79,25 +79,25 @@ public void crudOperations() throws Exception { { // Get secret using kid WO version - SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()); compareSecrets(secret, readBundle); } { // Get secret using full kid as defined in the bundle - SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secret.id()); compareSecrets(secret, readBundle); } { // Get secret using vault and secret name. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME); compareSecrets(secret, readBundle); } { // Get secret using vault, secret name and version. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()); compareSecrets(secret, readBundle); } @@ -119,7 +119,7 @@ public void crudOperations() throws Exception { .withContentType(secret.contentType()) .withAttributes(secret.attributes()) .withTags(secret.tags()) - .build()).getBody(); + .build()); compareSecrets(secret, updatedSecret); // Subsequent operations must use the updated bundle for comparison. @@ -146,7 +146,7 @@ public void crudOperations() throws Exception { .withContentType(secret.contentType()) .withAttributes(secret.attributes()) .withTags(secret.tags()) - .build()).getBody(); + .build()); compareSecrets(secret, updatedSecret); validateSecret(updatedSecret, @@ -157,7 +157,7 @@ public void crudOperations() throws Exception { { // Delete secret - SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); compareSecrets(secret, deleteBundle); } @@ -181,7 +181,7 @@ public void listSecrets() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()); SecretIdentifier id = new SecretIdentifier(secret.id()); secrets.add(id.baseIdentifier()); break; @@ -197,7 +197,7 @@ public void listSecrets() throws Exception { } } - PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -233,7 +233,7 @@ public void listSecretVersions() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()); secrets.add(secret.id()); break; } catch (KeyVaultErrorException e) { @@ -248,10 +248,10 @@ public void listSecretVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); + listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME); for (SecretItem item : listResult) { if(item != null) { secrets.remove(item.id()); From bbe0f0645a4b2b2eddb0a46d892ae292fd65db21 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Sep 2016 09:10:52 -0700 Subject: [PATCH 24/47] PIP test tweak --- .../test/java/com/microsoft/azure/TestPublicIpAddress.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java index d6d454cd763de..cfa7ec675cd05 100644 --- a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java +++ b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java @@ -47,7 +47,11 @@ public PublicIpAddress updateResource(PublicIpAddress resource) throws Exception } @Override - public void print(PublicIpAddress resource) { + public void print(PublicIpAddress pip) { + TestPublicIpAddress.printPIP(pip); + } + + public static void printPIP(PublicIpAddress resource) { System.out.println(new StringBuilder().append("Public IP Address: ").append(resource.id()) .append("Name: ").append(resource.name()) .append("\n\tResource group: ").append(resource.resourceGroupName()) From f97df3f6191c3aa6e51b7faa0589a32068c69003 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 14 Sep 2016 14:18:20 -0700 Subject: [PATCH 25/47] Remove unnecessary throws --- .../collection/implementation/CreatableResourcesImpl.java | 2 +- .../management/resources/fluentcore/model/Appliable.java | 3 +-- .../management/resources/fluentcore/model/Creatable.java | 3 +-- .../fluentcore/model/implementation/CreatableImpl.java | 6 +++--- .../model/implementation/CreatableUpdatableImpl.java | 2 +- .../fluentcore/model/implementation/CreatorTaskGroup.java | 3 +-- .../management/resources/implementation/DeploymentImpl.java | 2 +- .../resources/implementation/GenericResourceImpl.java | 2 +- .../test/java/com/microsoft/azure/TestVirtualMachine.java | 1 - 9 files changed, 10 insertions(+), 14 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java index 7ce888f985c7a..d3e7c3d1ca818 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java @@ -297,7 +297,7 @@ public Observable> createResourceAsync() { } @Override - public CreatableResourcesRoot createResource() throws Exception { + public CreatableResourcesRoot createResource() { return this; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Appliable.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Appliable.java index 14a4b3f6d143e..c675270d1d62a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Appliable.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Appliable.java @@ -22,9 +22,8 @@ public interface Appliable extends Indexable { * Execute the update request. * * @return the updated resource - * @throws Exception exceptions from Azure */ - T apply() throws Exception; + T apply(); /** * Execute the update request asynchronously. diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Creatable.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Creatable.java index 110f2e1008832..375101ee45f29 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Creatable.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Creatable.java @@ -27,9 +27,8 @@ public interface Creatable extends Indexable { * Execute the create request. * * @return the create resource - * @throws Exception exceptions from Azure */ - T create() throws Exception; + T create(); /** * Puts the request into the queue and allow the HTTP client to execute diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java index f216e36b5c570..7caed01b832a4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java @@ -67,10 +67,9 @@ public String name() { * Default implementation of create(). * * @return the created resource - * @throws Exception when anything goes wrong */ @SuppressWarnings("unchecked") - public FluentModelT create() throws Exception { + public FluentModelT create() { return createAsync().toBlocking().single(); } @@ -108,10 +107,11 @@ public CreatorTaskGroup creatorTaskGroup() { } @Override - public FluentModelT createResource() throws Exception { + public FluentModelT createResource() { return this.createResourceAsync().toBlocking().last(); } + @SuppressWarnings("unchecked") protected Func1 innerToFluentMap(final FluentModelImplT fluentModelImplT) { return new Func1() { @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java index 24d8d5c0e8b76..fb5f8aa56fca4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java @@ -40,7 +40,7 @@ public FluentModelImplT update() { } @Override - public FluentModelT apply() throws Exception { + public FluentModelT apply() { return applyAsync().toBlocking().last(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java index e099589edb62f..d28fd68c8e682 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java @@ -26,9 +26,8 @@ interface ResourceCreator { * Creates the resource synchronously. * * @return the created resource - * @throws Exception */ - T createResource() throws Exception; + T createResource(); /** * @return Gets the task group. diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java index bff13a8a94857..25bd884bc15af 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java @@ -281,7 +281,7 @@ public DeploymentImpl beginCreate() throws Exception { } @Override - public DeploymentImpl create() throws Exception { + public DeploymentImpl create() { if (this.creatableResourceGroup != null) { this.creatableResourceGroup.create(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index 3049b256600b9..578aab023e54f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -117,7 +117,7 @@ public GenericResourceImpl withApiVersion(String apiVersion) { } @Override - public GenericResourceImpl create() throws Exception { + public GenericResourceImpl create() { createResource(); return this; } diff --git a/azure/src/test/java/com/microsoft/azure/TestVirtualMachine.java b/azure/src/test/java/com/microsoft/azure/TestVirtualMachine.java index 3a80d2198d5a8..a4ef4e2cc0353 100644 --- a/azure/src/test/java/com/microsoft/azure/TestVirtualMachine.java +++ b/azure/src/test/java/com/microsoft/azure/TestVirtualMachine.java @@ -15,7 +15,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import okhttp3.logging.HttpLoggingInterceptor; import org.junit.Test; -import rx.Subscriber; import rx.functions.Action1; public class TestVirtualMachine extends TestTemplate { From aa238f63713e6fdbee0d08a6c0368872113bbd03 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 14 Sep 2016 22:08:14 -0700 Subject: [PATCH 26/47] Remove throws uncheck exceptions in generated code --- .../batch/implementation/AccountsInner.java | 76 ++----- .../implementation/ApplicationsInner.java | 67 ++---- .../implementation/SubscriptionsInner.java | 5 +- .../implementation/AvailabilitySetsInner.java | 25 +-- .../compute/implementation/UsagesInner.java | 15 +- .../VirtualMachineExtensionImagesInner.java | 20 +- .../VirtualMachineExtensionsInner.java | 32 +-- .../VirtualMachineImagesInner.java | 30 +-- .../VirtualMachineScaleSetVMsInner.java | 98 ++------- .../VirtualMachineScaleSetsInner.java | 196 ++++-------------- .../VirtualMachineSizesInner.java | 5 +- .../implementation/VirtualMachinesInner.java | 137 +++--------- .../implementation/ApplicationsInner.java | 60 ++---- .../graphrbac/implementation/GroupsInner.java | 71 ++----- .../implementation/ObjectsInner.java | 5 +- .../ServicePrincipalsInner.java | 67 ++---- .../graphrbac/implementation/UsersInner.java | 47 +---- .../keyvault/implementation/VaultsInner.java | 82 +++----- .../ApplicationGatewaysInner.java | 78 ++----- ...xpressRouteCircuitAuthorizationsInner.java | 42 +--- .../ExpressRouteCircuitPeeringsInner.java | 42 +--- .../ExpressRouteCircuitsInner.java | 99 ++------- .../ExpressRouteServiceProvidersInner.java | 15 +- .../FrontendIPConfigurationInner.java | 5 +- .../implementation/LoadBalancersInner.java | 61 ++---- .../LocalNetworkGatewaysInner.java | 42 +--- .../NetworkInterfaceIPConfigurationInner.java | 7 +- .../implementation/NetworkInterfaceInner.java | 7 +- .../NetworkInterfacesInner.java | 121 +++-------- .../NetworkManagementClientImpl.java | 10 +- .../NetworkSecurityGroupsInner.java | 61 ++---- .../PublicIPAddressesInner.java | 61 ++---- .../implementation/RouteTablesInner.java | 61 ++---- .../network/implementation/RoutesInner.java | 42 +--- .../implementation/SecurityRulesInner.java | 42 +--- .../network/implementation/SubnetInner.java | 5 +- .../network/implementation/SubnetsInner.java | 47 +---- .../network/implementation/UsagesInner.java | 15 +- ...VirtualNetworkGatewayConnectionsInner.java | 91 ++------ .../VirtualNetworkGatewaysInner.java | 63 ++---- .../VirtualNetworkPeeringsInner.java | 42 +--- .../implementation/VirtualNetworksInner.java | 71 ++----- .../azure/management/redis/SkuFamily.java | 2 +- .../implementation/PatchSchedulesInner.java | 15 +- .../redis/implementation/RedisInner.java | 81 ++------ .../DeploymentOperationsInner.java | 27 +-- .../implementation/DeploymentsInner.java | 84 ++------ .../implementation/FeaturesInner.java | 39 +--- .../implementation/ProvidersInner.java | 42 +--- .../implementation/ResourceGroupsInner.java | 79 ++----- .../implementation/ResourcesInner.java | 53 ++--- .../implementation/SubscriptionsInner.java | 25 +-- .../resources/implementation/TagsInner.java | 35 +--- .../implementation/TenantsInner.java | 15 +- .../search/implementation/AdminKeysInner.java | 5 +- .../search/implementation/QueryKeysInner.java | 5 +- .../search/implementation/ServicesInner.java | 15 +- .../management/storage/StorageAccount.java | 16 +- .../implementation/StorageAccountImpl.java | 6 +- .../implementation/StorageAccountsInner.java | 51 +---- .../storage/implementation/UsagesInner.java | 5 +- 61 files changed, 629 insertions(+), 2139 deletions(-) diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java index fb1bf7287622a..b36117d75a83f 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.batch.BatchAccountRegenerateKeyParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -126,13 +125,9 @@ interface AccountsService { * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the AccountResourceInner object if successful. */ - public AccountResourceInner create(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public AccountResourceInner create(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().last().getBody(); } @@ -201,12 +196,9 @@ public Observable> createWithServiceRespon * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AccountResourceInner object if successful. */ - public AccountResourceInner beginCreate(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public AccountResourceInner beginCreate(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().getBody(); } @@ -293,12 +285,9 @@ private ServiceResponse beginCreateDelegate(Response updateDelegate(Response> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group that contains the Batch account to be deleted. * @param accountName The name of the account to be deleted. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String accountName) { beginDeleteWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -532,12 +514,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AccountResourceInner object if successful. */ - public AccountResourceInner get(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public AccountResourceInner get(String resourceGroupName, String accountName) { return getWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -613,16 +592,13 @@ private ServiceResponse getDelegate(Response /** * Gets information about the Batch accounts associated with the subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<AccountResourceInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -717,16 +693,13 @@ private ServiceResponse> listDelegate(Response listByResourceGroup(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroup(final String resourceGroupName) { ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -829,11 +802,8 @@ private ServiceResponse> listByResourceGroupDeleg * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the Batch account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void synchronizeAutoStorageKeys(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public void synchronizeAutoStorageKeys(String resourceGroupName, String accountName) { synchronizeAutoStorageKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -911,12 +881,9 @@ private ServiceResponse synchronizeAutoStorageKeysDelegate(Response regenerateKeyDeleg * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BatchAccountListKeyResultInner object if successful. */ - public BatchAccountListKeyResultInner listKeys(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public BatchAccountListKeyResultInner listKeys(String resourceGroupName, String accountName) { return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -1084,16 +1048,13 @@ private ServiceResponse listKeysDelegate(Respons * Gets information about the Batch accounts associated with the subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<AccountResourceInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1190,16 +1151,13 @@ private ServiceResponse> listNextDelegate(Respons * Gets information about the Batch accounts associated within the specified resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<AccountResourceInner> object if successful. */ - public PagedList listByResourceGroupNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroupNext(final String nextPageLink) { ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java index 35ccdd891a633..3859973a440c9 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.batch.ActivateApplicationPackageParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -115,11 +114,8 @@ interface ApplicationsService { * @param id The id of the application. * @param version The version of the application to activate. * @param format The format of the application package binary file. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void activateApplicationPackage(String resourceGroupName, String accountName, String id, String version, String format) throws CloudException, IOException, IllegalArgumentException { + public void activateApplicationPackage(String resourceGroupName, String accountName, String id, String version, String format) { activateApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, id, version, format).toBlocking().single().getBody(); } @@ -217,12 +213,9 @@ private ServiceResponse activateApplicationPackageDelegate(Response> call(Response * @param accountName The name of the Batch account. * @param applicationId The id of the application. * @param parameters The parameters for the request. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationInner object if successful. */ - public ApplicationInner addApplication(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ApplicationInner addApplication(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { return addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).toBlocking().single().getBody(); } @@ -396,11 +386,8 @@ private ServiceResponse addApplicationDelegate(Response deleteApplicationDelegate(Response r * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the Batch account. * @param applicationId The id of the application. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationInner object if successful. */ - public ApplicationInner getApplication(String resourceGroupName, String accountName, String applicationId) throws CloudException, IOException, IllegalArgumentException { + public ApplicationInner getApplication(String resourceGroupName, String accountName, String applicationId) { return getApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId).toBlocking().single().getBody(); } @@ -575,11 +559,8 @@ private ServiceResponse getApplicationDelegate(Response updateApplicationDelegate(Response r * @param accountName The name of the Batch account. * @param applicationId The id of the application. * @param version The version of the application. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AddApplicationPackageResultInner object if successful. */ - public AddApplicationPackageResultInner addApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) throws CloudException, IOException, IllegalArgumentException { + public AddApplicationPackageResultInner addApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) { return addApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); } @@ -768,11 +746,8 @@ private ServiceResponse addApplicationPackageD * @param accountName The name of the Batch account. * @param applicationId The id of the application. * @param version The version of the application to delete. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void deleteApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) throws CloudException, IOException, IllegalArgumentException { + public void deleteApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) { deleteApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); } @@ -863,12 +838,9 @@ private ServiceResponse deleteApplicationPackageDelegate(Response getApplicationPackageD * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the Batch account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ApplicationInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String accountName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String accountName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, accountName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1072,16 +1041,13 @@ public Observable>> call(Response list(final String resourceGroupName, final String accountName, final Integer maxresults) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String accountName, final Integer maxresults) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, accountName, maxresults).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1194,16 +1160,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java index d7896f7b3c2e0..621c91676a545 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java @@ -62,12 +62,9 @@ interface SubscriptionsService { * Gets the Batch service quotas for the specified suscription. * * @param locationName The desired region for the quotas. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SubscriptionQuotasGetResultInner object if successful. */ - public SubscriptionQuotasGetResultInner getSubscriptionQuotas(String locationName) throws CloudException, IOException, IllegalArgumentException { + public SubscriptionQuotasGetResultInner getSubscriptionQuotas(String locationName) { return getSubscriptionQuotasWithServiceResponseAsync(locationName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsInner.java index 7ca42ada6ca33..dc366e34235ad 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsInner.java @@ -85,12 +85,9 @@ interface AvailabilitySetsService { * @param resourceGroupName The name of the resource group. * @param name Parameters supplied to the Create Availability Set operation. * @param parameters Parameters supplied to the Create Availability Set operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AvailabilitySetInner object if successful. */ - public AvailabilitySetInner createOrUpdate(String resourceGroupName, String name, AvailabilitySetInner parameters) throws CloudException, IOException, IllegalArgumentException { + public AvailabilitySetInner createOrUpdate(String resourceGroupName, String name, AvailabilitySetInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -175,11 +172,8 @@ private ServiceResponse createOrUpdateDelegate(Response deleteDelegate(Response response) th * * @param resourceGroupName The name of the resource group. * @param availabilitySetName The name of the availability set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AvailabilitySetInner object if successful. */ - public AvailabilitySetInner get(String resourceGroupName, String availabilitySetName) throws CloudException, IOException, IllegalArgumentException { + public AvailabilitySetInner get(String resourceGroupName, String availabilitySetName) { return getWithServiceResponseAsync(resourceGroupName, availabilitySetName).toBlocking().single().getBody(); } @@ -339,12 +330,9 @@ private ServiceResponse getDelegate(Response * The operation to list the availability sets. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<AvailabilitySetInner> object if successful. */ - public List list(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public List list(String resourceGroupName) { return listWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -417,12 +405,9 @@ private ServiceResponse> listDelegate(Response listAvailableSizes(String resourceGroupName, String availabilitySetName) throws CloudException, IOException, IllegalArgumentException { + public List listAvailableSizes(String resourceGroupName, String availabilitySetName) { return listAvailableSizesWithServiceResponseAsync(resourceGroupName, availabilitySetName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/UsagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/UsagesInner.java index 169e7b3332908..40a924fe871e7 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/UsagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/UsagesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; import java.io.IOException; @@ -71,16 +70,13 @@ interface UsagesService { * Lists compute usages for a subscription. * * @param location The location upon which resource usage is queried. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList list(final String location) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String location) { ServiceResponse> response = listSinglePageAsync(location).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -182,16 +178,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesInner.java index c3cc3f210be78..14529247e919b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesInner.java @@ -74,12 +74,9 @@ interface VirtualMachineExtensionImagesService { * @param publisherName the String value * @param type the String value * @param version the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineExtensionImageInner object if successful. */ - public VirtualMachineExtensionImageInner get(String location, String publisherName, String type, String version) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineExtensionImageInner get(String location, String publisherName, String type, String version) { return getWithServiceResponseAsync(location, publisherName, type, version).toBlocking().single().getBody(); } @@ -169,12 +166,9 @@ private ServiceResponse getDelegate(Response< * * @param location the String value * @param publisherName the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineExtensionImageInner> object if successful. */ - public List listTypes(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { + public List listTypes(String location, String publisherName) { return listTypesWithServiceResponseAsync(location, publisherName).toBlocking().single().getBody(); } @@ -253,12 +247,9 @@ private ServiceResponse> listTypesDelega * @param location the String value * @param publisherName the String value * @param type the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineExtensionImageInner> object if successful. */ - public List listVersions(String location, String publisherName, String type) throws CloudException, IOException, IllegalArgumentException { + public List listVersions(String location, String publisherName, String type) { return listVersionsWithServiceResponseAsync(location, publisherName, type).toBlocking().single().getBody(); } @@ -342,12 +333,9 @@ public Observable>> call * @param filter The filter to apply on the operation. * @param top the Integer value * @param orderby the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineExtensionImageInner> object if successful. */ - public List listVersions(String location, String publisherName, String type, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { + public List listVersions(String location, String publisherName, String type, String filter, Integer top, String orderby) { return listVersionsWithServiceResponseAsync(location, publisherName, type, filter, top, orderby).toBlocking().single().getBody(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsInner.java index 8ac198723470a..b984fe3cc6fac 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsInner.java @@ -85,13 +85,9 @@ interface VirtualMachineExtensionsService { * @param vmName The name of the virtual machine where the extension should be create or updated. * @param vmExtensionName The name of the virtual machine extension. * @param extensionParameters Parameters supplied to the Create Virtual Machine Extension operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualMachineExtensionInner object if successful. */ - public VirtualMachineExtensionInner createOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualMachineExtensionInner createOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName, extensionParameters).toBlocking().last().getBody(); } @@ -167,12 +163,9 @@ public Observable> createOrUpdateW * @param vmName The name of the virtual machine where the extension should be create or updated. * @param vmExtensionName The name of the virtual machine extension. * @param extensionParameters Parameters supplied to the Create Virtual Machine Extension operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineExtensionInner object if successful. */ - public VirtualMachineExtensionInner beginCreateOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineExtensionInner beginCreateOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName, extensionParameters).toBlocking().single().getBody(); } @@ -265,12 +258,8 @@ private ServiceResponse beginCreateOrUpdateDelegat * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine where the extension should be deleted. * @param vmExtensionName The name of the virtual machine extension. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String vmName, String vmExtensionName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String vmName, String vmExtensionName) { deleteWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName).toBlocking().last().getBody(); } @@ -338,11 +327,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine where the extension should be deleted. * @param vmExtensionName The name of the virtual machine extension. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String vmName, String vmExtensionName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String vmName, String vmExtensionName) { beginDeleteWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName).toBlocking().single().getBody(); } @@ -427,12 +413,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine containing the extension. * @param vmExtensionName The name of the virtual machine extension. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineExtensionInner object if successful. */ - public VirtualMachineExtensionInner get(String resourceGroupName, String vmName, String vmExtensionName) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineExtensionInner get(String resourceGroupName, String vmName, String vmExtensionName) { return getWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName).toBlocking().single().getBody(); } @@ -512,12 +495,9 @@ public Observable> call(Response getDelegate(Response list(String location, String publisherName, String offer, String skus) throws CloudException, IOException, IllegalArgumentException { + public List list(String location, String publisherName, String offer, String skus) { return listWithServiceResponseAsync(location, publisherName, offer, skus).toBlocking().single().getBody(); } @@ -282,12 +276,9 @@ public Observable>> call( * @param filter The filter to apply on the operation. * @param top the Integer value * @param orderby the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineImageResourceInner> object if successful. */ - public List list(String location, String publisherName, String offer, String skus, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { + public List list(String location, String publisherName, String offer, String skus, String filter, Integer top, String orderby) { return listWithServiceResponseAsync(location, publisherName, offer, skus, filter, top, orderby).toBlocking().single().getBody(); } @@ -386,12 +377,9 @@ private ServiceResponse> listDelegate(Res * * @param location the String value * @param publisherName the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineImageResourceInner> object if successful. */ - public List listOffers(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { + public List listOffers(String location, String publisherName) { return listOffersWithServiceResponseAsync(location, publisherName).toBlocking().single().getBody(); } @@ -468,12 +456,9 @@ private ServiceResponse> listOffersDelega * Gets a list of virtual machine image publishers. * * @param location the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineImageResourceInner> object if successful. */ - public List listPublishers(String location) throws CloudException, IOException, IllegalArgumentException { + public List listPublishers(String location) { return listPublishersWithServiceResponseAsync(location).toBlocking().single().getBody(); } @@ -546,12 +531,9 @@ private ServiceResponse> listPublishersDe * @param location the String value * @param publisherName the String value * @param offer the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineImageResourceInner> object if successful. */ - public List listSkus(String location, String publisherName, String offer) throws CloudException, IOException, IllegalArgumentException { + public List listSkus(String location, String publisherName, String offer) { return listSkusWithServiceResponseAsync(location, publisherName, offer).toBlocking().single().getBody(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetVMsInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetVMsInner.java index 7f6440659974c..d3192ca53d7e3 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetVMsInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetVMsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -132,12 +131,8 @@ interface VirtualMachineScaleSetVMsService { * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void reimage(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void reimage(String resourceGroupName, String vmScaleSetName, String instanceId) { reimageWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -205,11 +200,8 @@ public Observable> reimageWithServiceResponseAsync(String * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginReimage(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginReimage(String resourceGroupName, String vmScaleSetName, String instanceId) { beginReimageWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -293,12 +285,8 @@ private ServiceResponse beginReimageDelegate(Response respon * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void deallocate(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void deallocate(String resourceGroupName, String vmScaleSetName, String instanceId) { deallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -366,11 +354,8 @@ public Observable> deallocateWithServiceResponseAsync(Stri * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDeallocate(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginDeallocate(String resourceGroupName, String vmScaleSetName, String instanceId) { beginDeallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -454,12 +439,8 @@ private ServiceResponse beginDeallocateDelegate(Response res * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String vmScaleSetName, String instanceId) { deleteWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -527,11 +508,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String vmScaleSetName, String instanceId) { beginDeleteWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -617,12 +595,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineScaleSetVMInner object if successful. */ - public VirtualMachineScaleSetVMInner get(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineScaleSetVMInner get(String resourceGroupName, String vmScaleSetName, String instanceId) { return getWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -707,12 +682,9 @@ private ServiceResponse getDelegate(Response getInstanceVi * * @param resourceGroupName The name of the resource group. * @param virtualMachineScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetVMInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String virtualMachineScaleSetName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, virtualMachineScaleSetName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -914,16 +883,13 @@ public Observable>> call(Res * @param filter The filter to apply on the operation. * @param select The list parameters. * @param expand The expand expression to apply on the operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetVMInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String virtualMachineScaleSetName, final String filter, final String select, final String expand) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String virtualMachineScaleSetName, final String filter, final String select, final String expand) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, virtualMachineScaleSetName, filter, select, expand).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1046,12 +1012,8 @@ private ServiceResponse> listDelegate(R * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void powerOff(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void powerOff(String resourceGroupName, String vmScaleSetName, String instanceId) { powerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -1119,11 +1081,8 @@ public Observable> powerOffWithServiceResponseAsync(String * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginPowerOff(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginPowerOff(String resourceGroupName, String vmScaleSetName, String instanceId) { beginPowerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -1207,12 +1166,8 @@ private ServiceResponse beginPowerOffDelegate(Response respo * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void restart(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void restart(String resourceGroupName, String vmScaleSetName, String instanceId) { restartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -1280,11 +1235,8 @@ public Observable> restartWithServiceResponseAsync(String * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginRestart(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginRestart(String resourceGroupName, String vmScaleSetName, String instanceId) { beginRestartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -1368,12 +1320,8 @@ private ServiceResponse beginRestartDelegate(Response respon * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void start(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void start(String resourceGroupName, String vmScaleSetName, String instanceId) { startWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().last().getBody(); } @@ -1441,11 +1389,8 @@ public Observable> startWithServiceResponseAsync(String re * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceId The instance id of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStart(String resourceGroupName, String vmScaleSetName, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public void beginStart(String resourceGroupName, String vmScaleSetName, String instanceId) { beginStartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId).toBlocking().single().getBody(); } @@ -1527,16 +1472,13 @@ private ServiceResponse beginStartDelegate(Response response * Lists all virtual machines in a VM scale sets. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetVMInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsInner.java index 47de6b0de9d1e..68f63c9f7b008 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.compute.VirtualMachineScaleSetVMInstanceRequiredIDs; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -177,13 +176,9 @@ interface VirtualMachineScaleSetsService { * @param resourceGroupName The name of the resource group. * @param name Parameters supplied to the Create Virtual Machine Scale Set operation. * @param parameters Parameters supplied to the Create Virtual Machine Scale Set operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualMachineScaleSetInner object if successful. */ - public VirtualMachineScaleSetInner createOrUpdate(String resourceGroupName, String name, VirtualMachineScaleSetInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualMachineScaleSetInner createOrUpdate(String resourceGroupName, String name, VirtualMachineScaleSetInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } @@ -252,12 +247,9 @@ public Observable> createOrUpdateWi * @param resourceGroupName The name of the resource group. * @param name Parameters supplied to the Create Virtual Machine Scale Set operation. * @param parameters Parameters supplied to the Create Virtual Machine Scale Set operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineScaleSetInner object if successful. */ - public VirtualMachineScaleSetInner beginCreateOrUpdate(String resourceGroupName, String name, VirtualMachineScaleSetInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineScaleSetInner beginCreateOrUpdate(String resourceGroupName, String name, VirtualMachineScaleSetInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -343,12 +335,8 @@ private ServiceResponse beginCreateOrUpdateDelegate * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void deallocate(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void deallocate(String resourceGroupName, String vmScaleSetName) { deallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().getBody(); } @@ -412,12 +400,8 @@ public Observable> deallocateWithServiceResponseAsync(Stri * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void deallocate(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void deallocate(String resourceGroupName, String vmScaleSetName, List instanceIds) { deallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -487,11 +471,8 @@ public Observable> deallocateWithServiceResponseAsync(Stri * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDeallocate(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginDeallocate(String resourceGroupName, String vmScaleSetName) { beginDeallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -566,11 +547,8 @@ public Observable> call(Response response) { * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDeallocate(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginDeallocate(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginDeallocateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -656,12 +634,8 @@ private ServiceResponse beginDeallocateDelegate(Response res * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String vmScaleSetName) { deleteWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().getBody(); } @@ -722,11 +696,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String vmScaleSetName) { beginDeleteWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -805,12 +776,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineScaleSetInner object if successful. */ - public VirtualMachineScaleSetInner get(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineScaleSetInner get(String resourceGroupName, String vmScaleSetName) { return getWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -889,12 +857,8 @@ private ServiceResponse getDelegate(Response instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void deleteInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) { deleteInstancesWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -965,11 +929,8 @@ public Observable> deleteInstancesWithServiceResponseAsync * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDeleteInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginDeleteInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginDeleteInstancesWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -1055,12 +1016,9 @@ private ServiceResponse beginDeleteInstancesDelegate(Response getInstanceView * Lists all virtual machine scale sets under a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1247,16 +1202,13 @@ private ServiceResponse> listDelegate(Res /** * Lists all Virtual Machine Scale Sets in the subscription. Use nextLink property in the response to get the next page of Virtual Machine Scale Sets. Do this till nextLink is not null to fetch all the Virtual Machine Scale Sets. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1352,16 +1304,13 @@ private ServiceResponse> listAllDelegate( * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetSkuInner> object if successful. */ - public PagedList listSkus(final String resourceGroupName, final String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSkus(final String resourceGroupName, final String vmScaleSetName) { ServiceResponse> response = listSkusSinglePageAsync(resourceGroupName, vmScaleSetName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1471,12 +1420,8 @@ private ServiceResponse> listSkusDeleg * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void powerOff(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void powerOff(String resourceGroupName, String vmScaleSetName) { powerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().getBody(); } @@ -1540,12 +1485,8 @@ public Observable> powerOffWithServiceResponseAsync(String * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void powerOff(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void powerOff(String resourceGroupName, String vmScaleSetName, List instanceIds) { powerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -1615,11 +1556,8 @@ public Observable> powerOffWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginPowerOff(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginPowerOff(String resourceGroupName, String vmScaleSetName) { beginPowerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -1694,11 +1632,8 @@ public Observable> call(Response response) { * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginPowerOff(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginPowerOff(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginPowerOffWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -1784,12 +1719,8 @@ private ServiceResponse beginPowerOffDelegate(Response respo * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void restart(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void restart(String resourceGroupName, String vmScaleSetName) { restartWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().getBody(); } @@ -1853,12 +1784,8 @@ public Observable> restartWithServiceResponseAsync(String * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void restart(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void restart(String resourceGroupName, String vmScaleSetName, List instanceIds) { restartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -1928,11 +1855,8 @@ public Observable> restartWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginRestart(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginRestart(String resourceGroupName, String vmScaleSetName) { beginRestartWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -2007,11 +1931,8 @@ public Observable> call(Response response) { * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginRestart(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginRestart(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginRestartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -2097,12 +2018,8 @@ private ServiceResponse beginRestartDelegate(Response respon * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void start(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void start(String resourceGroupName, String vmScaleSetName) { startWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().last().getBody(); } @@ -2166,12 +2083,8 @@ public Observable> startWithServiceResponseAsync(String re * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void start(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void start(String resourceGroupName, String vmScaleSetName, List instanceIds) { startWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -2241,11 +2154,8 @@ public Observable> startWithServiceResponseAsync(String re * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStart(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginStart(String resourceGroupName, String vmScaleSetName) { beginStartWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -2320,11 +2230,8 @@ public Observable> call(Response response) { * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStart(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginStart(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginStartWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -2411,12 +2318,8 @@ private ServiceResponse beginStartDelegate(Response response * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void updateInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void updateInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) { updateInstancesWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().last().getBody(); } @@ -2487,11 +2390,8 @@ public Observable> updateInstancesWithServiceResponseAsync * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. * @param instanceIds the virtual machine scale set instance ids. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginUpdateInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) throws CloudException, IOException, IllegalArgumentException { + public void beginUpdateInstances(String resourceGroupName, String vmScaleSetName, List instanceIds) { beginUpdateInstancesWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceIds).toBlocking().single().getBody(); } @@ -2577,12 +2477,8 @@ private ServiceResponse beginUpdateInstancesDelegate(Response> reimageWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginReimage(String resourceGroupName, String vmScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public void beginReimage(String resourceGroupName, String vmScaleSetName) { beginReimageWithServiceResponseAsync(resourceGroupName, vmScaleSetName).toBlocking().single().getBody(); } @@ -2723,16 +2616,13 @@ private ServiceResponse beginReimageDelegate(Response respon * Lists all virtual machine scale sets under a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2829,16 +2719,13 @@ private ServiceResponse> listNextDelegate * Lists all Virtual Machine Scale Sets in the subscription. Use nextLink property in the response to get the next page of Virtual Machine Scale Sets. Do this till nextLink is not null to fetch all the Virtual Machine Scale Sets. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2935,16 +2822,13 @@ private ServiceResponse> listAllNextDeleg * Displays available skus for your virtual machine scale set including the minimum and maximum vm instances allowed for a particular sku. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineScaleSetSkuInner> object if successful. */ - public PagedList listSkusNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSkusNext(final String nextPageLink) { ServiceResponse> response = listSkusNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesInner.java index d75d3b18b908b..7753de7dfe385 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesInner.java @@ -63,12 +63,9 @@ interface VirtualMachineSizesService { * Lists all available virtual machine sizes for a subscription in a location. * * @param location The location upon which virtual-machine-sizes is queried. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineSizeInner> object if successful. */ - public List list(String location) throws CloudException, IOException, IllegalArgumentException { + public List list(String location) { return listWithServiceResponseAsync(location).toBlocking().single().getBody(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesInner.java index 2f2ca09da5ac1..b195f42873f2d 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesInner.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.compute.InstanceViewTypes; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -164,13 +163,9 @@ interface VirtualMachinesService { * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Capture Virtual Machine operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualMachineCaptureResultInner object if successful. */ - public VirtualMachineCaptureResultInner capture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualMachineCaptureResultInner capture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) { return captureWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().last().getBody(); } @@ -239,12 +234,9 @@ public Observable> captureWith * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Capture Virtual Machine operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineCaptureResultInner object if successful. */ - public VirtualMachineCaptureResultInner beginCapture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineCaptureResultInner beginCapture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) { return beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().single().getBody(); } @@ -331,13 +323,9 @@ private ServiceResponse beginCaptureDelegate(R * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Create Virtual Machine operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualMachineInner object if successful. */ - public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().last().getBody(); } @@ -406,12 +394,9 @@ public Observable> createOrUpdateWithServic * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Create Virtual Machine operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineInner object if successful. */ - public VirtualMachineInner beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineInner beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().single().getBody(); } @@ -497,12 +482,8 @@ private ServiceResponse beginCreateOrUpdateDelegate(Respons * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String vmName) { deleteWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -563,11 +544,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String vmName) { beginDeleteWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -645,12 +623,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualMachineInner object if successful. */ - public VirtualMachineInner get(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public VirtualMachineInner get(String resourceGroupName, String vmName) { return getWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -723,12 +698,9 @@ public Observable> call(Response getDelegate(Response * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void deallocate(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void deallocate(String resourceGroupName, String vmName) { deallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -875,11 +843,8 @@ public Observable> deallocateWithServiceResponseAsync(Stri * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDeallocate(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginDeallocate(String resourceGroupName, String vmName) { beginDeallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -956,11 +921,8 @@ private ServiceResponse beginDeallocateDelegate(Response res * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void generalize(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void generalize(String resourceGroupName, String vmName) { generalizeWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1036,16 +998,13 @@ private ServiceResponse generalizeDelegate(Response response * The operation to list virtual machines under a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1146,16 +1105,13 @@ private ServiceResponse> listDelegate(Response listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1251,12 +1207,9 @@ private ServiceResponse> listAllDelegate(Response * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VirtualMachineSizeInner> object if successful. */ - public List listAvailableSizes(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public List listAvailableSizes(String resourceGroupName, String vmName) { return listAvailableSizesWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1335,12 +1288,8 @@ private ServiceResponse> listAvailableSizesDel * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void powerOff(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void powerOff(String resourceGroupName, String vmName) { powerOffWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -1401,11 +1350,8 @@ public Observable> powerOffWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginPowerOff(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginPowerOff(String resourceGroupName, String vmName) { beginPowerOffWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1482,12 +1428,8 @@ private ServiceResponse beginPowerOffDelegate(Response respo * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void restart(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void restart(String resourceGroupName, String vmName) { restartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -1548,11 +1490,8 @@ public Observable> restartWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginRestart(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginRestart(String resourceGroupName, String vmName) { beginRestartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1629,12 +1568,8 @@ private ServiceResponse beginRestartDelegate(Response respon * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void start(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void start(String resourceGroupName, String vmName) { startWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -1695,11 +1630,8 @@ public Observable> startWithServiceResponseAsync(String re * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStart(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginStart(String resourceGroupName, String vmName) { beginStartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1776,12 +1708,8 @@ private ServiceResponse beginStartDelegate(Response response * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void redeploy(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void redeploy(String resourceGroupName, String vmName) { redeployWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().getBody(); } @@ -1842,11 +1770,8 @@ public Observable> redeployWithServiceResponseAsync(String * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginRedeploy(String resourceGroupName, String vmName) throws CloudException, IOException, IllegalArgumentException { + public void beginRedeploy(String resourceGroupName, String vmName) { beginRedeployWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().getBody(); } @@ -1922,16 +1847,13 @@ private ServiceResponse beginRedeployDelegate(Response respo * The operation to list virtual machines under a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2028,16 +1950,13 @@ private ServiceResponse> listNextDelegate(Respons * Gets the list of Virtual Machines in the subscription. Use nextLink property in the response to get the next page of Virtual Machines. Do this till nextLink is not null to fetch all the Virtual Machines. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualMachineInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ApplicationsInner.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ApplicationsInner.java index d77097b6d262b..3d988d0f4b72f 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ApplicationsInner.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ApplicationsInner.java @@ -102,12 +102,9 @@ interface ApplicationsService { * Create a new application. Reference: http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx. * * @param parameters Parameters to create an application. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationInner object if successful. */ - public ApplicationInner create(ApplicationCreateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public ApplicationInner create(ApplicationCreateParametersInner parameters) { return createWithServiceResponseAsync(parameters).toBlocking().single().getBody(); } @@ -178,12 +175,9 @@ private ServiceResponse createDelegate(Response /** * Lists applications by filter parameters. Reference: http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx. * - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<ApplicationInner> object if successful. */ - public List list() throws GraphErrorException, IOException, IllegalArgumentException { + public List list() { return listWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -243,12 +237,9 @@ public Observable>> call(Response list(String filter) throws GraphErrorException, IOException, IllegalArgumentException { + public List list(String filter) { return listWithServiceResponseAsync(filter).toBlocking().single().getBody(); } @@ -317,11 +308,8 @@ private ServiceResponse> listDelegate(Response deleteDelegate(Response response) th * Get an application by object Id. Reference: http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx. * * @param applicationObjectId Application object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationInner object if successful. */ - public ApplicationInner get(String applicationObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public ApplicationInner get(String applicationObjectId) { return getWithServiceResponseAsync(applicationObjectId).toBlocking().single().getBody(); } @@ -469,11 +454,8 @@ private ServiceResponse getDelegate(Response res * * @param applicationObjectId Application object id * @param parameters Parameters to update an existing application. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void patch(String applicationObjectId, ApplicationUpdateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public void patch(String applicationObjectId, ApplicationUpdateParametersInner parameters) { patchWithServiceResponseAsync(applicationObjectId, parameters).toBlocking().single().getBody(); } @@ -551,12 +533,9 @@ private ServiceResponse patchDelegate(Response response) thr * Get keyCredentials associated with the application by object Id. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type. * * @param applicationObjectId Application object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyCredentialInner> object if successful. */ - public List listKeyCredentials(String applicationObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public List listKeyCredentials(String applicationObjectId) { return listKeyCredentialsWithServiceResponseAsync(applicationObjectId).toBlocking().single().getBody(); } @@ -628,11 +607,8 @@ private ServiceResponse> listKeyCredentialsDelegate * Update keyCredentials associated with an existing application. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type. * * @param applicationObjectId Application object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updateKeyCredentials(String applicationObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void updateKeyCredentials(String applicationObjectId) { updateKeyCredentialsWithServiceResponseAsync(applicationObjectId).toBlocking().single().getBody(); } @@ -700,11 +676,8 @@ public Observable> call(Response response) { * * @param applicationObjectId Application object id * @param value KeyCredential list. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updateKeyCredentials(String applicationObjectId, List value) throws GraphErrorException, IOException, IllegalArgumentException { + public void updateKeyCredentials(String applicationObjectId, List value) { updateKeyCredentialsWithServiceResponseAsync(applicationObjectId, value).toBlocking().single().getBody(); } @@ -781,12 +754,9 @@ private ServiceResponse updateKeyCredentialsDelegate(Response listPasswordCredentials(String applicationObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public List listPasswordCredentials(String applicationObjectId) { return listPasswordCredentialsWithServiceResponseAsync(applicationObjectId).toBlocking().single().getBody(); } @@ -858,11 +828,8 @@ private ServiceResponse> listPasswordCredentia * Updates passwordCredentials associated with an existing application. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type. * * @param applicationObjectId Application object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updatePasswordCredentials(String applicationObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void updatePasswordCredentials(String applicationObjectId) { updatePasswordCredentialsWithServiceResponseAsync(applicationObjectId).toBlocking().single().getBody(); } @@ -930,11 +897,8 @@ public Observable> call(Response response) { * * @param applicationObjectId Application object id * @param value PasswordCredential list. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updatePasswordCredentials(String applicationObjectId, List value) throws GraphErrorException, IOException, IllegalArgumentException { + public void updatePasswordCredentials(String applicationObjectId, List value) { updatePasswordCredentialsWithServiceResponseAsync(applicationObjectId, value).toBlocking().single().getBody(); } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GroupsInner.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GroupsInner.java index 909a198bd2881..16952a222ca24 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GroupsInner.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GroupsInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.graphrbac.GroupGetMemberGroupsParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -114,12 +113,9 @@ interface GroupsService { * Checks whether the specified user, group, contact, or service principal is a direct or a transitive member of the specified group. * * @param parameters Check group membership parameters. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CheckGroupMembershipResultInner object if successful. */ - public CheckGroupMembershipResultInner isMemberOf(CheckGroupMembershipParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public CheckGroupMembershipResultInner isMemberOf(CheckGroupMembershipParametersInner parameters) { return isMemberOfWithServiceResponseAsync(parameters).toBlocking().single().getBody(); } @@ -192,11 +188,8 @@ private ServiceResponse isMemberOfDelegate(Resp * * @param groupObjectId Group object id * @param memberObjectId Member Object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void removeMember(String groupObjectId, String memberObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void removeMember(String groupObjectId, String memberObjectId) { removeMemberWithServiceResponseAsync(groupObjectId, memberObjectId).toBlocking().single().getBody(); } @@ -274,11 +267,8 @@ private ServiceResponse removeMemberDelegate(Response respon * * @param groupObjectId Group object id * @param url Member Object Url as "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, application, servicePrincipal, group) to be added. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void addMember(String groupObjectId, String url) throws GraphErrorException, IOException, IllegalArgumentException { + public void addMember(String groupObjectId, String url) { addMemberWithServiceResponseAsync(groupObjectId, url).toBlocking().single().getBody(); } @@ -357,11 +347,8 @@ private ServiceResponse addMemberDelegate(Response response) * Delete a group in the directory. Reference: http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx. * * @param groupObjectId Object id - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String groupObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void delete(String groupObjectId) { deleteWithServiceResponseAsync(groupObjectId).toBlocking().single().getBody(); } @@ -432,12 +419,9 @@ private ServiceResponse deleteDelegate(Response response) th * Create a group in the directory. Reference: http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx. * * @param parameters Parameters to create a group - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ADGroupInner object if successful. */ - public ADGroupInner create(GroupCreateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public ADGroupInner create(GroupCreateParametersInner parameters) { return createWithServiceResponseAsync(parameters).toBlocking().single().getBody(); } @@ -508,16 +492,13 @@ private ServiceResponse createDelegate(Response resp /** * Gets list of groups for the current tenant. * - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ADGroupInner> object if successful. */ - public PagedList list() throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -606,16 +587,13 @@ public Observable>> call(Response list(final String filter) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list(final String filter) { ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -714,16 +692,13 @@ private ServiceResponse> listDelegate(Response getGroupMembers(final String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList getGroupMembers(final String objectId) { ServiceResponse> response = getGroupMembersSinglePageAsync(objectId).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return getGroupMembersNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -825,12 +800,9 @@ private ServiceResponse> getGroupMembersDelegate(Respo * Gets group information from the directory. * * @param objectId User objectId to get group information. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ADGroupInner object if successful. */ - public ADGroupInner get(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public ADGroupInner get(String objectId) { return getWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -902,12 +874,9 @@ private ServiceResponse getDelegate(Response respons * * @param objectId Group filtering parameters. * @param securityEnabledOnly If true only membership in security enabled groups should be checked. Otherwise membership in all groups should be checked - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<String> object if successful. */ - public List getMemberGroups(String objectId, boolean securityEnabledOnly) throws GraphErrorException, IOException, IllegalArgumentException { + public List getMemberGroups(String objectId, boolean securityEnabledOnly) { return getMemberGroupsWithServiceResponseAsync(objectId, securityEnabledOnly).toBlocking().single().getBody(); } @@ -984,16 +953,13 @@ private ServiceResponse> getMemberGroupsDelegate(Response listNext(final String nextLink) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextLink) { ServiceResponse> response = listNextSinglePageAsync(nextLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -1096,16 +1062,13 @@ private ServiceResponse> listNextDelegate(Response getGroupMembersNext(final String nextLink) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList getGroupMembersNext(final String nextLink) { ServiceResponse> response = getGroupMembersNextSinglePageAsync(nextLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return getGroupMembersNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ObjectsInner.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ObjectsInner.java index 98ae94a7696e8..8acffcf122a23 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ObjectsInner.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ObjectsInner.java @@ -61,12 +61,9 @@ interface ObjectsService { /** * Gets the details for current logged in user. * - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AADObjectInner object if successful. */ - public AADObjectInner getCurrentUser() throws GraphErrorException, IOException, IllegalArgumentException { + public AADObjectInner getCurrentUser() { return getCurrentUserWithServiceResponseAsync().toBlocking().single().getBody(); } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsInner.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsInner.java index 963ea8bfe2840..2dc922bc25f9a 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsInner.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.graphrbac.PasswordCredentialsUpdateParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -107,12 +106,9 @@ interface ServicePrincipalsService { * Creates a service principal in the directory. * * @param parameters Parameters to create a service principal. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ServicePrincipalInner object if successful. */ - public ServicePrincipalInner create(ServicePrincipalCreateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public ServicePrincipalInner create(ServicePrincipalCreateParametersInner parameters) { return createWithServiceResponseAsync(parameters).toBlocking().single().getBody(); } @@ -183,16 +179,13 @@ private ServiceResponse createDelegate(Response list() throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -281,16 +274,13 @@ public Observable>> call(Response list(final String filter) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list(final String filter) { ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -389,11 +379,8 @@ private ServiceResponse> listDelegate(Response< * Deletes service principal from the directory. * * @param objectId Object id to delete service principal information. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void delete(String objectId) { deleteWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -464,12 +451,9 @@ private ServiceResponse deleteDelegate(Response response) th * Gets service principal information from the directory. * * @param objectId Object id to get service principal information. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ServicePrincipalInner object if successful. */ - public ServicePrincipalInner get(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public ServicePrincipalInner get(String objectId) { return getWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -540,12 +524,9 @@ private ServiceResponse getDelegate(Response listKeyCredentials(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public List listKeyCredentials(String objectId) { return listKeyCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -617,11 +598,8 @@ private ServiceResponse> listKeyCredentialsDelegate * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type. * * @param objectId Object id to get service principal information. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updateKeyCredentials(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void updateKeyCredentials(String objectId) { updateKeyCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -689,11 +667,8 @@ public Observable> call(Response response) { * * @param objectId Object id to get service principal information. * @param value KeyCredential list. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updateKeyCredentials(String objectId, List value) throws GraphErrorException, IOException, IllegalArgumentException { + public void updateKeyCredentials(String objectId, List value) { updateKeyCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().getBody(); } @@ -770,12 +745,9 @@ private ServiceResponse updateKeyCredentialsDelegate(Response listPasswordCredentials(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public List listPasswordCredentials(String objectId) { return listPasswordCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -847,11 +819,8 @@ private ServiceResponse> listPasswordCredentia * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type. * * @param objectId Object id to get service principal information. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updatePasswordCredentials(String objectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void updatePasswordCredentials(String objectId) { updatePasswordCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody(); } @@ -919,11 +888,8 @@ public Observable> call(Response response) { * * @param objectId Object id to get service principal information. * @param value PasswordCredential list. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void updatePasswordCredentials(String objectId, List value) throws GraphErrorException, IOException, IllegalArgumentException { + public void updatePasswordCredentials(String objectId, List value) { updatePasswordCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().getBody(); } @@ -1000,16 +966,13 @@ private ServiceResponse updatePasswordCredentialsDelegate(Response listNext(final String nextLink) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextLink) { ServiceResponse> response = listNextSinglePageAsync(nextLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersInner.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersInner.java index 91499376d8cdd..729686e710d16 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersInner.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersInner.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.graphrbac.UserGetMemberGroupsParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,9 @@ interface UsersService { * Create a new user. Reference: https://msdn.microsoft.com/library/azure/ad/graph/api/users-operations#CreateUser. * * @param parameters Parameters to create a user. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner create(UserCreateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public UserInner create(UserCreateParametersInner parameters) { return createWithServiceResponseAsync(parameters).toBlocking().single().getBody(); } @@ -174,16 +170,13 @@ private ServiceResponse createDelegate(Response respons /** * Gets list of users for the current tenant. Reference https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers. * - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UserInner> object if successful. */ - public PagedList list() throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -272,16 +265,13 @@ public Observable>> call(Response * Gets list of users for the current tenant. Reference https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers. * * @param filter The filter to apply on the operation. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UserInner> object if successful. */ - public PagedList list(final String filter) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList list(final String filter) { ServiceResponse> response = listSinglePageAsync(filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; @@ -380,12 +370,9 @@ private ServiceResponse> listDelegate(Response getDelegate(Response response) * * @param upnOrObjectId User object Id or user principal name to get user information. * @param parameters Parameters to update an exisitng user. - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void update(String upnOrObjectId, UserUpdateParametersInner parameters) throws GraphErrorException, IOException, IllegalArgumentException { + public void update(String upnOrObjectId, UserUpdateParametersInner parameters) { updateWithServiceResponseAsync(upnOrObjectId, parameters).toBlocking().single().getBody(); } @@ -539,11 +523,8 @@ private ServiceResponse updateDelegate(Response response) th * Delete a user. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#DeleteUser. * * @param upnOrObjectId user object id or user principal name (upn) - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String upnOrObjectId) throws GraphErrorException, IOException, IllegalArgumentException { + public void delete(String upnOrObjectId) { deleteWithServiceResponseAsync(upnOrObjectId).toBlocking().single().getBody(); } @@ -615,12 +596,9 @@ private ServiceResponse deleteDelegate(Response response) th * * @param objectId User filtering parameters. * @param securityEnabledOnly If true only membership in security enabled groups should be checked. Otherwise membership in all groups should be checked - * @throws GraphErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<String> object if successful. */ - public List getMemberGroups(String objectId, boolean securityEnabledOnly) throws GraphErrorException, IOException, IllegalArgumentException { + public List getMemberGroups(String objectId, boolean securityEnabledOnly) { return getMemberGroupsWithServiceResponseAsync(objectId, securityEnabledOnly).toBlocking().single().getBody(); } @@ -697,16 +675,13 @@ private ServiceResponse> getMemberGroupsDelegate(Response listNext(final String nextLink) throws GraphErrorException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextLink) { ServiceResponse> response = listNextSinglePageAsync(nextLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { return listNextSinglePageAsync(nextLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsInner.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsInner.java index 33bc29b7c4892..91572f5f50a41 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsInner.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsInner.java @@ -8,6 +8,7 @@ package com.microsoft.azure.management.keyvault.implementation; +import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceResponseBuilder; @@ -15,28 +16,24 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; import okhttp3.ResponseBody; -import retrofit2.Response; -import retrofit2.Retrofit; import retrofit2.http.Body; import retrofit2.http.GET; -import retrofit2.http.HTTP; import retrofit2.http.Header; import retrofit2.http.Headers; -import retrofit2.http.PUT; +import retrofit2.http.HTTP; import retrofit2.http.Path; +import retrofit2.http.PUT; import retrofit2.http.Query; -import retrofit2.http.Url; -import rx.Observable; +import retrofit2.Response; import rx.functions.Func1; - -import java.io.IOException; -import java.util.List; +import rx.Observable; /** * An instance of this class provides access to all the operations defined @@ -85,12 +82,12 @@ interface VaultsService { Observable> list(@Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Observable> listByResourceGroupNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> listByResourceGroupNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Observable> listNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> listNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -100,12 +97,9 @@ interface VaultsService { * @param resourceGroupName The name of the Resource Group to which the server belongs. * @param vaultName Name of the vault * @param parameters Parameters to create or update the vault - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VaultInner object if successful. */ - public VaultInner createOrUpdate(String resourceGroupName, String vaultName, VaultCreateOrUpdateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VaultInner createOrUpdate(String resourceGroupName, String vaultName, VaultCreateOrUpdateParametersInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, vaultName, parameters).toBlocking().single().getBody(); } @@ -191,11 +185,8 @@ private ServiceResponse createOrUpdateDelegate(Response deleteDelegate(Response response) th * * @param resourceGroupName The name of the Resource Group to which the vault belongs. * @param vaultName The name of the vault. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VaultInner object if successful. */ - public VaultInner get(String resourceGroupName, String vaultName) throws CloudException, IOException, IllegalArgumentException { + public VaultInner get(String resourceGroupName, String vaultName) { return getWithServiceResponseAsync(resourceGroupName, vaultName).toBlocking().single().getBody(); } @@ -354,16 +342,13 @@ private ServiceResponse getDelegate(Response response) * The List operation gets information about the vaults associated with the subscription and within the specified resource group. * * @param resourceGroupName The name of the Resource Group to which the vault belongs. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VaultInner> object if successful. */ - public PagedList listByResourceGroup(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroup(final String resourceGroupName) { ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -460,16 +445,13 @@ public Observable>> call(Response * * @param resourceGroupName The name of the Resource Group to which the vault belongs. * @param top Maximum number of results to return. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VaultInner> object if successful. */ - public PagedList listByResourceGroup(final String resourceGroupName, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroup(final String resourceGroupName, final Integer top) { ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -574,16 +556,13 @@ private ServiceResponse> listByResourceGroupDelegate(Respon /** * The List operation gets information about the vaults associated with the subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VaultInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -671,16 +650,13 @@ public Observable>> call(Response * The List operation gets information about the vaults associated with the subscription. * * @param top Maximum number of results to return. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VaultInner> object if successful. */ - public PagedList list(final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final Integer top) { ServiceResponse> response = listSinglePageAsync(top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -778,16 +754,13 @@ private ServiceResponse> listDelegate(Response listByResourceGroupNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroupNext(final String nextPageLink) { ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -884,16 +857,13 @@ private ServiceResponse> listByResourceGroupNextDelegate(Re * The List operation gets information about the vaults associated with the subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VaultInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ApplicationGatewaysInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ApplicationGatewaysInner.java index 8ccbe1c3793e4..664ea62d4a072 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ApplicationGatewaysInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ApplicationGatewaysInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -122,12 +121,8 @@ interface ApplicationGatewaysService { * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String applicationGatewayName) { deleteWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().last().getBody(); } @@ -188,11 +183,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String applicationGatewayName) { beginDeleteWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().getBody(); } @@ -271,12 +263,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationGatewayInner object if successful. */ - public ApplicationGatewayInner get(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException { + public ApplicationGatewayInner get(String resourceGroupName, String applicationGatewayName) { return getWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().getBody(); } @@ -355,13 +344,9 @@ private ServiceResponse getDelegate(Response> createOrUpdateWithSe * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the ApplicationGateway. * @param parameters Parameters supplied to the create/delete ApplicationGateway operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ApplicationGatewayInner object if successful. */ - public ApplicationGatewayInner beginCreateOrUpdate(String resourceGroupName, String applicationGatewayName, ApplicationGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ApplicationGatewayInner beginCreateOrUpdate(String resourceGroupName, String applicationGatewayName, ApplicationGatewayInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, applicationGatewayName, parameters).toBlocking().single().getBody(); } @@ -520,16 +502,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Res * The List ApplicationGateway operation retrieves all the application gateways in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ApplicationGatewayInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -630,16 +609,13 @@ private ServiceResponse> listDelegate(Response /** * The List ApplicationGateway operation retrieves all the application gateways in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ApplicationGatewayInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -735,12 +711,8 @@ private ServiceResponse> listAllDelegate(Respo * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void start(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void start(String resourceGroupName, String applicationGatewayName) { startWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().last().getBody(); } @@ -801,11 +773,8 @@ public Observable> startWithServiceResponseAsync(String re * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStart(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException { + public void beginStart(String resourceGroupName, String applicationGatewayName) { beginStartWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().getBody(); } @@ -883,12 +852,8 @@ private ServiceResponse beginStartDelegate(Response response * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void stop(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void stop(String resourceGroupName, String applicationGatewayName) { stopWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().last().getBody(); } @@ -949,11 +914,8 @@ public Observable> stopWithServiceResponseAsync(String res * * @param resourceGroupName The name of the resource group. * @param applicationGatewayName The name of the application gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginStop(String resourceGroupName, String applicationGatewayName) throws CloudException, IOException, IllegalArgumentException { + public void beginStop(String resourceGroupName, String applicationGatewayName) { beginStopWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().getBody(); } @@ -1030,16 +992,13 @@ private ServiceResponse beginStopDelegate(Response response) * The List ApplicationGateway operation retrieves all the application gateways in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ApplicationGatewayInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1136,16 +1095,13 @@ private ServiceResponse> listNextDelegate(Resp * The List ApplicationGateway operation retrieves all the application gateways in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ApplicationGatewayInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitAuthorizationsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitAuthorizationsInner.java index 3314682ab2585..a15094a6a269b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitAuthorizationsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitAuthorizationsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface ExpressRouteCircuitAuthorizationsService { * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param authorizationName The name of the authorization. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String circuitName, String authorizationName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String circuitName, String authorizationName) { deleteWithServiceResponseAsync(resourceGroupName, circuitName, authorizationName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param authorizationName The name of the authorization. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String circuitName, String authorizationName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String circuitName, String authorizationName) { beginDeleteWithServiceResponseAsync(resourceGroupName, circuitName, authorizationName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param authorizationName The name of the authorization. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitAuthorizationInner object if successful. */ - public ExpressRouteCircuitAuthorizationInner get(String resourceGroupName, String circuitName, String authorizationName) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitAuthorizationInner get(String resourceGroupName, String circuitName, String authorizationName) { return getWithServiceResponseAsync(resourceGroupName, circuitName, authorizationName).toBlocking().single().getBody(); } @@ -352,13 +341,9 @@ private ServiceResponse getDelegate(Respo * @param circuitName The name of the express route circuit. * @param authorizationName The name of the authorization. * @param authorizationParameters Parameters supplied to the create/update ExpressRouteCircuitAuthorization operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ExpressRouteCircuitAuthorizationInner object if successful. */ - public ExpressRouteCircuitAuthorizationInner createOrUpdate(String resourceGroupName, String circuitName, String authorizationName, ExpressRouteCircuitAuthorizationInner authorizationParameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ExpressRouteCircuitAuthorizationInner createOrUpdate(String resourceGroupName, String circuitName, String authorizationName, ExpressRouteCircuitAuthorizationInner authorizationParameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters).toBlocking().last().getBody(); } @@ -434,12 +419,9 @@ public Observable> create * @param circuitName The name of the express route circuit. * @param authorizationName The name of the authorization. * @param authorizationParameters Parameters supplied to the create/update ExpressRouteCircuitAuthorization operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitAuthorizationInner object if successful. */ - public ExpressRouteCircuitAuthorizationInner beginCreateOrUpdate(String resourceGroupName, String circuitName, String authorizationName, ExpressRouteCircuitAuthorizationInner authorizationParameters) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitAuthorizationInner beginCreateOrUpdate(String resourceGroupName, String circuitName, String authorizationName, ExpressRouteCircuitAuthorizationInner authorizationParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, circuitName, authorizationName, authorizationParameters).toBlocking().single().getBody(); } @@ -531,16 +513,13 @@ private ServiceResponse beginCreateOrUpda * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitAuthorizationInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String circuitName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String circuitName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, circuitName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -649,16 +628,13 @@ private ServiceResponse> listDel * The List authorization operation retrieves all the authorizations in an ExpressRouteCircuit. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitAuthorizationInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitPeeringsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitPeeringsInner.java index 185f29fe45ca2..4ca5a6ef8aade 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitPeeringsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitPeeringsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface ExpressRouteCircuitPeeringsService { * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param peeringName The name of the peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String circuitName, String peeringName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String circuitName, String peeringName) { deleteWithServiceResponseAsync(resourceGroupName, circuitName, peeringName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param peeringName The name of the peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String circuitName, String peeringName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String circuitName, String peeringName) { beginDeleteWithServiceResponseAsync(resourceGroupName, circuitName, peeringName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @param peeringName The name of the peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitPeeringInner object if successful. */ - public ExpressRouteCircuitPeeringInner get(String resourceGroupName, String circuitName, String peeringName) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitPeeringInner get(String resourceGroupName, String circuitName, String peeringName) { return getWithServiceResponseAsync(resourceGroupName, circuitName, peeringName).toBlocking().single().getBody(); } @@ -352,13 +341,9 @@ private ServiceResponse getDelegate(Response> createOrUpda * @param circuitName The name of the express route circuit. * @param peeringName The name of the peering. * @param peeringParameters Parameters supplied to the create/update ExpressRouteCircuit Peering operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitPeeringInner object if successful. */ - public ExpressRouteCircuitPeeringInner beginCreateOrUpdate(String resourceGroupName, String circuitName, String peeringName, ExpressRouteCircuitPeeringInner peeringParameters) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitPeeringInner beginCreateOrUpdate(String resourceGroupName, String circuitName, String peeringName, ExpressRouteCircuitPeeringInner peeringParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, circuitName, peeringName, peeringParameters).toBlocking().single().getBody(); } @@ -531,16 +513,13 @@ private ServiceResponse beginCreateOrUpdateDele * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitPeeringInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String circuitName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String circuitName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, circuitName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -649,16 +628,13 @@ private ServiceResponse> listDelegate( * The List peering operation retrieves all the peerings in an ExpressRouteCircuit. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitPeeringInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitsInner.java index 3019ec44955e6..3a913c807e0b1 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteCircuitsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -138,12 +137,8 @@ interface ExpressRouteCircuitsService { * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route Circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String circuitName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String circuitName) { deleteWithServiceResponseAsync(resourceGroupName, circuitName).toBlocking().last().getBody(); } @@ -204,11 +199,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route Circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String circuitName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String circuitName) { beginDeleteWithServiceResponseAsync(resourceGroupName, circuitName).toBlocking().single().getBody(); } @@ -287,12 +279,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitInner object if successful. */ - public ExpressRouteCircuitInner get(String resourceGroupName, String circuitName) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitInner get(String resourceGroupName, String circuitName) { return getWithServiceResponseAsync(resourceGroupName, circuitName).toBlocking().single().getBody(); } @@ -371,13 +360,9 @@ private ServiceResponse getDelegate(Response> createOrUpdateWithS * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. * @param parameters Parameters supplied to the create/delete ExpressRouteCircuit operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitInner object if successful. */ - public ExpressRouteCircuitInner beginCreateOrUpdate(String resourceGroupName, String circuitName, ExpressRouteCircuitInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitInner beginCreateOrUpdate(String resourceGroupName, String circuitName, ExpressRouteCircuitInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, circuitName, parameters).toBlocking().single().getBody(); } @@ -539,13 +521,9 @@ private ServiceResponse beginCreateOrUpdateDelegate(Re * @param circuitName The name of the circuit. * @param peeringName The name of the peering. * @param devicePath The path of the device. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ExpressRouteCircuitsArpTableListResultInner object if successful. */ - public ExpressRouteCircuitsArpTableListResultInner listArpTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ExpressRouteCircuitsArpTableListResultInner listArpTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) { return listArpTableWithServiceResponseAsync(resourceGroupName, circuitName, peeringName, devicePath).toBlocking().last().getBody(); } @@ -620,12 +598,9 @@ public Observable> * @param circuitName The name of the circuit. * @param peeringName The name of the peering. * @param devicePath The path of the device. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitsArpTableListResultInner object if successful. */ - public ExpressRouteCircuitsArpTableListResultInner beginListArpTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitsArpTableListResultInner beginListArpTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) { return beginListArpTableWithServiceResponseAsync(resourceGroupName, circuitName, peeringName, devicePath).toBlocking().single().getBody(); } @@ -718,13 +693,9 @@ private ServiceResponse beginListAr * @param circuitName The name of the circuit. * @param peeringName The name of the peering. * @param devicePath The path of the device. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ExpressRouteCircuitsRoutesTableListResultInner object if successful. */ - public ExpressRouteCircuitsRoutesTableListResultInner listRoutesTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ExpressRouteCircuitsRoutesTableListResultInner listRoutesTable(String resourceGroupName, String circuitName, String peeringName, String devicePath) { return listRoutesTableWithServiceResponseAsync(resourceGroupName, circuitName, peeringName, devicePath).toBlocking().last().getBody(); } @@ -799,12 +770,9 @@ public Observable beginLis * @param circuitName The name of the circuit. * @param peeringName The name of the peering. * @param devicePath The path of the device. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ExpressRouteCircuitsRoutesTableSummaryListResultInner object if successful. */ - public ExpressRouteCircuitsRoutesTableSummaryListResultInner listRoutesTableSummary(String resourceGroupName, String circuitName, String peeringName, String devicePath) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ExpressRouteCircuitsRoutesTableSummaryListResultInner listRoutesTableSummary(String resourceGroupName, String circuitName, String peeringName, String devicePath) { return listRoutesTableSummaryWithServiceResponseAsync(resourceGroupName, circuitName, peeringName, devicePath).toBlocking().last().getBody(); } @@ -978,12 +942,9 @@ public Observable b * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitStatsInner object if successful. */ - public ExpressRouteCircuitStatsInner getStats(String resourceGroupName, String circuitName) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitStatsInner getStats(String resourceGroupName, String circuitName) { return getStatsWithServiceResponseAsync(resourceGroupName, circuitName).toBlocking().single().getBody(); } @@ -1158,12 +1116,9 @@ private ServiceResponse getStatsDelegate(Response * @param resourceGroupName The name of the resource group. * @param circuitName The name of the circuit. * @param peeringName The name of the peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ExpressRouteCircuitStatsInner object if successful. */ - public ExpressRouteCircuitStatsInner getPeeringStats(String resourceGroupName, String circuitName, String peeringName) throws CloudException, IOException, IllegalArgumentException { + public ExpressRouteCircuitStatsInner getPeeringStats(String resourceGroupName, String circuitName, String peeringName) { return getPeeringStatsWithServiceResponseAsync(resourceGroupName, circuitName, peeringName).toBlocking().single().getBody(); } @@ -1246,16 +1201,13 @@ private ServiceResponse getPeeringStatsDelegate(R * The List ExpressRouteCircuit operation retrieves all the ExpressRouteCircuits in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1356,16 +1308,13 @@ private ServiceResponse> listDelegate(Respons /** * The List ExpressRouteCircuit operation retrieves all the ExpressRouteCircuits in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1460,16 +1409,13 @@ private ServiceResponse> listAllDelegate(Resp * The List ExpressRouteCircuit operation retrieves all the ExpressRouteCircuits in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1566,16 +1512,13 @@ private ServiceResponse> listNextDelegate(Res * The List ExpressRouteCircuit operation retrieves all the ExpressRouteCircuits in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteCircuitInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteServiceProvidersInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteServiceProvidersInner.java index 7891dbb853d4b..9ec55ea02bf7d 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteServiceProvidersInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ExpressRouteServiceProvidersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; import java.io.IOException; @@ -70,16 +69,13 @@ interface ExpressRouteServiceProvidersService { /** * The List ExpressRouteServiceProvider operation retrieves all the available ExpressRouteServiceProviders. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteServiceProviderInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -174,16 +170,13 @@ private ServiceResponse> listDelegate * The List ExpressRouteServiceProvider operation retrieves all the available ExpressRouteServiceProviders. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ExpressRouteServiceProviderInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendIPConfigurationInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendIPConfigurationInner.java index 3c7ac58f7bb72..17b1510705136 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendIPConfigurationInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendIPConfigurationInner.java @@ -8,12 +8,13 @@ package com.microsoft.azure.management.network.implementation; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.azure.SubResource; import com.microsoft.azure.management.network.IPAllocationMethod; -import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; +import java.util.List; + /** * Frontend IP address of the load balancer. */ diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersInner.java index 6502f15a306da..379dad1e819bf 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -105,12 +104,8 @@ interface LoadBalancersService { * * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the loadBalancer. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String loadBalancerName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String loadBalancerName) { deleteWithServiceResponseAsync(resourceGroupName, loadBalancerName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the loadBalancer. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String loadBalancerName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String loadBalancerName) { beginDeleteWithServiceResponseAsync(resourceGroupName, loadBalancerName).toBlocking().single().getBody(); } @@ -254,12 +246,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the loadBalancer. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the LoadBalancerInner object if successful. */ - public LoadBalancerInner get(String resourceGroupName, String loadBalancerName) throws CloudException, IOException, IllegalArgumentException { + public LoadBalancerInner get(String resourceGroupName, String loadBalancerName) { return getWithServiceResponseAsync(resourceGroupName, loadBalancerName).toBlocking().single().getBody(); } @@ -332,12 +321,9 @@ public Observable> call(Response getDelegate(Response re * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the loadBalancer. * @param parameters Parameters supplied to the create/delete LoadBalancer operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the LoadBalancerInner object if successful. */ - public LoadBalancerInner createOrUpdate(String resourceGroupName, String loadBalancerName, LoadBalancerInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public LoadBalancerInner createOrUpdate(String resourceGroupName, String loadBalancerName, LoadBalancerInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, loadBalancerName, parameters).toBlocking().last().getBody(); } @@ -494,12 +476,9 @@ public Observable> createOrUpdateWithServiceR * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the loadBalancer. * @param parameters Parameters supplied to the create/delete LoadBalancer operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the LoadBalancerInner object if successful. */ - public LoadBalancerInner beginCreateOrUpdate(String resourceGroupName, String loadBalancerName, LoadBalancerInner parameters) throws CloudException, IOException, IllegalArgumentException { + public LoadBalancerInner beginCreateOrUpdate(String resourceGroupName, String loadBalancerName, LoadBalancerInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, loadBalancerName, parameters).toBlocking().single().getBody(); } @@ -583,16 +562,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Response< /** * The List loadBalancer operation retrieves all the load balancers in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<LoadBalancerInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -687,16 +663,13 @@ private ServiceResponse> listAllDelegate(Response list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -798,16 +771,13 @@ private ServiceResponse> listDelegate(Response listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -904,16 +874,13 @@ private ServiceResponse> listAllNextDelegate(Respons * The List loadBalancer operation retrieves all the load balancers in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<LoadBalancerInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LocalNetworkGatewaysInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LocalNetworkGatewaysInner.java index afe6f8c0570be..01316714ecfba 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LocalNetworkGatewaysInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LocalNetworkGatewaysInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,13 +97,9 @@ interface LocalNetworkGatewaysService { * @param resourceGroupName The name of the resource group. * @param localNetworkGatewayName The name of the local network gateway. * @param parameters Parameters supplied to the Begin Create or update Local Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the LocalNetworkGatewayInner object if successful. */ - public LocalNetworkGatewayInner createOrUpdate(String resourceGroupName, String localNetworkGatewayName, LocalNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public LocalNetworkGatewayInner createOrUpdate(String resourceGroupName, String localNetworkGatewayName, LocalNetworkGatewayInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName, parameters).toBlocking().last().getBody(); } @@ -173,12 +168,9 @@ public Observable> createOrUpdateWithS * @param resourceGroupName The name of the resource group. * @param localNetworkGatewayName The name of the local network gateway. * @param parameters Parameters supplied to the Begin Create or update Local Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the LocalNetworkGatewayInner object if successful. */ - public LocalNetworkGatewayInner beginCreateOrUpdate(String resourceGroupName, String localNetworkGatewayName, LocalNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException { + public LocalNetworkGatewayInner beginCreateOrUpdate(String resourceGroupName, String localNetworkGatewayName, LocalNetworkGatewayInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName, parameters).toBlocking().single().getBody(); } @@ -264,12 +256,9 @@ private ServiceResponse beginCreateOrUpdateDelegate(Re * * @param resourceGroupName The name of the resource group. * @param localNetworkGatewayName The name of the local network gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the LocalNetworkGatewayInner object if successful. */ - public LocalNetworkGatewayInner get(String resourceGroupName, String localNetworkGatewayName) throws CloudException, IOException, IllegalArgumentException { + public LocalNetworkGatewayInner get(String resourceGroupName, String localNetworkGatewayName) { return getWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName).toBlocking().single().getBody(); } @@ -347,12 +336,8 @@ private ServiceResponse getDelegate(Response> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param localNetworkGatewayName The name of the local network gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String localNetworkGatewayName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String localNetworkGatewayName) { beginDeleteWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName).toBlocking().single().getBody(); } @@ -495,16 +477,13 @@ private ServiceResponse beginDeleteDelegate(Response respons * The List LocalNetworkGateways operation retrieves all the local network gateways stored. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<LocalNetworkGatewayInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -606,16 +585,13 @@ private ServiceResponse> listDelegate(Respons * The List LocalNetworkGateways operation retrieves all the local network gateways stored. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<LocalNetworkGatewayInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceIPConfigurationInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceIPConfigurationInner.java index e17f787dad1a9..6ab2a6ebd5779 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceIPConfigurationInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceIPConfigurationInner.java @@ -8,12 +8,13 @@ package com.microsoft.azure.management.network.implementation; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.SubResource; import com.microsoft.azure.management.network.IPAllocationMethod; import com.microsoft.azure.management.network.IPVersion; -import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; -import com.microsoft.azure.SubResource; + +import java.util.List; /** * IPConfiguration in a NetworkInterface. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceInner.java index dc7cedfe2591d..8f94833168904 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceInner.java @@ -8,12 +8,13 @@ package com.microsoft.azure.management.network.implementation; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Resource; import com.microsoft.azure.SubResource; -import java.util.List; import com.microsoft.azure.management.network.NetworkInterfaceDnsSettings; -import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; -import com.microsoft.azure.Resource; + +import java.util.List; /** * A NetworkInterface in a resource group. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesInner.java index 9e8077df408a5..9c85af68efed3 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -142,12 +141,8 @@ interface NetworkInterfacesService { * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String networkInterfaceName) { deleteWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().last().getBody(); } @@ -208,11 +203,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String networkInterfaceName) { beginDeleteWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().getBody(); } @@ -291,12 +283,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkInterfaceInner object if successful. */ - public NetworkInterfaceInner get(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException { + public NetworkInterfaceInner get(String resourceGroupName, String networkInterfaceName) { return getWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().getBody(); } @@ -369,12 +358,9 @@ public Observable> call(Response getDelegate(Response> createOrUpdateWithServ * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. * @param parameters Parameters supplied to the create/update NetworkInterface operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkInterfaceInner object if successful. */ - public NetworkInterfaceInner beginCreateOrUpdate(String resourceGroupName, String networkInterfaceName, NetworkInterfaceInner parameters) throws CloudException, IOException, IllegalArgumentException { + public NetworkInterfaceInner beginCreateOrUpdate(String resourceGroupName, String networkInterfaceName, NetworkInterfaceInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkInterfaceName, parameters).toBlocking().single().getBody(); } @@ -623,16 +602,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Respo * @param resourceGroupName The name of the resource group. * @param virtualMachineScaleSetName The name of the virtual machine scale set. * @param virtualmachineIndex The virtual machine index. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listVirtualMachineScaleSetVMNetworkInterfaces(final String resourceGroupName, final String virtualMachineScaleSetName, final String virtualmachineIndex) throws CloudException, IOException, IllegalArgumentException { + public PagedList listVirtualMachineScaleSetVMNetworkInterfaces(final String resourceGroupName, final String virtualMachineScaleSetName, final String virtualmachineIndex) { ServiceResponse> response = listVirtualMachineScaleSetVMNetworkInterfacesSinglePageAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listVirtualMachineScaleSetVMNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -749,16 +725,13 @@ private ServiceResponse> listVirtualMachineScale * * @param resourceGroupName The name of the resource group. * @param virtualMachineScaleSetName The name of the virtual machine scale set. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listVirtualMachineScaleSetNetworkInterfaces(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listVirtualMachineScaleSetNetworkInterfaces(final String resourceGroupName, final String virtualMachineScaleSetName) { ServiceResponse> response = listVirtualMachineScaleSetNetworkInterfacesSinglePageAsync(resourceGroupName, virtualMachineScaleSetName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listVirtualMachineScaleSetNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -870,12 +843,9 @@ private ServiceResponse> listVirtualMachineScale * @param virtualMachineScaleSetName The name of the virtual machine scale set. * @param virtualmachineIndex The virtual machine index. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkInterfaceInner object if successful. */ - public NetworkInterfaceInner getVirtualMachineScaleSetNetworkInterface(String resourceGroupName, String virtualMachineScaleSetName, String virtualmachineIndex, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException { + public NetworkInterfaceInner getVirtualMachineScaleSetNetworkInterface(String resourceGroupName, String virtualMachineScaleSetName, String virtualmachineIndex, String networkInterfaceName) { return getVirtualMachineScaleSetNetworkInterfaceWithServiceResponseAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName).toBlocking().single().getBody(); } @@ -962,12 +932,9 @@ public Observable> call(Response getVirtualMachineScaleSetNetworkI /** * The List networkInterfaces operation retrieves all the networkInterfaces in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1162,16 +1126,13 @@ private ServiceResponse> listAllDelegate(Respons * The List networkInterfaces operation retrieves all the networkInterfaces in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1274,13 +1235,9 @@ private ServiceResponse> listDelegate(Response> getEffectiveRo * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the EffectiveRouteListResultInner object if successful. */ - public EffectiveRouteListResultInner beginGetEffectiveRouteTable(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException { + public EffectiveRouteListResultInner beginGetEffectiveRouteTable(String resourceGroupName, String networkInterfaceName) { return beginGetEffectiveRouteTableWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().getBody(); } @@ -1425,13 +1379,9 @@ private ServiceResponse beginGetEffectiveRouteTab * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the EffectiveNetworkSecurityGroupListResultInner object if successful. */ - public EffectiveNetworkSecurityGroupListResultInner listEffectiveNetworkSecurityGroups(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public EffectiveNetworkSecurityGroupListResultInner listEffectiveNetworkSecurityGroups(String resourceGroupName, String networkInterfaceName) { return listEffectiveNetworkSecurityGroupsWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().last().getBody(); } @@ -1492,12 +1442,9 @@ public Observable> * * @param resourceGroupName The name of the resource group. * @param networkInterfaceName The name of the network interface. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the EffectiveNetworkSecurityGroupListResultInner object if successful. */ - public EffectiveNetworkSecurityGroupListResultInner beginListEffectiveNetworkSecurityGroups(String resourceGroupName, String networkInterfaceName) throws CloudException, IOException, IllegalArgumentException { + public EffectiveNetworkSecurityGroupListResultInner beginListEffectiveNetworkSecurityGroups(String resourceGroupName, String networkInterfaceName) { return beginListEffectiveNetworkSecurityGroupsWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().getBody(); } @@ -1575,16 +1522,13 @@ private ServiceResponse beginListE * The list network interface operation retrieves information about all network interfaces in a virtual machine from a virtual machine scale set. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listVirtualMachineScaleSetVMNetworkInterfacesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listVirtualMachineScaleSetVMNetworkInterfacesNext(final String nextPageLink) { ServiceResponse> response = listVirtualMachineScaleSetVMNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listVirtualMachineScaleSetVMNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1681,16 +1625,13 @@ private ServiceResponse> listVirtualMachineScale * The list network interface operation retrieves information about all network interfaces in a virtual machine scale set. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listVirtualMachineScaleSetNetworkInterfacesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listVirtualMachineScaleSetNetworkInterfacesNext(final String nextPageLink) { ServiceResponse> response = listVirtualMachineScaleSetNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listVirtualMachineScaleSetNetworkInterfacesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1787,16 +1728,13 @@ private ServiceResponse> listVirtualMachineScale * The List networkInterfaces operation retrieves all the networkInterfaces in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1893,16 +1831,13 @@ private ServiceResponse> listAllNextDelegate(Res * The List networkInterfaces operation retrieves all the networkInterfaces in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkInterfaceInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManagementClientImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManagementClientImpl.java index 62ca97b891b57..bf3f064bddb80 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManagementClientImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManagementClientImpl.java @@ -488,12 +488,9 @@ interface NetworkManagementClientService { * Checks whether a domain name in the cloudapp.net zone is available for use. * * @param location The location of the domain name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DnsNameAvailabilityResultInner object if successful. */ - public DnsNameAvailabilityResultInner checkDnsNameAvailability(String location) throws CloudException, IOException, IllegalArgumentException { + public DnsNameAvailabilityResultInner checkDnsNameAvailability(String location) { return checkDnsNameAvailabilityWithServiceResponseAsync(location).toBlocking().single().getBody(); } @@ -559,12 +556,9 @@ public Observable> call(Response * * @param location The location of the domain name * @param domainNameLabel The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DnsNameAvailabilityResultInner object if successful. */ - public DnsNameAvailabilityResultInner checkDnsNameAvailability(String location, String domainNameLabel) throws CloudException, IOException, IllegalArgumentException { + public DnsNameAvailabilityResultInner checkDnsNameAvailability(String location, String domainNameLabel) { return checkDnsNameAvailabilityWithServiceResponseAsync(location, domainNameLabel).toBlocking().single().getBody(); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsInner.java index 4280a092e30ac..403bdfe1ab715 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -105,12 +104,8 @@ interface NetworkSecurityGroupsService { * * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String networkSecurityGroupName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String networkSecurityGroupName) { deleteWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String networkSecurityGroupName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String networkSecurityGroupName) { beginDeleteWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName).toBlocking().single().getBody(); } @@ -254,12 +246,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkSecurityGroupInner object if successful. */ - public NetworkSecurityGroupInner get(String resourceGroupName, String networkSecurityGroupName) throws CloudException, IOException, IllegalArgumentException { + public NetworkSecurityGroupInner get(String resourceGroupName, String networkSecurityGroupName) { return getWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName).toBlocking().single().getBody(); } @@ -332,12 +321,9 @@ public Observable> call(Response getDelegate(Response> createOrUpdateWith * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. * @param parameters Parameters supplied to the create/update Network Security Group operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkSecurityGroupInner object if successful. */ - public NetworkSecurityGroupInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, NetworkSecurityGroupInner parameters) throws CloudException, IOException, IllegalArgumentException { + public NetworkSecurityGroupInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, NetworkSecurityGroupInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, parameters).toBlocking().single().getBody(); } @@ -583,16 +562,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(R /** * The list NetworkSecurityGroups returns all network security groups in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkSecurityGroupInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -687,16 +663,13 @@ private ServiceResponse> listAllDelegate(Res * The list NetworkSecurityGroups returns all network security groups in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkSecurityGroupInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -798,16 +771,13 @@ private ServiceResponse> listDelegate(Respon * The list NetworkSecurityGroups returns all network security groups in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkSecurityGroupInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -904,16 +874,13 @@ private ServiceResponse> listAllNextDelegate * The list NetworkSecurityGroups returns all network security groups in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NetworkSecurityGroupInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIPAddressesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIPAddressesInner.java index 62be22e6e6de9..9a0a7f915d461 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIPAddressesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIPAddressesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -105,12 +104,8 @@ interface PublicIPAddressesService { * * @param resourceGroupName The name of the resource group. * @param publicIpAddressName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String publicIpAddressName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String publicIpAddressName) { deleteWithServiceResponseAsync(resourceGroupName, publicIpAddressName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param publicIpAddressName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String publicIpAddressName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String publicIpAddressName) { beginDeleteWithServiceResponseAsync(resourceGroupName, publicIpAddressName).toBlocking().single().getBody(); } @@ -254,12 +246,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param publicIpAddressName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PublicIPAddressInner object if successful. */ - public PublicIPAddressInner get(String resourceGroupName, String publicIpAddressName) throws CloudException, IOException, IllegalArgumentException { + public PublicIPAddressInner get(String resourceGroupName, String publicIpAddressName) { return getWithServiceResponseAsync(resourceGroupName, publicIpAddressName).toBlocking().single().getBody(); } @@ -332,12 +321,9 @@ public Observable> call(Response getDelegate(Response * @param resourceGroupName The name of the resource group. * @param publicIpAddressName The name of the publicIpAddress. * @param parameters Parameters supplied to the create/update PublicIPAddress operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the PublicIPAddressInner object if successful. */ - public PublicIPAddressInner createOrUpdate(String resourceGroupName, String publicIpAddressName, PublicIPAddressInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public PublicIPAddressInner createOrUpdate(String resourceGroupName, String publicIpAddressName, PublicIPAddressInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, publicIpAddressName, parameters).toBlocking().last().getBody(); } @@ -494,12 +476,9 @@ public Observable> createOrUpdateWithServi * @param resourceGroupName The name of the resource group. * @param publicIpAddressName The name of the publicIpAddress. * @param parameters Parameters supplied to the create/update PublicIPAddress operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PublicIPAddressInner object if successful. */ - public PublicIPAddressInner beginCreateOrUpdate(String resourceGroupName, String publicIpAddressName, PublicIPAddressInner parameters) throws CloudException, IOException, IllegalArgumentException { + public PublicIPAddressInner beginCreateOrUpdate(String resourceGroupName, String publicIpAddressName, PublicIPAddressInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, publicIpAddressName, parameters).toBlocking().single().getBody(); } @@ -583,16 +562,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Respon /** * The List publicIpAddress operation retrieves all the publicIpAddresses in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<PublicIPAddressInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -687,16 +663,13 @@ private ServiceResponse> listAllDelegate(Response * The List publicIpAddress operation retrieves all the publicIpAddresses in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<PublicIPAddressInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -798,16 +771,13 @@ private ServiceResponse> listDelegate(Response listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -904,16 +874,13 @@ private ServiceResponse> listAllNextDelegate(Resp * The List publicIpAddress operation retrieves all the publicIpAddresses in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<PublicIPAddressInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RouteTablesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RouteTablesInner.java index 42ea56a7090a6..16e2dca8733bc 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RouteTablesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RouteTablesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -105,12 +104,8 @@ interface RouteTablesService { * * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String routeTableName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String routeTableName) { deleteWithServiceResponseAsync(resourceGroupName, routeTableName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String routeTableName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String routeTableName) { beginDeleteWithServiceResponseAsync(resourceGroupName, routeTableName).toBlocking().single().getBody(); } @@ -254,12 +246,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RouteTableInner object if successful. */ - public RouteTableInner get(String resourceGroupName, String routeTableName) throws CloudException, IOException, IllegalArgumentException { + public RouteTableInner get(String resourceGroupName, String routeTableName) { return getWithServiceResponseAsync(resourceGroupName, routeTableName).toBlocking().single().getBody(); } @@ -332,12 +321,9 @@ public Observable> call(Response * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param expand expand references resources. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RouteTableInner object if successful. */ - public RouteTableInner get(String resourceGroupName, String routeTableName, String expand) throws CloudException, IOException, IllegalArgumentException { + public RouteTableInner get(String resourceGroupName, String routeTableName, String expand) { return getWithServiceResponseAsync(resourceGroupName, routeTableName, expand).toBlocking().single().getBody(); } @@ -419,13 +405,9 @@ private ServiceResponse getDelegate(Response resp * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param parameters Parameters supplied to the create/update Route Table operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the RouteTableInner object if successful. */ - public RouteTableInner createOrUpdate(String resourceGroupName, String routeTableName, RouteTableInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public RouteTableInner createOrUpdate(String resourceGroupName, String routeTableName, RouteTableInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, routeTableName, parameters).toBlocking().last().getBody(); } @@ -494,12 +476,9 @@ public Observable> createOrUpdateWithServiceRes * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param parameters Parameters supplied to the create/update Route Table operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RouteTableInner object if successful. */ - public RouteTableInner beginCreateOrUpdate(String resourceGroupName, String routeTableName, RouteTableInner parameters) throws CloudException, IOException, IllegalArgumentException { + public RouteTableInner beginCreateOrUpdate(String resourceGroupName, String routeTableName, RouteTableInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, routeTableName, parameters).toBlocking().single().getBody(); } @@ -584,16 +563,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Response list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -694,16 +670,13 @@ private ServiceResponse> listDelegate(Response listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -798,16 +771,13 @@ private ServiceResponse> listAllDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -904,16 +874,13 @@ private ServiceResponse> listNextDelegate(Response listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RoutesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RoutesInner.java index b01e15aa293d4..e0c87908f24e9 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RoutesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/RoutesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface RoutesService { * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param routeName The name of the route. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String routeTableName, String routeName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String routeTableName, String routeName) { deleteWithServiceResponseAsync(resourceGroupName, routeTableName, routeName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param routeName The name of the route. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String routeTableName, String routeName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String routeTableName, String routeName) { beginDeleteWithServiceResponseAsync(resourceGroupName, routeTableName, routeName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param routeTableName The name of the route table. * @param routeName The name of the route. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RouteInner object if successful. */ - public RouteInner get(String resourceGroupName, String routeTableName, String routeName) throws CloudException, IOException, IllegalArgumentException { + public RouteInner get(String resourceGroupName, String routeTableName, String routeName) { return getWithServiceResponseAsync(resourceGroupName, routeTableName, routeName).toBlocking().single().getBody(); } @@ -352,13 +341,9 @@ private ServiceResponse getDelegate(Response response) * @param routeTableName The name of the route table. * @param routeName The name of the route. * @param routeParameters Parameters supplied to the create/update route operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the RouteInner object if successful. */ - public RouteInner createOrUpdate(String resourceGroupName, String routeTableName, String routeName, RouteInner routeParameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public RouteInner createOrUpdate(String resourceGroupName, String routeTableName, String routeName, RouteInner routeParameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, routeTableName, routeName, routeParameters).toBlocking().last().getBody(); } @@ -434,12 +419,9 @@ public Observable> createOrUpdateWithServiceResponse * @param routeTableName The name of the route table. * @param routeName The name of the route. * @param routeParameters Parameters supplied to the create/update route operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RouteInner object if successful. */ - public RouteInner beginCreateOrUpdate(String resourceGroupName, String routeTableName, String routeName, RouteInner routeParameters) throws CloudException, IOException, IllegalArgumentException { + public RouteInner beginCreateOrUpdate(String resourceGroupName, String routeTableName, String routeName, RouteInner routeParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, routeTableName, routeName, routeParameters).toBlocking().single().getBody(); } @@ -531,16 +513,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Response list(final String resourceGroupName, final String routeTableName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String routeTableName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, routeTableName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -649,16 +628,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SecurityRulesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SecurityRulesInner.java index df8a4050396ab..40312ea096e73 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SecurityRulesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SecurityRulesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface SecurityRulesService { * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. * @param securityRuleName The name of the security rule. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) { deleteWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. * @param securityRuleName The name of the security rule. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) { beginDeleteWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. * @param securityRuleName The name of the security rule. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecurityRuleInner object if successful. */ - public SecurityRuleInner get(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) throws CloudException, IOException, IllegalArgumentException { + public SecurityRuleInner get(String resourceGroupName, String networkSecurityGroupName, String securityRuleName) { return getWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName).toBlocking().single().getBody(); } @@ -352,13 +341,9 @@ private ServiceResponse getDelegate(Response re * @param networkSecurityGroupName The name of the network security group. * @param securityRuleName The name of the security rule. * @param securityRuleParameters Parameters supplied to the create/update network security rule operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SecurityRuleInner object if successful. */ - public SecurityRuleInner createOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SecurityRuleInner createOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).toBlocking().last().getBody(); } @@ -434,12 +419,9 @@ public Observable> createOrUpdateWithServiceR * @param networkSecurityGroupName The name of the network security group. * @param securityRuleName The name of the security rule. * @param securityRuleParameters Parameters supplied to the create/update network security rule operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecurityRuleInner object if successful. */ - public SecurityRuleInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) throws CloudException, IOException, IllegalArgumentException { + public SecurityRuleInner beginCreateOrUpdate(String resourceGroupName, String networkSecurityGroupName, String securityRuleName, SecurityRuleInner securityRuleParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters).toBlocking().single().getBody(); } @@ -531,16 +513,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Response< * * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SecurityRuleInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String networkSecurityGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String networkSecurityGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, networkSecurityGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -649,16 +628,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetInner.java index fa90a39596b4b..0a7b87da64181 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetInner.java @@ -8,10 +8,11 @@ package com.microsoft.azure.management.network.implementation; -import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; import com.microsoft.azure.SubResource; +import com.microsoft.rest.serializer.JsonFlatten; + +import java.util.List; /** * Subnet in a VirtualNework resource. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetsInner.java index 9201f3b6bb85a..6a42a897d3f4b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface SubnetsService { * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String virtualNetworkName, String subnetName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String virtualNetworkName, String subnetName) { deleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String virtualNetworkName, String subnetName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String virtualNetworkName, String subnetName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SubnetInner object if successful. */ - public SubnetInner get(String resourceGroupName, String virtualNetworkName, String subnetName) throws CloudException, IOException, IllegalArgumentException { + public SubnetInner get(String resourceGroupName, String virtualNetworkName, String subnetName) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName).toBlocking().single().getBody(); } @@ -346,12 +335,9 @@ public Observable> call(Response resp * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. * @param expand expand references resources. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SubnetInner object if successful. */ - public SubnetInner get(String resourceGroupName, String virtualNetworkName, String subnetName, String expand) throws CloudException, IOException, IllegalArgumentException { + public SubnetInner get(String resourceGroupName, String virtualNetworkName, String subnetName, String expand) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName, expand).toBlocking().single().getBody(); } @@ -440,13 +426,9 @@ private ServiceResponse getDelegate(Response response * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. * @param subnetParameters Parameters supplied to the create/update Subnet operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SubnetInner object if successful. */ - public SubnetInner createOrUpdate(String resourceGroupName, String virtualNetworkName, String subnetName, SubnetInner subnetParameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SubnetInner createOrUpdate(String resourceGroupName, String virtualNetworkName, String subnetName, SubnetInner subnetParameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters).toBlocking().last().getBody(); } @@ -522,12 +504,9 @@ public Observable> createOrUpdateWithServiceRespons * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. * @param subnetParameters Parameters supplied to the create/update Subnet operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SubnetInner object if successful. */ - public SubnetInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String subnetName, SubnetInner subnetParameters) throws CloudException, IOException, IllegalArgumentException { + public SubnetInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String subnetName, SubnetInner subnetParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters).toBlocking().single().getBody(); } @@ -619,16 +598,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Response list(final String resourceGroupName, final String virtualNetworkName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String virtualNetworkName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, virtualNetworkName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -737,16 +713,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/UsagesInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/UsagesInner.java index 47531e7fc6db0..66bbf13f953da 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/UsagesInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/UsagesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; import java.io.IOException; @@ -71,16 +70,13 @@ interface UsagesService { * Lists compute usages for a subscription. * * @param location The location upon which resource usage is queried. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList list(final String location) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String location) { ServiceResponse> response = listSinglePageAsync(location).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -182,16 +178,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewayConnectionsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewayConnectionsInner.java index 939777b93fc62..b40ee946f6c78 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewayConnectionsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewayConnectionsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -119,13 +118,9 @@ interface VirtualNetworkGatewayConnectionsService { * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection. * @param parameters Parameters supplied to the Begin Create or update Virtual Network Gateway connection operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualNetworkGatewayConnectionInner object if successful. */ - public VirtualNetworkGatewayConnectionInner createOrUpdate(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualNetworkGatewayConnectionInner createOrUpdate(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).toBlocking().last().getBody(); } @@ -194,12 +189,9 @@ public Observable> createO * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection. * @param parameters Parameters supplied to the Begin Create or update Virtual Network Gateway connection operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkGatewayConnectionInner object if successful. */ - public VirtualNetworkGatewayConnectionInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkGatewayConnectionInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).toBlocking().single().getBody(); } @@ -285,12 +277,9 @@ private ServiceResponse beginCreateOrUpdat * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkGatewayConnectionInner object if successful. */ - public VirtualNetworkGatewayConnectionInner get(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkGatewayConnectionInner get(String resourceGroupName, String virtualNetworkGatewayConnectionName) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().getBody(); } @@ -368,12 +357,8 @@ private ServiceResponse getDelegate(Respon * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String virtualNetworkGatewayConnectionName) { deleteWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().last().getBody(); } @@ -434,11 +419,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String virtualNetworkGatewayConnectionName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().getBody(); } @@ -517,12 +499,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param connectionSharedKeyName The virtual network gateway connection shared key name. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionSharedKeyResultInner object if successful. */ - public ConnectionSharedKeyResultInner getSharedKey(String resourceGroupName, String connectionSharedKeyName) throws CloudException, IOException, IllegalArgumentException { + public ConnectionSharedKeyResultInner getSharedKey(String resourceGroupName, String connectionSharedKeyName) { return getSharedKeyWithServiceResponseAsync(resourceGroupName, connectionSharedKeyName).toBlocking().single().getBody(); } @@ -599,16 +578,13 @@ private ServiceResponse getSharedKeyDelegate(Res * The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkGatewayConnectionInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -711,13 +687,9 @@ private ServiceResponse> listDele * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection reset shared key Name. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ConnectionResetSharedKeyInner object if successful. */ - public ConnectionResetSharedKeyInner resetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ConnectionResetSharedKeyInner resetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) { return resetSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().last().getBody(); } @@ -781,13 +753,9 @@ public Observable> resetSharedKey * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection reset shared key Name. * @param keyLength The virtual network connection reset shared key length - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ConnectionResetSharedKeyInner object if successful. */ - public ConnectionResetSharedKeyInner resetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, Long keyLength) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ConnectionResetSharedKeyInner resetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, Long keyLength) { return resetSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, keyLength).toBlocking().last().getBody(); } @@ -853,12 +821,9 @@ public Observable> resetSharedKey * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection reset shared key Name. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionResetSharedKeyInner object if successful. */ - public ConnectionResetSharedKeyInner beginResetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException { + public ConnectionResetSharedKeyInner beginResetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) { return beginResetSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().getBody(); } @@ -933,12 +898,9 @@ public Observable> call(Response< * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection reset shared key Name. * @param keyLength The virtual network connection reset shared key length - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionResetSharedKeyInner object if successful. */ - public ConnectionResetSharedKeyInner beginResetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, Long keyLength) throws CloudException, IOException, IllegalArgumentException { + public ConnectionResetSharedKeyInner beginResetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, Long keyLength) { return beginResetSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, keyLength).toBlocking().single().getBody(); } @@ -1022,13 +984,9 @@ private ServiceResponse beginResetSharedKeyDelega * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection name. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ConnectionSharedKeyInner object if successful. */ - public ConnectionSharedKeyInner setSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ConnectionSharedKeyInner setSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) { return setSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().last().getBody(); } @@ -1092,13 +1050,9 @@ public Observable> setSharedKeyWithSer * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection name. * @param value The virtual network connection shared key value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ConnectionSharedKeyInner object if successful. */ - public ConnectionSharedKeyInner setSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, String value) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ConnectionSharedKeyInner setSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, String value) { return setSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, value).toBlocking().last().getBody(); } @@ -1164,12 +1118,9 @@ public Observable> setSharedKeyWithSer * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayConnectionName The virtual network gateway connection name. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionSharedKeyInner object if successful. */ - public ConnectionSharedKeyInner beginSetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) throws CloudException, IOException, IllegalArgumentException { + public ConnectionSharedKeyInner beginSetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) { return beginSetSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().getBody(); } @@ -1244,12 +1195,9 @@ public Observable> call(Response beginSetSharedKeyDelegate(Resp * The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkGatewayConnectionInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewaysInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewaysInner.java index eefb70202de6f..d082e3ddeacb3 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewaysInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkGatewaysInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.network.VpnClientParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -113,13 +112,9 @@ interface VirtualNetworkGatewaysService { * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. * @param parameters Parameters supplied to the Begin Create or update Virtual Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualNetworkGatewayInner object if successful. */ - public VirtualNetworkGatewayInner createOrUpdate(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualNetworkGatewayInner createOrUpdate(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().last().getBody(); } @@ -188,12 +183,9 @@ public Observable> createOrUpdateWit * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. * @param parameters Parameters supplied to the Begin Create or update Virtual Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkGatewayInner object if successful. */ - public VirtualNetworkGatewayInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkGatewayInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().single().getBody(); } @@ -279,12 +271,9 @@ private ServiceResponse beginCreateOrUpdateDelegate( * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkGatewayInner object if successful. */ - public VirtualNetworkGatewayInner get(String resourceGroupName, String virtualNetworkGatewayName) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkGatewayInner get(String resourceGroupName, String virtualNetworkGatewayName) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().single().getBody(); } @@ -362,12 +351,8 @@ private ServiceResponse getDelegate(Response> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String virtualNetworkGatewayName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String virtualNetworkGatewayName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().single().getBody(); } @@ -510,16 +492,13 @@ private ServiceResponse beginDeleteDelegate(Response respons * The List VirtualNetworkGateways operation retrieves all the virtual network gateways stored. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkGatewayInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -623,13 +602,9 @@ private ServiceResponse> listDelegate(Respo * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. * @param parameters Parameters supplied to the Begin Reset Virtual Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualNetworkGatewayInner object if successful. */ - public VirtualNetworkGatewayInner reset(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualNetworkGatewayInner reset(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) { return resetWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().last().getBody(); } @@ -698,12 +673,9 @@ public Observable> resetWithServiceR * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. * @param parameters Parameters supplied to the Begin Reset Virtual Network Gateway operation through Network resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkGatewayInner object if successful. */ - public VirtualNetworkGatewayInner beginReset(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkGatewayInner beginReset(String resourceGroupName, String virtualNetworkGatewayName, VirtualNetworkGatewayInner parameters) { return beginResetWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().single().getBody(); } @@ -789,12 +761,9 @@ private ServiceResponse beginResetDelegate(Response< * * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the String object if successful. */ - public String generatevpnclientpackage(String resourceGroupName, String virtualNetworkGatewayName) throws CloudException, IOException, IllegalArgumentException { + public String generatevpnclientpackage(String resourceGroupName, String virtualNetworkGatewayName) { return generatevpnclientpackageWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().single().getBody(); } @@ -869,12 +838,9 @@ public Observable> call(Response response) * @param resourceGroupName The name of the resource group. * @param virtualNetworkGatewayName The name of the virtual network gateway. * @param processorArchitecture VPN client Processor Architecture -Amd64/X86. Possible values include: 'Amd64', 'X86' - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the String object if successful. */ - public String generatevpnclientpackage(String resourceGroupName, String virtualNetworkGatewayName, ProcessorArchitecture processorArchitecture) throws CloudException, IOException, IllegalArgumentException { + public String generatevpnclientpackage(String resourceGroupName, String virtualNetworkGatewayName, ProcessorArchitecture processorArchitecture) { return generatevpnclientpackageWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, processorArchitecture).toBlocking().single().getBody(); } @@ -956,16 +922,13 @@ private ServiceResponse generatevpnclientpackageDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkPeeringsInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkPeeringsInner.java index fc5f01c86e0a6..b68559fb5041d 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkPeeringsInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworkPeeringsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -98,12 +97,8 @@ interface VirtualNetworkPeeringsService { * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param virtualNetworkPeeringName The name of the virtual network peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) { deleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).toBlocking().last().getBody(); } @@ -171,11 +166,8 @@ public Observable> deleteWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param virtualNetworkPeeringName The name of the virtual network peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).toBlocking().single().getBody(); } @@ -261,12 +253,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param virtualNetworkPeeringName The name of the virtual network peering. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkPeeringInner object if successful. */ - public VirtualNetworkPeeringInner get(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkPeeringInner get(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName).toBlocking().single().getBody(); } @@ -352,13 +341,9 @@ private ServiceResponse getDelegate(Response> createOrUpdateWit * @param virtualNetworkName The name of the virtual network. * @param virtualNetworkPeeringName The name of the peering. * @param virtualNetworkPeeringParameters Parameters supplied to the create/update virtual network peering operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkPeeringInner object if successful. */ - public VirtualNetworkPeeringInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName, VirtualNetworkPeeringInner virtualNetworkPeeringParameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkPeeringInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName, VirtualNetworkPeeringInner virtualNetworkPeeringParameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters).toBlocking().single().getBody(); } @@ -531,16 +513,13 @@ private ServiceResponse beginCreateOrUpdateDelegate( * * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkPeeringInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String virtualNetworkName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String virtualNetworkName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, virtualNetworkName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -649,16 +628,13 @@ private ServiceResponse> listDelegate(Respo * The List virtual network peerings operation retrieves all the peerings in a virtual network. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkPeeringInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworksInner.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworksInner.java index 3c61a7a708130..2d037a0ae6e4e 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworksInner.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/VirtualNetworksInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -109,12 +108,8 @@ interface VirtualNetworksService { * * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String virtualNetworkName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String virtualNetworkName) { deleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName).toBlocking().last().getBody(); } @@ -175,11 +170,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String virtualNetworkName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String virtualNetworkName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualNetworkName).toBlocking().single().getBody(); } @@ -258,12 +250,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkInner object if successful. */ - public VirtualNetworkInner get(String resourceGroupName, String virtualNetworkName) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkInner get(String resourceGroupName, String virtualNetworkName) { return getWithServiceResponseAsync(resourceGroupName, virtualNetworkName).toBlocking().single().getBody(); } @@ -336,12 +325,9 @@ public Observable> call(Response getDelegate(Response * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param parameters Parameters supplied to the create/update Virtual Network operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the VirtualNetworkInner object if successful. */ - public VirtualNetworkInner createOrUpdate(String resourceGroupName, String virtualNetworkName, VirtualNetworkInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public VirtualNetworkInner createOrUpdate(String resourceGroupName, String virtualNetworkName, VirtualNetworkInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, parameters).toBlocking().last().getBody(); } @@ -498,12 +480,9 @@ public Observable> createOrUpdateWithServic * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param parameters Parameters supplied to the create/update Virtual Network operation - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VirtualNetworkInner object if successful. */ - public VirtualNetworkInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, VirtualNetworkInner parameters) throws CloudException, IOException, IllegalArgumentException { + public VirtualNetworkInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, VirtualNetworkInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, parameters).toBlocking().single().getBody(); } @@ -587,16 +566,13 @@ private ServiceResponse beginCreateOrUpdateDelegate(Respons /** * The list VirtualNetwork returns all Virtual Networks in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -691,16 +667,13 @@ private ServiceResponse> listAllDelegate(Response< * The list VirtualNetwork returns all Virtual Networks in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -803,12 +776,9 @@ private ServiceResponse> listDelegate(Response> call(Respon * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param ipAddress The private IP address to be verified. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IPAddressAvailabilityResultInner object if successful. */ - public IPAddressAvailabilityResultInner checkIPAddressAvailability(String resourceGroupName, String virtualNetworkName, String ipAddress) throws CloudException, IOException, IllegalArgumentException { + public IPAddressAvailabilityResultInner checkIPAddressAvailability(String resourceGroupName, String virtualNetworkName, String ipAddress) { return checkIPAddressAvailabilityWithServiceResponseAsync(resourceGroupName, virtualNetworkName, ipAddress).toBlocking().single().getBody(); } @@ -966,16 +933,13 @@ private ServiceResponse checkIPAddressAvailabi * The list VirtualNetwork returns all Virtual Networks in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkInner> object if successful. */ - public PagedList listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1072,16 +1036,13 @@ private ServiceResponse> listAllNextDelegate(Respo * The list VirtualNetwork returns all Virtual Networks in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<VirtualNetworkInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/SkuFamily.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/SkuFamily.java index 0c37984ddee56..4027ed51be408 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/SkuFamily.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/SkuFamily.java @@ -56,4 +56,4 @@ public boolean equals(Object obj) { return value.equals(rhs.value); } } -} \ No newline at end of file +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java index 8f30dc7df61bd..a9c2ee749926c 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java @@ -78,12 +78,9 @@ interface PatchSchedulesService { * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param scheduleEntries List of patch schedules for redis cache. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RedisPatchSchedulesResponseInner object if successful. */ - public RedisPatchSchedulesResponseInner createOrUpdate(String resourceGroupName, String name, List scheduleEntries) throws CloudException, IOException, IllegalArgumentException { + public RedisPatchSchedulesResponseInner createOrUpdate(String resourceGroupName, String name, List scheduleEntries) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, scheduleEntries).toBlocking().single().getBody(); } @@ -170,11 +167,8 @@ private ServiceResponse createOrUpdateDelegate * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public void delete(String resourceGroupName, String name) { deleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -251,12 +245,9 @@ private ServiceResponse deleteDelegate(Response response) th * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RedisPatchSchedulesResponseInner object if successful. */ - public RedisPatchSchedulesResponseInner get(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public RedisPatchSchedulesResponseInner get(String resourceGroupName, String name) { return getWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java index 2582e709acfc8..e55d69c5f485b 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java @@ -18,7 +18,6 @@ import com.microsoft.azure.management.redis.RedisRegenerateKeyParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -129,12 +128,9 @@ interface RedisService { * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Parameters supplied to the CreateOrUpdate redis operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RedisResourceWithAccessKeyInner object if successful. */ - public RedisResourceWithAccessKeyInner createOrUpdate(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public RedisResourceWithAccessKeyInner createOrUpdate(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -220,11 +216,8 @@ private ServiceResponse createOrUpdateDelegate( * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public void delete(String resourceGroupName, String name) { deleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -302,12 +295,9 @@ private ServiceResponse deleteDelegate(Response response) th * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RedisResourceInner object if successful. */ - public RedisResourceInner get(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public RedisResourceInner get(String resourceGroupName, String name) { return getWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -384,16 +374,13 @@ private ServiceResponse getDelegate(Response r * Gets all redis caches in a resource group. * * @param resourceGroupName The name of the resource group. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<RedisResourceInner> object if successful. */ - public PagedList listByResourceGroup(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroup(final String resourceGroupName) { ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -494,16 +481,13 @@ private ServiceResponse> listByResourceGroupDelegat /** * Gets all redis caches in the specified subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<RedisResourceInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -599,12 +583,9 @@ private ServiceResponse> listDelegate(Response listKeysDelegate(Response regenerateKeyDelegate(Response * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Specifies which redis node(s) to reboot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void forceReboot(String resourceGroupName, String name, RedisRebootParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public void forceReboot(String resourceGroupName, String name, RedisRebootParametersInner parameters) { forceRebootWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -865,12 +840,8 @@ private ServiceResponse forceRebootDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Parameters for redis import operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void importMethod(String resourceGroupName, String name, ImportRDBParametersInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void importMethod(String resourceGroupName, String name, ImportRDBParametersInner parameters) { importMethodWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } @@ -939,11 +910,8 @@ public Observable> importMethodWithServiceResponseAsync(St * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Parameters for redis import operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginImport(String resourceGroupName, String name, ImportRDBParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public void beginImport(String resourceGroupName, String name, ImportRDBParametersInner parameters) { beginImportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -1028,12 +996,8 @@ private ServiceResponse beginImportDelegate(Response respons * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Parameters for redis export operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void export(String resourceGroupName, String name, ExportRDBParametersInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void export(String resourceGroupName, String name, ExportRDBParametersInner parameters) { exportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } @@ -1102,11 +1066,8 @@ public Observable> exportWithServiceResponseAsync(String r * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param parameters Parameters for redis export operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginExport(String resourceGroupName, String name, ExportRDBParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public void beginExport(String resourceGroupName, String name, ExportRDBParametersInner parameters) { beginExportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } @@ -1189,16 +1150,13 @@ private ServiceResponse beginExportDelegate(Response respons * Gets all redis caches in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<RedisResourceInner> object if successful. */ - public PagedList listByResourceGroupNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listByResourceGroupNext(final String nextPageLink) { ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1295,16 +1253,13 @@ private ServiceResponse> listByResourceGroupNextDel * Gets all redis caches in the specified subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<RedisResourceInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsInner.java index e19d40052394b..7db21a2484cd6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -78,12 +77,9 @@ interface DeploymentOperationsService { * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. * @param operationId Operation Id. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentOperationInner object if successful. */ - public DeploymentOperationInner get(String resourceGroupName, String deploymentName, String operationId) throws CloudException, IOException, IllegalArgumentException { + public DeploymentOperationInner get(String resourceGroupName, String deploymentName, String operationId) { return getWithServiceResponseAsync(resourceGroupName, deploymentName, operationId).toBlocking().single().getBody(); } @@ -167,16 +163,13 @@ private ServiceResponse getDelegate(Response list(final String resourceGroupName, final String deploymentName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String deploymentName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, deploymentName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -281,16 +274,13 @@ public Observable>> call(Response * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. * @param top Query parameters. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentOperationInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String deploymentName, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String deploymentName, final Integer top) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, deploymentName, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -403,16 +393,13 @@ private ServiceResponse> listDelegate(Respons * Gets a list of deployments operations. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentOperationInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java index e2e5578be9019..123f7ba6b5a68 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java @@ -8,7 +8,6 @@ package com.microsoft.azure.management.resources.implementation; -import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceResponseBuilder; @@ -16,27 +15,28 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; -import java.io.IOException; -import java.util.List; import okhttp3.ResponseBody; +import retrofit2.Response; +import retrofit2.Retrofit; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.HEAD; +import retrofit2.http.HTTP; import retrofit2.http.Header; import retrofit2.http.Headers; -import retrofit2.http.HTTP; -import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; +import retrofit2.http.Path; import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; import rx.Observable; +import rx.functions.Func1; + +import java.io.IOException; +import java.util.List; /** * An instance of this class provides access to all the operations defined @@ -115,12 +115,8 @@ interface DeploymentsService { * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment to be deleted. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void delete(String resourceGroupName, String deploymentName) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void delete(String resourceGroupName, String deploymentName) { deleteWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().last().getBody(); } @@ -181,11 +177,8 @@ public Observable> deleteWithServiceResponseAsync(String r * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment to be deleted. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName, String deploymentName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName, String deploymentName) { beginDeleteWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().getBody(); } @@ -263,12 +256,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. * @param deploymentName The name of the deployment. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the boolean object if successful. */ - public boolean checkExistence(String resourceGroupName, String deploymentName) throws CloudException, IOException, IllegalArgumentException { + public boolean checkExistence(String resourceGroupName, String deploymentName) { return checkExistenceWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().getBody(); } @@ -348,13 +338,9 @@ private ServiceResponse checkExistenceDelegate(Response response) * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. * @param parameters Additional parameters supplied to the operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the DeploymentExtendedInner object if successful. */ - public DeploymentExtendedInner createOrUpdate(String resourceGroupName, String deploymentName, DeploymentInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public DeploymentExtendedInner createOrUpdate(String resourceGroupName, String deploymentName, DeploymentInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, deploymentName, parameters).toBlocking().last().getBody(); } @@ -423,12 +409,9 @@ public Observable> createOrUpdateWithSe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. * @param parameters Additional parameters supplied to the operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentExtendedInner object if successful. */ - public DeploymentExtendedInner beginCreateOrUpdate(String resourceGroupName, String deploymentName, DeploymentInner parameters) throws CloudException, IOException, IllegalArgumentException { + public DeploymentExtendedInner beginCreateOrUpdate(String resourceGroupName, String deploymentName, DeploymentInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, deploymentName, parameters).toBlocking().single().getBody(); } @@ -514,12 +497,9 @@ private ServiceResponse beginCreateOrUpdateDelegate(Res * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. * @param deploymentName The name of the deployment. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentExtendedInner object if successful. */ - public DeploymentExtendedInner get(String resourceGroupName, String deploymentName) throws CloudException, IOException, IllegalArgumentException { + public DeploymentExtendedInner get(String resourceGroupName, String deploymentName) { return getWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().getBody(); } @@ -597,11 +577,8 @@ private ServiceResponse getDelegate(Response cancelDelegate(Response response) th * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. * @param parameters Deployment to validate. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentValidateResultInner object if successful. */ - public DeploymentValidateResultInner validate(String resourceGroupName, String deploymentName, DeploymentInner parameters) throws CloudException, IOException, IllegalArgumentException { + public DeploymentValidateResultInner validate(String resourceGroupName, String deploymentName, DeploymentInner parameters) { return validateWithServiceResponseAsync(resourceGroupName, deploymentName, parameters).toBlocking().single().getBody(); } @@ -770,12 +744,9 @@ private ServiceResponse validateDelegate(Response * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param deploymentName The name of the deployment. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentExportResultInner object if successful. */ - public DeploymentExportResultInner exportTemplate(String resourceGroupName, String deploymentName) throws CloudException, IOException, IllegalArgumentException { + public DeploymentExportResultInner exportTemplate(String resourceGroupName, String deploymentName) { return exportTemplateWithServiceResponseAsync(resourceGroupName, deploymentName).toBlocking().single().getBody(); } @@ -852,16 +823,13 @@ private ServiceResponse exportTemplateDelegate(Resp * Get a list of deployments. * * @param resourceGroupName The name of the resource group to filter by. The name is case insensitive. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentExtendedInner> object if successful. */ - public PagedList list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName) { ServiceResponse> response = listSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -960,16 +928,13 @@ public Observable>> call(Response< * @param resourceGroupName The name of the resource group to filter by. The name is case insensitive. * @param filter The filter to apply on the operation. * @param top Query parameters. If null is passed returns all deployments. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentExtendedInner> object if successful. */ - public PagedList list(final String resourceGroupName, final String filter, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceGroupName, final String filter, final Integer top) { ServiceResponse> response = listSinglePageAsync(resourceGroupName, filter, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1079,16 +1044,13 @@ private ServiceResponse> listDelegate(Response * Get a list of deployments. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentExtendedInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInner.java index 275cc84dad320..96ad58a008213 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -88,16 +87,13 @@ interface FeaturesService { /** * Gets a list of previewed features for all the providers in the current subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<FeatureResultInner> object if successful. */ - public PagedList listAll() throws CloudException, IOException, IllegalArgumentException { + public PagedList listAll() { ServiceResponse> response = listAllSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -192,16 +188,13 @@ private ServiceResponse> listAllDelegate(Response list(final String resourceProviderNamespace) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String resourceProviderNamespace) { ServiceResponse> response = listSinglePageAsync(resourceProviderNamespace).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -304,12 +297,9 @@ private ServiceResponse> listDelegate(Response getDelegate(Response r * * @param resourceProviderNamespace Namespace of the resource provider. * @param featureName Previewed feature name in the resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the FeatureResultInner object if successful. */ - public FeatureResultInner register(String resourceProviderNamespace, String featureName) throws CloudException, IOException, IllegalArgumentException { + public FeatureResultInner register(String resourceProviderNamespace, String featureName) { return registerWithServiceResponseAsync(resourceProviderNamespace, featureName).toBlocking().single().getBody(); } @@ -469,16 +456,13 @@ private ServiceResponse registerDelegate(Response listAllNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listAllNext(final String nextPageLink) { ServiceResponse> response = listAllNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listAllNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -575,16 +559,13 @@ private ServiceResponse> listAllNextDelegate(Respon * Gets a list of previewed features of a resource provider. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<FeatureResultInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersInner.java index 3d20ded7ca856..9e29aa6f8eed3 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -85,12 +84,9 @@ interface ProvidersService { * Unregisters provider from a subscription. * * @param resourceProviderNamespace Namespace of the resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ProviderInner object if successful. */ - public ProviderInner unregister(String resourceProviderNamespace) throws CloudException, IOException, IllegalArgumentException { + public ProviderInner unregister(String resourceProviderNamespace) { return unregisterWithServiceResponseAsync(resourceProviderNamespace).toBlocking().single().getBody(); } @@ -161,12 +157,9 @@ private ServiceResponse unregisterDelegate(Response * Registers provider to be used with a subscription. * * @param resourceProviderNamespace Namespace of the resource provider. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ProviderInner object if successful. */ - public ProviderInner register(String resourceProviderNamespace) throws CloudException, IOException, IllegalArgumentException { + public ProviderInner register(String resourceProviderNamespace) { return registerWithServiceResponseAsync(resourceProviderNamespace).toBlocking().single().getBody(); } @@ -236,16 +229,13 @@ private ServiceResponse registerDelegate(Response r /** * Gets a list of resource providers. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ProviderInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -336,16 +326,13 @@ public Observable>> call(Response list(final Integer top, final String expand) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final Integer top, final String expand) { ServiceResponse> response = listSinglePageAsync(top, expand).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -448,12 +435,9 @@ private ServiceResponse> listDelegate(Response> call(Response re * * @param resourceProviderNamespace Namespace of the resource provider. * @param expand The $expand query parameter. e.g. To include property aliases in response, use $expand=resourceTypes/aliases. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ProviderInner object if successful. */ - public ProviderInner get(String resourceProviderNamespace, String expand) throws CloudException, IOException, IllegalArgumentException { + public ProviderInner get(String resourceProviderNamespace, String expand) { return getWithServiceResponseAsync(resourceProviderNamespace, expand).toBlocking().single().getBody(); } @@ -598,16 +579,13 @@ private ServiceResponse getDelegate(Response respon * Gets a list of resource providers. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ProviderInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsInner.java index 62b80c03dbd40..5d9c6339bfeb4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -115,16 +114,13 @@ interface ResourceGroupsService { * Get all of the resources under a subscription. * * @param resourceGroupName Query parameters. If null is passed returns all resource groups. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<GenericResourceInner> object if successful. */ - public PagedList listResources(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList listResources(final String resourceGroupName) { ServiceResponse> response = listResourcesSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listResourcesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -225,16 +221,13 @@ public Observable>> call(Response listResources(final String resourceGroupName, final String filter, final String expand, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList listResources(final String resourceGroupName, final String filter, final String expand, final Integer top) { ServiceResponse> response = listResourcesSinglePageAsync(resourceGroupName, filter, expand, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listResourcesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -348,12 +341,9 @@ private ServiceResponse> listResourcesDelegate(Re * Checks whether resource group exists. * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the boolean object if successful. */ - public boolean checkExistence(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public boolean checkExistence(String resourceGroupName) { return checkExistenceWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -426,12 +416,9 @@ private ServiceResponse checkExistenceDelegate(Response response) * * @param resourceGroupName The name of the resource group to be created or updated. * @param parameters Parameters supplied to the create or update resource group service operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ResourceGroupInner object if successful. */ - public ResourceGroupInner createOrUpdate(String resourceGroupName, ResourceGroupInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ResourceGroupInner createOrUpdate(String resourceGroupName, ResourceGroupInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().getBody(); } @@ -510,12 +497,8 @@ private ServiceResponse createOrUpdateDelegate(Response> deleteWithServiceResponseAsync(String r * Delete resource group. * * @param resourceGroupName The name of the resource group to be deleted. The name is case insensitive. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginDelete(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public void beginDelete(String resourceGroupName) { beginDeleteWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -644,12 +624,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * Get a resource group. * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ResourceGroupInner object if successful. */ - public ResourceGroupInner get(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public ResourceGroupInner get(String resourceGroupName) { return getWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -721,12 +698,9 @@ private ServiceResponse getDelegate(Response r * * @param resourceGroupName The name of the resource group to be created or updated. The name is case insensitive. * @param parameters Parameters supplied to the update state resource group service operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ResourceGroupInner object if successful. */ - public ResourceGroupInner patch(String resourceGroupName, ResourceGroupInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ResourceGroupInner patch(String resourceGroupName, ResourceGroupInner parameters) { return patchWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().getBody(); } @@ -805,12 +779,9 @@ private ServiceResponse patchDelegate(Response * * @param resourceGroupName The name of the resource group to be created or updated. * @param parameters Parameters supplied to the export template resource group operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ResourceGroupExportResultInner object if successful. */ - public ResourceGroupExportResultInner exportTemplate(String resourceGroupName, ExportTemplateRequestInner parameters) throws CloudException, IOException, IllegalArgumentException { + public ResourceGroupExportResultInner exportTemplate(String resourceGroupName, ExportTemplateRequestInner parameters) { return exportTemplateWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().getBody(); } @@ -887,16 +858,13 @@ private ServiceResponse exportTemplateDelegate(R /** * Gets a collection of resource groups. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceGroupInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -987,16 +955,13 @@ public Observable>> call(Response list(final String filter, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String filter, final Integer top) { ServiceResponse> response = listSinglePageAsync(filter, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1099,16 +1064,13 @@ private ServiceResponse> listDelegate(Response listResourcesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listResourcesNext(final String nextPageLink) { ServiceResponse> response = listResourcesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listResourcesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1205,16 +1167,13 @@ private ServiceResponse> listResourcesNextDelegat * Gets a collection of resource groups. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceGroupInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java index 0934350db8831..bb2c32959fb31 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -103,12 +102,8 @@ interface ResourcesService { * * @param sourceResourceGroupName Source resource group name. * @param parameters move resources' parameters. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted */ - public void moveResources(String sourceResourceGroupName, ResourcesMoveInfoInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public void moveResources(String sourceResourceGroupName, ResourcesMoveInfoInner parameters) { moveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().last().getBody(); } @@ -170,11 +165,8 @@ public Observable> moveResourcesWithServiceResponseAsync(S * * @param sourceResourceGroupName Source resource group name. * @param parameters move resources' parameters. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void beginMoveResources(String sourceResourceGroupName, ResourcesMoveInfoInner parameters) throws CloudException, IOException, IllegalArgumentException { + public void beginMoveResources(String sourceResourceGroupName, ResourcesMoveInfoInner parameters) { beginMoveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().single().getBody(); } @@ -251,16 +243,13 @@ private ServiceResponse beginMoveResourcesDelegate(Response /** * Get all of the resources under a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<GenericResourceInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -353,16 +342,13 @@ public Observable>> call(Response list(final String filter, final String expand, final Integer top) throws CloudException, IOException, IllegalArgumentException { + public PagedList list(final String filter, final String expand, final Integer top) { ServiceResponse> response = listSinglePageAsync(filter, expand, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -474,12 +460,9 @@ private ServiceResponse> listDelegate(Response checkExistenceDelegate(Response response) * @param resourceType Resource identity. * @param resourceName Resource identity. * @param apiVersion the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws CloudException, IOException, IllegalArgumentException { + public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { deleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).toBlocking().single().getBody(); } @@ -692,12 +672,9 @@ private ServiceResponse deleteDelegate(Response response) th * @param resourceName Resource identity. * @param apiVersion the String value * @param parameters Create or update resource parameters. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the GenericResourceInner object if successful. */ - public GenericResourceInner createOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) throws CloudException, IOException, IllegalArgumentException { + public GenericResourceInner createOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().single().getBody(); } @@ -808,12 +785,9 @@ private ServiceResponse createOrUpdateDelegate(Response getDelegate(Response * Get all of the resources under a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<GenericResourceInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java index f345f8365800d..259fa24a190e7 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -80,12 +79,9 @@ interface SubscriptionsService { * Gets a list of the subscription locations. * * @param subscriptionId Id of the subscription - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<LocationInner> object if successful. */ - public List listLocations(String subscriptionId) throws CloudException, IOException, IllegalArgumentException { + public List listLocations(String subscriptionId) { return listLocationsWithServiceResponseAsync(subscriptionId).toBlocking().single().getBody(); } @@ -154,12 +150,9 @@ private ServiceResponse> listLocationsDelegate(Response< * Gets details about particular subscription. * * @param subscriptionId Id of the subscription. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SubscriptionInner object if successful. */ - public SubscriptionInner get(String subscriptionId) throws CloudException, IOException, IllegalArgumentException { + public SubscriptionInner get(String subscriptionId) { return getWithServiceResponseAsync(subscriptionId).toBlocking().single().getBody(); } @@ -226,16 +219,13 @@ private ServiceResponse getDelegate(Response re /** * Gets a list of the subscriptionIds. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SubscriptionInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -327,16 +317,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TagsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TagsInner.java index 4aac409cf588f..954125cd55c35 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TagsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TagsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -91,11 +90,8 @@ interface TagsService { * * @param tagName The name of the tag. * @param tagValue The value of the tag. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void deleteValue(String tagName, String tagValue) throws CloudException, IOException, IllegalArgumentException { + public void deleteValue(String tagName, String tagValue) { deleteValueWithServiceResponseAsync(tagName, tagValue).toBlocking().single().getBody(); } @@ -173,12 +169,9 @@ private ServiceResponse deleteValueDelegate(Response respons * * @param tagName The name of the tag. * @param tagValue The value of the tag. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the TagValueInner object if successful. */ - public TagValueInner createOrUpdateValue(String tagName, String tagValue) throws CloudException, IOException, IllegalArgumentException { + public TagValueInner createOrUpdateValue(String tagName, String tagValue) { return createOrUpdateValueWithServiceResponseAsync(tagName, tagValue).toBlocking().single().getBody(); } @@ -256,12 +249,9 @@ private ServiceResponse createOrUpdateValueDelegate(Response createOrUpdateDelegate(Response deleteDelegate(Response response) th /** * Get a list of subscription resource tags. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TagDetailsInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -511,16 +495,13 @@ private ServiceResponse> listDelegate(Response listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java index 53bdf83d29392..b1f43fac8b23a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; import java.io.IOException; @@ -70,16 +69,13 @@ interface TenantsService { /** * Gets a list of the tenantIds. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TenantIdDescriptionInner> object if successful. */ - public PagedList list() throws CloudException, IOException, IllegalArgumentException { + public PagedList list() { ServiceResponse> response = listSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -171,16 +167,13 @@ private ServiceResponse> listDelegate(Respon * Gets a list of the tenantIds. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TenantIdDescriptionInner> object if successful. */ - public PagedList listNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listNext(final String nextPageLink) { ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/AdminKeysInner.java b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/AdminKeysInner.java index 85da65d20eece..7c1c774fa31a5 100644 --- a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/AdminKeysInner.java +++ b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/AdminKeysInner.java @@ -63,12 +63,9 @@ interface AdminKeysService { * * @param resourceGroupName The name of the resource group within the current subscription. * @param serviceName The name of the Search service for which to list admin keys. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AdminKeyResultInner object if successful. */ - public AdminKeyResultInner list(String resourceGroupName, String serviceName) throws CloudException, IOException, IllegalArgumentException { + public AdminKeyResultInner list(String resourceGroupName, String serviceName) { return listWithServiceResponseAsync(resourceGroupName, serviceName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/QueryKeysInner.java b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/QueryKeysInner.java index d26f37d6fd855..b4f8bfed27afa 100644 --- a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/QueryKeysInner.java +++ b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/QueryKeysInner.java @@ -63,12 +63,9 @@ interface QueryKeysService { * * @param resourceGroupName The name of the resource group within the current subscription. * @param serviceName The name of the Search service for which to list query keys. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ListQueryKeysResultInner object if successful. */ - public ListQueryKeysResultInner list(String resourceGroupName, String serviceName) throws CloudException, IOException, IllegalArgumentException { + public ListQueryKeysResultInner list(String resourceGroupName, String serviceName) { return listWithServiceResponseAsync(resourceGroupName, serviceName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/ServicesInner.java b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/ServicesInner.java index a53415ec98176..e4e9f4eea96c1 100644 --- a/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/ServicesInner.java +++ b/azure-mgmt-search/src/main/java/com/microsoft/azure/management/search/implementation/ServicesInner.java @@ -76,12 +76,9 @@ interface ServicesService { * @param resourceGroupName The name of the resource group within the current subscription. * @param serviceName The name of the Search service to create or update. * @param parameters The properties to set or update on the Search service. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SearchServiceResourceInner object if successful. */ - public SearchServiceResourceInner createOrUpdate(String resourceGroupName, String serviceName, SearchServiceCreateOrUpdateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public SearchServiceResourceInner createOrUpdate(String resourceGroupName, String serviceName, SearchServiceCreateOrUpdateParametersInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, serviceName, parameters).toBlocking().single().getBody(); } @@ -167,11 +164,8 @@ private ServiceResponse createOrUpdateDelegate(Respo * * @param resourceGroupName The name of the resource group within the current subscription. * @param serviceName The name of the Search service to delete. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void delete(String resourceGroupName, String serviceName) throws CloudException, IOException, IllegalArgumentException { + public void delete(String resourceGroupName, String serviceName) { deleteWithServiceResponseAsync(resourceGroupName, serviceName).toBlocking().single().getBody(); } @@ -249,12 +243,9 @@ private ServiceResponse deleteDelegate(Response response) th * Returns a list of all Search services in the given resource group. * * @param resourceGroupName The name of the resource group within the current subscription. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SearchServiceListResultInner object if successful. */ - public SearchServiceListResultInner list(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public SearchServiceListResultInner list(String resourceGroupName) { return listWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccount.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccount.java index 0079054677b16..1d2e4ac31dfb6 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccount.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccount.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.storage; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType; @@ -21,7 +20,6 @@ import com.microsoft.azure.management.storage.implementation.StorageAccountInner; import org.joda.time.DateTime; -import java.io.IOException; import java.util.List; /** @@ -102,34 +100,26 @@ public interface StorageAccount extends /** * @return the access keys for this storage account - * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ @LangMethodDefinition(AsType = LangMethodType.Method) - List keys() throws CloudException, IOException; + List keys(); /** * Fetch the up-to-date access keys from Azure for this storage account. * * @return the access keys for this storage account - * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ @LangMethodDefinition(AsType = LangMethodType.Method) - List refreshKeys() throws CloudException, IOException; + List refreshKeys(); /** * Regenerates the access keys for this storage account. * * @param keyName if the key name * @return the generated access keys for this storage account - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ @LangMethodDefinition(AsType = LangMethodType.Method) - List regenerateKey(String keyName) throws CloudException, IOException; + List regenerateKey(String keyName); /************************************************************** * Fluent interfaces to provision a StorageAccount diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java index 6c6c8ff49b2c2..109b71c848962 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java @@ -114,7 +114,7 @@ public AccessTier accessTier() { } @Override - public List keys() throws CloudException, IOException { + public List keys() { if (cachedAccountKeys == null) { cachedAccountKeys = refreshKeys(); } @@ -122,7 +122,7 @@ public List keys() throws CloudException, IOException { } @Override - public List refreshKeys() throws CloudException, IOException { + public List refreshKeys() { StorageAccountListKeysResultInner response = this.client.listKeys(this.resourceGroupName(), this.name()); cachedAccountKeys = response.keys(); @@ -130,7 +130,7 @@ public List refreshKeys() throws CloudException, IOException } @Override - public List regenerateKey(String keyName) throws CloudException, IOException { + public List regenerateKey(String keyName) { StorageAccountListKeysResultInner response = this.client.regenerateKey(this.resourceGroupName(), this.name(), keyName); cachedAccountKeys = response.keys(); diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsInner.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsInner.java index acb1ccbdae176..531ead4b3a31f 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsInner.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsInner.java @@ -107,12 +107,9 @@ interface StorageAccountsService { * Checks that account name is valid and is not in use. * * @param name the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CheckNameAvailabilityResultInner object if successful. */ - public CheckNameAvailabilityResultInner checkNameAvailability(String name) throws CloudException, IOException, IllegalArgumentException { + public CheckNameAvailabilityResultInner checkNameAvailability(String name) { return checkNameAvailabilityWithServiceResponseAsync(name).toBlocking().single().getBody(); } @@ -187,13 +184,9 @@ private ServiceResponse checkNameAvailabilityD * @param resourceGroupName The name of the resource group within the user's subscription. * @param accountName 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 parameters The parameters to provide for the created account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the StorageAccountInner object if successful. */ - public StorageAccountInner create(String resourceGroupName, String accountName, StorageAccountCreateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public StorageAccountInner create(String resourceGroupName, String accountName, StorageAccountCreateParametersInner parameters) { return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().last().getBody(); } @@ -262,12 +255,9 @@ public Observable> createWithServiceRespons * @param resourceGroupName The name of the resource group within the user's subscription. * @param accountName 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 parameters The parameters to provide for the created account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StorageAccountInner object if successful. */ - public StorageAccountInner beginCreate(String resourceGroupName, String accountName, StorageAccountCreateParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public StorageAccountInner beginCreate(String resourceGroupName, String accountName, StorageAccountCreateParametersInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().getBody(); } @@ -353,11 +343,8 @@ private ServiceResponse beginCreateDelegate(Response deleteDelegate(Response response) th * * @param resourceGroupName The name of the resource group within the user's subscription. * @param accountName 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. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StorageAccountInner object if successful. */ - public StorageAccountInner getProperties(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public StorageAccountInner getProperties(String resourceGroupName, String accountName) { return getPropertiesWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -519,12 +503,9 @@ private ServiceResponse getPropertiesDelegate(Response updateDelegate(Response list() throws CloudException, IOException, IllegalArgumentException { + public List list() { return listWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -678,12 +656,9 @@ private ServiceResponse> listDelegate(Response listByResourceGroup(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public List listByResourceGroup(String resourceGroupName) { return listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -756,12 +731,9 @@ private ServiceResponse> listByResourceGroupDelega * * @param resourceGroupName The name of the resource group. * @param accountName The name of the storage account. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StorageAccountListKeysResultInner object if successful. */ - public StorageAccountListKeysResultInner listKeys(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + public StorageAccountListKeysResultInner listKeys(String resourceGroupName, String accountName) { return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -840,12 +812,9 @@ private ServiceResponse listKeysDelegate(Resp * @param resourceGroupName The name of the resource group within the user's subscription. * @param accountName 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 keyName the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StorageAccountListKeysResultInner object if successful. */ - public StorageAccountListKeysResultInner regenerateKey(String resourceGroupName, String accountName, String keyName) throws CloudException, IOException, IllegalArgumentException { + public StorageAccountListKeysResultInner regenerateKey(String resourceGroupName, String accountName, String keyName) { return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, keyName).toBlocking().single().getBody(); } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesInner.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesInner.java index 3b72461bbabc5..fa7b6da95ef8e 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesInner.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesInner.java @@ -62,12 +62,9 @@ interface UsagesService { /** * Gets the current usage count and the limit for the resources under the subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<UsageInner> object if successful. */ - public List list() throws CloudException, IOException, IllegalArgumentException { + public List list() { return listWithServiceResponseAsync().toBlocking().single().getBody(); } From 4950754624d352fea7e53b9dfd5a80ec626c1870 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 00:02:00 -0700 Subject: [PATCH 27/47] Remove throws on many methods --- .../management/compute/VirtualMachine.java | 70 +- .../implementation/AvailabilitySetImpl.java | 2 +- .../implementation/AvailabilitySetsImpl.java | 13 +- ...VirtualMachineExtensionImageTypesImpl.java | 5 +- ...tualMachineExtensionImageVersionsImpl.java | 5 +- .../VirtualMachineExtensionImpl.java | 2 +- .../VirtualMachineImagesInSkuImpl.java | 2 +- .../implementation/VirtualMachineImpl.java | 41 +- .../VirtualMachineOffersImpl.java | 5 +- .../VirtualMachineSkusImpl.java | 5 +- .../implementation/VirtualMachinesImpl.java | 8 +- .../implementation/ServicePrincipalImpl.java | 2 +- .../implementation/ServicePrincipalsImpl.java | 2 +- .../graphrbac/implementation/UserImpl.java | 2 +- .../graphrbac/implementation/UsersImpl.java | 3 +- .../keyvault/implementation/VaultImpl.java | 2 +- .../keyvault/implementation/VaultsImpl.java | 11 +- .../management/network/NetworkInterface.java | 8 +- .../network/NicIpConfiguration.java | 11 +- .../implementation/LoadBalancerImpl.java | 2 +- .../implementation/LoadBalancersImpl.java | 11 +- .../network/implementation/NetworkImpl.java | 2 +- .../implementation/NetworkInterfaceImpl.java | 6 +- .../implementation/NetworkInterfacesImpl.java | 10 +- .../NetworkSecurityGroupImpl.java | 2 +- .../NetworkSecurityGroupsImpl.java | 10 +- .../network/implementation/NetworksImpl.java | 10 +- .../NicIpConfigurationImpl.java | 6 +- .../implementation/PublicIpAddressImpl.java | 2 +- .../implementation/PublicIpAddressesImpl.java | 11 +- .../network/model/HasNetworkInterfaces.java | 12 +- .../collection/SupportsDeletingByGroup.java | 3 +- .../collection/SupportsGettingByGroup.java | 2 +- .../arm/collection/SupportsGettingById.java | 2 +- .../arm/collection/SupportsGettingByName.java | 7 +- .../collection/SupportsListingByGroup.java | 7 +- .../CreatableResourcesImpl.java | 2 +- .../GroupableResourcesImpl.java | 7 +- .../implementation/ReadableWrappersImpl.java | 8 +- .../models/implementation/GroupPagedList.java | 14 +- .../collection/SupportsListing.java | 2 +- .../fluentcore/model/Refreshable.java | 3 +- .../IndexableRefreshableImpl.java | 2 +- .../fluentcore/utils/PagedListConverter.java | 4 +- .../implementation/DeploymentImpl.java | 2 +- .../DeploymentOperationImpl.java | 2 +- .../DeploymentOperationsImpl.java | 7 +- .../implementation/DeploymentsImpl.java | 15 +- .../implementation/FeaturesImpl.java | 5 +- .../FeaturesInResourceProviderImpl.java | 5 +- .../implementation/GenericResourceImpl.java | 2 +- .../implementation/GenericResourcesImpl.java | 8 +- .../implementation/ProvidersImpl.java | 4 +- .../implementation/ResourceGroupImpl.java | 2 +- .../implementation/ResourceGroupsImpl.java | 4 +- .../implementation/SubscriptionImpl.java | 5 +- .../implementation/SubscriptionsImpl.java | 8 +- .../resources/implementation/TenantsImpl.java | 5 +- .../resources/GroupPagedListTests.java | 7 +- .../resources/childresource/PulletImpl.java | 2 +- .../implementation/StorageAccountImpl.java | 4 +- .../implementation/StorageAccountsImpl.java | 8 +- .../storage/implementation/UsagesImpl.java | 5 +- .../CertificateOrdersInner.java | 99 +- .../implementation/CertificatesInner.java | 60 +- .../ClassicMobileServicesInner.java | 25 +- .../website/implementation/DomainsInner.java | 45 +- .../GlobalCertificateOrdersInner.java | 20 +- .../GlobalDomainRegistrationsInner.java | 49 +- .../GlobalResourceGroupsInner.java | 5 +- .../website/implementation/GlobalsInner.java | 143 +- .../HostingEnvironmentsInner.java | 469 ++----- .../ManagedHostingEnvironmentsInner.java | 112 +- .../implementation/ProvidersInner.java | 35 +- .../implementation/RecommendationsInner.java | 35 +- .../implementation/ServerFarmsInner.java | 168 +-- .../website/implementation/SitesInner.java | 1166 ++++------------- .../implementation/TopLevelDomainsInner.java | 41 +- .../website/implementation/UsagesInner.java | 5 +- .../java/com/microsoft/azure/PagedList.java | 23 +- .../com/microsoft/azure/PagedListTests.java | 3 +- 81 files changed, 745 insertions(+), 2204 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java index 11cdde960a851..9a62a82739d35 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java @@ -1,23 +1,21 @@ package com.microsoft.azure.management.compute; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; -import com.microsoft.azure.management.compute.implementation.VirtualMachineInner; import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.compute.implementation.VirtualMachineInner; import com.microsoft.azure.management.network.Network; import com.microsoft.azure.management.network.NetworkInterface; import com.microsoft.azure.management.network.PublicIpAddress; import com.microsoft.azure.management.network.model.HasNetworkInterfaces; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; -import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.resources.fluentcore.model.Updatable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.storage.StorageAccount; -import java.io.IOException; import java.util.List; import java.util.Map; @@ -38,67 +36,40 @@ public interface VirtualMachine extends * Shuts down the Virtual Machine and releases the compute resources. *

* You are not billed for the compute resources that this Virtual Machine uses - * - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException thrown for IO exception. - * @throws InterruptedException exception thrown when the operation is interrupted */ - void deallocate() throws CloudException, IOException, InterruptedException; + void deallocate(); /** * Generalize the Virtual Machine. - * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ - void generalize() throws CloudException, IOException; + void generalize(); /** * Power off (stop) the virtual machine. *

* You will be billed for the compute resources that this Virtual Machine uses. - * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void powerOff() throws CloudException, IOException, InterruptedException; + void powerOff(); /** * Restart the virtual machine. - * - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted - */ - void restart() throws CloudException, IOException, InterruptedException; += */ + void restart(); /** * Start the virtual machine. - * - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void start() throws CloudException, IOException, InterruptedException; + void start(); /** * Redeploy the virtual machine. - * - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void redeploy() throws CloudException, IOException, InterruptedException; + void redeploy(); /** * List of all available virtual machine sizes this virtual machine can resized to. - * - * @return the virtual machine sizes - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization */ - PagedList availableSizes() throws CloudException, IOException; + PagedList availableSizes(); /** * Captures the virtual machine by copying virtual hard disks of the VM and returns template as json @@ -107,11 +78,8 @@ public interface VirtualMachine extends * @param containerName destination container name to store the captured Vhd * @param overwriteVhd whether to overwrites destination vhd if it exists * @return the template as json string - * @throws CloudException thrown for an invalid response from the service - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - String capture(String containerName, boolean overwriteVhd) throws CloudException, IOException, InterruptedException; + String capture(String containerName, boolean overwriteVhd); /** * Refreshes the virtual machine instance view to sync with Azure. @@ -119,10 +87,8 @@ public interface VirtualMachine extends * this will caches the instance view which can be later retrieved using {@link VirtualMachine#instanceView()}. * * @return the refreshed instance view - * @throws CloudException thrown for an invalid response from the service - * @throws IOException exception thrown from serialization/deserialization */ - VirtualMachineInstanceView refreshInstanceView() throws CloudException, IOException; + VirtualMachineInstanceView refreshInstanceView(); // Getters // @@ -168,10 +134,8 @@ public interface VirtualMachine extends * note that this method makes a rest API call to fetch the resource. * * @return the public IP of the primary network interface - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - PublicIpAddress primaryPublicIpAddress() throws CloudException, IOException; + PublicIpAddress primaryPublicIpAddress(); /** * Returns id to the availability set this virtual machine associated with. @@ -247,10 +211,8 @@ public interface VirtualMachine extends * this method returns the cached instance view, to refresh the cache call {@link VirtualMachine#refreshInstanceView()}. * * @return the virtual machine instance view - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - VirtualMachineInstanceView instanceView() throws CloudException, IOException; + VirtualMachineInstanceView instanceView(); // Setters // diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java index 3271a73bafcba..317c712563b8a 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java @@ -73,7 +73,7 @@ public List statuses() { } @Override - public AvailabilitySet refresh() throws Exception { + public AvailabilitySet refresh() { AvailabilitySetInner response = client.get(this.resourceGroupName(), this.name()); this.setInner(response); this.idOfVMsInSet = null; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 985317572a932..39aff4bd430dc 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.AvailabilitySet; @@ -13,9 +12,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; -import com.microsoft.rest.RestException; -import java.io.IOException; import java.util.List; /** @@ -38,22 +35,22 @@ class AvailabilitySetsImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { return new GroupPagedList(this.myManager.resourceManager().resourceGroups().list()) { @Override - public List listNextGroup(String resourceGroupName) throws RestException, IOException { + public List listNextGroup(String resourceGroupName) { return wrapList(innerCollection.list(resourceGroupName)); } }; } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public AvailabilitySetImpl getByGroup(String groupName, String name) throws CloudException, IOException { + public AvailabilitySetImpl getByGroup(String groupName, String name) { AvailabilitySetInner response = this.innerCollection.get(groupName, name); return wrapModel(response); } @@ -69,7 +66,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageTypesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageTypesImpl.java index a330474a0c993..39e9aa7e32a7a 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageTypesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageTypesImpl.java @@ -1,14 +1,11 @@ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageType; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageTypes; import com.microsoft.azure.management.compute.VirtualMachinePublisher; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineExtensionImageTypes}. */ @@ -24,7 +21,7 @@ class VirtualMachineExtensionImageTypesImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.client.listTypes(this.publisher.region().toString(), this.publisher.name())); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionsImpl.java index 764f865ac5df0..e8146c46de18b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionsImpl.java @@ -1,14 +1,11 @@ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageType; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersion; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersions; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineExtensionImageVersions}. */ @@ -24,7 +21,7 @@ public class VirtualMachineExtensionImageVersionsImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.client.listVersions(this.type.regionName(), this.type.publisher().name(), this.type.name())); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java index 13519bb0fa48d..885693bc7463b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java @@ -199,7 +199,7 @@ public VirtualMachineImpl attach() { } @Override - public VirtualMachineExtensionImpl refresh() throws Exception { + public VirtualMachineExtensionImpl refresh() { VirtualMachineExtensionInner inner = this.client.get(this.parent.resourceGroupName(), this.parent.name(), this.name()); this.setInner(inner); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesInSkuImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesInSkuImpl.java index d609afb170768..bc66c1fdb311a 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesInSkuImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesInSkuImpl.java @@ -26,7 +26,7 @@ class VirtualMachineImagesInSkuImpl implements VirtualMachineImagesInSku { this.innerCollection = innerCollection; } - public PagedList list() throws RestException, IOException { + public PagedList list() { final List images = new ArrayList<>(); for (VirtualMachineImageResourceInner inner : innerCollection.list( diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index b18ccb1329277..a564307a92634 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -1,7 +1,7 @@ package com.microsoft.azure.management.compute.implementation; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.CloudException; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.SubResource; @@ -49,11 +49,10 @@ import com.microsoft.azure.management.resources.implementation.PageImpl; import com.microsoft.azure.management.storage.StorageAccount; import com.microsoft.azure.management.storage.implementation.StorageManager; -import com.microsoft.rest.RestException; import rx.Observable; +import rx.exceptions.Exceptions; import rx.functions.Func1; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -146,7 +145,7 @@ public VirtualMachineSize typeConvert(VirtualMachineSizeInner inner) { // Verbs @Override - public VirtualMachine refresh() throws Exception { + public VirtualMachine refresh() { VirtualMachineInner response = this.client.get(this.resourceGroupName(), this.name()); this.setInner(response); @@ -162,61 +161,65 @@ public Observable applyAsync() { } @Override - public void deallocate() throws CloudException, IOException, InterruptedException { + public void deallocate() { this.client.deallocate(this.resourceGroupName(), this.name()); } @Override - public void generalize() throws CloudException, IOException { + public void generalize() { this.client.generalize(this.resourceGroupName(), this.name()); } @Override - public void powerOff() throws CloudException, IOException, InterruptedException { + public void powerOff() { this.client.powerOff(this.resourceGroupName(), this.name()); } @Override - public void restart() throws CloudException, IOException, InterruptedException { + public void restart() { this.client.restart(this.resourceGroupName(), this.name()); } @Override - public void start() throws CloudException, IOException, InterruptedException { + public void start() { this.client.start(this.resourceGroupName(), this.name()); } @Override - public void redeploy() throws CloudException, IOException, InterruptedException { + public void redeploy() { this.client.redeploy(this.resourceGroupName(), this.name()); } @Override - public PagedList availableSizes() throws CloudException, IOException { + public PagedList availableSizes() { PageImpl page = new PageImpl<>(); page.setItems(this.client.listAvailableSizes(this.resourceGroupName(), this.name())); page.setNextPageLink(null); return this.virtualMachineSizeConverter.convert(new PagedList(page) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return null; } }); } @Override - public String capture(String containerName, boolean overwriteVhd) throws CloudException, IOException, InterruptedException { + public String capture(String containerName, boolean overwriteVhd) { VirtualMachineCaptureParametersInner parameters = new VirtualMachineCaptureParametersInner(); parameters.withDestinationContainerName(containerName); parameters.withOverwriteVhds(overwriteVhd); VirtualMachineCaptureResultInner captureResult = this.client.capture(this.resourceGroupName(), this.name(), parameters); ObjectMapper mapper = new ObjectMapper(); //Object to JSON string - return mapper.writeValueAsString(captureResult.output()); + try { + return mapper.writeValueAsString(captureResult.output()); + } catch (JsonProcessingException e) { + throw Exceptions.propagate(e); + } } @Override - public VirtualMachineInstanceView refreshInstanceView() throws CloudException, IOException { + public VirtualMachineInstanceView refreshInstanceView() { this.virtualMachineInstanceView = this.client.get(this.resourceGroupName(), this.name(), InstanceViewTypes.INSTANCE_VIEW).instanceView(); @@ -754,7 +757,7 @@ public List dataDisks() { } @Override - public NetworkInterface primaryNetworkInterface() throws CloudException, IOException { + public NetworkInterface primaryNetworkInterface() { if (this.primaryNetworkInterface == null) { String primaryNicId = primaryNetworkInterfaceId(); this.primaryNetworkInterface = this.networkManager.networkInterfaces().getById(primaryNicId); @@ -763,7 +766,7 @@ public NetworkInterface primaryNetworkInterface() throws CloudException, IOExcep } @Override - public PublicIpAddress primaryPublicIpAddress() throws CloudException, IOException { + public PublicIpAddress primaryPublicIpAddress() { if (this.primaryPublicIpAddress == null) { this.primaryPublicIpAddress = this.primaryNetworkInterface().primaryPublicIpAddress(); } @@ -857,7 +860,7 @@ public String vmId() { } @Override - public VirtualMachineInstanceView instanceView() throws CloudException, IOException { + public VirtualMachineInstanceView instanceView() { if (this.virtualMachineInstanceView == null) { this.refreshInstanceView(); } @@ -981,7 +984,7 @@ private void setHardwareProfileDefaults() { } } - private void handleStorageSettings() throws Exception { + private void handleStorageSettings() { StorageAccount storageAccount = null; if (this.creatableStorageAccountKey != null) { storageAccount = (StorageAccount) this.createdResource(this.creatableStorageAccountKey); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineOffersImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineOffersImpl.java index d930383600436..e768bde345ad6 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineOffersImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineOffersImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.VirtualMachineOffer; @@ -13,8 +12,6 @@ import com.microsoft.azure.management.compute.VirtualMachinePublisher; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineOffers}. */ @@ -37,7 +34,7 @@ protected VirtualMachineOfferImpl wrapModel(VirtualMachineImageResourceInner inn } @Override - public PagedList list() throws CloudException, IllegalArgumentException, IOException { + public PagedList list() { return wrapList(innerCollection.listOffers(publisher.region().toString(), publisher.name())); } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSkusImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSkusImpl.java index 5f9f8f97a60a5..45e2002a96389 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSkusImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSkusImpl.java @@ -11,9 +11,6 @@ import com.microsoft.azure.management.compute.VirtualMachineSkus; import com.microsoft.azure.management.compute.VirtualMachineSku; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import com.microsoft.rest.RestException; - -import java.io.IOException; /** * The implementation for {@link VirtualMachineSkus}. @@ -32,7 +29,7 @@ class VirtualMachineSkusImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { return wrapList(innerCollection.listSkus( offer.region().toString(), offer.publisher().name(), diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index 813c6d2af3034..58c937fd8dd5a 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -59,17 +59,17 @@ class VirtualMachinesImpl // Actions @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public VirtualMachine getByGroup(String groupName, String name) throws CloudException, IOException { + public VirtualMachine getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -79,7 +79,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java index c3d44c2b99f7d..0dbe0d5258fd6 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java @@ -68,7 +68,7 @@ public ServicePrincipalImpl withAccountEnabled(boolean enabled) { } @Override - public ServicePrincipal refresh() throws Exception { + public ServicePrincipal refresh() { return null; } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java index 1268109be659a..469c16af2cd93 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java @@ -41,7 +41,7 @@ class ServicePrincipalsImpl } @Override - public PagedList list() throws GraphErrorException, IOException { + public PagedList list() { return wrapList(this.innerCollection.list()); } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java index 1180a58cac48e..9779e5c7fd706 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java @@ -101,7 +101,7 @@ public UserImpl withPassword(String password, boolean forceChangePasswordNextLog } @Override - public User refresh() throws Exception { + public User refresh() { return null; } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java index 6f4504497f9f2..c292aee5f2e6e 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java @@ -11,7 +11,6 @@ import com.microsoft.azure.management.graphrbac.User; import com.microsoft.azure.management.graphrbac.Users; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -40,7 +39,7 @@ class UsersImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { return wrapList(this.innerCollection.list()); } diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java index bfb4d8b762837..597c5a48078a4 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java @@ -257,7 +257,7 @@ public Observable call(Object o) { } @Override - public VaultImpl refresh() throws Exception { + public VaultImpl refresh() { setInner(client.get(resourceGroupName(), name())); return this; } diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java index be66f6aa2336e..0594b1a947cb8 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.keyvault.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.graphrbac.implementation.GraphRbacManager; import com.microsoft.azure.management.keyvault.SkuName; @@ -15,9 +14,7 @@ import com.microsoft.azure.management.keyvault.Vaults; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.rest.RestException; -import java.io.IOException; import java.util.UUID; /** @@ -45,17 +42,17 @@ class VaultsImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { return wrapList(this.innerCollection.list()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.listByResourceGroup(groupName)); } @Override - public Vault getByGroup(String groupName, String name) throws CloudException, IOException { + public Vault getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -65,7 +62,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java index fc8018ae87feb..41caacdc81084 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java @@ -77,10 +77,8 @@ public interface NetworkInterface extends * This method makes a rest API call to fetch the public IP. * * @return the public IP associated with this network interface - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - PublicIpAddress primaryPublicIpAddress() throws CloudException, IOException; + PublicIpAddress primaryPublicIpAddress(); /** * @return the resource id of the virtual network subnet associated with this network interface. @@ -93,10 +91,8 @@ public interface NetworkInterface extends * This method makes a rest API call to fetch the virtual network. * * @return the virtual network associated with this network interface. - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - Network primaryNetwork() throws CloudException, IOException; + Network primaryNetwork(); /** * Gets the private IP address allocated to this network interface's primary IP configuration. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java index c03849b104108..3f9fd39d8a740 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.network; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner; import com.microsoft.azure.management.network.model.HasPrivateIpAddress; @@ -10,8 +9,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; -import java.io.IOException; - /** * An IP configuration in a network interface. */ @@ -35,10 +32,8 @@ public interface NicIpConfiguration extends * This method makes a rest API call to fetch the public IP. * * @return the public IP associated with this IP configuration or null if there is no public IP associated - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - PublicIpAddress publicIpAddress() throws CloudException, IOException; + PublicIpAddress publicIpAddress(); /** * @return the resource id of the virtual network subnet associated with this IP configuration. @@ -51,10 +46,8 @@ public interface NicIpConfiguration extends * This method makes a rest API call to fetch the public IP. * * @return the virtual network associated with this this IP configuration. - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - Network network() throws CloudException, IOException; + Network network(); // Setters (fluent) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java index 9d64084ff1e83..4611b6ee92124 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java @@ -76,7 +76,7 @@ class LoadBalancerImpl // Verbs @Override - public LoadBalancerImpl refresh() throws Exception { + public LoadBalancerImpl refresh() { LoadBalancerInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(inner); initializeChildrenFromInner(); diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java index 33253d1dfa4bc..429f9441a9daf 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.LoadBalancer; @@ -13,8 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; - /** * Implementation for {@link LoadBalancers}. */ @@ -35,17 +32,17 @@ class LoadBalancersImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public LoadBalancerImpl getByGroup(String groupName, String name) throws CloudException, IOException { + public LoadBalancerImpl getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -55,7 +52,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java index 2f59b64bda3fa..8ba739be39692 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java @@ -58,7 +58,7 @@ protected void initializeChildrenFromInner() { // Verbs @Override - public NetworkImpl refresh() throws Exception { + public NetworkImpl refresh() { VirtualNetworkInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(inner); initializeChildrenFromInner(); diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index fa3a62aa490fa..dfdeee4106a59 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -80,7 +80,7 @@ class NetworkInterfaceImpl // Verbs @Override - public NetworkInterface refresh() throws Exception { + public NetworkInterface refresh() { NetworkInterfaceInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(inner); clearCachedRelatedResources(); @@ -278,7 +278,7 @@ public List dnsServers() { } @Override - public PublicIpAddress primaryPublicIpAddress() throws CloudException, IOException { + public PublicIpAddress primaryPublicIpAddress() { if (this.primaryPublicIp == null) { this.primaryPublicIp = this.primaryIpConfiguration().publicIpAddress(); } @@ -291,7 +291,7 @@ public String primarySubnetId() { } @Override - public Network primaryNetwork() throws CloudException, IOException { + public Network primaryNetwork() { if (this.primaryNetwork == null) { this.primaryNetwork = this.primaryIpConfiguration().network(); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index 33ee1e3f96374..433fad1c4181b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.NetworkInterface; @@ -9,7 +8,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; import java.util.ArrayList; /** @@ -32,17 +30,17 @@ class NetworkInterfacesImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(innerCollection.list(groupName)); } @Override - public NetworkInterface getByGroup(String groupName, String name) throws CloudException, IOException { + public NetworkInterface getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -52,7 +50,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java index 24c04d6f4764d..e94871b845c27 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java @@ -80,7 +80,7 @@ public NetworkSecurityRuleImpl defineRule(String name) { } @Override - public NetworkSecurityGroupImpl refresh() throws Exception { + public NetworkSecurityGroupImpl refresh() { NetworkSecurityGroupInner response = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(response); initializeChildrenFromInner(); diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index b60be34f07c69..3147439c7d74c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.NetworkSecurityGroup; @@ -13,7 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; import java.util.ArrayList; /** @@ -36,17 +34,17 @@ class NetworkSecurityGroupsImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public NetworkSecurityGroupImpl getByGroup(String groupName, String name) throws CloudException, IOException { + public NetworkSecurityGroupImpl getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -56,7 +54,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index 30eab4179fb27..7a4233fb1af50 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.AddressSpace; @@ -15,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; import java.util.ArrayList; /** @@ -38,17 +36,17 @@ class NetworksImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public NetworkImpl getByGroup(String groupName, String name) throws CloudException, IOException { + public NetworkImpl getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -58,7 +56,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java index 7ac23a2aca97f..16ffde7d23195 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.SubResource; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.IPAllocationMethod; @@ -13,7 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ChildResourceImpl; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -92,7 +90,7 @@ public String publicIpAddressId() { } @Override - public PublicIpAddress publicIpAddress() throws CloudException, IOException { + public PublicIpAddress publicIpAddress() { String id = publicIpAddressId(); if (id == null) { return null; @@ -108,7 +106,7 @@ public String subnetId() { } @Override - public Network network() throws CloudException, IOException { + public Network network() { String id = subnetId(); return this.networkManager.networks().getByGroup(ResourceUtils.groupFromResourceId(id), ResourceUtils.extractFromResourceId(id, "virtualNetworks")); diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index 213ecd3d2ea80..3f35f853c2acd 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -45,7 +45,7 @@ public Observable applyAsync() { } @Override - public PublicIpAddress refresh() throws Exception { + public PublicIpAddress refresh() { PublicIPAddressInner response = this.client.get(this.resourceGroupName(), this.name()); this.setInner(response); return this; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index a7421e734ae30..26a167b62ba7c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.network.PublicIPAddressDnsSettings; import com.microsoft.azure.management.network.PublicIpAddress; @@ -14,8 +13,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; - /** * Implementation for {@link PublicIpAddresses}. */ @@ -36,17 +33,17 @@ class PublicIpAddressesImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.list(groupName)); } @Override - public PublicIpAddressImpl getByGroup(String groupName, String name) throws CloudException, IOException { + public PublicIpAddressImpl getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -56,7 +53,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/model/HasNetworkInterfaces.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/model/HasNetworkInterfaces.java index cfb0bf322bb2c..05981f1ce71e1 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/model/HasNetworkInterfaces.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/model/HasNetworkInterfaces.java @@ -5,12 +5,10 @@ */ package com.microsoft.azure.management.network.model; -import java.io.IOException; -import java.util.List; - -import com.microsoft.azure.CloudException; -import com.microsoft.azure.management.network.NetworkInterface; import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.network.NetworkInterface; + +import java.util.List; /** * Interface exposing a list of network interfaces. @@ -23,10 +21,8 @@ public interface HasNetworkInterfaces { * Note that this method can result in a call to the cloud to fetch the network interface information. * * @return the primary network interface associated with this resource - * @throws CloudException exceptions thrown from the cloud - * @throws IOException exceptions thrown from serialization/deserialization. */ - NetworkInterface primaryNetworkInterface() throws CloudException, IOException; + NetworkInterface primaryNetworkInterface(); /** * @return the resource id of the primary network interface associated with this resource diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java index c7431e958fc63..6dacc8134db55 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java @@ -21,7 +21,6 @@ public interface SupportsDeletingByGroup { * * @param groupName The group the resource is part of * @param name The name of the resource - * @throws Exception error to throw */ - void delete(String groupName, String name) throws Exception; + void delete(String groupName, String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java index b3774800bb0bd..9a8740a76e831 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java @@ -30,5 +30,5 @@ public interface SupportsGettingByGroup { * @throws CloudException exceptions thrown from the cloud. * @throws IOException exceptions thrown from serialization/deserialization. */ - T getByGroup(String resourceGroupName, String name) throws CloudException, IOException; + T getByGroup(String resourceGroupName, String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java index db84ecfb284fe..f994ab3a62986 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java @@ -29,5 +29,5 @@ public interface SupportsGettingById { * @throws IOException exceptions thrown from serialization/deserialization * @throws IllegalArgumentException exceptions thrown when something is wrong with the input parameters */ - T getById(String id) throws CloudException, IllegalArgumentException, IOException; + T getById(String id); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java index ca590d17b3fd8..37555808413e0 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java @@ -7,12 +7,9 @@ package com.microsoft.azure.management.resources.fluentcore.arm.collection; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import java.io.IOException; - /** * Provides access to getting a specific Azure resource based on its name within the current resource group. * @@ -25,8 +22,6 @@ public interface SupportsGettingByName { * * @param name the name of the resource. (Note, this is not the resource ID.) * @return an immutable representation of the resource - * @throws CloudException exceptions thrown from the cloud - * @throws IOException exceptions thrown from serialization/deserialization */ - T getByName(String name) throws CloudException, IOException; + T getByName(String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java index 973acc2d694a1..feae0361c09ea 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java @@ -6,13 +6,10 @@ package com.microsoft.azure.management.resources.fluentcore.arm.collection; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import java.io.IOException; - /** * Provides access to listing Azure resources of a specific type in a specific resource group. * @@ -27,8 +24,6 @@ public interface SupportsListingByGroup { * * @param resourceGroupName the name of the resource group to list the resources from * @return the list of resources - * @throws CloudException exception thrown from the cloud - * @throws IOException exception thrown from serialization/deserialization */ - PagedList listByGroup(String resourceGroupName) throws CloudException, IOException; + PagedList listByGroup(String resourceGroupName); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java index d3e7c3d1ca818..1f9ec0342b1ff 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java @@ -306,7 +306,7 @@ public CreatableResourcesRoot createResource() { // resources. @Override - public CreatableResourcesRoot refresh() throws Exception { + public CreatableResourcesRoot refresh() { return null; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index 3cb20c9a11e61..a73a476717995 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -5,9 +5,6 @@ */ package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; -import java.io.IOException; - -import com.microsoft.azure.CloudException; import com.microsoft.azure.Resource; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; @@ -45,10 +42,10 @@ protected GroupableResourcesImpl( } @Override - public abstract T getByGroup(String groupName, String name) throws CloudException, IOException; + public abstract T getByGroup(String groupName, String name); @Override - public T getById(String id) throws CloudException, IOException { + public T getById(String id) { return this.getByGroup( ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ReadableWrappersImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ReadableWrappersImpl.java index 6bc8e90766d06..79cf88793a923 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ReadableWrappersImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ReadableWrappersImpl.java @@ -5,14 +5,12 @@ */ package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; -import java.io.IOException; -import java.util.List; - import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.PageImpl; -import com.microsoft.rest.RestException; + +import java.util.List; /** * Base class for readable wrapper collections, i.e. those whose models can only be read, not created. @@ -49,7 +47,7 @@ protected PagedList wrapList(List list) { page.setNextPageLink(null); PagedList pagedList = new PagedList(page) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return null; } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupPagedList.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupPagedList.java index 2ad8436c50398..4c79130be6e66 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupPagedList.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupPagedList.java @@ -10,9 +10,7 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.implementation.PageImpl; -import com.microsoft.rest.RestException; -import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -32,15 +30,11 @@ public abstract class GroupPagedList extends PagedList { */ public GroupPagedList(PagedList resourceGroupList) { this.resourceGroupItr = resourceGroupList.iterator(); - try { - setCurrentPage(nextPage("dummy")); - } catch (IOException e) { - throw new RuntimeException(e); - } + setCurrentPage(nextPage("dummy")); } @Override - public Page nextPage(String s) throws RestException, IOException { + public Page nextPage(String s) { if (resourceGroupItr.hasNext()) { ResourceGroup resourceGroup = resourceGroupItr.next(); PageImpl page = new PageImpl<>(); @@ -60,8 +54,6 @@ public Page nextPage(String s) throws RestException, IOException { * * @param resourceGroupName the name of the resource group * @return the list of resources in this group. - * @throws RestException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ - public abstract List listNextGroup(String resourceGroupName) throws RestException, IOException; + public abstract List listNextGroup(String resourceGroupName); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java index df35181f8576a..7c0b1d7929a40 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java @@ -29,5 +29,5 @@ public interface SupportsListing { * @throws RestException exceptions thrown from the cloud. * @throws IOException exceptions thrown from serialization/deserialization. */ - PagedList list() throws RestException, IOException; + PagedList list(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Refreshable.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Refreshable.java index c57e34a4983d2..8975687a40461 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Refreshable.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Refreshable.java @@ -19,7 +19,6 @@ public interface Refreshable { * Refreshes the resource to sync with Azure. * * @return the refreshed resource - * @throws Exception exceptions thrown from Azure */ - T refresh() throws Exception; + T refresh(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/IndexableRefreshableImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/IndexableRefreshableImpl.java index 56e00e6a43006..b7408ac4d2e4d 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/IndexableRefreshableImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/IndexableRefreshableImpl.java @@ -22,5 +22,5 @@ protected IndexableRefreshableImpl() { } @Override - public abstract T refresh() throws Exception; + public abstract T refresh(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java index 8e84d87007c03..9d8a23de785d7 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java @@ -9,9 +9,7 @@ import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.implementation.PageImpl; -import com.microsoft.rest.RestException; -import java.io.IOException; import java.util.ArrayList; /** @@ -49,7 +47,7 @@ public PagedList convert(final PagedList uList) { } return new PagedList(vPage) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { Page uPage = uList.nextPage(nextPageLink); PageImpl vPage = new PageImpl<>(); vPage.setNextPageLink(uPage.getNextPageLink()); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java index 25bd884bc15af..dfd2dfa3875cd 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java @@ -308,7 +308,7 @@ public Observable call(ResourceGroup resourceGroup) { } @Override - public Deployment refresh() throws Exception { + public Deployment refresh() { return null; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationImpl.java index 4ae2346c25d6f..ea8a11c0d9906 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationImpl.java @@ -77,7 +77,7 @@ public TargetResource targetResource() { } @Override - public DeploymentOperation refresh() throws Exception { + public DeploymentOperation refresh() { this.setInner(client.get(resourceGroupName, deploymentName, operationId())); return this; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java index 0dba4a4aa4c6c..44cede39c6c68 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java @@ -6,15 +6,12 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Deployment; import com.microsoft.azure.management.resources.DeploymentOperation; import com.microsoft.azure.management.resources.DeploymentOperations; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation of {@link DeploymentOperations}. */ @@ -31,12 +28,12 @@ final class DeploymentOperationsImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(client.list(deployment.resourceGroupName(), deployment.name())); } @Override - public DeploymentOperation getById(String operationId) throws CloudException, IllegalArgumentException, IOException { + public DeploymentOperation getById(String operationId) { return wrapModel(client.get(deployment.resourceGroupName(), deployment.name(), operationId)); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index ed2ca9d51b2b8..e66360703b22d 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -14,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.rest.RestException; import java.io.IOException; import java.util.List; @@ -45,22 +44,22 @@ public Deployment typeConvert(DeploymentExtendedInner deploymentInner) { } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { return new GroupPagedList(this.resourceManager.resourceGroups().list()) { @Override - public List listNextGroup(String resourceGroupName) throws RestException, IOException { + public List listNextGroup(String resourceGroupName) { return converter.convert(client.list(resourceGroupName)); } }; } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return converter.convert(client.list(groupName)); } @Override - public Deployment getByName(String name) throws IOException, CloudException { + public Deployment getByName(String name) { for (ResourceGroup group : this.resourceManager.resourceGroups().list()) { DeploymentExtendedInner inner = client.get(group.name(), name); if (inner != null) { @@ -71,7 +70,7 @@ public Deployment getByName(String name) throws IOException, CloudException { } @Override - public Deployment getByGroup(String groupName, String name) throws IOException, CloudException { + public Deployment getByGroup(String groupName, String name) { return createFluentModel(client.get(groupName, name)); } @@ -81,7 +80,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { client.delete(groupName, name); } @@ -108,7 +107,7 @@ protected DeploymentImpl createFluentModel(DeploymentExtendedInner deploymentExt } @Override - public Deployment getById(String id) throws CloudException, IllegalArgumentException, IOException { + public Deployment getById(String id) { return this.getByGroup( ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesImpl.java index 34ade7e2cfcbe..fd893f990e112 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesImpl.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Feature; import com.microsoft.azure.management.resources.Features; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation of {@link Features}. */ @@ -27,7 +24,7 @@ final class FeaturesImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(client.listAll()); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java index c1be1b5bbdf0b..f896288c975df 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java @@ -11,7 +11,6 @@ import com.microsoft.azure.management.resources.Feature; import com.microsoft.azure.management.resources.Features; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.rest.RestException; import java.io.IOException; @@ -29,7 +28,7 @@ final class FeaturesInResourceProviderImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { PagedListConverter converter = new PagedListConverter() { @Override public Feature typeConvert(FeatureResultInner tenantInner) { @@ -45,7 +44,7 @@ public Feature register(String featureName) throws IOException, CloudException { } @Override - public Feature getByName(String name) throws CloudException, IOException { + public Feature getByName(String name) { return new FeatureImpl(client.get(resourceProviderNamespace, name)); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index 578aab023e54f..c4b4669c2b5b1 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -72,7 +72,7 @@ public Object properties() { } @Override - public GenericResource refresh() throws Exception { + public GenericResource refresh() { return null; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index d683cb6c44433..233225f7df456 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -37,7 +37,7 @@ final class GenericResourcesImpl } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.serviceClient.resourceGroups().listResources(groupName)); } @@ -63,7 +63,7 @@ public boolean checkExistence(String resourceGroupName, String resourceProviderN } @Override - public GenericResource getById(String id) throws CloudException, IOException { + public GenericResource getById(String id) { return this.get( ResourceUtils.groupFromResourceId(id), ResourceUtils.resourceProviderFromResourceId(id), @@ -76,7 +76,7 @@ public GenericResource get( String resourceGroupName, String providerNamespace, String resourceType, - String name) throws CloudException, IOException { + String name) { PagedList genericResources = this.listByGroup(resourceGroupName); for (GenericResource resource : genericResources) { @@ -166,7 +166,7 @@ protected GenericResourceImpl wrapModel(GenericResourceInner inner) { } @Override - public GenericResource getByGroup(String groupName, String name) throws CloudException, IOException { + public GenericResource getByGroup(String groupName, String name) { // Not needed, can't be supported, provided only to satisfy GroupableResourceImpl's requirements return null; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java index 480e4cca4d79a..648ce3de6f2b8 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java @@ -27,7 +27,7 @@ final class ProvidersImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(client.list()); } @@ -42,7 +42,7 @@ public Provider register(String resourceProviderNamespace) throws CloudException } @Override - public Provider getByName(String resourceProviderNamespace) throws CloudException, IOException { + public Provider getByName(String resourceProviderNamespace) { return wrapModel(client.get(resourceProviderNamespace)); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java index 4cd3d09c1d1e8..bb73064c55875 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java @@ -120,7 +120,7 @@ public Observable applyAsync() { } @Override - public ResourceGroupImpl refresh() throws Exception { + public ResourceGroupImpl refresh() { this.setInner(client.get(this.key)); return this; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java index f609c088d3095..703629854d0be 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java @@ -34,12 +34,12 @@ final class ResourceGroupsImpl } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(client.list()); } @Override - public ResourceGroupImpl getByName(String name) throws CloudException, IOException { + public ResourceGroupImpl getByName(String name) { return wrapModel(client.get(name)); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java index 9226c2ed18eed..cb71188979131 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java @@ -11,10 +11,9 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Location; import com.microsoft.azure.management.resources.Subscription; +import com.microsoft.azure.management.resources.SubscriptionPolicies; import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableWrapperImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.azure.management.resources.SubscriptionPolicies; -import com.microsoft.rest.RestException; import java.io.IOException; import java.util.List; @@ -71,7 +70,7 @@ private PagedList toPagedList(List list) { page.setNextPageLink(null); return new PagedList(page) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return null; } }; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java index 948704d62b419..0ebea48117e2f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java @@ -6,14 +6,10 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Subscription; import com.microsoft.azure.management.resources.Subscriptions; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.rest.RestException; - -import java.io.IOException; /** * The implementation of {@link Subscriptions}. @@ -27,7 +23,7 @@ final class SubscriptionsImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { PagedListConverter converter = new PagedListConverter() { @Override public Subscription typeConvert(SubscriptionInner subscriptionInner) { @@ -39,7 +35,7 @@ public Subscription typeConvert(SubscriptionInner subscriptionInner) { @Override // Gets a specific resource group - public SubscriptionImpl getByName(String name) throws CloudException, IOException { + public SubscriptionImpl getByName(String name) { SubscriptionInner subscription = client.get(name); return new SubscriptionImpl(subscription, client); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsImpl.java index 4d760e5b6f0c9..9ab02bc033643 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsImpl.java @@ -10,9 +10,6 @@ import com.microsoft.azure.management.resources.Tenant; import com.microsoft.azure.management.resources.Tenants; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.rest.RestException; - -import java.io.IOException; /** * Implementation for {@link Tenants}. @@ -26,7 +23,7 @@ final class TenantsImpl } @Override - public PagedList list() throws RestException, IOException { + public PagedList list() { PagedListConverter converter = new PagedListConverter() { @Override public Tenant typeConvert(TenantIdDescriptionInner tenantInner) { diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java index 31e258ae08a11..dbc779b656eba 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java @@ -7,7 +7,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.implementation.PageImpl; import com.microsoft.azure.management.resources.implementation.ResourceGroupInner; -import com.microsoft.rest.RestException; import org.junit.Assert; import org.junit.Test; @@ -85,7 +84,7 @@ public void isResourceLoadedLazily() { PagedList pagedResourceList = new PagedList(pages.get(0)) { @Override - public Page nextPage(String nextLink) throws RestException, IOException { + public Page nextPage(String nextLink) { Assert.assertSame(itr.next(), nextLink); int index = Integer.parseInt(nextLink); return pages.get(index); @@ -94,7 +93,7 @@ public Page nextPage(String nextLink) throws RestException, IOExc GroupPagedList groupedResourceList = new GroupPagedList(pagedResourceList) { @Override - public List listNextGroup(String s) throws RestException, IOException { + public List listNextGroup(String s) { List groupItems = new ArrayList<>(); groupItems.add(s + "Vm1"); groupItems.add(s + "Vm2"); @@ -159,7 +158,7 @@ public String key() { } @Override - public ResourceGroup refresh() throws Exception { + public ResourceGroup refresh() { return null; } diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java index 0a5dc17baf349..db55a6c340f8f 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletImpl.java @@ -81,7 +81,7 @@ public Observable deleteAsync() { } @Override - public PulletImpl refresh() throws Exception { + public PulletImpl refresh() { return null; } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java index 109b71c848962..508795dce67a5 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.storage.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import com.microsoft.azure.management.storage.AccessTier; import com.microsoft.azure.management.storage.CustomDomain; @@ -23,7 +22,6 @@ import rx.functions.Action1; import rx.functions.Func1; -import java.io.IOException; import java.util.List; /** @@ -138,7 +136,7 @@ public List regenerateKey(String keyName) { } @Override - public StorageAccountImpl refresh() throws Exception { + public StorageAccountImpl refresh() { StorageAccountInner response = this.client.getProperties(this.resourceGroupName(), this.name()); this.setInner(response); diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index 42394d94ea0bb..dd5e5a813d213 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -41,17 +41,17 @@ public CheckNameAvailabilityResult checkNameAvailability(String name) throws Clo } @Override - public PagedList list() throws CloudException, IOException { + public PagedList list() { return wrapList(this.innerCollection.list()); } @Override - public PagedList listByGroup(String groupName) throws CloudException, IOException { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.listByResourceGroup(groupName)); } @Override - public StorageAccount getByGroup(String groupName, String name) throws CloudException, IOException { + public StorageAccount getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.getProperties(groupName, name)); } @@ -61,7 +61,7 @@ public void delete(String id) throws Exception { } @Override - public void delete(String groupName, String name) throws Exception { + public void delete(String groupName, String name) { this.innerCollection.delete(groupName, name); } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesImpl.java index 55ccef9406e6e..9b9e27843c6ee 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/UsagesImpl.java @@ -1,13 +1,10 @@ package com.microsoft.azure.management.storage.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; import com.microsoft.azure.management.storage.StorageUsage; import com.microsoft.azure.management.storage.Usages; -import java.io.IOException; - /** * The implementation of {@link Usages}. */ @@ -20,7 +17,7 @@ class UsagesImpl extends ReadableWrappersImpl list() throws CloudException, IOException { + public PagedList list() { return wrapList(client.usages().list()); } diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificateOrdersInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificateOrdersInner.java index 00544c2f9e8cc..a81e24655eaed 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificateOrdersInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificateOrdersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -144,12 +143,9 @@ interface CertificateOrdersService { * @param resourceGroupName Azure resource group name * @param certificateOrderName Certificate name * @param name Certificate name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOrderCertificateInner object if successful. */ - public CertificateOrderCertificateInner getCertificate(String resourceGroupName, String certificateOrderName, String name) throws CloudException, IOException, IllegalArgumentException { + public CertificateOrderCertificateInner getCertificate(String resourceGroupName, String certificateOrderName, String name) { return getCertificateWithServiceResponseAsync(resourceGroupName, certificateOrderName, name).toBlocking().single().getBody(); } @@ -235,12 +231,9 @@ private ServiceResponse getCertificateDelegate * @param certificateOrderName Certificate name * @param name Certificate name * @param keyVaultCertificate Key Vault secret csm Id - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOrderCertificateInner object if successful. */ - public CertificateOrderCertificateInner createOrUpdateCertificate(String resourceGroupName, String certificateOrderName, String name, CertificateOrderCertificateInner keyVaultCertificate) throws CloudException, IOException, IllegalArgumentException { + public CertificateOrderCertificateInner createOrUpdateCertificate(String resourceGroupName, String certificateOrderName, String name, CertificateOrderCertificateInner keyVaultCertificate) { return createOrUpdateCertificateWithServiceResponseAsync(resourceGroupName, certificateOrderName, name, keyVaultCertificate).toBlocking().single().getBody(); } @@ -332,12 +325,9 @@ private ServiceResponse createOrUpdateCertific * @param resourceGroupName Azure resource group name * @param certificateOrderName Certificate name * @param name Certificate name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteCertificate(String resourceGroupName, String certificateOrderName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteCertificate(String resourceGroupName, String certificateOrderName, String name) { return deleteCertificateWithServiceResponseAsync(resourceGroupName, certificateOrderName, name).toBlocking().single().getBody(); } @@ -423,12 +413,9 @@ private ServiceResponse deleteCertificateDelegate(Response * @param certificateOrderName Certificate name * @param name Certificate name * @param keyVaultCertificate Key Vault secret csm Id - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOrderCertificateInner object if successful. */ - public CertificateOrderCertificateInner updateCertificate(String resourceGroupName, String certificateOrderName, String name, CertificateOrderCertificateInner keyVaultCertificate) throws CloudException, IOException, IllegalArgumentException { + public CertificateOrderCertificateInner updateCertificate(String resourceGroupName, String certificateOrderName, String name, CertificateOrderCertificateInner keyVaultCertificate) { return updateCertificateWithServiceResponseAsync(resourceGroupName, certificateOrderName, name, keyVaultCertificate).toBlocking().single().getBody(); } @@ -519,12 +506,9 @@ private ServiceResponse updateCertificateDeleg * * @param resourceGroupName Azure resource group name * @param name Certificate name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOrderInner object if successful. */ - public CertificateOrderInner getCertificateOrder(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public CertificateOrderInner getCertificateOrder(String resourceGroupName, String name) { return getCertificateOrderWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -603,12 +587,9 @@ private ServiceResponse getCertificateOrderDelegate(Respo * @param resourceGroupName Azure resource group name * @param name Certificate name * @param certificateDistinguishedName Distinguished name to be used for purchasing certificate - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOrderInner object if successful. */ - public CertificateOrderInner createOrUpdateCertificateOrder(String resourceGroupName, String name, CertificateOrderInner certificateDistinguishedName) throws CloudException, IOException, IllegalArgumentException { + public CertificateOrderInner createOrUpdateCertificateOrder(String resourceGroupName, String name, CertificateOrderInner certificateDistinguishedName) { return createOrUpdateCertificateOrderWithServiceResponseAsync(resourceGroupName, name, certificateDistinguishedName).toBlocking().single().getBody(); } @@ -693,12 +674,9 @@ private ServiceResponse createOrUpdateCertificateOrderDel * * @param resourceGroupName Azure resource group name * @param name Certificate name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteCertificateOrder(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteCertificateOrder(String resourceGroupName, String name) { return deleteCertificateOrderWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -777,12 +755,9 @@ private ServiceResponse deleteCertificateOrderDelegate(Response updateCertificateOrderDelegate(Re * Get certificate orders in a resource group. * * @param resourceGroupName Azure resource group name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateOrderInner> object if successful. */ - public PagedList getCertificateOrders(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificateOrders(final String resourceGroupName) { ServiceResponse> response = getCertificateOrdersSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -978,16 +950,13 @@ private ServiceResponse> getCertificateOrdersDel * * @param resourceGroupName Azure resource group name * @param certificateOrderName Certificate name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateOrderCertificateInner> object if successful. */ - public PagedList getCertificates(final String resourceGroupName, final String certificateOrderName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String resourceGroupName, final String certificateOrderName) { ServiceResponse> response = getCertificatesSinglePageAsync(resourceGroupName, certificateOrderName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1098,12 +1067,9 @@ private ServiceResponse> getCertifica * @param resourceGroupName Azure resource group name * @param name Certificate name * @param reissueCertificateOrderRequest Reissue parameters - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object reissueCertificateOrder(String resourceGroupName, String name, ReissueCertificateOrderRequestInner reissueCertificateOrderRequest) throws CloudException, IOException, IllegalArgumentException { + public Object reissueCertificateOrder(String resourceGroupName, String name, ReissueCertificateOrderRequestInner reissueCertificateOrderRequest) { return reissueCertificateOrderWithServiceResponseAsync(resourceGroupName, name, reissueCertificateOrderRequest).toBlocking().single().getBody(); } @@ -1189,12 +1155,9 @@ private ServiceResponse reissueCertificateOrderDelegate(Response renewCertificateOrderDelegate(Response retrieveCertificateActions(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public List retrieveCertificateActions(String resourceGroupName, String name) { return retrieveCertificateActionsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1362,12 +1322,9 @@ private ServiceResponse> retrieveCertificateAc * * @param resourceGroupName Azure resource group name * @param name Certificate order name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateEmailInner> object if successful. */ - public List retrieveCertificateEmailHistory(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public List retrieveCertificateEmailHistory(String resourceGroupName, String name) { return retrieveCertificateEmailHistoryWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1445,12 +1402,9 @@ private ServiceResponse> retrieveCertificateEmailHis * * @param resourceGroupName Azure resource group name * @param name Certificate order name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object resendCertificateEmail(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object resendCertificateEmail(String resourceGroupName, String name) { return resendCertificateEmailWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1528,12 +1482,9 @@ private ServiceResponse resendCertificateEmailDelegate(Response verifyDomainOwnershipDelegate(Response getCertificateOrdersNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificateOrdersNext(final String nextPageLink) { ServiceResponse> response = getCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1716,16 +1664,13 @@ private ServiceResponse> getCertificateOrdersNex * List all certificates associated with a certificate order (only one certificate can be associated with an order at a time). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateOrderCertificateInner> object if successful. */ - public PagedList getCertificatesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificatesNext(final String nextPageLink) { ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificatesInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificatesInner.java index 621783bc44e5b..3bb4718d73733 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificatesInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/CertificatesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -113,16 +112,13 @@ interface CertificatesService { * Get certificates for a subscription in the specified resource group. * * @param resourceGroupName Name of the resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateInner> object if successful. */ - public PagedList getCertificates(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String resourceGroupName) { ServiceResponse> response = getCertificatesSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -225,12 +221,9 @@ private ServiceResponse> getCertificatesDelegate(Resp * * @param resourceGroupName Name of the resource group * @param name Name of the certificate. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateInner object if successful. */ - public CertificateInner getCertificate(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public CertificateInner getCertificate(String resourceGroupName, String name) { return getCertificateWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -309,12 +302,9 @@ private ServiceResponse getCertificateDelegate(Response createOrUpdateCertificateDelegate(Resp * * @param resourceGroupName Name of the resource group * @param name Name of the certificate to be deleted. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteCertificate(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteCertificate(String resourceGroupName, String name) { return deleteCertificateWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -483,12 +470,9 @@ private ServiceResponse deleteCertificateDelegate(Response * @param resourceGroupName Name of the resource group * @param name Name of the certificate. * @param certificateEnvelope Details of certificate if it exists already. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateInner object if successful. */ - public CertificateInner updateCertificate(String resourceGroupName, String name, CertificateInner certificateEnvelope) throws CloudException, IOException, IllegalArgumentException { + public CertificateInner updateCertificate(String resourceGroupName, String name, CertificateInner certificateEnvelope) { return updateCertificateWithServiceResponseAsync(resourceGroupName, name, certificateEnvelope).toBlocking().single().getBody(); } @@ -572,12 +556,9 @@ private ServiceResponse updateCertificateDelegate(Response getCsrs(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public List getCsrs(String resourceGroupName) { return getCsrsWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); } @@ -649,12 +630,9 @@ private ServiceResponse> getCsrsDelegate(Response r * * @param resourceGroupName Name of the resource group * @param name Name of the certificate. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CsrInner object if successful. */ - public CsrInner getCsr(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public CsrInner getCsr(String resourceGroupName, String name) { return getCsrWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -733,12 +711,9 @@ private ServiceResponse getCsrDelegate(Response response * @param resourceGroupName Name of the resource group * @param name Name of the certificate. * @param csrEnvelope Details of certificate signing request if it exists already. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CsrInner object if successful. */ - public CsrInner createOrUpdateCsr(String resourceGroupName, String name, CsrInner csrEnvelope) throws CloudException, IOException, IllegalArgumentException { + public CsrInner createOrUpdateCsr(String resourceGroupName, String name, CsrInner csrEnvelope) { return createOrUpdateCsrWithServiceResponseAsync(resourceGroupName, name, csrEnvelope).toBlocking().single().getBody(); } @@ -823,12 +798,9 @@ private ServiceResponse createOrUpdateCsrDelegate(Response deleteCsrDelegate(Response respons * @param resourceGroupName Name of the resource group * @param name Name of the certificate. * @param csrEnvelope Details of certificate signing request if it exists already. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CsrInner object if successful. */ - public CsrInner updateCsr(String resourceGroupName, String name, CsrInner csrEnvelope) throws CloudException, IOException, IllegalArgumentException { + public CsrInner updateCsr(String resourceGroupName, String name, CsrInner csrEnvelope) { return updateCsrWithServiceResponseAsync(resourceGroupName, name, csrEnvelope).toBlocking().single().getBody(); } @@ -996,16 +965,13 @@ private ServiceResponse updateCsrDelegate(Response respo * Get certificates for a subscription in the specified resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateInner> object if successful. */ - public PagedList getCertificatesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getCertificatesNext(final String nextPageLink) { ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ClassicMobileServicesInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ClassicMobileServicesInner.java index c896462250058..a42a748e3ee0b 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ClassicMobileServicesInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ClassicMobileServicesInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -81,16 +80,13 @@ interface ClassicMobileServicesService { * Get all mobile services in a resource group. * * @param resourceGroupName Name of resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ClassicMobileServiceInner> object if successful. */ - public PagedList getClassicMobileServices(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getClassicMobileServices(final String resourceGroupName) { ServiceResponse> response = getClassicMobileServicesSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -193,12 +189,9 @@ private ServiceResponse> getClassicMobileSer * * @param resourceGroupName Name of resource group * @param name Name of mobile service - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ClassicMobileServiceInner object if successful. */ - public ClassicMobileServiceInner getClassicMobileService(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public ClassicMobileServiceInner getClassicMobileService(String resourceGroupName, String name) { return getClassicMobileServiceWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -276,12 +269,9 @@ private ServiceResponse getClassicMobileServiceDelega * * @param resourceGroupName Name of resource group * @param name Name of mobile service - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteClassicMobileService(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteClassicMobileService(String resourceGroupName, String name) { return deleteClassicMobileServiceWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -358,16 +348,13 @@ private ServiceResponse deleteClassicMobileServiceDelegate(Response getClassicMobileServicesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getClassicMobileServicesNext(final String nextPageLink) { ServiceResponse> response = getClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/DomainsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/DomainsInner.java index e803331013350..b2ee42f851034 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/DomainsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/DomainsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -97,16 +96,13 @@ interface DomainsService { * Lists domains under a resource group. * * @param resourceGroupName Name of the resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DomainInner> object if successful. */ - public PagedList getDomains(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDomains(final String resourceGroupName) { ServiceResponse> response = getDomainsSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -209,12 +205,9 @@ private ServiceResponse> getDomainsDelegate(Response getDomainDelegate(Response re * @param resourceGroupName &gt;Name of the resource group * @param domainName Name of the domain * @param domain Domain registration information - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DomainInner object if successful. */ - public DomainInner createOrUpdateDomain(String resourceGroupName, String domainName, DomainInner domain) throws CloudException, IOException, IllegalArgumentException { + public DomainInner createOrUpdateDomain(String resourceGroupName, String domainName, DomainInner domain) { return createOrUpdateDomainWithServiceResponseAsync(resourceGroupName, domainName, domain).toBlocking().single().getBody(); } @@ -384,12 +374,9 @@ private ServiceResponse createOrUpdateDomainDelegate(Response> call(Response response) * @param resourceGroupName Name of the resource group * @param domainName Name of the domain * @param forceHardDeleteDomain If true then the domain will be deleted immediately instead of after 24 hours - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteDomain(String resourceGroupName, String domainName, Boolean forceHardDeleteDomain) throws CloudException, IOException, IllegalArgumentException { + public Object deleteDomain(String resourceGroupName, String domainName, Boolean forceHardDeleteDomain) { return deleteDomainWithServiceResponseAsync(resourceGroupName, domainName, forceHardDeleteDomain).toBlocking().single().getBody(); } @@ -549,12 +533,9 @@ private ServiceResponse deleteDomainDelegate(Response resp * @param resourceGroupName &gt;Name of the resource group * @param domainName Name of the domain * @param domain Domain registration information - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DomainInner object if successful. */ - public DomainInner updateDomain(String resourceGroupName, String domainName, DomainInner domain) throws CloudException, IOException, IllegalArgumentException { + public DomainInner updateDomain(String resourceGroupName, String domainName, DomainInner domain) { return updateDomainWithServiceResponseAsync(resourceGroupName, domainName, domain).toBlocking().single().getBody(); } @@ -641,12 +622,9 @@ private ServiceResponse updateDomainDelegate(Response * @param resourceGroupName Name of the resource group * @param domainName Name of the domain * @param operationId Domain purchase operation Id - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DomainInner object if successful. */ - public DomainInner getDomainOperation(String resourceGroupName, String domainName, String operationId) throws CloudException, IOException, IllegalArgumentException { + public DomainInner getDomainOperation(String resourceGroupName, String domainName, String operationId) { return getDomainOperationWithServiceResponseAsync(resourceGroupName, domainName, operationId).toBlocking().single().getBody(); } @@ -731,16 +709,13 @@ private ServiceResponse getDomainOperationDelegate(Response getDomainsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDomainsNext(final String nextPageLink) { ServiceResponse> response = getDomainsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalCertificateOrdersInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalCertificateOrdersInner.java index b3fb022c9eb5a..9f256a3dd2536 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalCertificateOrdersInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalCertificateOrdersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -78,16 +77,13 @@ interface GlobalCertificateOrdersService { /** * Lists all domains in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateOrderInner> object if successful. */ - public PagedList getAllCertificateOrders() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllCertificateOrders() { ServiceResponse> response = getAllCertificateOrdersSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -182,12 +178,9 @@ private ServiceResponse> getAllCertificateOrders * Validate certificate purchase information. * * @param certificateOrder Certificate order - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object validateCertificatePurchaseInformation(CertificateOrderInner certificateOrder) throws CloudException, IOException, IllegalArgumentException { + public Object validateCertificatePurchaseInformation(CertificateOrderInner certificateOrder) { return validateCertificatePurchaseInformationWithServiceResponseAsync(certificateOrder).toBlocking().single().getBody(); } @@ -259,16 +252,13 @@ private ServiceResponse validateCertificatePurchaseInformationDelegate(R * Lists all domains in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateOrderInner> object if successful. */ - public PagedList getAllCertificateOrdersNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllCertificateOrdersNext(final String nextPageLink) { ServiceResponse> response = getAllCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllCertificateOrdersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalDomainRegistrationsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalDomainRegistrationsInner.java index 9289a98ccf237..c8a1e17a8bf27 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalDomainRegistrationsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalDomainRegistrationsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -94,16 +93,13 @@ interface GlobalDomainRegistrationsService { /** * Lists all domains in a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DomainInner> object if successful. */ - public PagedList getAllDomains() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllDomains() { ServiceResponse> response = getAllDomainsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -197,12 +193,9 @@ private ServiceResponse> getAllDomainsDelegate(Response getDomainControlCent * Validates domain registration information. * * @param domainRegistrationInput Domain registration information - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object validateDomainPurchaseInformation(DomainRegistrationInputInner domainRegistrationInput) throws CloudException, IOException, IllegalArgumentException { + public Object validateDomainPurchaseInformation(DomainRegistrationInputInner domainRegistrationInput) { return validateDomainPurchaseInformationWithServiceResponseAsync(domainRegistrationInput).toBlocking().single().getBody(); } @@ -343,12 +333,9 @@ private ServiceResponse validateDomainPurchaseInformationDelegate(Respon /** * Checks if a domain is available for registration. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DomainAvailablilityCheckResultInner object if successful. */ - public DomainAvailablilityCheckResultInner checkDomainAvailability() throws CloudException, IOException, IllegalArgumentException { + public DomainAvailablilityCheckResultInner checkDomainAvailability() { return checkDomainAvailabilityWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -409,12 +396,9 @@ public Observable> call(Res * Checks if a domain is available for registration. * * @param name Name of the object - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DomainAvailablilityCheckResultInner object if successful. */ - public DomainAvailablilityCheckResultInner checkDomainAvailability(String name) throws CloudException, IOException, IllegalArgumentException { + public DomainAvailablilityCheckResultInner checkDomainAvailability(String name) { return checkDomainAvailabilityWithServiceResponseAsync(name).toBlocking().single().getBody(); } @@ -484,16 +468,13 @@ private ServiceResponse checkDomainAvailabi * Lists domain recommendations based on keywords. * * @param parameters Domain recommendation search parameters - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NameIdentifierInner> object if successful. */ - public PagedList listDomainRecommendations(final DomainRecommendationSearchParametersInner parameters) throws CloudException, IOException, IllegalArgumentException { + public PagedList listDomainRecommendations(final DomainRecommendationSearchParametersInner parameters) { ServiceResponse> response = listDomainRecommendationsSinglePageAsync(parameters).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listDomainRecommendationsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -596,16 +577,13 @@ private ServiceResponse> listDomainRecommendations * Lists all domains in a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DomainInner> object if successful. */ - public PagedList getAllDomainsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllDomainsNext(final String nextPageLink) { ServiceResponse> response = getAllDomainsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -702,16 +680,13 @@ private ServiceResponse> getAllDomainsNextDelegate(Respons * Lists domain recommendations based on keywords. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<NameIdentifierInner> object if successful. */ - public PagedList listDomainRecommendationsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listDomainRecommendationsNext(final String nextPageLink) { ServiceResponse> response = listDomainRecommendationsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listDomainRecommendationsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalResourceGroupsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalResourceGroupsInner.java index 06042400c71d6..4e146a8fa51e7 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalResourceGroupsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalResourceGroupsInner.java @@ -64,11 +64,8 @@ interface GlobalResourceGroupsService { * * @param resourceGroupName the String value * @param moveResourceEnvelope the CsmMoveResourceEnvelopeInner value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters */ - public void moveResources(String resourceGroupName, CsmMoveResourceEnvelopeInner moveResourceEnvelope) throws CloudException, IOException, IllegalArgumentException { + public void moveResources(String resourceGroupName, CsmMoveResourceEnvelopeInner moveResourceEnvelope) { moveResourcesWithServiceResponseAsync(resourceGroupName, moveResourceEnvelope).toBlocking().single().getBody(); } diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalsInner.java index fdbb078ce1d99..a0be88ef7bd9c 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/GlobalsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -147,12 +146,9 @@ interface GlobalsService { /** * Gets publishing credentials for the subscription owner. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner getSubscriptionPublishingCredentials() throws CloudException, IOException, IllegalArgumentException { + public UserInner getSubscriptionPublishingCredentials() { return getSubscriptionPublishingCredentialsWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -217,12 +213,9 @@ private ServiceResponse getSubscriptionPublishingCredentialsDelegate( * Updates publishing credentials for the subscription owner. * * @param requestMessage requestMessage with new publishing credentials - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner updateSubscriptionPublishingCredentials(UserInner requestMessage) throws CloudException, IOException, IllegalArgumentException { + public UserInner updateSubscriptionPublishingCredentials(UserInner requestMessage) { return updateSubscriptionPublishingCredentialsWithServiceResponseAsync(requestMessage).toBlocking().single().getBody(); } @@ -293,16 +286,13 @@ private ServiceResponse updateSubscriptionPublishingCredentialsDelega /** * Gets list of available geo regions. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<GeoRegionInner> object if successful. */ - public PagedList getSubscriptionGeoRegions() throws CloudException, IOException, IllegalArgumentException { + public PagedList getSubscriptionGeoRegions() { ServiceResponse> response = getSubscriptionGeoRegionsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSubscriptionGeoRegionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -391,16 +381,13 @@ public Observable>> call(Response getSubscriptionGeoRegions(final String sku) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSubscriptionGeoRegions(final String sku) { ServiceResponse> response = getSubscriptionGeoRegionsSinglePageAsync(sku).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSubscriptionGeoRegionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -498,16 +485,13 @@ private ServiceResponse> getSubscriptionGeoRegionsDeleg /** * Get all certificates for a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateInner> object if successful. */ - public PagedList getAllCertificates() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllCertificates() { ServiceResponse> response = getAllCertificatesSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -601,16 +585,13 @@ private ServiceResponse> getAllCertificatesDelegate(R /** * Gets all App Service Plans for a subcription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getAllServerFarms() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllServerFarms() { ServiceResponse> response = getAllServerFarmsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -700,16 +681,13 @@ public Observable>> call(Respon * * @param detailed False to return a subset of App Service Plan properties, true to return all of the properties. Retrieval of all properties may increase the API latency. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getAllServerFarms(final Boolean detailed) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllServerFarms(final Boolean detailed) { ServiceResponse> response = getAllServerFarmsSinglePageAsync(detailed).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -811,16 +789,13 @@ private ServiceResponse> getAllServerFarmsD /** * Gets all Web Apps for a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getAllSites() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllSites() { ServiceResponse> response = getAllSitesSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -914,16 +889,13 @@ private ServiceResponse> getAllSitesDelegate(Response getAllHostingEnvironments() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllHostingEnvironments() { ServiceResponse> response = getAllHostingEnvironmentsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1017,16 +989,13 @@ private ServiceResponse> getAllHostingEnvironm /** * Gets all managed hosting environments for a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ManagedHostingEnvironmentInner> object if successful. */ - public PagedList getAllManagedHostingEnvironments() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllManagedHostingEnvironments() { ServiceResponse> response = getAllManagedHostingEnvironmentsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1120,16 +1089,13 @@ private ServiceResponse> getAllManagedH /** * Gets all mobile services for a subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ClassicMobileServiceInner> object if successful. */ - public PagedList getAllClassicMobileServices() throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllClassicMobileServices() { ServiceResponse> response = getAllClassicMobileServicesSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1223,12 +1189,9 @@ private ServiceResponse> getAllClassicMobile /** * List premier add on offers. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object listPremierAddOnOffers() throws CloudException, IOException, IllegalArgumentException { + public Object listPremierAddOnOffers() { return listPremierAddOnOffersWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -1293,12 +1256,9 @@ private ServiceResponse listPremierAddOnOffersDelegate(Response isHostingEnvironmentNameAvailableDelegate(Respon * Whether hosting environment name is available. * * @param name Hosting environment name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object isHostingEnvironmentWithLegacyNameAvailable(String name) throws CloudException, IOException, IllegalArgumentException { + public Object isHostingEnvironmentWithLegacyNameAvailable(String name) { return isHostingEnvironmentWithLegacyNameAvailableWithServiceResponseAsync(name).toBlocking().single().getBody(); } @@ -1445,12 +1402,9 @@ private ServiceResponse isHostingEnvironmentWithLegacyNameAvailableDeleg * Check if resource name is available. * * @param request Name availability request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ResourceNameAvailabilityInner object if successful. */ - public ResourceNameAvailabilityInner checkNameAvailability(ResourceNameAvailabilityRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public ResourceNameAvailabilityInner checkNameAvailability(ResourceNameAvailabilityRequestInner request) { return checkNameAvailabilityWithServiceResponseAsync(request).toBlocking().single().getBody(); } @@ -1522,16 +1476,13 @@ private ServiceResponse checkNameAvailabilityDele * Gets list of available geo regions. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<GeoRegionInner> object if successful. */ - public PagedList getSubscriptionGeoRegionsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSubscriptionGeoRegionsNext(final String nextPageLink) { ServiceResponse> response = getSubscriptionGeoRegionsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSubscriptionGeoRegionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1628,16 +1579,13 @@ private ServiceResponse> getSubscriptionGeoRegionsNextD * Get all certificates for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateInner> object if successful. */ - public PagedList getAllCertificatesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllCertificatesNext(final String nextPageLink) { ServiceResponse> response = getAllCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1734,16 +1682,13 @@ private ServiceResponse> getAllCertificatesNextDelega * Gets all App Service Plans for a subcription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getAllServerFarmsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllServerFarmsNext(final String nextPageLink) { ServiceResponse> response = getAllServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1840,16 +1785,13 @@ private ServiceResponse> getAllServerFarmsN * Gets all Web Apps for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getAllSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllSitesNext(final String nextPageLink) { ServiceResponse> response = getAllSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1946,16 +1888,13 @@ private ServiceResponse> getAllSitesNextDelegate(Response getAllHostingEnvironmentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllHostingEnvironmentsNext(final String nextPageLink) { ServiceResponse> response = getAllHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2052,16 +1991,13 @@ private ServiceResponse> getAllHostingEnvironm * Gets all managed hosting environments for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ManagedHostingEnvironmentInner> object if successful. */ - public PagedList getAllManagedHostingEnvironmentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllManagedHostingEnvironmentsNext(final String nextPageLink) { ServiceResponse> response = getAllManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2158,16 +2094,13 @@ private ServiceResponse> getAllManagedH * Gets all mobile services for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ClassicMobileServiceInner> object if successful. */ - public PagedList getAllClassicMobileServicesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getAllClassicMobileServicesNext(final String nextPageLink) { ServiceResponse> response = getAllClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getAllClassicMobileServicesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/HostingEnvironmentsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/HostingEnvironmentsInner.java index 1a59eb2dcdfbe..dbe31b3792bff 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/HostingEnvironmentsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/HostingEnvironmentsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -327,12 +326,9 @@ interface HostingEnvironmentsService { * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostingEnvironmentInner object if successful. */ - public HostingEnvironmentInner getHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public HostingEnvironmentInner getHostingEnvironment(String resourceGroupName, String name) { return getHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -411,13 +407,9 @@ private ServiceResponse getHostingEnvironmentDelegate(R * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param hostingEnvironmentEnvelope Properties of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the HostingEnvironmentInner object if successful. */ - public HostingEnvironmentInner createOrUpdateHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner hostingEnvironmentEnvelope) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public HostingEnvironmentInner createOrUpdateHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner hostingEnvironmentEnvelope) { return createOrUpdateHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, hostingEnvironmentEnvelope).toBlocking().last().getBody(); } @@ -486,12 +478,9 @@ public Observable> createOrUpdateHostin * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param hostingEnvironmentEnvelope Properties of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostingEnvironmentInner object if successful. */ - public HostingEnvironmentInner beginCreateOrUpdateHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner hostingEnvironmentEnvelope) throws CloudException, IOException, IllegalArgumentException { + public HostingEnvironmentInner beginCreateOrUpdateHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner hostingEnvironmentEnvelope) { return beginCreateOrUpdateHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, hostingEnvironmentEnvelope).toBlocking().single().getBody(); } @@ -580,13 +569,9 @@ private ServiceResponse beginCreateOrUpdateHostingEnvir * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the Object object if successful. */ - public Object deleteHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public Object deleteHostingEnvironment(String resourceGroupName, String name) { return deleteHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().last().getBody(); } @@ -648,13 +633,9 @@ public Observable> deleteHostingEnvironmentWithServiceRe * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param forceDelete Delete even if the hostingEnvironment (App Service Environment) contains resources - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the Object object if successful. */ - public Object deleteHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public Object deleteHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) { return deleteHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, forceDelete).toBlocking().last().getBody(); } @@ -718,12 +699,9 @@ public Observable> deleteHostingEnvironmentWithServiceRe * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginDeleteHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object beginDeleteHostingEnvironment(String resourceGroupName, String name) { return beginDeleteHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -796,12 +774,9 @@ public Observable> call(Response response) * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param forceDelete Delete even if the hostingEnvironment (App Service Environment) contains resources - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginDeleteHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) throws CloudException, IOException, IllegalArgumentException { + public Object beginDeleteHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) { return beginDeleteHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, forceDelete).toBlocking().single().getBody(); } @@ -886,12 +861,9 @@ private ServiceResponse beginDeleteHostingEnvironmentDelegate(Response getHostingEnvironmentDiagnostics(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public List getHostingEnvironmentDiagnostics(String resourceGroupName, String name) { return getHostingEnvironmentDiagnosticsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -970,12 +942,9 @@ private ServiceResponse> getHostingEnvi * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param diagnosticsName Name of the diagnostics - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostingEnvironmentDiagnosticsInner object if successful. */ - public HostingEnvironmentDiagnosticsInner getHostingEnvironmentDiagnosticsItem(String resourceGroupName, String name, String diagnosticsName) throws CloudException, IOException, IllegalArgumentException { + public HostingEnvironmentDiagnosticsInner getHostingEnvironmentDiagnosticsItem(String resourceGroupName, String name, String diagnosticsName) { return getHostingEnvironmentDiagnosticsItemWithServiceResponseAsync(resourceGroupName, name, diagnosticsName).toBlocking().single().getBody(); } @@ -1059,16 +1028,13 @@ private ServiceResponse getHostingEnvironmen * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<StampCapacityInner> object if successful. */ - public PagedList getHostingEnvironmentCapacities(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentCapacities(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentCapacitiesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentCapacitiesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1178,12 +1144,9 @@ private ServiceResponse> getHostingEnvironmentCapac * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AddressResponseInner object if successful. */ - public AddressResponseInner getHostingEnvironmentVips(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public AddressResponseInner getHostingEnvironmentVips(String resourceGroupName, String name) { return getHostingEnvironmentVipsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1260,16 +1223,13 @@ private ServiceResponse getHostingEnvironmentVipsDelegate( * Get all hostingEnvironments (App Service Environments) in a resource group. * * @param resourceGroupName Name of resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostingEnvironmentInner> object if successful. */ - public PagedList getHostingEnvironments(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironments(final String resourceGroupName) { ServiceResponse> response = getHostingEnvironmentsSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1372,12 +1332,9 @@ private ServiceResponse> getHostingEnvironment * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object rebootHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object rebootHostingEnvironment(String resourceGroupName, String name) { return rebootHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1458,12 +1415,9 @@ private ServiceResponse rebootHostingEnvironmentDelegate(Response getHostingEnvironmentOperationsDelegate(Response * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param operationId operation identifier GUID - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getHostingEnvironmentOperation(String resourceGroupName, String name, String operationId) throws CloudException, IOException, IllegalArgumentException { + public Object getHostingEnvironmentOperation(String resourceGroupName, String name, String operationId) { return getHostingEnvironmentOperationWithServiceResponseAsync(resourceGroupName, name, operationId).toBlocking().single().getBody(); } @@ -1634,16 +1585,13 @@ private ServiceResponse getHostingEnvironmentOperationDelegate(Response< * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentMetrics(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMetrics(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentMetricsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1750,16 +1698,13 @@ public Observable>> call(Response getHostingEnvironmentMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) { ServiceResponse> response = getHostingEnvironmentMetricsSinglePageAsync(resourceGroupName, name, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1877,12 +1822,9 @@ private ServiceResponse> getHostingEnvironmentMetr * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the MetricDefinitionInner object if successful. */ - public MetricDefinitionInner getHostingEnvironmentMetricDefinitions(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public MetricDefinitionInner getHostingEnvironmentMetricDefinitions(String resourceGroupName, String name) { return getHostingEnvironmentMetricDefinitionsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1960,16 +1902,13 @@ private ServiceResponse getHostingEnvironmentMetricDefini * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getHostingEnvironmentUsages(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentUsages(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentUsagesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2074,16 +2013,13 @@ public Observable>> call(Response getHostingEnvironmentUsages(final String resourceGroupName, final String name, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentUsages(final String resourceGroupName, final String name, final String filter) { ServiceResponse> response = getHostingEnvironmentUsagesSinglePageAsync(resourceGroupName, name, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2197,16 +2133,13 @@ private ServiceResponse> getHostingEnvironmentUsage * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleMetrics(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleMetrics(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentMultiRoleMetricsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2319,16 +2252,13 @@ public Observable>> call(Response getHostingEnvironmentMultiRoleMetrics(final String resourceGroupName, final String name, final String startTime, final String endTime, final String timeGrain, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleMetrics(final String resourceGroupName, final String name, final String startTime, final String endTime, final String timeGrain, final Boolean details, final String filter) { ServiceResponse> response = getHostingEnvironmentMultiRoleMetricsSinglePageAsync(resourceGroupName, name, startTime, endTime, timeGrain, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2459,16 +2389,13 @@ private ServiceResponse> getHostingEnvironmentMult * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerMetrics(final String resourceGroupName, final String name, final String workerPoolName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerMetrics(final String resourceGroupName, final String name, final String workerPoolName) { ServiceResponse> response = getHostingEnvironmentWebWorkerMetricsSinglePageAsync(resourceGroupName, name, workerPoolName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2583,16 +2510,13 @@ public Observable>> call(Response getHostingEnvironmentWebWorkerMetrics(final String resourceGroupName, final String name, final String workerPoolName, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerMetrics(final String resourceGroupName, final String name, final String workerPoolName, final Boolean details, final String filter) { ServiceResponse> response = getHostingEnvironmentWebWorkerMetricsSinglePageAsync(resourceGroupName, name, workerPoolName, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2717,16 +2641,13 @@ private ServiceResponse> getHostingEnvironmentWebW * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleMetricDefinitions(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleMetricDefinitions(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentMultiRoleMetricDefinitionsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2837,16 +2758,13 @@ private ServiceResponse> getHostingEnvironmentMu * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerMetricDefinitions(final String resourceGroupName, final String name, final String workerPoolName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerMetricDefinitions(final String resourceGroupName, final String name, final String workerPoolName) { ServiceResponse> response = getHostingEnvironmentWebWorkerMetricDefinitionsSinglePageAsync(resourceGroupName, name, workerPoolName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2963,16 +2881,13 @@ private ServiceResponse> getHostingEnvironmentWe * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleUsages(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleUsages(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentMultiRoleUsagesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3083,16 +2998,13 @@ private ServiceResponse> getHostingEnvironmentMultiRoleUsag * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerUsages(final String resourceGroupName, final String name, final String workerPoolName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerUsages(final String resourceGroupName, final String name, final String workerPoolName) { ServiceResponse> response = getHostingEnvironmentWebWorkerUsagesSinglePageAsync(resourceGroupName, name, workerPoolName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3209,16 +3121,13 @@ private ServiceResponse> getHostingEnvironmentWebWorkerUsag * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getHostingEnvironmentSites(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentSites(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentSitesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3323,16 +3232,13 @@ public Observable>> call(Response * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param propertiesToInclude Comma separated list of site properties to include - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getHostingEnvironmentSites(final String resourceGroupName, final String name, final String propertiesToInclude) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentSites(final String resourceGroupName, final String name, final String propertiesToInclude) { ServiceResponse> response = getHostingEnvironmentSitesSinglePageAsync(resourceGroupName, name, propertiesToInclude).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3446,16 +3352,13 @@ private ServiceResponse> getHostingEnvironmentSitesDelegate( * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getHostingEnvironmentWebHostingPlans(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebHostingPlans(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentWebHostingPlansSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3565,16 +3468,13 @@ private ServiceResponse> getHostingEnvironm * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getHostingEnvironmentServerFarms(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentServerFarms(final String resourceGroupName, final String name) { ServiceResponse> response = getHostingEnvironmentServerFarmsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3684,16 +3584,13 @@ private ServiceResponse> getHostingEnvironm * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<WorkerPoolInner> object if successful. */ - public PagedList getMultiRolePools(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getMultiRolePools(final String resourceGroupName, final String name) { ServiceResponse> response = getMultiRolePoolsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getMultiRolePoolsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3803,12 +3700,9 @@ private ServiceResponse> getMultiRolePoolsDelegate(Res * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the WorkerPoolInner object if successful. */ - public WorkerPoolInner getMultiRolePool(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public WorkerPoolInner getMultiRolePool(String resourceGroupName, String name) { return getMultiRolePoolWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -3887,13 +3781,9 @@ private ServiceResponse getMultiRolePoolDelegate(Response> createOrUpdateMultiRolePoolW * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param multiRolePoolEnvelope Properties of multiRole pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the WorkerPoolInner object if successful. */ - public WorkerPoolInner beginCreateOrUpdateMultiRolePool(String resourceGroupName, String name, WorkerPoolInner multiRolePoolEnvelope) throws CloudException, IOException, IllegalArgumentException { + public WorkerPoolInner beginCreateOrUpdateMultiRolePool(String resourceGroupName, String name, WorkerPoolInner multiRolePoolEnvelope) { return beginCreateOrUpdateMultiRolePoolWithServiceResponseAsync(resourceGroupName, name, multiRolePoolEnvelope).toBlocking().single().getBody(); } @@ -4056,16 +3943,13 @@ private ServiceResponse beginCreateOrUpdateMultiRolePoolDelegat * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SkuInfoInner> object if successful. */ - public PagedList getMultiRolePoolSkus(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getMultiRolePoolSkus(final String resourceGroupName, final String name) { ServiceResponse> response = getMultiRolePoolSkusSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getMultiRolePoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -4175,16 +4059,13 @@ private ServiceResponse> getMultiRolePoolSkusDelegate(Res * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<WorkerPoolInner> object if successful. */ - public PagedList getWorkerPools(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getWorkerPools(final String resourceGroupName, final String name) { ServiceResponse> response = getWorkerPoolsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getWorkerPoolsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -4295,12 +4176,9 @@ private ServiceResponse> getWorkerPoolsDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the WorkerPoolInner object if successful. */ - public WorkerPoolInner getWorkerPool(String resourceGroupName, String name, String workerPoolName) throws CloudException, IOException, IllegalArgumentException { + public WorkerPoolInner getWorkerPool(String resourceGroupName, String name, String workerPoolName) { return getWorkerPoolWithServiceResponseAsync(resourceGroupName, name, workerPoolName).toBlocking().single().getBody(); } @@ -4386,13 +4264,9 @@ private ServiceResponse getWorkerPoolDelegate(Response> createOrUpdateWorkerPoolWith * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool * @param workerPoolEnvelope Properties of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the WorkerPoolInner object if successful. */ - public WorkerPoolInner beginCreateOrUpdateWorkerPool(String resourceGroupName, String name, String workerPoolName, WorkerPoolInner workerPoolEnvelope) throws CloudException, IOException, IllegalArgumentException { + public WorkerPoolInner beginCreateOrUpdateWorkerPool(String resourceGroupName, String name, String workerPoolName, WorkerPoolInner workerPoolEnvelope) { return beginCreateOrUpdateWorkerPoolWithServiceResponseAsync(resourceGroupName, name, workerPoolName, workerPoolEnvelope).toBlocking().single().getBody(); } @@ -4569,16 +4440,13 @@ private ServiceResponse beginCreateOrUpdateWorkerPoolDelegate(R * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SkuInfoInner> object if successful. */ - public PagedList getWorkerPoolSkus(final String resourceGroupName, final String name, final String workerPoolName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getWorkerPoolSkus(final String resourceGroupName, final String name, final String workerPoolName) { ServiceResponse> response = getWorkerPoolSkusSinglePageAsync(resourceGroupName, name, workerPoolName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getWorkerPoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -4697,12 +4565,9 @@ private ServiceResponse> getWorkerPoolSkusDelegate(Respon * @param name Name of hostingEnvironment (App Service Environment) * @param workerPoolName Name of worker pool * @param instance Name of instance in the worker pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getWorkerPoolInstanceMetrics(String resourceGroupName, String name, String workerPoolName, String instance) throws CloudException, IOException, IllegalArgumentException { + public Object getWorkerPoolInstanceMetrics(String resourceGroupName, String name, String workerPoolName, String instance) { return getWorkerPoolInstanceMetricsWithServiceResponseAsync(resourceGroupName, name, workerPoolName, instance).toBlocking().single().getBody(); } @@ -4791,12 +4656,9 @@ public Observable> call(Response response) * @param instance Name of instance in the worker pool * @param details Include instance details * @param filter Return only usages/metrics specified in the filter. Filter conforms to odata syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2') and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain eq duration'[Hour|Minute|Day]'. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getWorkerPoolInstanceMetrics(String resourceGroupName, String name, String workerPoolName, String instance, Boolean details, String filter) throws CloudException, IOException, IllegalArgumentException { + public Object getWorkerPoolInstanceMetrics(String resourceGroupName, String name, String workerPoolName, String instance, Boolean details, String filter) { return getWorkerPoolInstanceMetricsWithServiceResponseAsync(resourceGroupName, name, workerPoolName, instance, details, filter).toBlocking().single().getBody(); } @@ -4894,12 +4756,9 @@ private ServiceResponse getWorkerPoolInstanceMetricsDelegate(Response getWorkerPoolInstanceMetricDefinitionsDelegate(R * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param instance Name of instance in the multiRole pool - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getMultiRolePoolInstanceMetrics(String resourceGroupName, String name, String instance) throws CloudException, IOException, IllegalArgumentException { + public Object getMultiRolePoolInstanceMetrics(String resourceGroupName, String name, String instance) { return getMultiRolePoolInstanceMetricsWithServiceResponseAsync(resourceGroupName, name, instance).toBlocking().single().getBody(); } @@ -5075,12 +4931,9 @@ public Observable> call(Response response) * @param name Name of hostingEnvironment (App Service Environment) * @param instance Name of instance in the multiRole pool * @param details Include instance details - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getMultiRolePoolInstanceMetrics(String resourceGroupName, String name, String instance, Boolean details) throws CloudException, IOException, IllegalArgumentException { + public Object getMultiRolePoolInstanceMetrics(String resourceGroupName, String name, String instance, Boolean details) { return getMultiRolePoolInstanceMetricsWithServiceResponseAsync(resourceGroupName, name, instance, details).toBlocking().single().getBody(); } @@ -5168,12 +5021,9 @@ private ServiceResponse getMultiRolePoolInstanceMetricsDelegate(Response * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) * @param instance Name of instance in the multiRole pool&gt; - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getMultiRolePoolInstanceMetricDefinitions(String resourceGroupName, String name, String instance) throws CloudException, IOException, IllegalArgumentException { + public Object getMultiRolePoolInstanceMetricDefinitions(String resourceGroupName, String name, String instance) { return getMultiRolePoolInstanceMetricDefinitionsWithServiceResponseAsync(resourceGroupName, name, instance).toBlocking().single().getBody(); } @@ -5257,17 +5107,13 @@ private ServiceResponse getMultiRolePoolInstanceMetricDefinitionsDelegat * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the PagedList<SiteInner> object if successful. */ - public PagedList suspendHostingEnvironment(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public PagedList suspendHostingEnvironment(final String resourceGroupName, final String name) { ServiceResponse> response = suspendHostingEnvironmentSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return suspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5378,16 +5224,13 @@ private ServiceResponse> suspendHostingEnvironmentDelegate(R * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList beginSuspendHostingEnvironment(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList beginSuspendHostingEnvironment(final String resourceGroupName, final String name) { ServiceResponse> response = beginSuspendHostingEnvironmentSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return beginSuspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5498,17 +5341,13 @@ private ServiceResponse> beginSuspendHostingEnvironmentDeleg * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the PagedList<SiteInner> object if successful. */ - public PagedList resumeHostingEnvironment(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public PagedList resumeHostingEnvironment(final String resourceGroupName, final String name) { ServiceResponse> response = resumeHostingEnvironmentSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return resumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5619,16 +5458,13 @@ private ServiceResponse> resumeHostingEnvironmentDelegate(Re * * @param resourceGroupName Name of resource group * @param name Name of hostingEnvironment (App Service Environment) - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList beginResumeHostingEnvironment(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList beginResumeHostingEnvironment(final String resourceGroupName, final String name) { ServiceResponse> response = beginResumeHostingEnvironmentSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return beginResumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5738,16 +5574,13 @@ private ServiceResponse> beginResumeHostingEnvironmentDelega * Get used, available, and total worker capacity for hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<StampCapacityInner> object if successful. */ - public PagedList getHostingEnvironmentCapacitiesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentCapacitiesNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentCapacitiesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentCapacitiesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5844,16 +5677,13 @@ private ServiceResponse> getHostingEnvironmentCapac * Get all hostingEnvironments (App Service Environments) in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostingEnvironmentInner> object if successful. */ - public PagedList getHostingEnvironmentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5950,16 +5780,13 @@ private ServiceResponse> getHostingEnvironment * Get global metrics of hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentMetricsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMetricsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentMetricsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6056,16 +5883,13 @@ private ServiceResponse> getHostingEnvironmentMetr * Get global usages of hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getHostingEnvironmentUsagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentUsagesNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentUsagesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6162,16 +5986,13 @@ private ServiceResponse> getHostingEnvironmentUsage * Get metrics for a multiRole pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleMetricsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleMetricsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentMultiRoleMetricsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6268,16 +6089,13 @@ private ServiceResponse> getHostingEnvironmentMult * Get metrics for a worker pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerMetricsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerMetricsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentWebWorkerMetricsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6374,16 +6192,13 @@ private ServiceResponse> getHostingEnvironmentWebW * Get metric definitions for a multiRole pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleMetricDefinitionsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleMetricDefinitionsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentMultiRoleMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6480,16 +6295,13 @@ private ServiceResponse> getHostingEnvironmentMu * Get metric definitions for a worker pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerMetricDefinitionsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerMetricDefinitionsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentWebWorkerMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6586,16 +6398,13 @@ private ServiceResponse> getHostingEnvironmentWe * Get usages for a multiRole pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList getHostingEnvironmentMultiRoleUsagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentMultiRoleUsagesNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentMultiRoleUsagesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentMultiRoleUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6692,16 +6501,13 @@ private ServiceResponse> getHostingEnvironmentMultiRoleUsag * Get usages for a worker pool of a hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<UsageInner> object if successful. */ - public PagedList getHostingEnvironmentWebWorkerUsagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebWorkerUsagesNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentWebWorkerUsagesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebWorkerUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6798,16 +6604,13 @@ private ServiceResponse> getHostingEnvironmentWebWorkerUsag * Get all sites on the hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getHostingEnvironmentSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentSitesNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6904,16 +6707,13 @@ private ServiceResponse> getHostingEnvironmentSitesNextDeleg * Get all serverfarms (App Service Plans) on the hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getHostingEnvironmentWebHostingPlansNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentWebHostingPlansNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7010,16 +6810,13 @@ private ServiceResponse> getHostingEnvironm * Get all serverfarms (App Service Plans) on the hostingEnvironment (App Service Environment). * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getHostingEnvironmentServerFarmsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getHostingEnvironmentServerFarmsNext(final String nextPageLink) { ServiceResponse> response = getHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7116,16 +6913,13 @@ private ServiceResponse> getHostingEnvironm * Get all multi role pools. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<WorkerPoolInner> object if successful. */ - public PagedList getMultiRolePoolsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getMultiRolePoolsNext(final String nextPageLink) { ServiceResponse> response = getMultiRolePoolsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getMultiRolePoolsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7222,16 +7016,13 @@ private ServiceResponse> getMultiRolePoolsNextDelegate * Get available skus for scaling a multiRole pool. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SkuInfoInner> object if successful. */ - public PagedList getMultiRolePoolSkusNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getMultiRolePoolSkusNext(final String nextPageLink) { ServiceResponse> response = getMultiRolePoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getMultiRolePoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7328,16 +7119,13 @@ private ServiceResponse> getMultiRolePoolSkusNextDelegate * Get all worker pools. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<WorkerPoolInner> object if successful. */ - public PagedList getWorkerPoolsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getWorkerPoolsNext(final String nextPageLink) { ServiceResponse> response = getWorkerPoolsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getWorkerPoolsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7434,16 +7222,13 @@ private ServiceResponse> getWorkerPoolsNextDelegate(Re * Get available skus for scaling a worker pool. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SkuInfoInner> object if successful. */ - public PagedList getWorkerPoolSkusNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getWorkerPoolSkusNext(final String nextPageLink) { ServiceResponse> response = getWorkerPoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getWorkerPoolSkusNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7540,17 +7325,13 @@ private ServiceResponse> getWorkerPoolSkusNextDelegate(Re * Suspends the hostingEnvironment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the PagedList<SiteInner> object if successful. */ - public PagedList suspendHostingEnvironmentNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public PagedList suspendHostingEnvironmentNext(final String nextPageLink) { ServiceResponse> response = suspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return suspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7648,16 +7429,13 @@ private ServiceResponse> suspendHostingEnvironmentNextDelega * Suspends the hostingEnvironment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList beginSuspendHostingEnvironmentNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList beginSuspendHostingEnvironmentNext(final String nextPageLink) { ServiceResponse> response = beginSuspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return beginSuspendHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7755,17 +7533,13 @@ private ServiceResponse> beginSuspendHostingEnvironmentNextD * Resumes the hostingEnvironment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the PagedList<SiteInner> object if successful. */ - public PagedList resumeHostingEnvironmentNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public PagedList resumeHostingEnvironmentNext(final String nextPageLink) { ServiceResponse> response = resumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return resumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7863,16 +7637,13 @@ private ServiceResponse> resumeHostingEnvironmentNextDelegat * Resumes the hostingEnvironment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList beginResumeHostingEnvironmentNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList beginResumeHostingEnvironmentNext(final String nextPageLink) { ServiceResponse> response = beginResumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return beginResumeHostingEnvironmentNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ManagedHostingEnvironmentsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ManagedHostingEnvironmentsInner.java index f0b5aca5b6515..2cb7f5a5b23cb 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ManagedHostingEnvironmentsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ManagedHostingEnvironmentsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -129,12 +128,9 @@ interface ManagedHostingEnvironmentsService { * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ManagedHostingEnvironmentInner object if successful. */ - public ManagedHostingEnvironmentInner getManagedHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public ManagedHostingEnvironmentInner getManagedHostingEnvironment(String resourceGroupName, String name) { return getManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -213,13 +209,9 @@ private ServiceResponse getManagedHostingEnviron * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param managedHostingEnvironmentEnvelope Properties of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the HostingEnvironmentInner object if successful. */ - public HostingEnvironmentInner createOrUpdateManagedHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner managedHostingEnvironmentEnvelope) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public HostingEnvironmentInner createOrUpdateManagedHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner managedHostingEnvironmentEnvelope) { return createOrUpdateManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, managedHostingEnvironmentEnvelope).toBlocking().last().getBody(); } @@ -288,12 +280,9 @@ public Observable> createOrUpdateManage * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param managedHostingEnvironmentEnvelope Properties of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostingEnvironmentInner object if successful. */ - public HostingEnvironmentInner beginCreateOrUpdateManagedHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner managedHostingEnvironmentEnvelope) throws CloudException, IOException, IllegalArgumentException { + public HostingEnvironmentInner beginCreateOrUpdateManagedHostingEnvironment(String resourceGroupName, String name, HostingEnvironmentInner managedHostingEnvironmentEnvelope) { return beginCreateOrUpdateManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, managedHostingEnvironmentEnvelope).toBlocking().single().getBody(); } @@ -381,13 +370,9 @@ private ServiceResponse beginCreateOrUpdateManagedHosti * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the Object object if successful. */ - public Object deleteManagedHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public Object deleteManagedHostingEnvironment(String resourceGroupName, String name) { return deleteManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().last().getBody(); } @@ -449,13 +434,9 @@ public Observable> deleteManagedHostingEnvironmentWithSe * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param forceDelete Delete even if the managed hosting environment contains resources - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the Object object if successful. */ - public Object deleteManagedHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public Object deleteManagedHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) { return deleteManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, forceDelete).toBlocking().last().getBody(); } @@ -519,12 +500,9 @@ public Observable> deleteManagedHostingEnvironmentWithSe * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginDeleteManagedHostingEnvironment(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object beginDeleteManagedHostingEnvironment(String resourceGroupName, String name) { return beginDeleteManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -597,12 +575,9 @@ public Observable> call(Response response) * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param forceDelete Delete even if the managed hosting environment contains resources - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginDeleteManagedHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) throws CloudException, IOException, IllegalArgumentException { + public Object beginDeleteManagedHostingEnvironment(String resourceGroupName, String name, Boolean forceDelete) { return beginDeleteManagedHostingEnvironmentWithServiceResponseAsync(resourceGroupName, name, forceDelete).toBlocking().single().getBody(); } @@ -685,16 +660,13 @@ private ServiceResponse beginDeleteManagedHostingEnvironmentDelegate(Res * Get all managed hosting environments in a resource group. * * @param resourceGroupName Name of resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostingEnvironmentInner> object if successful. */ - public PagedList getManagedHostingEnvironments(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironments(final String resourceGroupName) { ServiceResponse> response = getManagedHostingEnvironmentsSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -797,12 +769,9 @@ private ServiceResponse> getManagedHostingEnvi * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the AddressResponseInner object if successful. */ - public AddressResponseInner getManagedHostingEnvironmentVips(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public AddressResponseInner getManagedHostingEnvironmentVips(String resourceGroupName, String name) { return getManagedHostingEnvironmentVipsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -881,12 +850,9 @@ private ServiceResponse getManagedHostingEnvironmentVipsDe * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param operationId operation identifier GUID - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getManagedHostingEnvironmentOperation(String resourceGroupName, String name, String operationId) throws CloudException, IOException, IllegalArgumentException { + public Object getManagedHostingEnvironmentOperation(String resourceGroupName, String name, String operationId) { return getManagedHostingEnvironmentOperationWithServiceResponseAsync(resourceGroupName, name, operationId).toBlocking().single().getBody(); } @@ -973,16 +939,13 @@ private ServiceResponse getManagedHostingEnvironmentOperationDelegate(Re * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getManagedHostingEnvironmentSites(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentSites(final String resourceGroupName, final String name) { ServiceResponse> response = getManagedHostingEnvironmentSitesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1087,16 +1050,13 @@ public Observable>> call(Response * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment * @param propertiesToInclude Comma separated list of site properties to include - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getManagedHostingEnvironmentSites(final String resourceGroupName, final String name, final String propertiesToInclude) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentSites(final String resourceGroupName, final String name, final String propertiesToInclude) { ServiceResponse> response = getManagedHostingEnvironmentSitesSinglePageAsync(resourceGroupName, name, propertiesToInclude).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1210,16 +1170,13 @@ private ServiceResponse> getManagedHostingEnvironmentSitesDe * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getManagedHostingEnvironmentWebHostingPlans(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentWebHostingPlans(final String resourceGroupName, final String name) { ServiceResponse> response = getManagedHostingEnvironmentWebHostingPlansSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1329,16 +1286,13 @@ private ServiceResponse> getManagedHostingE * * @param resourceGroupName Name of resource group * @param name Name of managed hosting environment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getManagedHostingEnvironmentServerFarms(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentServerFarms(final String resourceGroupName, final String name) { ServiceResponse> response = getManagedHostingEnvironmentServerFarmsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1447,16 +1401,13 @@ private ServiceResponse> getManagedHostingE * Get all managed hosting environments in a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostingEnvironmentInner> object if successful. */ - public PagedList getManagedHostingEnvironmentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentsNext(final String nextPageLink) { ServiceResponse> response = getManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1553,16 +1504,13 @@ private ServiceResponse> getManagedHostingEnvi * Get all sites on the managed hosting environment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getManagedHostingEnvironmentSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentSitesNext(final String nextPageLink) { ServiceResponse> response = getManagedHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1659,16 +1607,13 @@ private ServiceResponse> getManagedHostingEnvironmentSitesNe * Get all serverfarms (App Service Plans) on the managed hosting environment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getManagedHostingEnvironmentWebHostingPlansNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentWebHostingPlansNext(final String nextPageLink) { ServiceResponse> response = getManagedHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentWebHostingPlansNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1765,16 +1710,13 @@ private ServiceResponse> getManagedHostingE * Get all serverfarms (App Service Plans) on the managed hosting environment. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getManagedHostingEnvironmentServerFarmsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getManagedHostingEnvironmentServerFarmsNext(final String nextPageLink) { ServiceResponse> response = getManagedHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getManagedHostingEnvironmentServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ProvidersInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ProvidersInner.java index 4a420b36327c8..5d6c56a1e3d86 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ProvidersInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ProvidersInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -90,16 +89,13 @@ interface ProvidersService { /** * Gets the source controls available for Azure websites. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SourceControlInner> object if successful. */ - public PagedList getSourceControls() throws CloudException, IOException, IllegalArgumentException { + public PagedList getSourceControls() { ServiceResponse> response = getSourceControlsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSourceControlsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -191,12 +187,9 @@ private ServiceResponse> getSourceControlsDelegate( * Gets source control token. * * @param sourceControlType Type of source control - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SourceControlInner object if successful. */ - public SourceControlInner getSourceControl(String sourceControlType) throws CloudException, IOException, IllegalArgumentException { + public SourceControlInner getSourceControl(String sourceControlType) { return getSourceControlWithServiceResponseAsync(sourceControlType).toBlocking().single().getBody(); } @@ -265,12 +258,9 @@ private ServiceResponse getSourceControlDelegate(Response updateSourceControlDelegate(Response /** * Gets publishing user. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner getPublishingUser() throws CloudException, IOException, IllegalArgumentException { + public UserInner getPublishingUser() { return getPublishingUserWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -411,12 +398,9 @@ private ServiceResponse getPublishingUserDelegate(Response updatePublishingUserDelegate(Response getSourceControlsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSourceControlsNext(final String nextPageLink) { ServiceResponse> response = getSourceControlsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSourceControlsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/RecommendationsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/RecommendationsInner.java index 95193158d53d4..bb11224023b8e 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/RecommendationsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/RecommendationsInner.java @@ -74,12 +74,9 @@ interface RecommendationsService { /** * Gets a list of recommendations associated with the specified subscription. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<RecommendationInner> object if successful. */ - public List getRecommendationBySubscription() throws CloudException, IOException, IllegalArgumentException { + public List getRecommendationBySubscription() { return getRecommendationBySubscriptionWithServiceResponseAsync().toBlocking().single().getBody(); } @@ -140,12 +137,9 @@ public Observable>> call(Response getRecommendationBySubscription(Boolean featured, String filter) throws CloudException, IOException, IllegalArgumentException { + public List getRecommendationBySubscription(Boolean featured, String filter) { return getRecommendationBySubscriptionWithServiceResponseAsync(featured, filter).toBlocking().single().getBody(); } @@ -218,12 +212,9 @@ private ServiceResponse> getRecommendationBySubscripti * @param resourceGroupName Resource group name * @param siteName Site name * @param name Recommendation rule name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RecommendationRuleInner object if successful. */ - public RecommendationRuleInner getRuleDetailsBySiteName(String resourceGroupName, String siteName, String name) throws CloudException, IOException, IllegalArgumentException { + public RecommendationRuleInner getRuleDetailsBySiteName(String resourceGroupName, String siteName, String name) { return getRuleDetailsBySiteNameWithServiceResponseAsync(resourceGroupName, siteName, name).toBlocking().single().getBody(); } @@ -307,12 +298,9 @@ private ServiceResponse getRuleDetailsBySiteNameDelegat * * @param resourceGroupName Resource group name * @param siteName Site name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<RecommendationInner> object if successful. */ - public List getRecommendedRulesForSite(String resourceGroupName, String siteName) throws CloudException, IOException, IllegalArgumentException { + public List getRecommendedRulesForSite(String resourceGroupName, String siteName) { return getRecommendedRulesForSiteWithServiceResponseAsync(resourceGroupName, siteName).toBlocking().single().getBody(); } @@ -389,12 +377,9 @@ public Observable>> call(Response getRecommendedRulesForSite(String resourceGroupName, String siteName, Boolean featured, String siteSku, Integer numSlots) throws CloudException, IOException, IllegalArgumentException { + public List getRecommendedRulesForSite(String resourceGroupName, String siteName, Boolean featured, String siteSku, Integer numSlots) { return getRecommendedRulesForSiteWithServiceResponseAsync(resourceGroupName, siteName, featured, siteSku, numSlots).toBlocking().single().getBody(); } @@ -481,12 +466,9 @@ private ServiceResponse> getRecommendedRulesForSiteDel * * @param resourceGroupName Resource group name * @param siteName Site name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<RecommendationInner> object if successful. */ - public List getRecommendationHistoryForSite(String resourceGroupName, String siteName) throws CloudException, IOException, IllegalArgumentException { + public List getRecommendationHistoryForSite(String resourceGroupName, String siteName) { return getRecommendationHistoryForSiteWithServiceResponseAsync(resourceGroupName, siteName).toBlocking().single().getBody(); } @@ -561,12 +543,9 @@ public Observable>> call(Response getRecommendationHistoryForSite(String resourceGroupName, String siteName, String startTime, String endTime) throws CloudException, IOException, IllegalArgumentException { + public List getRecommendationHistoryForSite(String resourceGroupName, String siteName, String startTime, String endTime) { return getRecommendationHistoryForSiteWithServiceResponseAsync(resourceGroupName, siteName, startTime, endTime).toBlocking().single().getBody(); } diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ServerFarmsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ServerFarmsInner.java index c7e26dffb26da..cb07a84e5ada6 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ServerFarmsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/ServerFarmsInner.java @@ -16,7 +16,6 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -166,16 +165,13 @@ interface ServerFarmsService { * Gets collection of App Service Plans in a resource group for a given subscription. * * @param resourceGroupName Name of resource group - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getServerFarms(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarms(final String resourceGroupName) { ServiceResponse> response = getServerFarmsSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -278,12 +274,9 @@ private ServiceResponse> getServerFarmsDele * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ServerFarmWithRichSkuInner object if successful. */ - public ServerFarmWithRichSkuInner getServerFarm(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public ServerFarmWithRichSkuInner getServerFarm(String resourceGroupName, String name) { return getServerFarmWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -362,13 +355,9 @@ private ServiceResponse getServerFarmDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of App Service Plan * @param serverFarmEnvelope Details of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ServerFarmWithRichSkuInner object if successful. */ - public ServerFarmWithRichSkuInner createOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ServerFarmWithRichSkuInner createOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope) { return createOrUpdateServerFarmWithServiceResponseAsync(resourceGroupName, name, serverFarmEnvelope).toBlocking().last().getBody(); } @@ -438,13 +427,9 @@ public Observable> createOrUpdateSer * @param name Name of App Service Plan * @param serverFarmEnvelope Details of App Service Plan * @param allowPendingState OBSOLETE: If true, allow pending state for App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the ServerFarmWithRichSkuInner object if successful. */ - public ServerFarmWithRichSkuInner createOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope, Boolean allowPendingState) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public ServerFarmWithRichSkuInner createOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope, Boolean allowPendingState) { return createOrUpdateServerFarmWithServiceResponseAsync(resourceGroupName, name, serverFarmEnvelope, allowPendingState).toBlocking().last().getBody(); } @@ -516,12 +501,9 @@ public Observable> createOrUpdateSer * @param resourceGroupName Name of resource group * @param name Name of App Service Plan * @param serverFarmEnvelope Details of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ServerFarmWithRichSkuInner object if successful. */ - public ServerFarmWithRichSkuInner beginCreateOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope) throws CloudException, IOException, IllegalArgumentException { + public ServerFarmWithRichSkuInner beginCreateOrUpdateServerFarm(String resourceGroupName, String name, ServerFarmWithRichSkuInner serverFarmEnvelope) { return beginCreateOrUpdateServerFarmWithServiceResponseAsync(resourceGroupName, name, serverFarmEnvelope).toBlocking().single().getBody(); } @@ -602,12 +584,9 @@ public Observable> call(Response beginCreateOrUpdateServerFar * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteServerFarm(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteServerFarm(String resourceGroupName, String name) { return deleteServerFarmWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -779,16 +755,13 @@ private ServiceResponse deleteServerFarmDelegate(Response * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getServerFarmMetrics(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmMetrics(final String resourceGroupName, final String name) { ServiceResponse> response = getServerFarmMetricsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -895,16 +868,13 @@ public Observable>> call(Response getServerFarmMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) { ServiceResponse> response = getServerFarmMetricsSinglePageAsync(resourceGroupName, name, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1022,16 +992,13 @@ private ServiceResponse> getServerFarmMetricsDeleg * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getServerFarmMetricDefintions(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmMetricDefintions(final String resourceGroupName, final String name) { ServiceResponse> response = getServerFarmMetricDefintionsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmMetricDefintionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1141,12 +1108,9 @@ private ServiceResponse> getServerFarmMetricDefi * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VnetInfoInner> object if successful. */ - public List getVnetsForServerFarm(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public List getVnetsForServerFarm(String resourceGroupName, String name) { return getVnetsForServerFarmWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -1225,12 +1189,9 @@ private ServiceResponse> getVnetsForServerFarmDelegate(Respo * @param resourceGroupName Name of resource group * @param name Name of App Service Plan * @param vnetName Name of virtual network - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetInfoInner object if successful. */ - public VnetInfoInner getVnetFromServerFarm(String resourceGroupName, String name, String vnetName) throws CloudException, IOException, IllegalArgumentException { + public VnetInfoInner getVnetFromServerFarm(String resourceGroupName, String name, String vnetName) { return getVnetFromServerFarmWithServiceResponseAsync(resourceGroupName, name, vnetName).toBlocking().single().getBody(); } @@ -1316,12 +1277,9 @@ private ServiceResponse getVnetFromServerFarmDelegate(Response getRoutesForVnet(String resourceGroupName, String name, String vnetName) throws CloudException, IOException, IllegalArgumentException { + public List getRoutesForVnet(String resourceGroupName, String name, String vnetName) { return getRoutesForVnetWithServiceResponseAsync(resourceGroupName, name, vnetName).toBlocking().single().getBody(); } @@ -1407,12 +1365,9 @@ private ServiceResponse> getRoutesForVnetDelegate(Response< * @param name Name of App Service Plan * @param vnetName Name of virtual network * @param routeName Name of the virtual network route - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VnetRouteInner> object if successful. */ - public List getRouteForVnet(String resourceGroupName, String name, String vnetName, String routeName) throws CloudException, IOException, IllegalArgumentException { + public List getRouteForVnet(String resourceGroupName, String name, String vnetName, String routeName) { return getRouteForVnetWithServiceResponseAsync(resourceGroupName, name, vnetName, routeName).toBlocking().single().getBody(); } @@ -1506,12 +1461,9 @@ private ServiceResponse> getRouteForVnetDelegate(Response createOrUpdateVnetRouteDelegate(Response * @param name Name of App Service Plan * @param vnetName Name of virtual network * @param routeName Name of the virtual network route - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteVnetRoute(String resourceGroupName, String name, String vnetName, String routeName) throws CloudException, IOException, IllegalArgumentException { + public Object deleteVnetRoute(String resourceGroupName, String name, String vnetName, String routeName) { return deleteVnetRouteWithServiceResponseAsync(resourceGroupName, name, vnetName, routeName).toBlocking().single().getBody(); } @@ -1711,12 +1660,9 @@ private ServiceResponse deleteVnetRouteDelegate(Response r * @param vnetName Name of virtual network * @param routeName Name of the virtual network route * @param route The route object - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetRouteInner object if successful. */ - public VnetRouteInner updateVnetRoute(String resourceGroupName, String name, String vnetName, String routeName, VnetRouteInner route) throws CloudException, IOException, IllegalArgumentException { + public VnetRouteInner updateVnetRoute(String resourceGroupName, String name, String vnetName, String routeName, VnetRouteInner route) { return updateVnetRouteWithServiceResponseAsync(resourceGroupName, name, vnetName, routeName, route).toBlocking().single().getBody(); } @@ -1817,12 +1763,9 @@ private ServiceResponse updateVnetRouteDelegate(Response getServerFarmVnetGatewayDelegate(Respo * @param vnetName The name of the virtual network * @param gatewayName The name of the gateway. Only 'primary' is supported. * @param connectionEnvelope The gateway entity. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetGatewayInner object if successful. */ - public VnetGatewayInner updateServerFarmVnetGateway(String resourceGroupName, String name, String vnetName, String gatewayName, VnetGatewayInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public VnetGatewayInner updateServerFarmVnetGateway(String resourceGroupName, String name, String vnetName, String gatewayName, VnetGatewayInner connectionEnvelope) { return updateServerFarmVnetGatewayWithServiceResponseAsync(resourceGroupName, name, vnetName, gatewayName, connectionEnvelope).toBlocking().single().getBody(); } @@ -2017,16 +1957,13 @@ private ServiceResponse updateServerFarmVnetGatewayDelegate(Re * * @param resourceGroupName Name of resource group * @param name Name of App Service Plan - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getServerFarmSites(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmSites(final String resourceGroupName, final String name) { ServiceResponse> response = getServerFarmSitesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2135,16 +2072,13 @@ public Observable>> call(Response * @param skipToken Skip to of web apps in a list. If specified, the resulting list will contain web apps starting from (including) the skipToken. Else, the resulting list contains web apps from the start of the list * @param filter Supported filter: $filter=state eq running. Returns only web apps that are currently running * @param top List page size. If specified, results are paged. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getServerFarmSites(final String resourceGroupName, final String name, final String skipToken, final String filter, final String top) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmSites(final String resourceGroupName, final String name, final String skipToken, final String filter, final String top) { ServiceResponse> response = getServerFarmSitesSinglePageAsync(resourceGroupName, name, skipToken, filter, top).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2267,12 +2201,9 @@ private ServiceResponse> getServerFarmSitesDelegate(Response * @param resourceGroupName Name of resource group * @param name Name of server farm * @param workerName Name of worker machine, typically starts with RD - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object rebootWorkerForServerFarm(String resourceGroupName, String name, String workerName) throws CloudException, IOException, IllegalArgumentException { + public Object rebootWorkerForServerFarm(String resourceGroupName, String name, String workerName) { return rebootWorkerForServerFarmWithServiceResponseAsync(resourceGroupName, name, workerName).toBlocking().single().getBody(); } @@ -2356,12 +2287,9 @@ private ServiceResponse rebootWorkerForServerFarmDelegate(Response> call(Response response) * @param resourceGroupName Name of resource group * @param name Name of App Service Plan * @param softRestart Soft restart applies the configuration settings and restarts the apps if necessary. Hard restart always restarts and reprovisions the apps - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object restartSitesForServerFarm(String resourceGroupName, String name, Boolean softRestart) throws CloudException, IOException, IllegalArgumentException { + public Object restartSitesForServerFarm(String resourceGroupName, String name, Boolean softRestart) { return restartSitesForServerFarmWithServiceResponseAsync(resourceGroupName, name, softRestart).toBlocking().single().getBody(); } @@ -2521,12 +2446,9 @@ private ServiceResponse restartSitesForServerFarmDelegate(Response getServerFarmOperationDelega * Gets collection of App Service Plans in a resource group for a given subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ServerFarmWithRichSkuInner> object if successful. */ - public PagedList getServerFarmsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmsNext(final String nextPageLink) { ServiceResponse> response = getServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2715,16 +2634,13 @@ private ServiceResponse> getServerFarmsNext * Queries for App Serice Plan metrics. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getServerFarmMetricsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmMetricsNext(final String nextPageLink) { ServiceResponse> response = getServerFarmMetricsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2821,16 +2737,13 @@ private ServiceResponse> getServerFarmMetricsNextD * List of metrics that can be queried for an App Service Plan. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getServerFarmMetricDefintionsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmMetricDefintionsNext(final String nextPageLink) { ServiceResponse> response = getServerFarmMetricDefintionsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmMetricDefintionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2927,16 +2840,13 @@ private ServiceResponse> getServerFarmMetricDefi * Gets list of Apps associated with an App Service Plan. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getServerFarmSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getServerFarmSitesNext(final String nextPageLink) { ServiceResponse> response = getServerFarmSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getServerFarmSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/SitesInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/SitesInner.java index 0adf2f21c17f7..59ad2457471eb 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/SitesInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/SitesInner.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.website.CsmPublishingProfileOptions; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -846,12 +845,9 @@ interface SitesService { * @param name The name of the web app * @param vnetName The name of the Virtual Network * @param slot The name of the slot for this web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetInfoInner object if successful. */ - public VnetInfoInner getSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot) throws CloudException, IOException, IllegalArgumentException { + public VnetInfoInner getSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot) { return getSiteVNETConnectionSlotWithServiceResponseAsync(resourceGroupName, name, vnetName, slot).toBlocking().single().getBody(); } @@ -944,12 +940,9 @@ private ServiceResponse getSiteVNETConnectionSlotDelegate(Respons * @param vnetName The name of the Virtual Network * @param slot The name of the slot for this web app. * @param connectionEnvelope The properties of this Virtual Network Connection - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetInfoInner object if successful. */ - public VnetInfoInner createOrUpdateSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot, VnetInfoInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public VnetInfoInner createOrUpdateSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot, VnetInfoInner connectionEnvelope) { return createOrUpdateSiteVNETConnectionSlotWithServiceResponseAsync(resourceGroupName, name, vnetName, slot, connectionEnvelope).toBlocking().single().getBody(); } @@ -1048,12 +1041,9 @@ private ServiceResponse createOrUpdateSiteVNETConnectionSlotDeleg * @param name The name of the web app * @param vnetName The name of the Virtual Network * @param slot The name of the slot for this web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteVNETConnectionSlot(String resourceGroupName, String name, String vnetName, String slot) { return deleteSiteVNETConnectionSlotWithServiceResponseAsync(resourceGroupName, name, vnetName, slot).toBlocking().single().getBody(); } @@ -1146,12 +1136,9 @@ private ServiceResponse deleteSiteVNETConnectionSlotDelegate(Response updateSiteVNETConnectionSlotDelegate(Resp * @param resourceGroupName The resource group name * @param name The name of the web app * @param vnetName The name of the Virtual Network - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetInfoInner object if successful. */ - public VnetInfoInner getSiteVNETConnection(String resourceGroupName, String name, String vnetName) throws CloudException, IOException, IllegalArgumentException { + public VnetInfoInner getSiteVNETConnection(String resourceGroupName, String name, String vnetName) { return getSiteVNETConnectionWithServiceResponseAsync(resourceGroupName, name, vnetName).toBlocking().single().getBody(); } @@ -1340,12 +1324,9 @@ private ServiceResponse getSiteVNETConnectionDelegate(Response createOrUpdateSiteVNETConnectionDelegate( * @param resourceGroupName The resource group name * @param name The name of the web app * @param vnetName The name of the Virtual Network - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteVNETConnection(String resourceGroupName, String name, String vnetName) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteVNETConnection(String resourceGroupName, String name, String vnetName) { return deleteSiteVNETConnectionWithServiceResponseAsync(resourceGroupName, name, vnetName).toBlocking().single().getBody(); } @@ -1528,12 +1506,9 @@ private ServiceResponse deleteSiteVNETConnectionDelegate(Response updateSiteVNETConnectionDelegate(Response * @param name The name of the web app * @param view The type of view. This can either be "summary" or "detailed". * @param slot The name of the slot for this web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkFeaturesInner object if successful. */ - public NetworkFeaturesInner getSiteNetworkFeaturesSlot(String resourceGroupName, String name, String view, String slot) throws CloudException, IOException, IllegalArgumentException { + public NetworkFeaturesInner getSiteNetworkFeaturesSlot(String resourceGroupName, String name, String view, String slot) { return getSiteNetworkFeaturesSlotWithServiceResponseAsync(resourceGroupName, name, view, slot).toBlocking().single().getBody(); } @@ -1723,12 +1695,9 @@ private ServiceResponse getSiteNetworkFeaturesSlotDelegate * @param resourceGroupName The resource group name * @param name The name of the web app * @param view The type of view. This can either be "summary" or "detailed". - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the NetworkFeaturesInner object if successful. */ - public NetworkFeaturesInner getSiteNetworkFeatures(String resourceGroupName, String name, String view) throws CloudException, IOException, IllegalArgumentException { + public NetworkFeaturesInner getSiteNetworkFeatures(String resourceGroupName, String name, String view) { return getSiteNetworkFeaturesWithServiceResponseAsync(resourceGroupName, name, view).toBlocking().single().getBody(); } @@ -1815,12 +1784,9 @@ private ServiceResponse getSiteNetworkFeaturesDelegate(Res * @param name Name of web app * @param operationId Id of an operation * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getSiteOperationSlot(String resourceGroupName, String name, String operationId, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object getSiteOperationSlot(String resourceGroupName, String name, String operationId, String slot) { return getSiteOperationSlotWithServiceResponseAsync(resourceGroupName, name, operationId, slot).toBlocking().single().getBody(); } @@ -1911,12 +1877,9 @@ private ServiceResponse getSiteOperationSlotDelegate(Response getSiteOperationDelegate(Response * @param resourceGroupName Name of resource group * @param name Name of web app * @param slotSwapEntity Request body that contains the target slot name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the Object object if successful. */ - public Object swapSlotWithProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public Object swapSlotWithProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) { return swapSlotWithProductionWithServiceResponseAsync(resourceGroupName, name, slotSwapEntity).toBlocking().last().getBody(); } @@ -2076,12 +2035,9 @@ public Observable> swapSlotWithProductionWithServiceResp * @param resourceGroupName Name of resource group * @param name Name of web app * @param slotSwapEntity Request body that contains the target slot name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginSwapSlotWithProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException { + public Object beginSwapSlotWithProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) { return beginSwapSlotWithProductionWithServiceResponseAsync(resourceGroupName, name, slotSwapEntity).toBlocking().single().getBody(); } @@ -2169,13 +2125,9 @@ private ServiceResponse beginSwapSlotWithProductionDelegate(Response> swapSlotsSlotWithServiceResponseAsync * @param name Name of web app * @param slot Name of source slot for the swap * @param slotSwapEntity Request body that contains the target slot name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object beginSwapSlotsSlot(String resourceGroupName, String name, String slot, CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException { + public Object beginSwapSlotsSlot(String resourceGroupName, String name, String slot, CsmSlotEntityInner slotSwapEntity) { return beginSwapSlotsSlotWithServiceResponseAsync(resourceGroupName, name, slot, slotSwapEntity).toBlocking().single().getBody(); } @@ -2349,16 +2298,13 @@ private ServiceResponse beginSwapSlotsSlotDelegate(Response getSlotsDifferencesFromProduction(final String resourceGroupName, final String name, final CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSlotsDifferencesFromProduction(final String resourceGroupName, final String name, final CsmSlotEntityInner slotSwapEntity) { ServiceResponse> response = getSlotsDifferencesFromProductionSinglePageAsync(resourceGroupName, name, slotSwapEntity).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSlotsDifferencesFromProductionNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2478,16 +2424,13 @@ private ServiceResponse> getSlotsDifferencesFromPr * @param name Name of web app * @param slot Name of the source slot * @param slotSwapEntity Request body that contains the target slot name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SlotDifferenceInner> object if successful. */ - public PagedList getSlotsDifferencesSlot(final String resourceGroupName, final String name, final String slot, final CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSlotsDifferencesSlot(final String resourceGroupName, final String name, final String slot, final CsmSlotEntityInner slotSwapEntity) { ServiceResponse> response = getSlotsDifferencesSlotSinglePageAsync(resourceGroupName, name, slot, slotSwapEntity).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSlotsDifferencesSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -2613,12 +2556,9 @@ private ServiceResponse> getSlotsDifferencesSlotDe * @param resourceGroupName Name of resource group * @param name Name of web app * @param slotSwapEntity Request body that contains the target slot name. Settings from that slot will be applied on the source slot - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object applySlotConfigToProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) throws CloudException, IOException, IllegalArgumentException { + public Object applySlotConfigToProduction(String resourceGroupName, String name, CsmSlotEntityInner slotSwapEntity) { return applySlotConfigToProductionWithServiceResponseAsync(resourceGroupName, name, slotSwapEntity).toBlocking().single().getBody(); } @@ -2705,12 +2645,9 @@ private ServiceResponse applySlotConfigToProductionDelegate(Response applySlotConfigSlotDelegate(Response resetProductionSlotConfigDelegate(Response resetSlotConfigSlotDelegate(Response getSlotConfigNamesDelegate * @param resourceGroupName Name of resource group * @param name Name of web app * @param slotConfigNames Request body containing the names of application settings and connection strings - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SlotConfigNamesResourceInner object if successful. */ - public SlotConfigNamesResourceInner updateSlotConfigNames(String resourceGroupName, String name, SlotConfigNamesResourceInner slotConfigNames) throws CloudException, IOException, IllegalArgumentException { + public SlotConfigNamesResourceInner updateSlotConfigNames(String resourceGroupName, String name, SlotConfigNamesResourceInner slotConfigNames) { return updateSlotConfigNamesWithServiceResponseAsync(resourceGroupName, name, slotConfigNames).toBlocking().single().getBody(); } @@ -3148,16 +3073,13 @@ private ServiceResponse updateSlotConfigNamesDeleg * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getSiteSlots(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteSlots(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteSlotsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteSlotsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3262,16 +3184,13 @@ public Observable>> call(Response * @param resourceGroupName Name of resource group * @param name Name of web app * @param propertiesToInclude List of app properties to include in the response - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getSiteSlots(final String resourceGroupName, final String name, final String propertiesToInclude) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteSlots(final String resourceGroupName, final String name, final String propertiesToInclude) { ServiceResponse> response = getSiteSlotsSinglePageAsync(resourceGroupName, name, propertiesToInclude).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteSlotsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3384,16 +3303,13 @@ private ServiceResponse> getSiteSlotsDelegate(Response getSites(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSites(final String resourceGroupName) { ServiceResponse> response = getSitesSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3494,16 +3410,13 @@ public Observable>> call(Response * @param propertiesToInclude Additional web app properties included in the response * @param includeSiteTypes Types of apps included in the response * @param includeSlots Whether or not to include deployments slots in results - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getSites(final String resourceGroupName, final String propertiesToInclude, final String includeSiteTypes, final Boolean includeSlots) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSites(final String resourceGroupName, final String propertiesToInclude, final String includeSiteTypes, final Boolean includeSlots) { ServiceResponse> response = getSitesSinglePageAsync(resourceGroupName, propertiesToInclude, includeSiteTypes, includeSlots).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -3618,12 +3531,9 @@ private ServiceResponse> getSitesDelegate(Response> call(Response respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param propertiesToInclude Additional web app properties included in the response - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner getSite(String resourceGroupName, String name, String propertiesToInclude) throws CloudException, IOException, IllegalArgumentException { + public SiteInner getSite(String resourceGroupName, String name, String propertiesToInclude) { return getSiteWithServiceResponseAsync(resourceGroupName, name, propertiesToInclude).toBlocking().single().getBody(); } @@ -3783,13 +3690,9 @@ private ServiceResponse getSiteDelegate(Response respon * @param resourceGroupName Name of the resource group * @param name Name of the web app * @param siteEnvelope Details of web app if it exists already - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SiteInner object if successful. */ - public SiteInner createOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SiteInner createOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope) { return createOrUpdateSiteWithServiceResponseAsync(resourceGroupName, name, siteEnvelope).toBlocking().last().getBody(); } @@ -3866,13 +3769,9 @@ public Observable> createOrUpdateSiteWithServiceRespo * @param skipCustomDomainVerification If true, custom (non *.azurewebsites.net) domains associated with web app are not verified. * @param forceDnsRegistration If true, web app hostname is force registered with DNS * @param ttlInSeconds Time to live in seconds for web app's default domain name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SiteInner object if successful. */ - public SiteInner createOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SiteInner createOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) { return createOrUpdateSiteWithServiceResponseAsync(resourceGroupName, name, siteEnvelope, skipDnsRegistration, skipCustomDomainVerification, forceDnsRegistration, ttlInSeconds).toBlocking().last().getBody(); } @@ -3956,12 +3855,9 @@ public Observable> createOrUpdateSiteWithServiceRespo * @param resourceGroupName Name of the resource group * @param name Name of the web app * @param siteEnvelope Details of web app if it exists already - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginCreateOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginCreateOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope) { return beginCreateOrUpdateSiteWithServiceResponseAsync(resourceGroupName, name, siteEnvelope).toBlocking().single().getBody(); } @@ -4049,12 +3945,9 @@ public Observable> call(Response respon * @param skipCustomDomainVerification If true, custom (non *.azurewebsites.net) domains associated with web app are not verified. * @param forceDnsRegistration If true, web app hostname is force registered with DNS * @param ttlInSeconds Time to live in seconds for web app's default domain name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginCreateOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginCreateOrUpdateSite(String resourceGroupName, String name, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) { return beginCreateOrUpdateSiteWithServiceResponseAsync(resourceGroupName, name, siteEnvelope, skipDnsRegistration, skipCustomDomainVerification, forceDnsRegistration, ttlInSeconds).toBlocking().single().getBody(); } @@ -4155,12 +4048,9 @@ private ServiceResponse beginCreateOrUpdateSiteDelegate(Response> call(Response response) * @param deleteEmptyServerFarm If true and App Service Plan is empty after web app deletion, App Service Plan is also deleted * @param skipDnsRegistration If true, DNS registration is skipped * @param deleteAllSlots If true, all slots associated with web app are also deleted - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSite(String resourceGroupName, String name, String deleteMetrics, String deleteEmptyServerFarm, String skipDnsRegistration, String deleteAllSlots) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSite(String resourceGroupName, String name, String deleteMetrics, String deleteEmptyServerFarm, String skipDnsRegistration, String deleteAllSlots) { return deleteSiteWithServiceResponseAsync(resourceGroupName, name, deleteMetrics, deleteEmptyServerFarm, skipDnsRegistration, deleteAllSlots).toBlocking().single().getBody(); } @@ -4335,12 +4222,9 @@ private ServiceResponse deleteSiteDelegate(Response respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner getSiteSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public SiteInner getSiteSlot(String resourceGroupName, String name, String slot) { return getSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -4420,12 +4304,9 @@ public Observable> call(Response respon * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param propertiesToInclude Additional web app properties included in the response - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner getSiteSlot(String resourceGroupName, String name, String slot, String propertiesToInclude) throws CloudException, IOException, IllegalArgumentException { + public SiteInner getSiteSlot(String resourceGroupName, String name, String slot, String propertiesToInclude) { return getSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, propertiesToInclude).toBlocking().single().getBody(); } @@ -4514,13 +4395,9 @@ private ServiceResponse getSiteSlotDelegate(Response re * @param name Name of the web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteEnvelope Details of web app if it exists already - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SiteInner object if successful. */ - public SiteInner createOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SiteInner createOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope) { return createOrUpdateSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteEnvelope).toBlocking().last().getBody(); } @@ -4604,13 +4481,9 @@ public Observable> createOrUpdateSiteSlotWithServiceR * @param skipCustomDomainVerification If true, custom (non *.azurewebsites.net) domains associated with web app are not verified. * @param forceDnsRegistration If true, web app hostname is force registered with DNS * @param ttlInSeconds Time to live in seconds for web app's default domain name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SiteInner object if successful. */ - public SiteInner createOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SiteInner createOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) { return createOrUpdateSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteEnvelope, skipDnsRegistration, skipCustomDomainVerification, forceDnsRegistration, ttlInSeconds).toBlocking().last().getBody(); } @@ -4701,12 +4574,9 @@ public Observable> createOrUpdateSiteSlotWithServiceR * @param name Name of the web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteEnvelope Details of web app if it exists already - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginCreateOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginCreateOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope) { return beginCreateOrUpdateSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteEnvelope).toBlocking().single().getBody(); } @@ -4801,12 +4671,9 @@ public Observable> call(Response respon * @param skipCustomDomainVerification If true, custom (non *.azurewebsites.net) domains associated with web app are not verified. * @param forceDnsRegistration If true, web app hostname is force registered with DNS * @param ttlInSeconds Time to live in seconds for web app's default domain name - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginCreateOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginCreateOrUpdateSiteSlot(String resourceGroupName, String name, String slot, SiteInner siteEnvelope, String skipDnsRegistration, String skipCustomDomainVerification, String forceDnsRegistration, String ttlInSeconds) { return beginCreateOrUpdateSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteEnvelope, skipDnsRegistration, skipCustomDomainVerification, forceDnsRegistration, ttlInSeconds).toBlocking().single().getBody(); } @@ -4914,12 +4781,9 @@ private ServiceResponse beginCreateOrUpdateSiteSlotDelegate(Response< * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteSlot(String resourceGroupName, String name, String slot) { return deleteSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -5005,12 +4869,9 @@ public Observable> call(Response response) * @param deleteEmptyServerFarm If true and App Service Plan is empty after web app deletion, App Service Plan is also deleted * @param skipDnsRegistration If true, DNS registration is skipped * @param deleteAllSlots If true, all slots associated with web app are also deleted - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteSlot(String resourceGroupName, String name, String slot, String deleteMetrics, String deleteEmptyServerFarm, String skipDnsRegistration, String deleteAllSlots) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteSlot(String resourceGroupName, String name, String slot, String deleteMetrics, String deleteEmptyServerFarm, String skipDnsRegistration, String deleteAllSlots) { return deleteSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, deleteMetrics, deleteEmptyServerFarm, skipDnsRegistration, deleteAllSlots).toBlocking().single().getBody(); } @@ -5106,12 +4967,9 @@ private ServiceResponse deleteSiteSlotDelegate(Response re * * @param resourceGroupName Name of the resource group * @param name Name of the web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteCloneabilityInner object if successful. */ - public SiteCloneabilityInner isSiteCloneable(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public SiteCloneabilityInner isSiteCloneable(String resourceGroupName, String name) { return isSiteCloneableWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -5190,12 +5048,9 @@ private ServiceResponse isSiteCloneableDelegate(Response< * @param resourceGroupName Name of the resource group * @param name Name of the web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteCloneabilityInner object if successful. */ - public SiteCloneabilityInner isSiteCloneableSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public SiteCloneabilityInner isSiteCloneableSlot(String resourceGroupName, String name, String slot) { return isSiteCloneableSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -5280,13 +5135,9 @@ private ServiceResponse isSiteCloneableSlotDelegate(Respo * @param resourceGroupName Name of resource group * @param name Name of web app * @param recoveryEntity Snapshot data used for web app recovery. Snapshot information can be obtained by calling GetDeletedSites or GetSiteSnapshots API. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the SiteInner object if successful. */ - public SiteInner recoverSite(String resourceGroupName, String name, CsmSiteRecoveryEntityInner recoveryEntity) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public SiteInner recoverSite(String resourceGroupName, String name, CsmSiteRecoveryEntityInner recoveryEntity) { return recoverSiteWithServiceResponseAsync(resourceGroupName, name, recoveryEntity).toBlocking().last().getBody(); } @@ -5355,12 +5206,9 @@ public Observable> recoverSiteWithServiceResponseAsyn * @param resourceGroupName Name of resource group * @param name Name of web app * @param recoveryEntity Snapshot data used for web app recovery. Snapshot information can be obtained by calling GetDeletedSites or GetSiteSnapshots API. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginRecoverSite(String resourceGroupName, String name, CsmSiteRecoveryEntityInner recoveryEntity) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginRecoverSite(String resourceGroupName, String name, CsmSiteRecoveryEntityInner recoveryEntity) { return beginRecoverSiteWithServiceResponseAsync(resourceGroupName, name, recoveryEntity).toBlocking().single().getBody(); } @@ -5448,13 +5296,9 @@ private ServiceResponse beginRecoverSiteDelegate(Response> recoverSiteSlotWithServiceResponse * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param recoveryEntity Snapshot data used for web app recovery. Snapshot information can be obtained by calling GetDeletedSites or GetSiteSnapshots API. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteInner object if successful. */ - public SiteInner beginRecoverSiteSlot(String resourceGroupName, String name, String slot, CsmSiteRecoveryEntityInner recoveryEntity) throws CloudException, IOException, IllegalArgumentException { + public SiteInner beginRecoverSiteSlot(String resourceGroupName, String name, String slot, CsmSiteRecoveryEntityInner recoveryEntity) { return beginRecoverSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, recoveryEntity).toBlocking().single().getBody(); } @@ -5627,12 +5468,9 @@ private ServiceResponse beginRecoverSiteSlotDelegate(Response getSiteSnapshotsDelegate(Response * @param resourceGroupName Webspace * @param name Website Name * @param slot Website Slot - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getSiteSnapshotsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object getSiteSnapshotsSlot(String resourceGroupName, String name, String slot) { return getSiteSnapshotsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -5799,16 +5634,13 @@ private ServiceResponse getSiteSnapshotsSlotDelegate(Response getDeletedSites(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeletedSites(final String resourceGroupName) { ServiceResponse> response = getDeletedSitesSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeletedSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -5907,16 +5739,13 @@ public Observable>> call(Response getDeletedSites(final String resourceGroupName, final String propertiesToInclude, final String includeSiteTypes) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeletedSites(final String resourceGroupName, final String propertiesToInclude, final String includeSiteTypes) { ServiceResponse> response = getDeletedSitesSinglePageAsync(resourceGroupName, propertiesToInclude, includeSiteTypes).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeletedSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6027,16 +5856,13 @@ private ServiceResponse> getDeletedSitesDelegate(Resp * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getDeployments(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeployments(final String resourceGroupName, final String name) { ServiceResponse> response = getDeploymentsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6147,16 +5973,13 @@ private ServiceResponse> getDeploymentsDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getDeploymentsSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeploymentsSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getDeploymentsSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6274,16 +6097,13 @@ private ServiceResponse> getDeploymentsSlotDelegate(Re * @param resourceGroupName Name of resource group * @param name Name of web app * @param instanceId Id of web app instance - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getInstanceDeployments(final String resourceGroupName, final String name, final String instanceId) throws CloudException, IOException, IllegalArgumentException { + public PagedList getInstanceDeployments(final String resourceGroupName, final String name, final String instanceId) { ServiceResponse> response = getInstanceDeploymentsSinglePageAsync(resourceGroupName, name, instanceId).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getInstanceDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6402,16 +6222,13 @@ private ServiceResponse> getInstanceDeploymentsDelegat * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param instanceId Id of web app instance - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getInstanceDeploymentsSlot(final String resourceGroupName, final String name, final String slot, final String instanceId) throws CloudException, IOException, IllegalArgumentException { + public PagedList getInstanceDeploymentsSlot(final String resourceGroupName, final String name, final String slot, final String instanceId) { ServiceResponse> response = getInstanceDeploymentsSlotSinglePageAsync(resourceGroupName, name, slot, instanceId).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getInstanceDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -6537,12 +6354,9 @@ private ServiceResponse> getInstanceDeploymentsSlotDel * @param name Name of web app * @param id Id of the deployment * @param instanceId Id of web app instance - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentInner object if successful. */ - public DeploymentInner getInstanceDeployment(String resourceGroupName, String name, String id, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public DeploymentInner getInstanceDeployment(String resourceGroupName, String name, String id, String instanceId) { return getInstanceDeploymentWithServiceResponseAsync(resourceGroupName, name, id, instanceId).toBlocking().single().getBody(); } @@ -6635,12 +6449,9 @@ private ServiceResponse getInstanceDeploymentDelegate(Response< * @param id Id of the deployment * @param instanceId Id of web app instance * @param deployment Details of deployment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentInner object if successful. */ - public DeploymentInner createInstanceDeployment(String resourceGroupName, String name, String id, String instanceId, DeploymentInner deployment) throws CloudException, IOException, IllegalArgumentException { + public DeploymentInner createInstanceDeployment(String resourceGroupName, String name, String id, String instanceId, DeploymentInner deployment) { return createInstanceDeploymentWithServiceResponseAsync(resourceGroupName, name, id, instanceId, deployment).toBlocking().single().getBody(); } @@ -6739,12 +6550,9 @@ private ServiceResponse createInstanceDeploymentDelegate(Respon * @param name Name of web app * @param id Id of the deployment * @param instanceId Id of web app instance - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteInstanceDeployment(String resourceGroupName, String name, String id, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public Object deleteInstanceDeployment(String resourceGroupName, String name, String id, String instanceId) { return deleteInstanceDeploymentWithServiceResponseAsync(resourceGroupName, name, id, instanceId).toBlocking().single().getBody(); } @@ -6835,12 +6643,9 @@ private ServiceResponse deleteInstanceDeploymentDelegate(Response getDeploymentDelegate(Response createDeploymentDelegate(Response deleteDeploymentDelegate(Response * @param name Name of web app * @param id Id of the deployment * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentInner object if successful. */ - public DeploymentInner getDeploymentSlot(String resourceGroupName, String name, String id, String slot) throws CloudException, IOException, IllegalArgumentException { + public DeploymentInner getDeploymentSlot(String resourceGroupName, String name, String id, String slot) { return getDeploymentSlotWithServiceResponseAsync(resourceGroupName, name, id, slot).toBlocking().single().getBody(); } @@ -7212,12 +7008,9 @@ private ServiceResponse getDeploymentSlotDelegate(Response createDeploymentSlotDelegate(Response deleteDeploymentSlotDelegate(Response getInstanceDeploymentSlotDelegate(Respo * @param slot Name of web app slot. If not specified then will default to production slot. * @param instanceId Id of web app instance * @param deployment Details of deployment - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the DeploymentInner object if successful. */ - public DeploymentInner createInstanceDeploymentSlot(String resourceGroupName, String name, String id, String slot, String instanceId, DeploymentInner deployment) throws CloudException, IOException, IllegalArgumentException { + public DeploymentInner createInstanceDeploymentSlot(String resourceGroupName, String name, String id, String slot, String instanceId, DeploymentInner deployment) { return createInstanceDeploymentSlotWithServiceResponseAsync(resourceGroupName, name, id, slot, instanceId, deployment).toBlocking().single().getBody(); } @@ -7630,12 +7414,9 @@ private ServiceResponse createInstanceDeploymentSlotDelegate(Re * @param id Id of the deployment * @param slot Name of web app slot. If not specified then will default to production slot. * @param instanceId Id of web app instance - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteInstanceDeploymentSlot(String resourceGroupName, String name, String id, String slot, String instanceId) throws CloudException, IOException, IllegalArgumentException { + public Object deleteInstanceDeploymentSlot(String resourceGroupName, String name, String id, String slot, String instanceId) { return deleteInstanceDeploymentSlotWithServiceResponseAsync(resourceGroupName, name, id, slot, instanceId).toBlocking().single().getBody(); } @@ -7731,16 +7512,13 @@ private ServiceResponse deleteInstanceDeploymentSlotDelegate(Response getSiteInstanceIdentifiers(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteInstanceIdentifiers(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteInstanceIdentifiersSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteInstanceIdentifiersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7851,16 +7629,13 @@ private ServiceResponse> getSiteInstanceIdentifiersD * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInstanceInner> object if successful. */ - public PagedList getSiteInstanceIdentifiersSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteInstanceIdentifiersSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getSiteInstanceIdentifiersSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteInstanceIdentifiersSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -7977,16 +7752,13 @@ private ServiceResponse> getSiteInstanceIdentifiersS * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostNameBindingInner> object if successful. */ - public PagedList getSiteHostNameBindings(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteHostNameBindings(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteHostNameBindingsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteHostNameBindingsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -8097,16 +7869,13 @@ private ServiceResponse> getSiteHostNameBindingsD * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostNameBindingInner> object if successful. */ - public PagedList getSiteHostNameBindingsSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteHostNameBindingsSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getSiteHostNameBindingsSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteHostNameBindingsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -8224,12 +7993,9 @@ private ServiceResponse> getSiteHostNameBindingsS * @param resourceGroupName Name of resource group * @param name Name of web app * @param hostName Name of host - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostNameBindingInner object if successful. */ - public HostNameBindingInner getSiteHostNameBinding(String resourceGroupName, String name, String hostName) throws CloudException, IOException, IllegalArgumentException { + public HostNameBindingInner getSiteHostNameBinding(String resourceGroupName, String name, String hostName) { return getSiteHostNameBindingWithServiceResponseAsync(resourceGroupName, name, hostName).toBlocking().single().getBody(); } @@ -8315,12 +8081,9 @@ private ServiceResponse getSiteHostNameBindingDelegate(Res * @param name Name of web app * @param hostName Name of host * @param hostNameBinding Host name binding information - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostNameBindingInner object if successful. */ - public HostNameBindingInner createOrUpdateSiteHostNameBinding(String resourceGroupName, String name, String hostName, HostNameBindingInner hostNameBinding) throws CloudException, IOException, IllegalArgumentException { + public HostNameBindingInner createOrUpdateSiteHostNameBinding(String resourceGroupName, String name, String hostName, HostNameBindingInner hostNameBinding) { return createOrUpdateSiteHostNameBindingWithServiceResponseAsync(resourceGroupName, name, hostName, hostNameBinding).toBlocking().single().getBody(); } @@ -8412,12 +8175,9 @@ private ServiceResponse createOrUpdateSiteHostNameBindingD * @param resourceGroupName Name of resource group * @param name Name of web app * @param hostName Name of host - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteHostNameBinding(String resourceGroupName, String name, String hostName) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteHostNameBinding(String resourceGroupName, String name, String hostName) { return deleteSiteHostNameBindingWithServiceResponseAsync(resourceGroupName, name, hostName).toBlocking().single().getBody(); } @@ -8503,12 +8263,9 @@ private ServiceResponse deleteSiteHostNameBindingDelegate(Response getSiteHostNameBindingSlotDelegate * @param hostName Name of host * @param slot Name of web app slot. If not specified then will default to production slot. * @param hostNameBinding Host name binding information - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the HostNameBindingInner object if successful. */ - public HostNameBindingInner createOrUpdateSiteHostNameBindingSlot(String resourceGroupName, String name, String hostName, String slot, HostNameBindingInner hostNameBinding) throws CloudException, IOException, IllegalArgumentException { + public HostNameBindingInner createOrUpdateSiteHostNameBindingSlot(String resourceGroupName, String name, String hostName, String slot, HostNameBindingInner hostNameBinding) { return createOrUpdateSiteHostNameBindingSlotWithServiceResponseAsync(resourceGroupName, name, hostName, slot, hostNameBinding).toBlocking().single().getBody(); } @@ -8705,12 +8459,9 @@ private ServiceResponse createOrUpdateSiteHostNameBindingS * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param hostName Name of host - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteHostNameBindingSlot(String resourceGroupName, String name, String slot, String hostName) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteHostNameBindingSlot(String resourceGroupName, String name, String slot, String hostName) { return deleteSiteHostNameBindingSlotWithServiceResponseAsync(resourceGroupName, name, slot, hostName).toBlocking().single().getBody(); } @@ -8800,12 +8551,9 @@ private ServiceResponse deleteSiteHostNameBindingSlotDelegate(Response getSiteConfigDelegate(Response createOrUpdateSiteConfigDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param siteConfig Request body that contains the configuraiton setting for the web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteConfigInner object if successful. */ - public SiteConfigInner updateSiteConfig(String resourceGroupName, String name, SiteConfigInner siteConfig) throws CloudException, IOException, IllegalArgumentException { + public SiteConfigInner updateSiteConfig(String resourceGroupName, String name, SiteConfigInner siteConfig) { return updateSiteConfigWithServiceResponseAsync(resourceGroupName, name, siteConfig).toBlocking().single().getBody(); } @@ -9066,12 +8808,9 @@ private ServiceResponse updateSiteConfigDelegate(Response getSiteConfigSlotDelegate(Response createOrUpdateSiteConfigSlotDelegate(Re * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteConfig Request body that contains the configuraiton setting for the web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteConfigInner object if successful. */ - public SiteConfigInner updateSiteConfigSlot(String resourceGroupName, String name, String slot, SiteConfigInner siteConfig) throws CloudException, IOException, IllegalArgumentException { + public SiteConfigInner updateSiteConfigSlot(String resourceGroupName, String name, String slot, SiteConfigInner siteConfig) { return updateSiteConfigSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteConfig).toBlocking().single().getBody(); } @@ -9351,12 +9084,9 @@ private ServiceResponse updateSiteConfigSlotDelegate(Response getSiteSourceControlDelegate(Res * @param resourceGroupName Name of resource group * @param name Name of web app * @param siteSourceControl Request body that contains the source control parameters - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteSourceControlInner object if successful. */ - public SiteSourceControlInner createOrUpdateSiteSourceControl(String resourceGroupName, String name, SiteSourceControlInner siteSourceControl) throws CloudException, IOException, IllegalArgumentException { + public SiteSourceControlInner createOrUpdateSiteSourceControl(String resourceGroupName, String name, SiteSourceControlInner siteSourceControl) { return createOrUpdateSiteSourceControlWithServiceResponseAsync(resourceGroupName, name, siteSourceControl).toBlocking().single().getBody(); } @@ -9525,12 +9252,9 @@ private ServiceResponse createOrUpdateSiteSourceControlD * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteSourceControl(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteSourceControl(String resourceGroupName, String name) { return deleteSiteSourceControlWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -9609,12 +9333,9 @@ private ServiceResponse deleteSiteSourceControlDelegate(Response updateSiteSourceControlDelegate( * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteSourceControlInner object if successful. */ - public SiteSourceControlInner getSiteSourceControlSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public SiteSourceControlInner getSiteSourceControlSlot(String resourceGroupName, String name, String slot) { return getSiteSourceControlSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -9791,12 +9509,9 @@ private ServiceResponse getSiteSourceControlSlotDelegate * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteSourceControl Request body that contains the source control parameters - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteSourceControlInner object if successful. */ - public SiteSourceControlInner createOrUpdateSiteSourceControlSlot(String resourceGroupName, String name, String slot, SiteSourceControlInner siteSourceControl) throws CloudException, IOException, IllegalArgumentException { + public SiteSourceControlInner createOrUpdateSiteSourceControlSlot(String resourceGroupName, String name, String slot, SiteSourceControlInner siteSourceControl) { return createOrUpdateSiteSourceControlSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteSourceControl).toBlocking().single().getBody(); } @@ -9888,12 +9603,9 @@ private ServiceResponse createOrUpdateSiteSourceControlS * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteSourceControlSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteSourceControlSlot(String resourceGroupName, String name, String slot) { return deleteSiteSourceControlSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -9979,12 +9691,9 @@ private ServiceResponse deleteSiteSourceControlSlotDelegate(Response updateSiteSourceControlSlotDeleg * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner listSiteAppSettingsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner listSiteAppSettingsSlot(String resourceGroupName, String name, String slot) { return listSiteAppSettingsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -10165,12 +9871,9 @@ private ServiceResponse listSiteAppSettingsSlotDelegate(R * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner listSiteAppSettings(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner listSiteAppSettings(String resourceGroupName, String name) { return listSiteAppSettingsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -10249,12 +9952,9 @@ private ServiceResponse listSiteAppSettingsDelegate(Respo * @param resourceGroupName Name of resource group * @param name Name of web app * @param appSettings Application settings of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner updateSiteAppSettings(String resourceGroupName, String name, StringDictionaryInner appSettings) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner updateSiteAppSettings(String resourceGroupName, String name, StringDictionaryInner appSettings) { return updateSiteAppSettingsWithServiceResponseAsync(resourceGroupName, name, appSettings).toBlocking().single().getBody(); } @@ -10341,12 +10041,9 @@ private ServiceResponse updateSiteAppSettingsDelegate(Res * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param appSettings Application settings of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner updateSiteAppSettingsSlot(String resourceGroupName, String name, String slot, StringDictionaryInner appSettings) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner updateSiteAppSettingsSlot(String resourceGroupName, String name, String slot, StringDictionaryInner appSettings) { return updateSiteAppSettingsSlotWithServiceResponseAsync(resourceGroupName, name, slot, appSettings).toBlocking().single().getBody(); } @@ -10437,12 +10134,9 @@ private ServiceResponse updateSiteAppSettingsSlotDelegate * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionStringDictionaryInner object if successful. */ - public ConnectionStringDictionaryInner listSiteConnectionStrings(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public ConnectionStringDictionaryInner listSiteConnectionStrings(String resourceGroupName, String name) { return listSiteConnectionStringsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -10521,12 +10215,9 @@ private ServiceResponse listSiteConnectionStrin * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionStringDictionaryInner object if successful. */ - public ConnectionStringDictionaryInner listSiteConnectionStringsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public ConnectionStringDictionaryInner listSiteConnectionStringsSlot(String resourceGroupName, String name, String slot) { return listSiteConnectionStringsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -10611,12 +10302,9 @@ private ServiceResponse listSiteConnectionStrin * @param resourceGroupName Name of resource group * @param name Name of web app * @param connectionStrings Connection strings associated with web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionStringDictionaryInner object if successful. */ - public ConnectionStringDictionaryInner updateSiteConnectionStrings(String resourceGroupName, String name, ConnectionStringDictionaryInner connectionStrings) throws CloudException, IOException, IllegalArgumentException { + public ConnectionStringDictionaryInner updateSiteConnectionStrings(String resourceGroupName, String name, ConnectionStringDictionaryInner connectionStrings) { return updateSiteConnectionStringsWithServiceResponseAsync(resourceGroupName, name, connectionStrings).toBlocking().single().getBody(); } @@ -10703,12 +10391,9 @@ private ServiceResponse updateSiteConnectionStr * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param connectionStrings Connection strings associated with web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the ConnectionStringDictionaryInner object if successful. */ - public ConnectionStringDictionaryInner updateSiteConnectionStringsSlot(String resourceGroupName, String name, String slot, ConnectionStringDictionaryInner connectionStrings) throws CloudException, IOException, IllegalArgumentException { + public ConnectionStringDictionaryInner updateSiteConnectionStringsSlot(String resourceGroupName, String name, String slot, ConnectionStringDictionaryInner connectionStrings) { return updateSiteConnectionStringsSlotWithServiceResponseAsync(resourceGroupName, name, slot, connectionStrings).toBlocking().single().getBody(); } @@ -10799,12 +10484,9 @@ private ServiceResponse updateSiteConnectionStr * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteAuthSettingsInner object if successful. */ - public SiteAuthSettingsInner listSiteAuthSettings(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public SiteAuthSettingsInner listSiteAuthSettings(String resourceGroupName, String name) { return listSiteAuthSettingsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -10883,12 +10565,9 @@ private ServiceResponse listSiteAuthSettingsDelegate(Resp * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteAuthSettingsInner object if successful. */ - public SiteAuthSettingsInner listSiteAuthSettingsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public SiteAuthSettingsInner listSiteAuthSettingsSlot(String resourceGroupName, String name, String slot) { return listSiteAuthSettingsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -10973,12 +10652,9 @@ private ServiceResponse listSiteAuthSettingsSlotDelegate( * @param resourceGroupName Name of resource group * @param name Name of web app * @param siteAuthSettings Auth settings associated with web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteAuthSettingsInner object if successful. */ - public SiteAuthSettingsInner updateSiteAuthSettings(String resourceGroupName, String name, SiteAuthSettingsInner siteAuthSettings) throws CloudException, IOException, IllegalArgumentException { + public SiteAuthSettingsInner updateSiteAuthSettings(String resourceGroupName, String name, SiteAuthSettingsInner siteAuthSettings) { return updateSiteAuthSettingsWithServiceResponseAsync(resourceGroupName, name, siteAuthSettings).toBlocking().single().getBody(); } @@ -11065,12 +10741,9 @@ private ServiceResponse updateSiteAuthSettingsDelegate(Re * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteAuthSettings Auth settings associated with web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteAuthSettingsInner object if successful. */ - public SiteAuthSettingsInner updateSiteAuthSettingsSlot(String resourceGroupName, String name, String slot, SiteAuthSettingsInner siteAuthSettings) throws CloudException, IOException, IllegalArgumentException { + public SiteAuthSettingsInner updateSiteAuthSettingsSlot(String resourceGroupName, String name, String slot, SiteAuthSettingsInner siteAuthSettings) { return updateSiteAuthSettingsSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteAuthSettings).toBlocking().single().getBody(); } @@ -11161,13 +10834,9 @@ private ServiceResponse updateSiteAuthSettingsSlotDelegat * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the UserInner object if successful. */ - public UserInner listSitePublishingCredentials(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public UserInner listSitePublishingCredentials(String resourceGroupName, String name) { return listSitePublishingCredentialsWithServiceResponseAsync(resourceGroupName, name).toBlocking().last().getBody(); } @@ -11228,12 +10897,9 @@ public Observable> listSitePublishingCredentialsWithS * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner beginListSitePublishingCredentials(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public UserInner beginListSitePublishingCredentials(String resourceGroupName, String name) { return beginListSitePublishingCredentialsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -11312,13 +10978,9 @@ private ServiceResponse beginListSitePublishingCredentialsDelegate(Re * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the UserInner object if successful. */ - public UserInner listSitePublishingCredentialsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public UserInner listSitePublishingCredentialsSlot(String resourceGroupName, String name, String slot) { return listSitePublishingCredentialsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().last().getBody(); } @@ -11386,12 +11048,9 @@ public Observable> listSitePublishingCredentialsSlotW * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UserInner object if successful. */ - public UserInner beginListSitePublishingCredentialsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public UserInner beginListSitePublishingCredentialsSlot(String resourceGroupName, String name, String slot) { return beginListSitePublishingCredentialsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -11475,12 +11134,9 @@ private ServiceResponse beginListSitePublishingCredentialsSlotDelegat * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner listSiteMetadata(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner listSiteMetadata(String resourceGroupName, String name) { return listSiteMetadataWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -11559,12 +11215,9 @@ private ServiceResponse listSiteMetadataDelegate(Response * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner listSiteMetadataSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner listSiteMetadataSlot(String resourceGroupName, String name, String slot) { return listSiteMetadataSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -11649,12 +11302,9 @@ private ServiceResponse listSiteMetadataSlotDelegate(Resp * @param resourceGroupName Name of resource group * @param name Name of web app * @param metadata Meta data of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner updateSiteMetadata(String resourceGroupName, String name, StringDictionaryInner metadata) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner updateSiteMetadata(String resourceGroupName, String name, StringDictionaryInner metadata) { return updateSiteMetadataWithServiceResponseAsync(resourceGroupName, name, metadata).toBlocking().single().getBody(); } @@ -11741,12 +11391,9 @@ private ServiceResponse updateSiteMetadataDelegate(Respon * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param metadata Meta data of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the StringDictionaryInner object if successful. */ - public StringDictionaryInner updateSiteMetadataSlot(String resourceGroupName, String name, String slot, StringDictionaryInner metadata) throws CloudException, IOException, IllegalArgumentException { + public StringDictionaryInner updateSiteMetadataSlot(String resourceGroupName, String name, String slot, StringDictionaryInner metadata) { return updateSiteMetadataSlotWithServiceResponseAsync(resourceGroupName, name, slot, metadata).toBlocking().single().getBody(); } @@ -11837,12 +11484,9 @@ private ServiceResponse updateSiteMetadataSlotDelegate(Re * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteLogsConfigInner object if successful. */ - public SiteLogsConfigInner getSiteLogsConfig(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public SiteLogsConfigInner getSiteLogsConfig(String resourceGroupName, String name) { return getSiteLogsConfigWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -11921,12 +11565,9 @@ private ServiceResponse getSiteLogsConfigDelegate(Response< * @param resourceGroupName Name of resource group * @param name Name of web app * @param siteLogsConfig Site logs configuration - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteLogsConfigInner object if successful. */ - public SiteLogsConfigInner updateSiteLogsConfig(String resourceGroupName, String name, SiteLogsConfigInner siteLogsConfig) throws CloudException, IOException, IllegalArgumentException { + public SiteLogsConfigInner updateSiteLogsConfig(String resourceGroupName, String name, SiteLogsConfigInner siteLogsConfig) { return updateSiteLogsConfigWithServiceResponseAsync(resourceGroupName, name, siteLogsConfig).toBlocking().single().getBody(); } @@ -12012,12 +11653,9 @@ private ServiceResponse updateSiteLogsConfigDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteLogsConfigInner object if successful. */ - public SiteLogsConfigInner getSiteLogsConfigSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public SiteLogsConfigInner getSiteLogsConfigSlot(String resourceGroupName, String name, String slot) { return getSiteLogsConfigSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -12103,12 +11741,9 @@ private ServiceResponse getSiteLogsConfigSlotDelegate(Respo * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param siteLogsConfig Site logs configuration - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SiteLogsConfigInner object if successful. */ - public SiteLogsConfigInner updateSiteLogsConfigSlot(String resourceGroupName, String name, String slot, SiteLogsConfigInner siteLogsConfig) throws CloudException, IOException, IllegalArgumentException { + public SiteLogsConfigInner updateSiteLogsConfigSlot(String resourceGroupName, String name, String slot, SiteLogsConfigInner siteLogsConfig) { return updateSiteLogsConfigSlotWithServiceResponseAsync(resourceGroupName, name, slot, siteLogsConfig).toBlocking().single().getBody(); } @@ -12198,12 +11833,9 @@ private ServiceResponse updateSiteLogsConfigSlotDelegate(Re * * @param resourceGroupName the String value * @param name the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object listSitePremierAddOns(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object listSitePremierAddOns(String resourceGroupName, String name) { return listSitePremierAddOnsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -12278,12 +11910,9 @@ private ServiceResponse listSitePremierAddOnsDelegate(Response listSitePremierAddOnsSlotDelegate(Response getSitePremierAddOnDelegate(Response addSitePremierAddOnDelegate(Response deleteSitePremierAddOnDelegate(Response getSitePremierAddOnSlotDelegate(Response addSitePremierAddOnSlotDelegate(Response deleteSitePremierAddOnSlotDelegate(Response getSiteBackupConfigurationDelegate(R * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupRequestInner object if successful. */ - public BackupRequestInner getSiteBackupConfigurationSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public BackupRequestInner getSiteBackupConfigurationSlot(String resourceGroupName, String name, String slot) { return getSiteBackupConfigurationSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -13091,12 +12696,9 @@ private ServiceResponse getSiteBackupConfigurationSlotDelega * @param resourceGroupName Name of resource group * @param name Name of web app * @param request Information on backup request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupRequestInner object if successful. */ - public BackupRequestInner updateSiteBackupConfiguration(String resourceGroupName, String name, BackupRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public BackupRequestInner updateSiteBackupConfiguration(String resourceGroupName, String name, BackupRequestInner request) { return updateSiteBackupConfigurationWithServiceResponseAsync(resourceGroupName, name, request).toBlocking().single().getBody(); } @@ -13183,12 +12785,9 @@ private ServiceResponse updateSiteBackupConfigurationDelegat * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param request Information on backup request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupRequestInner object if successful. */ - public BackupRequestInner updateSiteBackupConfigurationSlot(String resourceGroupName, String name, String slot, BackupRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public BackupRequestInner updateSiteBackupConfigurationSlot(String resourceGroupName, String name, String slot, BackupRequestInner request) { return updateSiteBackupConfigurationSlotWithServiceResponseAsync(resourceGroupName, name, slot, request).toBlocking().single().getBody(); } @@ -13280,12 +12879,9 @@ private ServiceResponse updateSiteBackupConfigurationSlotDel * @param resourceGroupName Name of resource group * @param name Name of web app * @param request Information on backup request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupItemInner object if successful. */ - public BackupItemInner backupSite(String resourceGroupName, String name, BackupRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public BackupItemInner backupSite(String resourceGroupName, String name, BackupRequestInner request) { return backupSiteWithServiceResponseAsync(resourceGroupName, name, request).toBlocking().single().getBody(); } @@ -13372,12 +12968,9 @@ private ServiceResponse backupSiteDelegate(Response backupSiteSlotDelegate(Response discoverSiteRestoreDelegate(Respons * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. * @param request Information on restore request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RestoreRequestInner object if successful. */ - public RestoreRequestInner discoverSiteRestoreSlot(String resourceGroupName, String name, String slot, RestoreRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public RestoreRequestInner discoverSiteRestoreSlot(String resourceGroupName, String name, String slot, RestoreRequestInner request) { return discoverSiteRestoreSlotWithServiceResponseAsync(resourceGroupName, name, slot, request).toBlocking().single().getBody(); } @@ -13657,16 +13244,13 @@ private ServiceResponse discoverSiteRestoreSlotDelegate(Res * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<BackupItemInner> object if successful. */ - public PagedList listSiteBackups(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSiteBackups(final String resourceGroupName, final String name) { ServiceResponse> response = listSiteBackupsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSiteBackupsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -13777,16 +13361,13 @@ private ServiceResponse> listSiteBackupsDelegate(Respo * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<BackupItemInner> object if successful. */ - public PagedList listSiteBackupsSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSiteBackupsSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = listSiteBackupsSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSiteBackupsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -13904,12 +13485,9 @@ private ServiceResponse> listSiteBackupsSlotDelegate(R * @param resourceGroupName Name of resource group * @param name Name of web app * @param backupId Id of backup - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupItemInner object if successful. */ - public BackupItemInner getSiteBackupStatus(String resourceGroupName, String name, String backupId) throws CloudException, IOException, IllegalArgumentException { + public BackupItemInner getSiteBackupStatus(String resourceGroupName, String name, String backupId) { return getSiteBackupStatusWithServiceResponseAsync(resourceGroupName, name, backupId).toBlocking().single().getBody(); } @@ -13994,12 +13572,9 @@ private ServiceResponse getSiteBackupStatusDelegate(Response deleteBackupDelegate(Response getSiteBackupStatusSlotDelegate(Respons * @param name Name of web app * @param backupId Id of backup * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupItemInner object if successful. */ - public BackupItemInner deleteBackupSlot(String resourceGroupName, String name, String backupId, String slot) throws CloudException, IOException, IllegalArgumentException { + public BackupItemInner deleteBackupSlot(String resourceGroupName, String name, String backupId, String slot) { return deleteBackupSlotWithServiceResponseAsync(resourceGroupName, name, backupId, slot).toBlocking().single().getBody(); } @@ -14280,12 +13849,9 @@ private ServiceResponse deleteBackupSlotDelegate(Response getSiteBackupStatusSecretsSlotDelegate( * @param name Name of web app * @param backupId Id of backup * @param request Information on backup request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupItemInner object if successful. */ - public BackupItemInner getSiteBackupStatusSecrets(String resourceGroupName, String name, String backupId, BackupRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public BackupItemInner getSiteBackupStatusSecrets(String resourceGroupName, String name, String backupId, BackupRequestInner request) { return getSiteBackupStatusSecretsWithServiceResponseAsync(resourceGroupName, name, backupId, request).toBlocking().single().getBody(); } @@ -14482,13 +14045,9 @@ private ServiceResponse getSiteBackupStatusSecretsDelegate(Resp * @param name Name of web app * @param backupId Id of backup to restore * @param request Information on restore request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the RestoreResponseInner object if successful. */ - public RestoreResponseInner restoreSite(String resourceGroupName, String name, String backupId, RestoreRequestInner request) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public RestoreResponseInner restoreSite(String resourceGroupName, String name, String backupId, RestoreRequestInner request) { return restoreSiteWithServiceResponseAsync(resourceGroupName, name, backupId, request).toBlocking().last().getBody(); } @@ -14564,12 +14123,9 @@ public Observable> restoreSiteWithServiceR * @param name Name of web app * @param backupId Id of backup to restore * @param request Information on restore request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RestoreResponseInner object if successful. */ - public RestoreResponseInner beginRestoreSite(String resourceGroupName, String name, String backupId, RestoreRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public RestoreResponseInner beginRestoreSite(String resourceGroupName, String name, String backupId, RestoreRequestInner request) { return beginRestoreSiteWithServiceResponseAsync(resourceGroupName, name, backupId, request).toBlocking().single().getBody(); } @@ -14663,13 +14219,9 @@ private ServiceResponse beginRestoreSiteDelegate(Response< * @param backupId Id of backup to restore * @param slot Name of web app slot. If not specified then will default to production slot. * @param request Information on restore request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @throws InterruptedException exception thrown when long running operation is interrupted * @return the RestoreResponseInner object if successful. */ - public RestoreResponseInner restoreSiteSlot(String resourceGroupName, String name, String backupId, String slot, RestoreRequestInner request) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + public RestoreResponseInner restoreSiteSlot(String resourceGroupName, String name, String backupId, String slot, RestoreRequestInner request) { return restoreSiteSlotWithServiceResponseAsync(resourceGroupName, name, backupId, slot, request).toBlocking().last().getBody(); } @@ -14752,12 +14304,9 @@ public Observable> restoreSiteSlotWithServ * @param backupId Id of backup to restore * @param slot Name of web app slot. If not specified then will default to production slot. * @param request Information on restore request - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RestoreResponseInner object if successful. */ - public RestoreResponseInner beginRestoreSiteSlot(String resourceGroupName, String name, String backupId, String slot, RestoreRequestInner request) throws CloudException, IOException, IllegalArgumentException { + public RestoreResponseInner beginRestoreSiteSlot(String resourceGroupName, String name, String backupId, String slot, RestoreRequestInner request) { return beginRestoreSiteSlotWithServiceResponseAsync(resourceGroupName, name, backupId, slot, request).toBlocking().single().getBody(); } @@ -14854,16 +14403,13 @@ private ServiceResponse beginRestoreSiteSlotDelegate(Respo * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getSiteUsages(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsages(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteUsagesSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -14968,16 +14514,13 @@ public Observable>> call(Response getSiteUsages(final String resourceGroupName, final String name, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsages(final String resourceGroupName, final String name, final String filter) { ServiceResponse> response = getSiteUsagesSinglePageAsync(resourceGroupName, name, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15092,16 +14635,13 @@ private ServiceResponse> getSiteUsagesDelegate(Resp * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getSiteUsagesSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsagesSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getSiteUsagesSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15214,16 +14754,13 @@ public Observable>> call(Response getSiteUsagesSlot(final String resourceGroupName, final String name, final String slot, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsagesSlot(final String resourceGroupName, final String name, final String slot, final String filter) { ServiceResponse> response = getSiteUsagesSlotSinglePageAsync(resourceGroupName, name, slot, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15344,16 +14881,13 @@ private ServiceResponse> getSiteUsagesSlotDelegate( * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getSiteMetrics(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetrics(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteMetricsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15460,16 +14994,13 @@ public Observable>> call(Response getSiteMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetrics(final String resourceGroupName, final String name, final Boolean details, final String filter) { ServiceResponse> response = getSiteMetricsSinglePageAsync(resourceGroupName, name, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15588,16 +15119,13 @@ private ServiceResponse> getSiteMetricsDelegate(Re * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getSiteMetricsSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricsSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getSiteMetricsSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15712,16 +15240,13 @@ public Observable>> call(Response getSiteMetricsSlot(final String resourceGroupName, final String name, final String slot, final Boolean details, final String filter) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricsSlot(final String resourceGroupName, final String name, final String slot, final Boolean details, final String filter) { ServiceResponse> response = getSiteMetricsSlotSinglePageAsync(resourceGroupName, name, slot, details, filter).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15847,16 +15372,13 @@ private ServiceResponse> getSiteMetricsSlotDelegat * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getSiteMetricDefinitionsSlot(final String resourceGroupName, final String name, final String slot) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricDefinitionsSlot(final String resourceGroupName, final String name, final String slot) { ServiceResponse> response = getSiteMetricDefinitionsSlotSinglePageAsync(resourceGroupName, name, slot).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricDefinitionsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -15973,16 +15495,13 @@ private ServiceResponse> getSiteMetricDefinition * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getSiteMetricDefinitions(final String resourceGroupName, final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricDefinitions(final String resourceGroupName, final String name) { ServiceResponse> response = getSiteMetricDefinitionsSinglePageAsync(resourceGroupName, name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -16092,12 +15611,9 @@ private ServiceResponse> getSiteMetricDefinition * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the InputStream object if successful. */ - public InputStream listSitePublishingProfileXml(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public InputStream listSitePublishingProfileXml(String resourceGroupName, String name) { return listSitePublishingProfileXmlWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -16175,12 +15691,9 @@ public Observable> call(Response resp FileZilla3 WebDeploy -- default Ftp - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the InputStream object if successful. */ - public InputStream listSitePublishingProfileXml(String resourceGroupName, String name, String format) throws CloudException, IOException, IllegalArgumentException { + public InputStream listSitePublishingProfileXml(String resourceGroupName, String name, String format) { return listSitePublishingProfileXmlWithServiceResponseAsync(resourceGroupName, name, format).toBlocking().single().getBody(); } @@ -16273,12 +15786,9 @@ private ServiceResponse listSitePublishingProfileXmlDelegate(Respon * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the InputStream object if successful. */ - public InputStream listSitePublishingProfileXmlSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public InputStream listSitePublishingProfileXmlSlot(String resourceGroupName, String name, String slot) { return listSitePublishingProfileXmlSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -16363,12 +15873,9 @@ public Observable> call(Response resp FileZilla3 WebDeploy -- default Ftp - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the InputStream object if successful. */ - public InputStream listSitePublishingProfileXmlSlot(String resourceGroupName, String name, String slot, String format) throws CloudException, IOException, IllegalArgumentException { + public InputStream listSitePublishingProfileXmlSlot(String resourceGroupName, String name, String slot, String format) { return listSitePublishingProfileXmlSlotWithServiceResponseAsync(resourceGroupName, name, slot, format).toBlocking().single().getBody(); } @@ -16467,12 +15974,9 @@ private ServiceResponse listSitePublishingProfileXmlSlotDelegate(Re * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object restartSiteSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object restartSiteSlot(String resourceGroupName, String name, String slot) { return restartSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -16554,12 +16058,9 @@ public Observable> call(Response response) * @param slot Name of web app slot. If not specified then will default to production slot. * @param softRestart Soft restart applies the configuration settings and restarts the app if necessary. Hard restart always restarts and reprovisions the app * @param synchronous If true then the API will block until the app has been restarted - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object restartSiteSlot(String resourceGroupName, String name, String slot, Boolean softRestart, Boolean synchronous) throws CloudException, IOException, IllegalArgumentException { + public Object restartSiteSlot(String resourceGroupName, String name, String slot, Boolean softRestart, Boolean synchronous) { return restartSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot, softRestart, synchronous).toBlocking().single().getBody(); } @@ -16649,12 +16150,9 @@ private ServiceResponse restartSiteSlotDelegate(Response r * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object restartSite(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object restartSite(String resourceGroupName, String name) { return restartSiteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -16729,12 +16227,9 @@ public Observable> call(Response response) * @param name Name of web app * @param softRestart Soft restart applies the configuration settings and restarts the app if necessary. Hard restart always restarts and reprovisions the app * @param synchronous If true then the API will block until the app has been restarted - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object restartSite(String resourceGroupName, String name, Boolean softRestart, Boolean synchronous) throws CloudException, IOException, IllegalArgumentException { + public Object restartSite(String resourceGroupName, String name, Boolean softRestart, Boolean synchronous) { return restartSiteWithServiceResponseAsync(resourceGroupName, name, softRestart, synchronous).toBlocking().single().getBody(); } @@ -16818,12 +16313,9 @@ private ServiceResponse restartSiteDelegate(Response respo * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object startSite(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object startSite(String resourceGroupName, String name) { return startSiteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -16902,12 +16394,9 @@ private ServiceResponse startSiteDelegate(Response respons * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object startSiteSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object startSiteSlot(String resourceGroupName, String name, String slot) { return startSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -16991,12 +16480,9 @@ private ServiceResponse startSiteSlotDelegate(Response res * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object stopSite(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object stopSite(String resourceGroupName, String name) { return stopSiteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -17075,12 +16561,9 @@ private ServiceResponse stopSiteDelegate(Response response * @param resourceGroupName Name of resource group * @param name Name of web app * @param slot Name of web app slot. If not specified then will default to production slot. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object stopSiteSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object stopSiteSlot(String resourceGroupName, String name, String slot) { return stopSiteSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -17163,12 +16646,9 @@ private ServiceResponse stopSiteSlotDelegate(Response resp * * @param resourceGroupName the String value * @param name the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object syncSiteRepository(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object syncSiteRepository(String resourceGroupName, String name) { return syncSiteRepositoryWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -17243,12 +16723,9 @@ private ServiceResponse syncSiteRepositoryDelegate(Response syncSiteRepositorySlotDelegate(Response generateNewSitePublishingPasswordSlotDelegate(Re * * @param resourceGroupName Name of resource group * @param name Name of web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object generateNewSitePublishingPassword(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public Object generateNewSitePublishingPassword(String resourceGroupName, String name) { return generateNewSitePublishingPasswordWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -17503,12 +16974,9 @@ private ServiceResponse generateNewSitePublishingPasswordDelegate(Respon * @param resourceGroupName The resource group name * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner getSiteRelayServiceConnection(String resourceGroupName, String name, String entityName) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner getSiteRelayServiceConnection(String resourceGroupName, String name, String entityName) { return getSiteRelayServiceConnectionWithServiceResponseAsync(resourceGroupName, name, entityName).toBlocking().single().getBody(); } @@ -17594,12 +17062,9 @@ private ServiceResponse getSiteRelayServiceCo * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified * @param connectionEnvelope The details of the Hybrid Connection - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner createOrUpdateSiteRelayServiceConnection(String resourceGroupName, String name, String entityName, RelayServiceConnectionEntityInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner createOrUpdateSiteRelayServiceConnection(String resourceGroupName, String name, String entityName, RelayServiceConnectionEntityInner connectionEnvelope) { return createOrUpdateSiteRelayServiceConnectionWithServiceResponseAsync(resourceGroupName, name, entityName, connectionEnvelope).toBlocking().single().getBody(); } @@ -17691,12 +17156,9 @@ private ServiceResponse createOrUpdateSiteRel * @param resourceGroupName The resource group name * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteRelayServiceConnection(String resourceGroupName, String name, String entityName) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteRelayServiceConnection(String resourceGroupName, String name, String entityName) { return deleteSiteRelayServiceConnectionWithServiceResponseAsync(resourceGroupName, name, entityName).toBlocking().single().getBody(); } @@ -17782,12 +17244,9 @@ private ServiceResponse deleteSiteRelayServiceConnectionDelegate(Respons * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified * @param connectionEnvelope The details of the Hybrid Connection - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner updateSiteRelayServiceConnection(String resourceGroupName, String name, String entityName, RelayServiceConnectionEntityInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner updateSiteRelayServiceConnection(String resourceGroupName, String name, String entityName, RelayServiceConnectionEntityInner connectionEnvelope) { return updateSiteRelayServiceConnectionWithServiceResponseAsync(resourceGroupName, name, entityName, connectionEnvelope).toBlocking().single().getBody(); } @@ -17880,12 +17339,9 @@ private ServiceResponse updateSiteRelayServic * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified * @param slot The name of the slot for the web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner getSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner getSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot) { return getSiteRelayServiceConnectionSlotWithServiceResponseAsync(resourceGroupName, name, entityName, slot).toBlocking().single().getBody(); } @@ -17978,12 +17434,9 @@ private ServiceResponse getSiteRelayServiceCo * @param entityName The name by which the Hybrid Connection is identified * @param slot The name of the slot for the web app. * @param connectionEnvelope The details of the Hybrid Connection - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner createOrUpdateSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot, RelayServiceConnectionEntityInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner createOrUpdateSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot, RelayServiceConnectionEntityInner connectionEnvelope) { return createOrUpdateSiteRelayServiceConnectionSlotWithServiceResponseAsync(resourceGroupName, name, entityName, slot, connectionEnvelope).toBlocking().single().getBody(); } @@ -18082,12 +17535,9 @@ private ServiceResponse createOrUpdateSiteRel * @param name The name of the web app * @param entityName The name by which the Hybrid Connection is identified * @param slot The name of the slot for the web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object deleteSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object deleteSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot) { return deleteSiteRelayServiceConnectionSlotWithServiceResponseAsync(resourceGroupName, name, entityName, slot).toBlocking().single().getBody(); } @@ -18180,12 +17630,9 @@ private ServiceResponse deleteSiteRelayServiceConnectionSlotDelegate(Res * @param entityName The name by which the Hybrid Connection is identified * @param slot The name of the slot for the web app. * @param connectionEnvelope The details of the Hybrid Connection - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner updateSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot, RelayServiceConnectionEntityInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner updateSiteRelayServiceConnectionSlot(String resourceGroupName, String name, String entityName, String slot, RelayServiceConnectionEntityInner connectionEnvelope) { return updateSiteRelayServiceConnectionSlotWithServiceResponseAsync(resourceGroupName, name, entityName, slot, connectionEnvelope).toBlocking().single().getBody(); } @@ -18283,12 +17730,9 @@ private ServiceResponse updateSiteRelayServic * @param resourceGroupName The resource group name * @param name The name of the web app * @param slot The name of the slot for the web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner listSiteRelayServiceConnectionsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner listSiteRelayServiceConnectionsSlot(String resourceGroupName, String name, String slot) { return listSiteRelayServiceConnectionsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -18372,12 +17816,9 @@ private ServiceResponse listSiteRelayServiceC * * @param resourceGroupName The resource group name * @param name The name of the web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the RelayServiceConnectionEntityInner object if successful. */ - public RelayServiceConnectionEntityInner listSiteRelayServiceConnections(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public RelayServiceConnectionEntityInner listSiteRelayServiceConnections(String resourceGroupName, String name) { return listSiteRelayServiceConnectionsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -18458,12 +17899,9 @@ private ServiceResponse listSiteRelayServiceC * @param vnetName The name of the Virtual Network * @param gatewayName The name of the gateway. The only gateway that exists presently is "primary" * @param slot The name of the slot for this web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getSiteVnetGatewaySlot(String resourceGroupName, String name, String vnetName, String gatewayName, String slot) throws CloudException, IOException, IllegalArgumentException { + public Object getSiteVnetGatewaySlot(String resourceGroupName, String name, String vnetName, String gatewayName, String slot) { return getSiteVnetGatewaySlotWithServiceResponseAsync(resourceGroupName, name, vnetName, gatewayName, slot).toBlocking().single().getBody(); } @@ -18564,12 +18002,9 @@ private ServiceResponse getSiteVnetGatewaySlotDelegate(Response createOrUpdateSiteVNETConnectionGatewa * @param gatewayName The name of the gateway. The only gateway that exists presently is "primary" * @param slot The name of the slot for this web app. * @param connectionEnvelope The properties to update this gateway with. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetGatewayInner object if successful. */ - public VnetGatewayInner updateSiteVNETConnectionGatewaySlot(String resourceGroupName, String name, String vnetName, String gatewayName, String slot, VnetGatewayInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public VnetGatewayInner updateSiteVNETConnectionGatewaySlot(String resourceGroupName, String name, String vnetName, String gatewayName, String slot, VnetGatewayInner connectionEnvelope) { return updateSiteVNETConnectionGatewaySlotWithServiceResponseAsync(resourceGroupName, name, vnetName, gatewayName, slot, connectionEnvelope).toBlocking().single().getBody(); } @@ -18786,12 +18218,9 @@ private ServiceResponse updateSiteVNETConnectionGatewaySlotDel * @param name The name of the web app * @param vnetName The name of the Virtual Network * @param gatewayName The name of the gateway. The only gateway that exists presently is "primary" - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getSiteVnetGateway(String resourceGroupName, String name, String vnetName, String gatewayName) throws CloudException, IOException, IllegalArgumentException { + public Object getSiteVnetGateway(String resourceGroupName, String name, String vnetName, String gatewayName) { return getSiteVnetGatewayWithServiceResponseAsync(resourceGroupName, name, vnetName, gatewayName).toBlocking().single().getBody(); } @@ -18885,12 +18314,9 @@ private ServiceResponse getSiteVnetGatewayDelegate(Response createOrUpdateSiteVNETConnectionGatewa * @param vnetName The name of the Virtual Network * @param gatewayName The name of the gateway. The only gateway that exists presently is "primary" * @param connectionEnvelope The properties to update this gateway with. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the VnetGatewayInner object if successful. */ - public VnetGatewayInner updateSiteVNETConnectionGateway(String resourceGroupName, String name, String vnetName, String gatewayName, VnetGatewayInner connectionEnvelope) throws CloudException, IOException, IllegalArgumentException { + public VnetGatewayInner updateSiteVNETConnectionGateway(String resourceGroupName, String name, String vnetName, String gatewayName, VnetGatewayInner connectionEnvelope) { return updateSiteVNETConnectionGatewayWithServiceResponseAsync(resourceGroupName, name, vnetName, gatewayName, connectionEnvelope).toBlocking().single().getBody(); } @@ -19092,12 +18515,9 @@ private ServiceResponse updateSiteVNETConnectionGatewayDelegat * * @param resourceGroupName The resource group name * @param name The name of the web app - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VnetInfoInner> object if successful. */ - public List getSiteVNETConnections(String resourceGroupName, String name) throws CloudException, IOException, IllegalArgumentException { + public List getSiteVNETConnections(String resourceGroupName, String name) { return getSiteVNETConnectionsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -19176,12 +18596,9 @@ private ServiceResponse> getSiteVNETConnectionsDelegate(Resp * @param resourceGroupName The resource group name * @param name The name of the web app * @param slot The name of the slot for this web app. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<VnetInfoInner> object if successful. */ - public List getSiteVNETConnectionsSlot(String resourceGroupName, String name, String slot) throws CloudException, IOException, IllegalArgumentException { + public List getSiteVNETConnectionsSlot(String resourceGroupName, String name, String slot) { return getSiteVNETConnectionsSlotWithServiceResponseAsync(resourceGroupName, name, slot).toBlocking().single().getBody(); } @@ -19264,16 +18681,13 @@ private ServiceResponse> getSiteVNETConnectionsSlotDelegate( * Get the difference in configuration settings between two web app slots. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SlotDifferenceInner> object if successful. */ - public PagedList getSlotsDifferencesFromProductionNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSlotsDifferencesFromProductionNext(final String nextPageLink) { ServiceResponse> response = getSlotsDifferencesFromProductionNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSlotsDifferencesFromProductionNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19370,16 +18784,13 @@ private ServiceResponse> getSlotsDifferencesFromPr * Get the difference in configuration settings between two web app slots. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SlotDifferenceInner> object if successful. */ - public PagedList getSlotsDifferencesSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSlotsDifferencesSlotNext(final String nextPageLink) { ServiceResponse> response = getSlotsDifferencesSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSlotsDifferencesSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19476,16 +18887,13 @@ private ServiceResponse> getSlotsDifferencesSlotNe * Gets all the slots for a web apps. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInner> object if successful. */ - public PagedList getSiteSlotsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteSlotsNext(final String nextPageLink) { ServiceResponse> response = getSiteSlotsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteSlotsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19582,16 +18990,13 @@ private ServiceResponse> getSiteSlotsNextDelegate(Response getSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSitesNext(final String nextPageLink) { ServiceResponse> response = getSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19688,16 +19093,13 @@ private ServiceResponse> getSitesNextDelegate(Response getDeletedSitesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeletedSitesNext(final String nextPageLink) { ServiceResponse> response = getDeletedSitesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeletedSitesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19794,16 +19196,13 @@ private ServiceResponse> getDeletedSitesNextDelegate( * List deployments. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getDeploymentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeploymentsNext(final String nextPageLink) { ServiceResponse> response = getDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -19900,16 +19299,13 @@ private ServiceResponse> getDeploymentsNextDelegate(Re * List deployments. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getDeploymentsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getDeploymentsSlotNext(final String nextPageLink) { ServiceResponse> response = getDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20006,16 +19402,13 @@ private ServiceResponse> getDeploymentsSlotNextDelegat * List deployments. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getInstanceDeploymentsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getInstanceDeploymentsNext(final String nextPageLink) { ServiceResponse> response = getInstanceDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getInstanceDeploymentsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20112,16 +19505,13 @@ private ServiceResponse> getInstanceDeploymentsNextDel * List deployments. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<DeploymentInner> object if successful. */ - public PagedList getInstanceDeploymentsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getInstanceDeploymentsSlotNext(final String nextPageLink) { ServiceResponse> response = getInstanceDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getInstanceDeploymentsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20218,16 +19608,13 @@ private ServiceResponse> getInstanceDeploymentsSlotNex * Gets all instance of a web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInstanceInner> object if successful. */ - public PagedList getSiteInstanceIdentifiersNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteInstanceIdentifiersNext(final String nextPageLink) { ServiceResponse> response = getSiteInstanceIdentifiersNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteInstanceIdentifiersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20324,16 +19711,13 @@ private ServiceResponse> getSiteInstanceIdentifiersN * Gets all instance of a web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SiteInstanceInner> object if successful. */ - public PagedList getSiteInstanceIdentifiersSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteInstanceIdentifiersSlotNext(final String nextPageLink) { ServiceResponse> response = getSiteInstanceIdentifiersSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteInstanceIdentifiersSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20430,16 +19814,13 @@ private ServiceResponse> getSiteInstanceIdentifiersS * Get web app hostname bindings. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostNameBindingInner> object if successful. */ - public PagedList getSiteHostNameBindingsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteHostNameBindingsNext(final String nextPageLink) { ServiceResponse> response = getSiteHostNameBindingsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteHostNameBindingsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20536,16 +19917,13 @@ private ServiceResponse> getSiteHostNameBindingsN * Get web app hostname bindings. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<HostNameBindingInner> object if successful. */ - public PagedList getSiteHostNameBindingsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteHostNameBindingsSlotNext(final String nextPageLink) { ServiceResponse> response = getSiteHostNameBindingsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteHostNameBindingsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20642,16 +20020,13 @@ private ServiceResponse> getSiteHostNameBindingsS * Lists all available backups for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<BackupItemInner> object if successful. */ - public PagedList listSiteBackupsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSiteBackupsNext(final String nextPageLink) { ServiceResponse> response = listSiteBackupsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSiteBackupsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20748,16 +20123,13 @@ private ServiceResponse> listSiteBackupsNextDelegate(R * Lists all available backups for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<BackupItemInner> object if successful. */ - public PagedList listSiteBackupsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listSiteBackupsSlotNext(final String nextPageLink) { ServiceResponse> response = listSiteBackupsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listSiteBackupsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20854,16 +20226,13 @@ private ServiceResponse> listSiteBackupsSlotNextDelega * Gets the quota usage numbers for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getSiteUsagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsagesNext(final String nextPageLink) { ServiceResponse> response = getSiteUsagesNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -20960,16 +20329,13 @@ private ServiceResponse> getSiteUsagesNextDelegate( * Gets the quota usage numbers for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CsmUsageQuotaInner> object if successful. */ - public PagedList getSiteUsagesSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteUsagesSlotNext(final String nextPageLink) { ServiceResponse> response = getSiteUsagesSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteUsagesSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -21066,16 +20432,13 @@ private ServiceResponse> getSiteUsagesSlotNextDeleg * Gets metrics for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getSiteMetricsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricsNext(final String nextPageLink) { ServiceResponse> response = getSiteMetricsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -21172,16 +20535,13 @@ private ServiceResponse> getSiteMetricsNextDelegat * Gets metrics for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<ResourceMetricInner> object if successful. */ - public PagedList getSiteMetricsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricsSlotNext(final String nextPageLink) { ServiceResponse> response = getSiteMetricsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -21278,16 +20638,13 @@ private ServiceResponse> getSiteMetricsSlotNextDel * Gets metric definitions for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getSiteMetricDefinitionsSlotNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricDefinitionsSlotNext(final String nextPageLink) { ServiceResponse> response = getSiteMetricDefinitionsSlotNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricDefinitionsSlotNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -21384,16 +20741,13 @@ private ServiceResponse> getSiteMetricDefinition * Gets metric definitions for web app. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<MetricDefinitionInner> object if successful. */ - public PagedList getSiteMetricDefinitionsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getSiteMetricDefinitionsNext(final String nextPageLink) { ServiceResponse> response = getSiteMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getSiteMetricDefinitionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/TopLevelDomainsInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/TopLevelDomainsInner.java index 9fd29283824a4..796f48bcf655d 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/TopLevelDomainsInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/TopLevelDomainsInner.java @@ -17,7 +17,6 @@ import com.microsoft.azure.management.website.TopLevelDomainAgreementOption; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -86,16 +85,13 @@ interface TopLevelDomainsService { /** * Lists all top level domains supported for registration. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TopLevelDomainInner> object if successful. */ - public PagedList getGetTopLevelDomains() throws CloudException, IOException, IllegalArgumentException { + public PagedList getGetTopLevelDomains() { ServiceResponse> response = getGetTopLevelDomainsSinglePageAsync().toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getGetTopLevelDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -190,12 +186,9 @@ private ServiceResponse> getGetTopLevelDomainsDele * Gets details of a top level domain. * * @param name Name of the top level domain - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the TopLevelDomainInner object if successful. */ - public TopLevelDomainInner getTopLevelDomain(String name) throws CloudException, IOException, IllegalArgumentException { + public TopLevelDomainInner getTopLevelDomain(String name) { return getTopLevelDomainWithServiceResponseAsync(name).toBlocking().single().getBody(); } @@ -266,16 +259,13 @@ private ServiceResponse getTopLevelDomainDelegate(Response< * Lists legal agreements that user needs to accept before purchasing domain. * * @param name Name of the top level domain - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TldLegalAgreementInner> object if successful. */ - public PagedList listTopLevelDomainAgreements(final String name) throws CloudException, IOException, IllegalArgumentException { + public PagedList listTopLevelDomainAgreements(final String name) { ServiceResponse> response = listTopLevelDomainAgreementsSinglePageAsync(name).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listTopLevelDomainAgreementsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -374,16 +364,13 @@ public Observable>> call(Response listTopLevelDomainAgreements(final String name, final Boolean includePrivacy) throws CloudException, IOException, IllegalArgumentException { + public PagedList listTopLevelDomainAgreements(final String name, final Boolean includePrivacy) { ServiceResponse> response = listTopLevelDomainAgreementsSinglePageAsync(name, includePrivacy).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listTopLevelDomainAgreementsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -491,16 +478,13 @@ private ServiceResponse> listTopLevelDomainAgre * Lists all top level domains supported for registration. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TopLevelDomainInner> object if successful. */ - public PagedList getGetTopLevelDomainsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList getGetTopLevelDomainsNext(final String nextPageLink) { ServiceResponse> response = getGetTopLevelDomainsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return getGetTopLevelDomainsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -597,16 +581,13 @@ private ServiceResponse> getGetTopLevelDomainsNext * Lists legal agreements that user needs to accept before purchasing domain. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<TldLegalAgreementInner> object if successful. */ - public PagedList listTopLevelDomainAgreementsNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + public PagedList listTopLevelDomainAgreementsNext(final String nextPageLink) { ServiceResponse> response = listTopLevelDomainAgreementsNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { + public Page nextPage(String nextPageLink) { return listTopLevelDomainAgreementsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; diff --git a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/UsagesInner.java b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/UsagesInner.java index d36b352b68fdb..9d2a730ad0ddb 100644 --- a/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/UsagesInner.java +++ b/azure-mgmt-website/src/main/java/com/microsoft/azure/management/website/implementation/UsagesInner.java @@ -65,12 +65,9 @@ interface UsagesService { * @param environmentName Environment name * @param lastId Last marker that was returned from the batch * @param batchSize size of the batch to be returned. - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Object object if successful. */ - public Object getUsage(String resourceGroupName, String environmentName, String lastId, int batchSize) throws CloudException, IOException, IllegalArgumentException { + public Object getUsage(String resourceGroupName, String environmentName, String lastId, int batchSize) { return getUsageWithServiceResponseAsync(resourceGroupName, environmentName, lastId, batchSize).toBlocking().single().getBody(); } diff --git a/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java b/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java index 46c02402ed531..86a4f9afcd6a3 100644 --- a/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java +++ b/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java @@ -7,9 +7,6 @@ package com.microsoft.azure; -import com.microsoft.rest.RestException; - -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -54,17 +51,13 @@ public PagedList(Page page) { } private void cachePage(String nextPageLink) { - try { - while (nextPageLink != null) { - cachedPage = nextPage(nextPageLink); - nextPageLink = cachedPage.getNextPageLink(); - if (hasNextPage()) { - // a legit, non-empty page has been fetched, otherwise keep fetching - break; - } + while (nextPageLink != null) { + cachedPage = nextPage(nextPageLink); + nextPageLink = cachedPage.getNextPageLink(); + if (hasNextPage()) { + // a legit, non-empty page has been fetched, otherwise keep fetching + break; } - } catch (IOException ex) { - throw new RuntimeException(ex); } } @@ -73,10 +66,8 @@ private void cachePage(String nextPageLink) { * * @param nextPageLink the link to get the next page of items. * @return the {@link Page} object storing a page of items and a link to the next page. - * @throws RestException thrown if an error is raised from Azure. - * @throws IOException thrown if there's any failure in deserialization. */ - public abstract Page nextPage(String nextPageLink) throws RestException, IOException; + public abstract Page nextPage(String nextPageLink); /** * If there are more pages available. diff --git a/runtimes/azure-client-runtime/src/test/java/com/microsoft/azure/PagedListTests.java b/runtimes/azure-client-runtime/src/test/java/com/microsoft/azure/PagedListTests.java index 04567aa1c6730..dfac45400504b 100644 --- a/runtimes/azure-client-runtime/src/test/java/com/microsoft/azure/PagedListTests.java +++ b/runtimes/azure-client-runtime/src/test/java/com/microsoft/azure/PagedListTests.java @@ -11,7 +11,6 @@ import org.junit.Before; import org.junit.Test; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,7 +22,7 @@ public class PagedListTests { public void setupList() { list = new PagedList(new TestPage(0, 21)) { @Override - public Page nextPage(String nextPageLink) throws CloudException, IOException { + public Page nextPage(String nextPageLink) { int pageNum = Integer.parseInt(nextPageLink); return new TestPage(pageNum, 21); } From a186bb74c616d48ffc20a6820fb48e31b64f99ce Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 15 Sep 2016 00:43:47 -0700 Subject: [PATCH 28/47] handling extenison references --- .../management/compute/VirtualMachine.java | 4 +- .../VirtualMachineExtensionImpl.java | 58 +++++++++++++- .../VirtualMachineExtensionsImpl.java | 30 ++++++-- .../implementation/VirtualMachineImpl.java | 3 +- .../compute/ComputeManagementTestBase.java | 2 +- ...irtualMachineExtensionOperationsTests.java | 77 +++++++++++++++++++ 6 files changed, 163 insertions(+), 11 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java index 11cdde960a851..db3dae63b1958 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java @@ -195,8 +195,10 @@ public interface VirtualMachine extends /** * @return the extensions attached to the Azure Virtual Machine + * @throws CloudException exceptions thrown from the cloud. + * @throws IOException exceptions thrown from serialization/deserialization. */ - Map extensions(); + Map extensions() throws CloudException, IOException; /** * @return the plan value diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java index 13519bb0fa48d..e4dd4d818cfde 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java @@ -4,6 +4,7 @@ import com.microsoft.azure.management.compute.VirtualMachineExtension; import com.microsoft.azure.management.compute.VirtualMachineExtensionImage; import com.microsoft.azure.management.compute.VirtualMachineExtensionInstanceView; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import rx.Observable; import rx.functions.Func1; @@ -200,8 +201,14 @@ public VirtualMachineImpl attach() { @Override public VirtualMachineExtensionImpl refresh() throws Exception { + String name; + if (this.isReference()) { + name = ResourceUtils.nameFromResourceId(this.inner().id()); + } else { + name = this.inner().name(); + } VirtualMachineExtensionInner inner = - this.client.get(this.parent.resourceGroupName(), this.parent.name(), this.name()); + this.client.get(this.parent.resourceGroupName(), this.parent.name(), name); this.setInner(inner); return this; } @@ -227,7 +234,43 @@ public VirtualMachineExtension call(VirtualMachineExtensionInner inner) { @Override public Observable updateAsync() { - return this.createAsync(); + if (this.isReference()) { + String extensionName = ResourceUtils.nameFromResourceId(this.inner().id()); + return this.client.getAsync(this.parent().resourceGroupName(), + this.parent().name(), extensionName) + .flatMap(new Func1>() { + @Override + public Observable call(VirtualMachineExtensionInner resource) { + inner() + .withPublisher(resource.publisher()) + .withVirtualMachineExtensionType(resource.virtualMachineExtensionType()) + .withTypeHandlerVersion(resource.typeHandlerVersion()); + if (inner().autoUpgradeMinorVersion() == null) { + inner().withAutoUpgradeMinorVersion(resource.autoUpgradeMinorVersion()); + } + if (resource.settings() != null) { + LinkedHashMap settings = + (LinkedHashMap) resource.settings(); + if (settings.size() > 0) { + if (inner().settings() == null) { + inner().withSettings(settings); + } else { + LinkedHashMap innerSettings = + (LinkedHashMap) inner().settings(); + for (Map.Entry entry : settings.entrySet()) { + if (!innerSettings.containsKey(entry.getKey())) { + innerSettings.put(entry.getKey(), entry.getValue()); + } + } + } + } + } + return createAsync(); + } + }); + } else { + return this.createAsync(); + } } @Override @@ -242,6 +285,17 @@ public Void call(Void result) { }); } + /** + * @return true if this is just a reference to the extension. + *

+ * An extension will present as a reference when the parent virtual machine was fetched using + * VM list, a GET on a specific VM will return fully expanded extension details. + *

+ */ + public boolean isReference() { + return this.inner().name() == null; + } + // Helper methods // private void nullifySettingsIfEmpty() { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java index 37da115a015ea..328e1812d0b67 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java @@ -1,7 +1,9 @@ package com.microsoft.azure.management.compute.implementation; import com.microsoft.azure.management.compute.VirtualMachineExtension; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -32,11 +34,19 @@ class VirtualMachineExtensionsImpl extends /** * @return the extension as a map indexed by name. + * @throws IOException the io exception */ - public Map asMap() { + public Map asMap() throws IOException { Map result = new HashMap<>(); for (Map.Entry entry : this.collection().entrySet()) { - result.put(entry.getKey(), entry.getValue()); + VirtualMachineExtensionImpl extension = entry.getValue(); + if (extension.isReference()) { + extension = new VirtualMachineExtensionImpl(entry.getKey(), + this.parent(), + this.client.get(parent().resourceGroupName(), parent().name(), entry.getKey()), + this.client); + } + result.put(entry.getKey(), extension); } return Collections.unmodifiableMap(result); } @@ -84,10 +94,18 @@ protected List listChildResources() { List childResources = new ArrayList<>(); if (parent().inner().resources() != null) { for (VirtualMachineExtensionInner inner : parent().inner().resources()) { - childResources.add(new VirtualMachineExtensionImpl(inner.name(), - this.parent(), - inner, - this.client)); + if (inner.name() == null) { + inner.withLocation(parent().regionName()); + childResources.add(new VirtualMachineExtensionImpl(ResourceUtils.nameFromResourceId(inner.id()), + this.parent(), + inner, + this.client)); + } else { + childResources.add(new VirtualMachineExtensionImpl(inner.name(), + this.parent(), + inner, + this.client)); + } } } return childResources; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index b18ccb1329277..3330d7e701160 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -55,6 +55,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -827,7 +828,7 @@ public String licenseType() { } @Override - public Map extensions() { + public Map extensions() throws CloudException, IOException { return this.virtualMachineExtensions.asMap(); } diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/ComputeManagementTestBase.java b/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/ComputeManagementTestBase.java index d592d2da2a92d..528c7b8a38a6b 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/ComputeManagementTestBase.java +++ b/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/ComputeManagementTestBase.java @@ -16,7 +16,7 @@ public static void createClients() { System.getenv("client-id"), System.getenv("domain"), System.getenv("secret"), - null); + AzureEnvironment.AZURE); RestClient restClient = AzureEnvironment.AZURE.newRestClientBuilder() .withCredentials(credentials) diff --git a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/VirtualMachineExtensionOperationsTests.java b/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/VirtualMachineExtensionOperationsTests.java index 914157c496db8..2c8423b840647 100644 --- a/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/VirtualMachineExtensionOperationsTests.java +++ b/azure-mgmt-compute/src/test/java/com/microsoft/azure/management/compute/VirtualMachineExtensionOperationsTests.java @@ -116,4 +116,81 @@ public void canInstallUninstallCustomExtension() throws Exception { Assert.assertTrue(vm.extensions().size() == 0); } + + @Test + public void canHandleExtensionReference() throws Exception { + final String RG_NAME = ResourceNamer.randomResourceName("vmexttest", 15); + final String LOCATION = "eastus"; + final String VMNAME = "javavm"; + + // Create a Linux VM + // + VirtualMachine vm = computeManager.virtualMachines() + .define(VMNAME) + .withRegion(LOCATION) + .withNewResourceGroup(RG_NAME) + .withNewPrimaryNetwork("10.0.0.0/28") + .withPrimaryPrivateIpAddressDynamic() + .withoutPrimaryPublicIpAddress() + .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS) + .withRootUserName("Foo12") + .withPassword("BaR@12abc!") + .withSize(VirtualMachineSizeTypes.STANDARD_D3) + .defineNewExtension("VMAccessForLinux") + .withPublisher("Microsoft.OSTCExtensions") + .withType("VMAccessForLinux") + .withVersion("1.4") + .withProtectedSetting("username", "Foo12") + .withProtectedSetting("password", "B12a6@12xyz!") + .withProtectedSetting("reset_ssh", "true") + .attach() + .create(); + + Assert.assertTrue(vm.extensions().size() > 0); + + // Get the created virtual machine via VM List not by VM GET + List virtualMachines = computeManager.virtualMachines() + .listByGroup(RG_NAME); + VirtualMachine vmWithExtensionReference = null; + for (VirtualMachine virtualMachine : virtualMachines) { + if (virtualMachine.name().equalsIgnoreCase(VMNAME)) { + vmWithExtensionReference = virtualMachine; + break; + } + } + // The VM retrieved from the list will contain extensions as reference (i.e. with only id) + Assert.assertNotNull(vmWithExtensionReference); + + // Update the extension + VirtualMachine vmWithExtensionUpdated = vmWithExtensionReference.update() + .updateExtension("VMAccessForLinux") + .withProtectedSetting("username", "Foo12") + .withProtectedSetting("password", "muy!234OR") + .withProtectedSetting("reset_ssh", "true") + .parent() + .apply(); + + // Again getting VM with extension reference + virtualMachines = computeManager.virtualMachines() + .listByGroup(RG_NAME); + vmWithExtensionReference = null; + for (VirtualMachine virtualMachine : virtualMachines) { + vmWithExtensionReference = virtualMachine; + } + Assert.assertNotNull(vmWithExtensionReference); + + VirtualMachineExtension accessExtension = null; + for (VirtualMachineExtension extension : vmWithExtensionReference.extensions().values()) { + if (extension.name().equalsIgnoreCase("VMAccessForLinux")) { + accessExtension = extension; + break; + } + } + // Even though VM's inner contain just extension reference VirtualMachine::extensions() + // should resolve the reference and get full extension. + Assert.assertNotNull(accessExtension); + Assert.assertNull(accessExtension.publisherName()); + Assert.assertNull(accessExtension.typeName()); + Assert.assertNull(accessExtension.versionName()); + } } \ No newline at end of file From 55cff3613e21230c187ac7e94574970ec0473a25 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 15 Sep 2016 07:26:24 -0700 Subject: [PATCH 29/47] fix build failure --- .../azure/management/samples/Utils.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java b/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java index 191bfd0611ff1..4e8d0ab83abaa 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java @@ -122,17 +122,21 @@ public static void print(VirtualMachine resource) { } StringBuilder extensions = new StringBuilder().append("\n\tExtensions: "); - for (Map.Entry extensionEntry : resource.extensions().entrySet()) { - VirtualMachineExtension extension = extensionEntry.getValue(); - extensions.append("\n\t\tExtension: ").append(extension.id()) - .append("\n\t\t\tName: ").append(extension.name()) - .append("\n\t\t\tTags: ").append(extension.tags()) - .append("\n\t\t\tProvisioningState: ").append(extension.provisioningState()) - .append("\n\t\t\tAuto upgrade minor version enabled: ").append(extension.autoUpgradeMinorVersionEnabled()) - .append("\n\t\t\tPublisher: ").append(extension.publisherName()) - .append("\n\t\t\tType: ").append(extension.typeName()) - .append("\n\t\t\tVersion: ").append(extension.versionName()) - .append("\n\t\t\tPublic Settings: ").append(extension.publicSettingsAsJsonString()); + try { + for (Map.Entry extensionEntry : resource.extensions().entrySet()) { + VirtualMachineExtension extension = extensionEntry.getValue(); + extensions.append("\n\t\tExtension: ").append(extension.id()) + .append("\n\t\t\tName: ").append(extension.name()) + .append("\n\t\t\tTags: ").append(extension.tags()) + .append("\n\t\t\tProvisioningState: ").append(extension.provisioningState()) + .append("\n\t\t\tAuto upgrade minor version enabled: ").append(extension.autoUpgradeMinorVersionEnabled()) + .append("\n\t\t\tPublisher: ").append(extension.publisherName()) + .append("\n\t\t\tType: ").append(extension.typeName()) + .append("\n\t\t\tVersion: ").append(extension.versionName()) + .append("\n\t\t\tPublic Settings: ").append(extension.publicSettingsAsJsonString()); + } + } catch (IOException ioException) { + throw new RuntimeException(ioException); } From 94b238c5720988eeefd6b8a2c42d40fe3e379cff Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 15 Sep 2016 07:37:28 -0700 Subject: [PATCH 30/47] Fix checkstyle error --- .../management/compute/implementation/VirtualMachineImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index 3330d7e701160..0721fae2f5b75 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -55,7 +55,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; From d829c89593f11f783a2c2df86ffe2f3841b578cc Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 09:09:15 -0700 Subject: [PATCH 31/47] Let's not break everyone with paged list yet --- .../fluentcore/utils/PagedListConverter.java | 4 +++- .../java/com/microsoft/azure/PagedList.java | 23 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java index 9d8a23de785d7..8e84d87007c03 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/utils/PagedListConverter.java @@ -9,7 +9,9 @@ import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.implementation.PageImpl; +import com.microsoft.rest.RestException; +import java.io.IOException; import java.util.ArrayList; /** @@ -47,7 +49,7 @@ public PagedList convert(final PagedList uList) { } return new PagedList(vPage) { @Override - public Page nextPage(String nextPageLink) { + public Page nextPage(String nextPageLink) throws RestException, IOException { Page uPage = uList.nextPage(nextPageLink); PageImpl vPage = new PageImpl<>(); vPage.setNextPageLink(uPage.getNextPageLink()); diff --git a/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java b/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java index 86a4f9afcd6a3..46c02402ed531 100644 --- a/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java +++ b/runtimes/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java @@ -7,6 +7,9 @@ package com.microsoft.azure; +import com.microsoft.rest.RestException; + +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -51,13 +54,17 @@ public PagedList(Page page) { } private void cachePage(String nextPageLink) { - while (nextPageLink != null) { - cachedPage = nextPage(nextPageLink); - nextPageLink = cachedPage.getNextPageLink(); - if (hasNextPage()) { - // a legit, non-empty page has been fetched, otherwise keep fetching - break; + try { + while (nextPageLink != null) { + cachedPage = nextPage(nextPageLink); + nextPageLink = cachedPage.getNextPageLink(); + if (hasNextPage()) { + // a legit, non-empty page has been fetched, otherwise keep fetching + break; + } } + } catch (IOException ex) { + throw new RuntimeException(ex); } } @@ -66,8 +73,10 @@ private void cachePage(String nextPageLink) { * * @param nextPageLink the link to get the next page of items. * @return the {@link Page} object storing a page of items and a link to the next page. + * @throws RestException thrown if an error is raised from Azure. + * @throws IOException thrown if there's any failure in deserialization. */ - public abstract Page nextPage(String nextPageLink); + public abstract Page nextPage(String nextPageLink) throws RestException, IOException; /** * If there are more pages available. From 419fb6956818fbb750d7a8f328e8c2e40659f107 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 11:28:11 -0700 Subject: [PATCH 32/47] Remove all exceptions thrown in fluent core and actions --- .../management/compute/VirtualMachine.java | 2 + .../VirtualMachineExtensionImageVersion.java | 8 +--- .../management/compute/VirtualMachines.java | 37 ++++--------------- .../implementation/AvailabilitySetsImpl.java | 2 +- .../implementation/ChildListFlattener.java | 6 +-- ...rtualMachineExtensionImageVersionImpl.java | 5 +-- .../VirtualMachineExtensionImagesImpl.java | 19 +++------- .../VirtualMachineImagesImpl.java | 15 +++----- .../VirtualMachinePublishersImpl.java | 7 +--- .../VirtualMachineSizesImpl.java | 7 +--- .../implementation/VirtualMachinesImpl.java | 26 +++++++------ .../graphrbac/ServicePrincipals.java | 14 ++----- .../azure/management/graphrbac/Users.java | 10 +---- .../implementation/ServicePrincipalsImpl.java | 9 ++--- .../graphrbac/implementation/UsersImpl.java | 9 ++--- .../keyvault/implementation/VaultsImpl.java | 2 +- .../management/network/NetworkInterface.java | 12 ++---- .../azure/management/network/Subnet.java | 8 +--- .../implementation/LoadBalancersImpl.java | 2 +- .../implementation/NetworkInterfaceImpl.java | 4 +- .../implementation/NetworkInterfacesImpl.java | 2 +- .../NetworkSecurityGroupsImpl.java | 2 +- .../network/implementation/NetworksImpl.java | 2 +- .../implementation/PublicIpAddressesImpl.java | 2 +- .../network/implementation/SubnetImpl.java | 5 +-- .../management/resources/Deployment.java | 12 ++---- .../management/resources/Deployments.java | 7 +--- .../azure/management/resources/Features.java | 7 +--- .../resources/GenericResources.java | 23 +++--------- .../azure/management/resources/Providers.java | 11 +----- .../management/resources/ResourceGroup.java | 7 +--- .../management/resources/ResourceGroups.java | 7 +--- .../management/resources/Subscription.java | 7 +--- .../collection/SupportsGettingByGroup.java | 5 --- .../arm/collection/SupportsGettingById.java | 6 --- .../CreatableResourcesImpl.java | 6 +-- .../collection/SupportsBatchCreation.java | 6 +-- .../collection/SupportsDeleting.java | 3 +- .../collection/SupportsListing.java | 5 --- .../collection/SupportsListingByRegion.java | 11 +----- .../resources/fluentcore/model/Updatable.java | 3 +- .../implementation/DeploymentImpl.java | 7 ++-- .../implementation/DeploymentsImpl.java | 6 +-- .../FeaturesInResourceProviderImpl.java | 5 +-- .../implementation/GenericResourcesImpl.java | 9 ++--- .../implementation/ProvidersImpl.java | 7 +--- .../implementation/ResourceGroupImpl.java | 4 +- .../implementation/ResourceGroupsImpl.java | 7 +--- .../implementation/SubscriptionImpl.java | 4 +- .../resources/GroupPagedListTests.java | 6 +-- .../management/storage/StorageAccounts.java | 7 +--- .../implementation/StorageAccountsImpl.java | 7 +--- 52 files changed, 115 insertions(+), 297 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java index 9a62a82739d35..21c4293598c51 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java @@ -68,6 +68,8 @@ public interface VirtualMachine extends /** * List of all available virtual machine sizes this virtual machine can resized to. + * + * @return the virtual machine sizes */ PagedList availableSizes(); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtensionImageVersion.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtensionImageVersion.java index 07f4deba96b76..ea5dee05085e5 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtensionImageVersion.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineExtensionImageVersion.java @@ -1,11 +1,8 @@ package com.microsoft.azure.management.compute; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.compute.implementation.VirtualMachineExtensionImageInner; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; -import java.io.IOException; - /** * An immutable client-side representation of an Azure virtual machine extension image version. */ @@ -33,9 +30,6 @@ public interface VirtualMachineExtensionImageVersion extends /** * @return virtual machine extension image this version represents - * - * @throws CloudException thrown for an invalid response from the service - * @throws IOException exception thrown from serialization/deserialization */ - VirtualMachineExtensionImage image() throws CloudException, IOException; + VirtualMachineExtensionImage image(); } \ No newline at end of file diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java index bfe2b274d4065..4aca1c10e329d 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.compute; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; @@ -11,8 +10,6 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; -import java.io.IOException; - /** * Entry point to virtual machine management API. */ @@ -39,21 +36,16 @@ public interface VirtualMachines extends * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException thrown for IO exception. - * @throws InterruptedException exception thrown when the operation is interrupted */ - void deallocate(String groupName, String name) throws CloudException, IOException, InterruptedException; + void deallocate(String groupName, String name); /** * Generalize the Virtual Machine. * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization */ - void generalize(String groupName, String name) throws CloudException, IOException; + void generalize(String groupName, String name); /** * Power off (stop) a virtual machine. @@ -62,44 +54,32 @@ public interface VirtualMachines extends * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void powerOff(String groupName, String name) throws CloudException, IOException, InterruptedException; + void powerOff(String groupName, String name); /** * Restart a virtual machine. * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void restart(String groupName, String name) throws CloudException, IOException, InterruptedException; + void restart(String groupName, String name); /** * Start a virtual machine. * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void start(String groupName, String name) throws CloudException, IOException, InterruptedException; + void start(String groupName, String name); /** * Redeploy a virtual machine. * * @param groupName the resource group name * @param name the virtual machine name - * @throws CloudException thrown for an invalid response from the service. - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - void redeploy(String groupName, String name) throws CloudException, IOException, InterruptedException; + void redeploy(String groupName, String name); /** * Captures the virtual machine by copying virtual hard disks of the VM and returns template as json @@ -110,9 +90,6 @@ public interface VirtualMachines extends * @param containerName destination container name to store the captured Vhd * @param overwriteVhd whether to overwrites destination vhd if it exists * @return the template as json string - * @throws CloudException thrown for an invalid response from the service - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when the operation is interrupted */ - String capture(String groupName, String name, String containerName, boolean overwriteVhd) throws CloudException, IOException, InterruptedException; + String capture(String groupName, String name, String containerName, boolean overwriteVhd); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 39aff4bd430dc..43b7ebc68a971 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -61,7 +61,7 @@ public AvailabilitySetImpl define(String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ChildListFlattener.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ChildListFlattener.java index b095483da8409..85af9aaea1ee8 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ChildListFlattener.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ChildListFlattener.java @@ -40,7 +40,7 @@ interface ChildListLoader { * @throws CloudException exceptions thrown from the cloud * @throws IOException exceptions thrown from serialization/deserialization */ - PagedList loadList(T parent) throws CloudException, IOException; + PagedList loadList(T parent); } /** @@ -61,7 +61,7 @@ interface ChildListLoader { * @throws CloudException exceptions thrown from the cloud * @throws IOException exceptions thrown from serialization/deserialization */ - public PagedList flatten() throws CloudException, IOException { + public PagedList flatten() { this.currentChildList = nextChildList(); if (this.currentChildList == null) { return emptyPagedList(); @@ -93,7 +93,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcept * @throws CloudException exceptions thrown from the cloud * @throws IOException exceptions thrown from serialization/deserialization */ - private PagedList nextChildList() throws CloudException, IOException { + private PagedList nextChildList() { while (parentItr.hasNext()) { PagedList nextChildList = childListLoader.loadList(parentItr.next()); if (nextChildList.iterator().hasNext()) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionImpl.java index ffbb649971304..f78b378e337dd 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImageVersionImpl.java @@ -1,13 +1,10 @@ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.compute.VirtualMachineExtensionImage; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageType; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersion; import com.microsoft.azure.management.resources.fluentcore.model.implementation.WrapperImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineExtensionImageVersion}. */ @@ -46,7 +43,7 @@ public VirtualMachineExtensionImageType type() { } @Override - public VirtualMachineExtensionImage image() throws CloudException, IOException { + public VirtualMachineExtensionImage image() { VirtualMachineExtensionImageInner inner = this.client.get(this.regionName(), this.type().publisher().name(), this.type().name(), diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesImpl.java index a68205c4b21b7..dea1c6b7b1d48 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImagesImpl.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.compute.VirtualMachineExtensionImage; import com.microsoft.azure.management.compute.VirtualMachineExtensionImageType; @@ -11,8 +10,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineExtensionImages}. */ @@ -25,18 +22,18 @@ class VirtualMachineExtensionImagesImpl } @Override - public PagedList listByRegion(Region region) throws CloudException, IOException { + public PagedList listByRegion(Region region) { return listByRegion(region.toString()); } @Override - public PagedList listByRegion(String regionName) throws CloudException, IOException { + public PagedList listByRegion(String regionName) { PagedList publishers = this.publishers().listByRegion(regionName); PagedList extensionTypes = new ChildListFlattener<>(publishers, new ChildListFlattener.ChildListLoader() { @Override - public PagedList loadList(VirtualMachinePublisher publisher) throws CloudException, IOException { + public PagedList loadList(VirtualMachinePublisher publisher) { return publisher.extensionTypes().list(); } }).flatten(); @@ -44,7 +41,7 @@ public PagedList loadList(VirtualMachinePublis PagedList extensionTypeVersions = new ChildListFlattener<>(extensionTypes, new ChildListFlattener.ChildListLoader() { @Override - public PagedList loadList(VirtualMachineExtensionImageType type) throws CloudException, IOException { + public PagedList loadList(VirtualMachineExtensionImageType type) { return type.versions().list(); } }).flatten(); @@ -53,13 +50,7 @@ public PagedList loadList(VirtualMachineExt new PagedListConverter() { @Override public VirtualMachineExtensionImage typeConvert(VirtualMachineExtensionImageVersion virtualMachineExtensionImageVersion) { - try { - return virtualMachineExtensionImageVersion.image(); - } catch (CloudException cloudException) { - throw new RuntimeException(cloudException); - } catch (IOException ioException) { - throw new RuntimeException(ioException); - } + return virtualMachineExtensionImageVersion.image(); } }; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java index 4b7d2c357fd6d..50792d9db85bf 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java @@ -1,18 +1,15 @@ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.VirtualMachineImage; import com.microsoft.azure.management.compute.VirtualMachineImages; import com.microsoft.azure.management.compute.VirtualMachineOffer; import com.microsoft.azure.management.compute.VirtualMachinePublisher; import com.microsoft.azure.management.compute.VirtualMachinePublishers; -import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.VirtualMachineSku; import com.microsoft.azure.management.resources.fluentcore.arm.Region; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineImages}. */ @@ -26,18 +23,18 @@ class VirtualMachineImagesImpl } @Override - public PagedList listByRegion(Region location) throws CloudException, IOException { + public PagedList listByRegion(Region location) { return listByRegion(location.toString()); } @Override - public PagedList listByRegion(String regionName) throws CloudException, IOException { + public PagedList listByRegion(String regionName) { PagedList publishers = this.publishers().listByRegion(regionName); PagedList offers = new ChildListFlattener<>(publishers, new ChildListFlattener.ChildListLoader() { @Override - public PagedList loadList(VirtualMachinePublisher publisher) throws CloudException, IOException { + public PagedList loadList(VirtualMachinePublisher publisher) { return publisher.offers().list(); } }).flatten(); @@ -45,7 +42,7 @@ public PagedList loadList(VirtualMachinePublisher publisher PagedList skus = new ChildListFlattener<>(offers, new ChildListFlattener.ChildListLoader() { @Override - public PagedList loadList(VirtualMachineOffer offer) throws CloudException, IOException { + public PagedList loadList(VirtualMachineOffer offer) { return offer.skus().list(); } }).flatten(); @@ -53,7 +50,7 @@ public PagedList loadList(VirtualMachineOffer offer) throws C PagedList images = new ChildListFlattener<>(skus, new ChildListFlattener.ChildListLoader() { @Override - public PagedList loadList(VirtualMachineSku sku) throws CloudException, IOException { + public PagedList loadList(VirtualMachineSku sku) { return sku.images().list(); } }).flatten(); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinePublishersImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinePublishersImpl.java index ef4a69c7fc9f4..c7cdc2dfb00ef 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinePublishersImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinePublishersImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.VirtualMachinePublisher; @@ -13,8 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachinePublishers}. */ @@ -32,7 +29,7 @@ class VirtualMachinePublishersImpl } @Override - public PagedList listByRegion(Region region) throws CloudException, IOException { + public PagedList listByRegion(Region region) { return listByRegion(region.toString()); } @@ -45,7 +42,7 @@ protected VirtualMachinePublisherImpl wrapModel(VirtualMachineImageResourceInner } @Override - public PagedList listByRegion(String regionName) throws CloudException, IOException { + public PagedList listByRegion(String regionName) { return wrapList(imagesInnerCollection.listPublishers(regionName)); } } \ No newline at end of file diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesImpl.java index d4e0fd2d0048c..c5684e9cce941 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineSizesImpl.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.compute.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.VirtualMachineSize; @@ -13,8 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link VirtualMachineSizes}. */ @@ -29,7 +26,7 @@ class VirtualMachineSizesImpl } @Override - public PagedList listByRegion(Region region) throws CloudException, IOException { + public PagedList listByRegion(Region region) { return listByRegion(region.toString()); } @@ -39,7 +36,7 @@ protected VirtualMachineSizeImpl wrapModel(VirtualMachineSizeInner inner) { } @Override - public PagedList listByRegion(String regionName) throws CloudException, IOException { + public PagedList listByRegion(String regionName) { return wrapList(innerCollection.list(regionName)); } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index 58c937fd8dd5a..810d9aa250011 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -5,8 +5,8 @@ */ package com.microsoft.azure.management.compute.implementation; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.DataDisk; @@ -22,8 +22,8 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.storage.implementation.StorageManager; +import rx.exceptions.Exceptions; -import java.io.IOException; import java.util.ArrayList; /** @@ -74,7 +74,7 @@ public VirtualMachine getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } @@ -89,46 +89,50 @@ public VirtualMachine.DefinitionStages.Blank define(String name) { } @Override - public void deallocate(String groupName, String name) throws CloudException, IOException, InterruptedException { + public void deallocate(String groupName, String name) { this.innerCollection.deallocate(groupName, name); } @Override - public void generalize(String groupName, String name) throws CloudException, IOException { + public void generalize(String groupName, String name) { this.innerCollection.generalize(groupName, name); } @Override - public void powerOff(String groupName, String name) throws CloudException, IOException, InterruptedException { + public void powerOff(String groupName, String name) { this.innerCollection.powerOff(groupName, name); } @Override - public void restart(String groupName, String name) throws CloudException, IOException, InterruptedException { + public void restart(String groupName, String name) { this.innerCollection.restart(groupName, name); } @Override - public void start(String groupName, String name) throws CloudException, IOException, InterruptedException { + public void start(String groupName, String name) { this.innerCollection.start(groupName, name); } @Override - public void redeploy(String groupName, String name) throws CloudException, IOException, InterruptedException { + public void redeploy(String groupName, String name) { this.innerCollection.redeploy(groupName, name); } @Override public String capture(String groupName, String name, String containerName, - boolean overwriteVhd) throws CloudException, IOException, InterruptedException { + boolean overwriteVhd) { VirtualMachineCaptureParametersInner parameters = new VirtualMachineCaptureParametersInner(); parameters.withDestinationContainerName(containerName); parameters.withOverwriteVhds(overwriteVhd); VirtualMachineCaptureResultInner captureResult = this.innerCollection.capture(groupName, name, parameters); ObjectMapper mapper = new ObjectMapper(); //Object to JSON string - return mapper.writeValueAsString(captureResult.output()); + try { + return mapper.writeValueAsString(captureResult.output()); + } catch (JsonProcessingException e) { + throw Exceptions.propagate(e); + } } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java index f9c2a80eecd3b..8dd433fa34a1d 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java @@ -13,8 +13,6 @@ import com.microsoft.rest.ServiceCallback; import rx.Observable; -import java.io.IOException; - /** * Entry point to service principal management API. */ @@ -27,30 +25,24 @@ public interface ServicePrincipals extends * * @param objectId the unique object id * @return an immutable representation of the resource - * @throws GraphErrorException exceptions thrown from the graph API - * @throws IOException exceptions thrown from serialization/deserialization */ - ServicePrincipal getByObjectId(String objectId) throws GraphErrorException, IOException; + ServicePrincipal getByObjectId(String objectId); /** * Gets the information about a service principal. * * @param appId the application id (or the client id) * @return an immutable representation of the resource - * @throws GraphErrorException exceptions thrown from the graph API - * @throws IOException exceptions thrown from serialization/deserialization */ - ServicePrincipal getByAppId(String appId) throws GraphErrorException, IOException; + ServicePrincipal getByAppId(String appId); /** * Gets the information about a service principal. * * @param spn the service principal name * @return an immutable representation of the resource - * @throws GraphErrorException exceptions thrown from the graph API - * @throws IOException exceptions thrown from serialization/deserialization */ - ServicePrincipal getByServicePrincipalName(String spn) throws GraphErrorException, IOException; + ServicePrincipal getByServicePrincipalName(String spn); /** * Gets the information about a service principal. diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java index bce73bb9aaed0..6697418f0b0c9 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java @@ -13,8 +13,6 @@ import com.microsoft.rest.ServiceCallback; import rx.Observable; -import java.io.IOException; - /** * Entry point to AD user management API. */ @@ -27,20 +25,16 @@ public interface Users extends * * @param objectId the unique object id * @return an immutable representation of the resource - * @throws GraphErrorException exceptions thrown from the graph API - * @throws IOException exceptions thrown from serialization/deserialization */ - User getByObjectId(String objectId) throws GraphErrorException, IOException; + User getByObjectId(String objectId); /** * Gets the information about a user. * * @param upn the user principal name * @return an immutable representation of the resource - * @throws GraphErrorException exceptions thrown from the graph API - * @throws IOException exceptions thrown from serialization/deserialization */ - User getByUserPrincipalName(String upn) throws GraphErrorException, IOException; + User getByUserPrincipalName(String upn); /** * Gets the information about a user. diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java index 469c16af2cd93..ede66beea7fb3 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java @@ -18,7 +18,6 @@ import rx.Observable; import rx.functions.Func1; -import java.io.IOException; import java.util.List; /** @@ -46,7 +45,7 @@ public PagedList list() { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { innerCollection.delete(id); } @@ -66,17 +65,17 @@ protected ServicePrincipalImpl wrapModel(ServicePrincipalInner servicePrincipalI } @Override - public ServicePrincipalImpl getByObjectId(String objectId) throws GraphErrorException, IOException { + public ServicePrincipalImpl getByObjectId(String objectId) { return new ServicePrincipalImpl(innerCollection.get(objectId), innerCollection); } @Override - public ServicePrincipal getByAppId(String appId) throws GraphErrorException, IOException { + public ServicePrincipal getByAppId(String appId) { return null; } @Override - public ServicePrincipal getByServicePrincipalName(String spn) throws GraphErrorException, IOException { + public ServicePrincipal getByServicePrincipalName(String spn) { List spList = innerCollection.list(String.format("servicePrincipalNames/any(c:c eq '%s')", spn)); if (spList == null || spList.isEmpty()) { return null; diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java index c292aee5f2e6e..6487b0f191e87 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java @@ -7,7 +7,6 @@ package com.microsoft.azure.management.graphrbac.implementation; import com.microsoft.azure.PagedList; -import com.microsoft.azure.management.graphrbac.GraphErrorException; import com.microsoft.azure.management.graphrbac.User; import com.microsoft.azure.management.graphrbac.Users; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; @@ -17,8 +16,6 @@ import rx.Observable; import rx.functions.Func1; -import java.io.IOException; - /** * The implementation of Users and its parent interfaces. */ @@ -44,7 +41,7 @@ public PagedList list() { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { innerCollection.delete(id); } @@ -64,12 +61,12 @@ protected UserImpl wrapModel(UserInner userInner) { } @Override - public UserImpl getByObjectId(String objectId) throws GraphErrorException, IOException { + public UserImpl getByObjectId(String objectId) { return new UserImpl(innerCollection.get(objectId), innerCollection); } @Override - public UserImpl getByUserPrincipalName(String upn) throws GraphErrorException, IOException { + public UserImpl getByUserPrincipalName(String upn) { return new UserImpl(innerCollection.get(upn), innerCollection); } diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java index 0594b1a947cb8..2bc06369a87f6 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java @@ -57,7 +57,7 @@ public Vault getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java index 41caacdc81084..6e52465237c46 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterface.java @@ -6,18 +6,16 @@ package com.microsoft.azure.management.network; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.implementation.NetworkInterfaceInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; -import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.resources.fluentcore.model.Updatable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; -import java.io.IOException; import java.util.List; import java.util.Map; @@ -131,10 +129,8 @@ public interface NetworkInterface extends * This method makes a rest API call to fetch the Network Security Group resource. * * @return the network security group associated with this network interface. - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - NetworkSecurityGroup networkSecurityGroup() throws CloudException, IOException; + NetworkSecurityGroup networkSecurityGroup(); // Setters (fluent) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java index 0d78c66fa2055..1706f48ebac88 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java @@ -5,7 +5,6 @@ */ package com.microsoft.azure.management.network; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.implementation.SubnetInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.ChildResource; @@ -13,8 +12,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; -import java.io.IOException; - /** * An immutable client-side representation of a subnet of a virtual network. */ @@ -32,11 +29,8 @@ public interface Subnet extends * @return the network security group associated with this subnet *

* Note that this method will result in a call to Azure each time it is invoked. - * @throws CloudException exceptions thrown from the cloud - * @throws IOException exceptions thrown from serialization/deserialization - * @throws IllegalArgumentException exceptions thrown when something is wrong with the input parameters */ - NetworkSecurityGroup networkSecurityGroup() throws CloudException, IllegalArgumentException, IOException; + NetworkSecurityGroup networkSecurityGroup(); /** * Grouping of subnet definition stages. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java index 429f9441a9daf..a6b53be72d760 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java @@ -47,7 +47,7 @@ public LoadBalancerImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index dfdeee4106a59..7bf0f924835a2 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.network.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.SubResource; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.IPAllocationMethod; @@ -24,7 +23,6 @@ import com.microsoft.azure.management.resources.fluentcore.utils.Utils; import rx.Observable; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -322,7 +320,7 @@ public String networkSecurityGroupId() { } @Override - public NetworkSecurityGroup networkSecurityGroup() throws CloudException, IOException { + public NetworkSecurityGroup networkSecurityGroup() { if (this.networkSecurityGroup == null && this.networkSecurityGroupId() != null) { String id = this.networkSecurityGroupId(); this.networkSecurityGroup = super.myManager diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index 433fad1c4181b..b3e3ece746abd 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -45,7 +45,7 @@ public NetworkInterface getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { this.delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index 3147439c7d74c..56cde273e9423 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -49,7 +49,7 @@ public NetworkSecurityGroupImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index 7a4233fb1af50..a72b9a2cd25b7 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -51,7 +51,7 @@ public NetworkImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 26a167b62ba7c..f2f738ca09da5 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -48,7 +48,7 @@ public PublicIpAddressImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java index bd584d858b34f..8f93d1292a419 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java @@ -5,9 +5,6 @@ */ package com.microsoft.azure.management.network.implementation; -import java.io.IOException; - -import com.microsoft.azure.CloudException; import com.microsoft.azure.SubResource; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.Network; @@ -43,7 +40,7 @@ public String name() { } @Override - public NetworkSecurityGroup networkSecurityGroup() throws CloudException, IllegalArgumentException, IOException { + public NetworkSecurityGroup networkSecurityGroup() { SubResource nsgResource = this.inner().networkSecurityGroup(); if (nsgResource == null) { return null; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployment.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployment.java index f3d409675339a..a2a223a9dcc43 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployment.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployment.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType; @@ -106,20 +105,15 @@ public interface Deployment extends /** * Cancel a currently running template deployment. - * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ - void cancel() throws CloudException, IOException; + void cancel(); /** * Exports a deployment template. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return the export result */ - DeploymentExportResult exportTemplate() throws CloudException, IOException; + DeploymentExportResult exportTemplate(); /** * Container interface for all the deployment definitions. @@ -244,7 +238,7 @@ interface WithMode { * deployment in the cloud, but exposing additional optional inputs to specify. */ interface WithCreate extends Creatable { - Deployment beginCreate() throws Exception; + Deployment beginCreate(); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java index ece9655b657e1..0b4f2558f7f3d 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; @@ -17,8 +16,6 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; -import java.io.IOException; - /** * Entry point to template deployment in Azure. */ @@ -38,8 +35,6 @@ public interface Deployments extends * @param resourceGroupName the resource group's name * @param deploymentName the deployment's name * @return true if the deployment exists; false otherwise - * @throws IOException serialization failures - * @throws CloudException failures thrown from Azure */ - boolean checkExistence(String resourceGroupName, String deploymentName) throws IOException, CloudException; + boolean checkExistence(String resourceGroupName, String deploymentName); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Features.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Features.java index 0590bbb23f087..37e4b1dc01533 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Features.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Features.java @@ -6,13 +6,10 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; -import java.io.IOException; - /** * Entry point to features management API. */ @@ -39,9 +36,7 @@ interface InResourceProvider extends * * @param featureName the name of the feature * @return the immutable client-side feature object created - * @throws IOException exception from serialization/deserialization - * @throws CloudException exception from Azure */ - Feature register(String featureName) throws IOException, CloudException; + Feature register(String featureName); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java index 8d468de589d4b..8a11e0ccad98a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java @@ -6,13 +6,11 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import java.io.IOException; import java.util.List; /** @@ -33,8 +31,6 @@ public interface GenericResources extends * @param resourceName the name of the resource * @param apiVersion the API version * @return true if the resource exists; false otherwise - * @throws IOException serialization failures - * @throws CloudException failures thrown from Azure */ boolean checkExistence( String resourceGroupName, @@ -42,7 +38,7 @@ boolean checkExistence( String parentResourcePath, String resourceType, String resourceName, - String apiVersion) throws IOException, CloudException; + String apiVersion); /** * Returns a resource belonging to a resource group. @@ -54,8 +50,6 @@ boolean checkExistence( * @param resourceName Resource identity. * @param apiVersion the String value * @return the generic resource - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ GenericResource get( String resourceGroupName, @@ -63,7 +57,7 @@ GenericResource get( String parentResourcePath, String resourceType, String resourceName, - String apiVersion) throws CloudException, IOException; + String apiVersion); /** * Returns a resource belonging to a resource group. @@ -72,14 +66,12 @@ GenericResource get( * @param resourceType the resource type * @param resourceName the name of the resource * @return the generic resource - * @throws IOException exception thrown from serialization/deserialization - * @throws CloudException exception thrown from REST call */ GenericResource get( String resourceGroupName, String providerNamespace, String resourceType, - String resourceName) throws CloudException, IOException; + String resourceName); /** * Move resources from one resource group to another. @@ -87,11 +79,8 @@ GenericResource get( * @param sourceResourceGroupName Source resource group name * @param targetResourceGroup target resource group, can be in a different subscription * @param resources the list of IDs of the resources to move - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws InterruptedException exception thrown when long running operation is interrupted */ - void moveResources(String sourceResourceGroupName, ResourceGroup targetResourceGroup, List resources) throws CloudException, IOException, InterruptedException; + void moveResources(String sourceResourceGroupName, ResourceGroup targetResourceGroup, List resources); /** * Delete resource and all of its child resources. @@ -102,8 +91,6 @@ GenericResource get( * @param resourceType Resource identity. * @param resourceName Resource identity. * @param apiVersion the String value - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ - void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws CloudException, IOException; + void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java index 5ce042215034f..44d014f44ab09 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; import com.microsoft.rest.ServiceResponse; -import java.io.IOException; - /** * Entry point to providers management API. */ @@ -25,19 +22,15 @@ public interface Providers extends * Unregisters provider from a subscription. * * @param resourceProviderNamespace Namespace of the resource provider - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return the ProviderInner object wrapped in {@link ServiceResponse} if successful */ - Provider unregister(String resourceProviderNamespace) throws CloudException, IOException; + Provider unregister(String resourceProviderNamespace); /** * Registers provider to be used with a subscription. * * @param resourceProviderNamespace Namespace of the resource provider - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return the ProviderInner object wrapped in {@link ServiceResponse} if successful */ - Provider register(String resourceProviderNamespace) throws CloudException, IOException; + Provider register(String resourceProviderNamespace); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroup.java index a7f257c653a5c..43e324e3d5edd 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroup.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; @@ -18,8 +17,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.resources.implementation.ResourceGroupInner; -import java.io.IOException; - /** * An immutable client-side representation of an Azure resource group. */ @@ -44,11 +41,9 @@ public interface ResourceGroup extends * Captures the specified resource group as a template. * * @param options the export options - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return the exported template result */ - ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options) throws CloudException, IOException; + ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options); /************************************************************** * Fluent interfaces to provision a ResourceGroup diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroups.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroups.java index de60ca3ff124a..69cf46e460772 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroups.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceGroups.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; @@ -14,8 +13,6 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; -import java.io.IOException; - /** * Entry point to resource group management API. */ @@ -30,9 +27,7 @@ public interface ResourceGroups extends * Checks whether resource group exists. * * @param name The name of the resource group to check. The name is case insensitive - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return true if the resource group exists; false otherwise */ - boolean checkExistence(String name) throws CloudException, IOException; + boolean checkExistence(String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java index 888e21fb404bc..3712045e3d5c2 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java @@ -6,15 +6,12 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.model.Indexable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.resources.implementation.SubscriptionInner; -import java.io.IOException; - /** * An immutable client-side representation of an Azure subscription. */ @@ -46,10 +43,8 @@ public interface Subscription extends /** * List the locations the subscription has access to. * - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization * @return the lazy list of locations */ - PagedList listLocations() throws IOException, CloudException; + PagedList listLocations(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java index 9a8740a76e831..f29a7c3d76ba1 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java @@ -6,12 +6,9 @@ package com.microsoft.azure.management.resources.fluentcore.arm.collection; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import java.io.IOException; - /** * Provides access to getting a specific Azure resource based on its name and resource group. * @@ -27,8 +24,6 @@ public interface SupportsGettingByGroup { * @param resourceGroupName the name of the resource group the resource is in * @param name the name of the resource. (Note, this is not the ID) * @return an immutable representation of the resource - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ T getByGroup(String resourceGroupName, String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java index f994ab3a62986..8e25be2555957 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java @@ -7,12 +7,9 @@ package com.microsoft.azure.management.resources.fluentcore.arm.collection; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import java.io.IOException; - /** * Provides access to getting a specific Azure resource based on its resource ID. * @@ -25,9 +22,6 @@ public interface SupportsGettingById { * * @param id the id of the resource. * @return an immutable representation of the resource - * @throws CloudException exceptions thrown from the cloud - * @throws IOException exceptions thrown from serialization/deserialization - * @throws IllegalArgumentException exceptions thrown when something is wrong with the input parameters */ T getById(String id); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java index 1f9ec0342b1ff..56f64cece1ae5 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java @@ -39,12 +39,12 @@ protected CreatableResourcesImpl() { @Override @SafeVarargs - public final CreatedResources create(Creatable ... creatables) throws Exception { + public final CreatedResources create(Creatable ... creatables) { return BlockingObservable.from(createAsync(creatables)).single(); } @Override - public final CreatedResources create(List> creatables) throws Exception { + public final CreatedResources create(List> creatables) { return BlockingObservable.from(createAsync(creatables)).single(); } @@ -236,7 +236,7 @@ public List subList(int fromIndex, int toIndex) { /** * The local root resource that is used as dummy parent resource for the batch creatable resources - * added via {@link CreatableResourcesImpl#create} or {@link CreatableResourcesImpl#createAsync}. + * added via {@link SupportsBatchCreation#create} or {@link CreatableResourcesImpl#createAsync}. * * @param the type of the resources in the batch. */ diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsBatchCreation.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsBatchCreation.java index 6f16ee9311a6d..1a343ee8360a0 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsBatchCreation.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsBatchCreation.java @@ -22,18 +22,16 @@ public interface SupportsBatchCreation { * * @param creatables the creatables in the batch * @return the batch operation result from which created resources in this batch can be accessed. - * @throws Exception exceptions from Azure */ - CreatedResources create(Creatable... creatables) throws Exception; + CreatedResources create(Creatable... creatables); /** * Executes the create requests on a collection (batch) of resources. * * @param creatables the list of creatables in the batch * @return the batch operation result from which created resources in this batch can be accessed. - * @throws Exception exceptions from Azure */ - CreatedResources create(List> creatables) throws Exception; + CreatedResources create(List> creatables); /** * Puts the requests to create a batch of resources into the queue and allow the HTTP client to execute it when diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java index eb6f36e79b375..9a1cb1721a05a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java @@ -19,7 +19,6 @@ public interface SupportsDeleting { * Deletes a resource from Azure, identifying it by its resource ID. * * @param id the resource ID of the resource to delete - * @throws Exception exceptions thrown from Azure */ - void delete(String id) throws Exception; + void delete(String id); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java index 7c0b1d7929a40..52edb0d3dc0dc 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java @@ -7,12 +7,9 @@ package com.microsoft.azure.management.resources.fluentcore.collection; import com.microsoft.azure.PagedList; -import com.microsoft.rest.RestException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import java.io.IOException; - /** * Provides access to listing Azure resources of a specific type in a subscription. *

@@ -26,8 +23,6 @@ public interface SupportsListing { * Lists all the resources of the specified type in the currently selected subscription. * * @return list of resources - * @throws RestException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ PagedList list(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByRegion.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByRegion.java index 1b33427b1126a..b23920b9c5266 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByRegion.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByRegion.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources.fluentcore.collection; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; import com.microsoft.azure.management.resources.fluentcore.arm.Region; -import java.io.IOException; - /** * Provides access to listing Azure resources of a specific type based on their region. *

@@ -28,17 +25,13 @@ public interface SupportsListingByRegion { * * @param region the selected Azure region * @return list of resources - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - PagedList listByRegion(Region region) throws CloudException, IOException; + PagedList listByRegion(Region region); /** * List all the resources of the specified type in the specified region. * @param regionName the name of an Azure region * @return list of resources - * @throws CloudException exceptions thrown from the cloud. - * @throws IOException exceptions thrown from serialization/deserialization. */ - PagedList listByRegion(String regionName) throws CloudException, IOException; + PagedList listByRegion(String regionName); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Updatable.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Updatable.java index 6d274e92c9a2a..ccec3b3094b1f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Updatable.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/Updatable.java @@ -23,7 +23,6 @@ public interface Updatable { * process in Azure is {@link Appliable#apply()}. * * @return the stage of new resource update - * @throws Exception exceptions thrown from Azure */ - T update() throws Exception; + T update(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java index dfd2dfa3875cd..5bee4c82c1159 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java @@ -7,7 +7,6 @@ package com.microsoft.azure.management.resources.implementation; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.resources.Dependency; import com.microsoft.azure.management.resources.Deployment; import com.microsoft.azure.management.resources.DeploymentExportResult; @@ -168,12 +167,12 @@ public DeploymentOperations deploymentOperations() { } @Override - public void cancel() throws CloudException, IOException { + public void cancel() { client.cancel(resourceGroupName, name()); } @Override - public DeploymentExportResult exportTemplate() throws CloudException, IOException { + public DeploymentExportResult exportTemplate() { DeploymentExportResultInner inner = client.exportTemplate(resourceGroupName(), name()); return new DeploymentExportResultImpl(inner); } @@ -268,7 +267,7 @@ public DeploymentImpl withParametersLink(String uri, String contentVersion) { } @Override - public DeploymentImpl beginCreate() throws Exception { + public DeploymentImpl beginCreate() { DeploymentInner inner = new DeploymentInner() .withProperties(new DeploymentProperties()); inner.properties().withMode(mode()); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index e66360703b22d..3d1a3d252c081 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Deployment; import com.microsoft.azure.management.resources.Deployments; @@ -15,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import java.io.IOException; import java.util.List; /** @@ -75,7 +73,7 @@ public Deployment getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { this.delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } @@ -90,7 +88,7 @@ public DeploymentImpl define(String name) { } @Override - public boolean checkExistence(String resourceGroupName, String deploymentName) throws IOException, CloudException { + public boolean checkExistence(String resourceGroupName, String deploymentName) { return client.checkExistence(resourceGroupName, deploymentName); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java index f896288c975df..aeff935c2601e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Feature; import com.microsoft.azure.management.resources.Features; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import java.io.IOException; - /** * The implementation of {@link Features.InResourceProvider}. */ @@ -39,7 +36,7 @@ public Feature typeConvert(FeatureResultInner tenantInner) { } @Override - public Feature register(String featureName) throws IOException, CloudException { + public Feature register(String featureName) { return new FeatureImpl(client.register(resourceProviderNamespace, featureName)); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index 233225f7df456..d079af7d0e265 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -14,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import java.io.IOException; import java.util.List; /** @@ -52,7 +51,7 @@ public GenericResource.DefinitionStages.Blank define(String name) { } @Override - public boolean checkExistence(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws IOException, CloudException { + public boolean checkExistence(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { return this.innerCollection.checkExistence( resourceGroupName, resourceProviderNamespace, @@ -96,7 +95,7 @@ public GenericResource get( String parentResourcePath, String resourceType, String resourceName, - String apiVersion) throws CloudException, IOException { + String apiVersion) { // Correct for auto-gen'd API's treatment parent path as required even though it makes sense only for child resources if (parentResourcePath == null) { @@ -125,7 +124,7 @@ public GenericResource get( } @Override - public void moveResources(String sourceResourceGroupName, ResourceGroup targetResourceGroup, List resources) throws CloudException, IOException, InterruptedException { + public void moveResources(String sourceResourceGroupName, ResourceGroup targetResourceGroup, List resources) { ResourcesMoveInfoInner moveInfo = new ResourcesMoveInfoInner(); moveInfo.withTargetResourceGroup(targetResourceGroup.id()); moveInfo.withResources(resources); @@ -133,7 +132,7 @@ public void moveResources(String sourceResourceGroupName, ResourceGroup targetRe } @Override - public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws CloudException, IOException { + public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { this.innerCollection.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java index 648ce3de6f2b8..9c637ea502dd1 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Provider; import com.microsoft.azure.management.resources.Providers; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; -import java.io.IOException; - /** * The implementation for {@link Providers}. */ @@ -32,12 +29,12 @@ public PagedList list() { } @Override - public Provider unregister(String resourceProviderNamespace) throws CloudException, IOException { + public Provider unregister(String resourceProviderNamespace) { return wrapModel(client.unregister(resourceProviderNamespace)); } @Override - public Provider register(String resourceProviderNamespace) throws CloudException, IOException { + public Provider register(String resourceProviderNamespace) { return wrapModel(client.register(resourceProviderNamespace)); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java index bb73064c55875..f4539bd31e681 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.ResourceGroupExportResult; import com.microsoft.azure.management.resources.ResourceGroupExportTemplateOptions; @@ -14,7 +13,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; import rx.Observable; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -73,7 +71,7 @@ public Map tags() { } @Override - public ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options) throws CloudException, IOException { + public ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options) { ExportTemplateRequestInner inner = new ExportTemplateRequestInner() .withResources(Arrays.asList("*")) .withOptions(options.toString()); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java index 703629854d0be..a49210905f2e5 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java @@ -6,14 +6,11 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.ResourceGroups; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableResourcesImpl; -import java.io.IOException; - /** * The implementation for {@link ResourceGroups} and its parent interfaces. */ @@ -44,7 +41,7 @@ public ResourceGroupImpl getByName(String name) { } @Override - public void delete(String name) throws Exception { + public void delete(String name) { client.delete(name); } @@ -54,7 +51,7 @@ public ResourceGroupImpl define(String name) { } @Override - public boolean checkExistence(String name) throws CloudException, IOException { + public boolean checkExistence(String name) { return client.checkExistence(name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java index cb71188979131..020eb8972d137 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.resources.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Location; @@ -15,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableWrapperImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import java.io.IOException; import java.util.List; /** @@ -54,7 +52,7 @@ public SubscriptionPolicies subscriptionPolicies() { } @Override - public PagedList listLocations() throws IOException, CloudException { + public PagedList listLocations() { PagedListConverter converter = new PagedListConverter() { @Override public Location typeConvert(LocationInner locationInner) { diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java index dbc779b656eba..2c40f69051ac1 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GroupPagedListTests.java @@ -1,6 +1,5 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.CloudException; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.Region; @@ -10,7 +9,6 @@ import org.junit.Assert; import org.junit.Test; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -108,7 +106,7 @@ public List listNextGroup(String s) { private static ResourceGroup resourceGroup(final String name) { return new ResourceGroup() { @Override - public Update update() throws Exception { + public Update update() { return null; } @@ -148,7 +146,7 @@ public Map tags() { } @Override - public ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options) throws CloudException, IOException { + public ResourceGroupExportResult exportTemplate(ResourceGroupExportTemplateOptions options) { return null; } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java index 8a521d1e0316c..fadd44e3a3e81 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.storage; -import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; @@ -17,8 +16,6 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; -import java.io.IOException; - /** * Entry point for storage accounts management API. */ @@ -37,8 +34,6 @@ public interface StorageAccounts extends * * @param name the account name to check * @return whether the name is available and other info if not - * @throws CloudException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization */ - CheckNameAvailabilityResult checkNameAvailability(String name) throws CloudException, IOException; + CheckNameAvailabilityResult checkNameAvailability(String name); } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index dd5e5a813d213..a49f8014aad24 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -6,7 +6,6 @@ package com.microsoft.azure.management.storage.implementation; -import com.microsoft.azure.CloudException; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; @@ -15,8 +14,6 @@ import com.microsoft.azure.management.storage.StorageAccount; import com.microsoft.azure.management.storage.StorageAccounts; -import java.io.IOException; - /** * The implementation of StorageAccounts and its parent interfaces. */ @@ -36,7 +33,7 @@ class StorageAccountsImpl } @Override - public CheckNameAvailabilityResult checkNameAvailability(String name) throws CloudException, IOException { + public CheckNameAvailabilityResult checkNameAvailability(String name) { return new CheckNameAvailabilityResult(this.innerCollection.checkNameAvailability(name)); } @@ -56,7 +53,7 @@ public StorageAccount getByGroup(String groupName, String name) { } @Override - public void delete(String id) throws Exception { + public void delete(String id) { delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } From 3ffdf388282346c5105e3da393f44e94941bd878 Mon Sep 17 00:00:00 2001 From: Anudeep Sharma Date: Mon, 12 Sep 2016 11:20:19 -0700 Subject: [PATCH 33/47] Updated batch to support batch account creation with fluent pattern. --- azure-mgmt-batch/pom.xml | 5 + .../azure/management/batch/BatchAccount.java | 212 ++++++++++++++++ .../management/batch/BatchAccountKeys.java | 46 ++++ .../azure/management/batch/BatchAccounts.java | 24 ++ .../implementation/BatchAccountImpl.java | 232 ++++++++++++++++++ .../implementation/BatchAccountsImpl.java | 76 ++++++ .../batch/implementation/BatchManager.java | 96 ++++++++ .../batch/BatchAccountOperationsTests.java | 99 ++++++++ .../batch/BatchManagementTestBase.java | 43 ++++ .../implementation/AvailabilitySetImpl.java | 4 +- .../implementation/VirtualMachineImpl.java | 37 +-- .../keyvault/implementation/VaultImpl.java | 2 +- .../implementation/LoadBalancerImpl.java | 4 +- .../network/implementation/NetworkImpl.java | 4 +- .../implementation/NetworkInterfaceImpl.java | 4 +- .../NetworkSecurityGroupImpl.java | 4 +- .../implementation/PublicIpAddressImpl.java | 4 +- .../models/implementation/ResourceImpl.java | 30 ++- .../model/implementation/CreatableImpl.java | 7 +- .../CreatableUpdatableImpl.java | 10 +- .../implementation/CreatorTaskGroup.java | 7 + .../model/implementation/CreatorTaskItem.java | 2 +- .../implementation/GenericResourceImpl.java | 4 +- .../implementation/StorageAccountImpl.java | 2 +- azure/pom.xml | 6 + .../main/java/com/microsoft/azure/Azure.java | 12 + .../java/com/microsoft/azure/AzureTests.java | 10 + .../java/com/microsoft/azure/TestBatch.java | 54 ++++ .../TestBatchUpdateWithNewStorageAccount.java | 20 ++ 29 files changed, 1004 insertions(+), 56 deletions(-) create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java create mode 100644 azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java create mode 100644 azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchAccountOperationsTests.java create mode 100644 azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchManagementTestBase.java create mode 100644 azure/src/test/java/com/microsoft/azure/TestBatch.java create mode 100644 azure/src/test/java/com/microsoft/azure/TestBatchUpdateWithNewStorageAccount.java diff --git a/azure-mgmt-batch/pom.xml b/azure-mgmt-batch/pom.xml index 94ec03ec44510..b85dcd5018f22 100644 --- a/azure-mgmt-batch/pom.xml +++ b/azure-mgmt-batch/pom.xml @@ -67,6 +67,11 @@ 1.0.0-SNAPSHOT test + + com.microsoft.azure + azure-mgmt-storage + 1.0.0-SNAPSHOT + diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java new file mode 100644 index 0000000000000..f350513100bb7 --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java @@ -0,0 +1,212 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.batch; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.batch.implementation.AccountResourceInner; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; +import com.microsoft.azure.management.resources.fluentcore.model.Updatable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.storage.StorageAccount; + +import java.io.IOException; + +/** + * An immutable client-side representation of an Azure batch account. + */ +public interface BatchAccount extends + GroupableResource, + Refreshable, + Updatable, + Wrapper { + + /** + * @return the provisioned state of the resource. Possible values include: + * 'Invalid', 'Creating', 'Deleting', 'Succeeded', 'Failed', 'Cancelled' + */ + AccountProvisioningState provisioningState(); + + /** + * @return Get the accountEndpoint value. + */ + String accountEndpoint(); + + /** + * @return the properties and status of any auto storage account associated with + * the account + */ + AutoStorageProperties autoStorage(); + + /** + * @return the core quota for this BatchAccount account + */ + int coreQuota(); + + /** + * @return the pool quota for this BatchAccount account + */ + int poolQuota(); + + /** + * @return the active job and job schedule quota for this BatchAccount account + */ + int activeJobAndJobScheduleQuota(); + + /** + * @return the access keys for this batch account + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + */ + BatchAccountKeys keys() throws CloudException, IOException; + + /** + * @return the access keys for this batch account + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + */ + BatchAccountKeys refreshKeys() throws CloudException, IOException; + + /** + * Regenerates the access keys for batch account. + * + * @param keyType either primary or secondary key to be regenerated + * @return the access keys for this batch account + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + */ + BatchAccountKeys regenerateKeys(AccountKeyType keyType) throws CloudException, IOException; + + /** + * Synchronize the storage account keys for batch account. + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + */ + void synchronizeAutoStorageKeys() throws CloudException, IOException; + + /************************************************************** + * Fluent interfaces to provision a BatchAccount + **************************************************************/ + + /** + * Container interface for all the definitions that need to be implemented. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithGroup, + DefinitionStages.WithCreate { + } + + /** + * Grouping of all the storage account definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the batch account definition. + */ + interface Blank extends Resource.DefinitionWithRegion { + } + + /** + * A batch account definition allowing resource group to be set. + */ + interface WithGroup extends GroupableResource.DefinitionStages.WithGroup { + } + + /** + * A batch account definition with sufficient inputs to create a new + * batch account in the cloud, but exposing additional optional inputs to + * specify. + */ + interface WithCreate extends + Creatable, + Resource.DefinitionWithTags { + + /** + * Specifies that an existing storage account to be attached with the batch account. + * + * @param storageAccount existing storage account to be used + * @return the stage representing creatable batch account definition + */ + DefinitionStages.WithCreate withStorageAccount(StorageAccount storageAccount); + + /** + * Specifies that a storage account to be attached with the batch account. + * + * @param storageAccountCreatable storage account to be created along with and used in batch + * @return the stage representing creatable batch account definition + */ + DefinitionStages.WithCreate withNewStorageAccount(Creatable storageAccountCreatable); + + /** + * Specifies that an existing storage account to be attached with the batch account. + * + * @param storageAccountName name of new storage account to be created and used in batch account + * @return the stage representing creatable batch account definition + */ + DefinitionStages.WithCreate withNewStorageAccount(String storageAccountName); + + } + } + /** + * The template for a storage account update operation, containing all the settings that can be modified. + */ + interface Update extends + Appliable, + Resource.UpdateWithTags, + UpdateStages.WithStorageAccount { + } + + /** + * Grouping of all the storage account update stages. + */ + interface UpdateStages { + /** + * The stage of the batch account update definition allowing to specify storage account. + */ + interface WithStorageAccount { + /** + * Specifies that an existing storage account to be attached with the batch account. + * + * @param storageAccount existing storage account to be used + * @return the stage representing updatable batch account definition + */ + Update withStorageAccount(StorageAccount storageAccount); + + /** + * Specifies that a storage account to be attached with the batch account. + * + * @param storageAccountCreatable storage account to be created along with and used in batch + * @return the stage representing updatable batch account definition + */ + Update withNewStorageAccount(Creatable storageAccountCreatable); + + /** + * Specifies that an existing storage account to be attached with the batch account. + * + * @param storageAccountName name of new storage account to be created and used in batch account + * @return the stage representing updatable batch account definition + */ + Update withNewStorageAccount(String storageAccountName); + + /** + * Specifies that storage account should be removed from the batch account. + * + * @return the stage representing updatable batch account definition + */ + Update withoutStorageAccount(); + } + } +} + diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java new file mode 100644 index 0000000000000..395d3365360b7 --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java @@ -0,0 +1,46 @@ +package com.microsoft.azure.management.batch; + +/** + * Created by ans on 9/13/2016. + */ +public class BatchAccountKeys { + /** + * The primary key associated with the account. + */ + private String primary; + + /** + * The secondary key associated with the account. + */ + private String secondary; + + /** + * Constructor for the class. + * + * @param primaryKey primary key value for the batch account + * @param secondaryKey secondary key value for the batch account + */ + public BatchAccountKeys(String primaryKey, String secondaryKey) { + primary = primaryKey; + secondary = secondaryKey; + } + + /** + * Get the primary value. + * + * @return the primary value + */ + public String primary() { + return this.primary; + } + + /** + * Get the secondary value. + * + * @return the secondary value + */ + public String secondary() { + return this.secondary; + } + +} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java new file mode 100644 index 0000000000000..128e536515738 --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.management.batch; + +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point to batch account management API. + */ +public interface BatchAccounts extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, + SupportsDeleting, + SupportsDeletingByGroup, + SupportsBatchCreation { +} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java new file mode 100644 index 0000000000000..40af752d8dc18 --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java @@ -0,0 +1,232 @@ +package com.microsoft.azure.management.batch.implementation; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.batch.AccountProvisioningState; +import com.microsoft.azure.management.batch.AutoStorageBaseProperties; +import com.microsoft.azure.management.batch.AutoStorageProperties; +import com.microsoft.azure.management.batch.BatchAccount; +import com.microsoft.azure.management.batch.BatchAccountKeys; +import com.microsoft.azure.management.batch.AccountKeyType; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.storage.StorageAccount; +import com.microsoft.azure.management.storage.implementation.StorageManager; +import rx.Observable; +import rx.functions.Func1; + +import java.io.IOException; + +/** + * Implementation for BatchAccount and its parent interfaces. + */ +public class BatchAccountImpl + extends + GroupableResourceImpl< + BatchAccount, + AccountResourceInner, + BatchAccountImpl, + BatchManager> + implements + BatchAccount, + BatchAccount.Definition, + BatchAccount.Update { + private final AccountsInner innerCollection; + private final StorageManager storageManager; + private String creatableStorageAccountKey; + private StorageAccount existingStorageAccountToAssociate; + + private BatchAccountKeys cachedKeys; + + protected BatchAccountImpl(String name, AccountResourceInner innerObject, AccountsInner innerCollection, BatchManager manager, final StorageManager storageManager) { + super(name, innerObject, manager); + this.innerCollection = innerCollection; + this.storageManager = storageManager; + } + + @Override + public BatchAccount refresh() throws Exception { + AccountResourceInner response = + this.innerCollection.get(this.resourceGroupName(), this.name()); + this.setInner(response); + return this; + } + + @Override + public Observable createResourceAsync() { + final BatchAccountImpl self = this; + + handleStorageSettings(); + BatchAccountCreateParametersInner batchAccountCreateParametersInner = new BatchAccountCreateParametersInner(); + if (this.inner().autoStorage() != null) { + batchAccountCreateParametersInner.withAutoStorage(new AutoStorageBaseProperties()); + batchAccountCreateParametersInner.autoStorage().withStorageAccountId(this.inner().autoStorage().storageAccountId()); + } + else { + batchAccountCreateParametersInner.withAutoStorage(null); + } + + batchAccountCreateParametersInner.withLocation(this.inner().location()); + batchAccountCreateParametersInner.withTags(this.inner().getTags()); + + return this.innerCollection.createAsync(this.resourceGroupName(), this.name(), batchAccountCreateParametersInner) + .map(new Func1() { + @Override + public BatchAccount call(AccountResourceInner accountResourceInner) { + self.creatableStorageAccountKey = null; + self.existingStorageAccountToAssociate = null; + setInner(accountResourceInner); + + return self; + } + }); + + } + + @Override + public Observable applyUpdateAsync() { + // TODO - ans - remove call to createResourceAsync and uncomment code below, after PATCH start sending the nulls. + return createResourceAsync(); + /* + final BatchAccountImpl self = this; + handleStorageSettings(); + BatchAccountUpdateParametersInner batchAccountUpdateParametersInner = new BatchAccountUpdateParametersInner(); + if (self.inner().autoStorage() != null) { + batchAccountUpdateParametersInner.withAutoStorage(new AutoStorageBaseProperties()); + batchAccountUpdateParametersInner.autoStorage().withStorageAccountId(self.inner().autoStorage().storageAccountId()); + } else { + batchAccountUpdateParametersInner.withAutoStorage(null); + } + + batchAccountUpdateParametersInner.withTags(self.inner().getTags()); + + return self.innerCollection.updateAsync(self.resourceGroupName(), self.name(), batchAccountUpdateParametersInner) + .map(new Func1, BatchAccount>() { + @Override + public BatchAccount call(ServiceResponse accountResourceInner) { + setInner(accountResourceInner.getBody()); + return self; + } + }); + */ + } + + @Override + public AccountProvisioningState provisioningState() { + return this.inner().provisioningState(); + } + + @Override + public String accountEndpoint() { + return this.inner().accountEndpoint(); + } + + @Override + public AutoStorageProperties autoStorage() { + return this.inner().autoStorage(); + } + + @Override + public int coreQuota() { + return this.inner().coreQuota(); + } + + @Override + public int poolQuota() { + return this.inner().poolQuota(); + } + + @Override + public int activeJobAndJobScheduleQuota() { + return this.inner().activeJobAndJobScheduleQuota(); + } + + @Override + public BatchAccountKeys keys() throws CloudException, IOException { + if (cachedKeys == null) { + cachedKeys = refreshKeys(); + } + + return cachedKeys; + } + + @Override + public BatchAccountKeys refreshKeys() throws CloudException, IOException { + BatchAccountListKeyResultInner keys = this.innerCollection.listKeys(this.resourceGroupName(), this.name()); + cachedKeys = new BatchAccountKeys(keys.primary(), keys.secondary()); + + return cachedKeys; + } + + @Override + public BatchAccountKeys regenerateKeys(AccountKeyType keyType) throws CloudException, IOException { + BatchAccountRegenerateKeyResultInner keys = this.innerCollection.regenerateKey(this.resourceGroupName(), this.name(), keyType); + cachedKeys = new BatchAccountKeys(keys.primary(), keys.secondary()); + + return cachedKeys; + } + + @Override + public void synchronizeAutoStorageKeys() throws CloudException, IOException { + this.innerCollection.synchronizeAutoStorageKeys(this.resourceGroupName(), this.name()); + } + + @Override + public BatchAccountImpl withStorageAccount(StorageAccount storageAccount) { + this.existingStorageAccountToAssociate = storageAccount; + this.creatableStorageAccountKey = null; + return this; + } + + @Override + public BatchAccountImpl withNewStorageAccount(Creatable creatable) { + // This method's effect is NOT additive. + if (this.creatableStorageAccountKey == null) { + this.creatableStorageAccountKey = creatable.key(); + this.addCreatableDependency(creatable); + } + this.existingStorageAccountToAssociate = null; + return this; + } + + @Override + public BatchAccountImpl withNewStorageAccount(String storageAccountName) { + StorageAccount.DefinitionStages.WithGroup definitionWithGroup = this.storageManager + .storageAccounts() + .define(storageAccountName) + .withRegion(this.regionName()); + Creatable definitionAfterGroup; + if (this.creatableGroup != null) { + definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.creatableGroup); + } else { + definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); + } + return withNewStorageAccount(definitionAfterGroup); + } + + @Override + public BatchAccountImpl withoutStorageAccount() { + this.existingStorageAccountToAssociate = null; + this.creatableStorageAccountKey = null; + this.inner().withAutoStorage(null); + return this; + } + + + private void handleStorageSettings() { + StorageAccount storageAccount; + if (this.creatableStorageAccountKey != null) { + storageAccount = (StorageAccount) this.createdResource(this.creatableStorageAccountKey); + } else if (this.existingStorageAccountToAssociate != null) { + storageAccount = this.existingStorageAccountToAssociate; + } else { + this.inner().withAutoStorage(null); + return; + } + + if (this.inner().autoStorage() == null) { + this.inner().withAutoStorage(new AutoStorageProperties()); + } + + inner().autoStorage().withStorageAccountId(storageAccount.id()); + } +} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java new file mode 100644 index 0000000000000..545927f9d0c07 --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java @@ -0,0 +1,76 @@ +package com.microsoft.azure.management.batch.implementation; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.batch.BatchAccount; +import com.microsoft.azure.management.batch.BatchAccounts; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import com.microsoft.azure.management.storage.implementation.StorageManager; + +import java.io.IOException; + +/** + * Implementation for BatchAccounts and its parent interfaces. + */ +public class BatchAccountsImpl + extends GroupableResourcesImpl + implements BatchAccounts { + private final StorageManager storageManager; + + protected BatchAccountsImpl(AccountsInner innerCollection, BatchManager manager, StorageManager storageManager) { + super(innerCollection, manager); + this.storageManager = storageManager; + } + + @Override + public void delete(String id) throws Exception { + delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + } + + @Override + public void delete(String groupName, String name) throws Exception { + this.innerCollection.delete(groupName, name); + } + + @Override + protected BatchAccountImpl wrapModel(String name) { + AccountResourceInner inner = new AccountResourceInner(); + + return new BatchAccountImpl( + name, + inner, + this.innerCollection, + super.myManager, this.storageManager); + } + + @Override + public PagedList list() throws CloudException, IOException { + return wrapList(this.innerCollection.list()); + } + + @Override + public PagedList listByGroup(String resourceGroupName) throws CloudException, IOException { + return wrapList(this.innerCollection.listByResourceGroup(resourceGroupName)); + } + + @Override + protected BatchAccountImpl wrapModel(AccountResourceInner inner) { + return new BatchAccountImpl( + inner.name(), + inner, + this.innerCollection, + this.myManager, + this.storageManager); + } + + @Override + public BatchAccount.DefinitionStages.Blank define(String name) { + return wrapModel(name); + } + + @Override + public BatchAccount getByGroup(String groupName, String name) throws CloudException, IOException { + return wrapModel(this.innerCollection.get(groupName, name)); + } +} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java new file mode 100644 index 0000000000000..47d4344ee006d --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java @@ -0,0 +1,96 @@ +package com.microsoft.azure.management.batch.implementation; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.RestClient; +import com.microsoft.azure.management.batch.BatchAccounts; +import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; +import com.microsoft.azure.management.storage.implementation.StorageManager; +import com.microsoft.rest.credentials.ServiceClientCredentials; + +/** + * Entry point to Azure batch account resource management. + */ +public class BatchManager extends Manager { + + private BatchAccounts batchAccounts; + private StorageManager storageManager; + + protected BatchManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new BatchManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + + storageManager = StorageManager.authenticate(restClient, subscriptionId); + } + + /** + * Get a Configurable instance that can be used to create BatchManager with optional configuration. + * + * @return Configurable + */ + public static Configurable configure() { + return new BatchManager.ConfigurableImpl(); + } + + /** + * Creates an instance of BatchManager that exposes Compute resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription + * @return the BatchManager + */ + public static BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId) { + return new BatchManager(AzureEnvironment.AZURE.newRestClientBuilder() + .withCredentials(credentials) + .build(), subscriptionId); + } + + /** + * Creates an instance of BatchManager that exposes Compute resource management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription + * @return the BatchManager + */ + public static BatchManager authenticate(RestClient restClient, String subscriptionId) { + return new BatchManager(restClient, subscriptionId); + } + + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of BatchManager that exposes Compute resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription + * @return the BatchManager + */ + BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId); + } + + /** + * The implementation for Configurable interface. + */ + private static final class ConfigurableImpl extends AzureConfigurableImpl implements Configurable { + @Override + public BatchManager authenticate(ServiceClientCredentials credentials, String subscriptionId) { + return BatchManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + + /** + * @return the batch account management API entry point + */ + public BatchAccounts batchAccounts() { + if (batchAccounts == null) { + batchAccounts = new BatchAccountsImpl(super.innerManagementClient.accounts(), this, this.storageManager); + } + + return batchAccounts; + } +} diff --git a/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchAccountOperationsTests.java b/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchAccountOperationsTests.java new file mode 100644 index 0000000000000..38f04baf01fca --- /dev/null +++ b/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchAccountOperationsTests.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.batch; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import org.joda.time.DateTime; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class BatchAccountOperationsTests extends BatchManagementTestBase { + private static final String RG_NAME = "javacbatch385"; + private static final String BATCH_NAME = "javacsmsa385"; + private static final String SA_NAME = "javacsmsa385"; + + private static ResourceGroup resourceGroup; + + @BeforeClass + public static void setup() throws Exception { + createClients(); + } + + @AfterClass + public static void cleanup() throws Exception { + resourceManager.resourceGroups().delete(RG_NAME); + } + + @Test + public void canCRUDBatchAccount() throws Exception { + // Create + BatchAccount batchAccount = batchManager.batchAccounts() + .define(BATCH_NAME) + .withRegion(Region.ASIA_EAST) + .withNewResourceGroup(RG_NAME) + .createAsync() + .toBlocking().last(); + Assert.assertEquals(RG_NAME, batchAccount.resourceGroupName()); + Assert.assertNull(batchAccount.autoStorage()); + // List + List accounts = batchManager.batchAccounts().listByGroup(RG_NAME); + boolean found = false; + for (BatchAccount account : accounts) { + if (account.name().equals(BATCH_NAME)) { + found = true; + } + } + Assert.assertTrue(found); + // Get + batchAccount = batchManager.batchAccounts().getByGroup(RG_NAME, BATCH_NAME); + Assert.assertNotNull(batchAccount); + + // Get Keys + BatchAccountKeys keys = batchAccount.keys(); + Assert.assertNotNull(keys.primary()); + Assert.assertNotNull(keys.secondary()); + + BatchAccountKeys newKeys = batchAccount.regenerateKeys(AccountKeyType.PRIMARY); + Assert.assertNotNull(newKeys.primary()); + Assert.assertNotNull(newKeys.secondary()); + + Assert.assertNotEquals(newKeys.primary(), keys.primary()); + Assert.assertEquals(newKeys.secondary(), keys.secondary()); + + batchAccount = batchAccount.update() + .withNewStorageAccount(SA_NAME) + .apply(); + + Assert.assertNotNull(batchAccount.autoStorage().storageAccountId()); + Assert.assertNotNull(batchAccount.autoStorage().lastKeySync()); + + DateTime lastSync = batchAccount.autoStorage().lastKeySync(); + + batchAccount.synchronizeAutoStorageKeys(); + batchAccount.refresh(); + + Assert.assertNotEquals(lastSync, batchAccount.autoStorage().lastKeySync()); + + batchManager.batchAccounts().delete(batchAccount.resourceGroupName(), batchAccount.name()); + try { + batchManager.batchAccounts().getById(batchAccount.id()); + Assert.assertTrue(false); + } + catch (CloudException exception) { + Assert.assertEquals(exception.getResponse().code(), 404); + } + } +} diff --git a/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchManagementTestBase.java b/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchManagementTestBase.java new file mode 100644 index 0000000000000..d374d038e18c6 --- /dev/null +++ b/azure-mgmt-batch/src/test/java/com/microsoft/azure/management/batch/BatchManagementTestBase.java @@ -0,0 +1,43 @@ +package com.microsoft.azure.management.batch; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.RestClient; +import com.microsoft.azure.credentials.ApplicationTokenCredentials; +import com.microsoft.azure.management.batch.implementation.BatchManager; +import com.microsoft.azure.management.resources.implementation.ResourceManager; +import okhttp3.logging.HttpLoggingInterceptor; + +import java.io.File; +import java.io.IOException; + +public abstract class BatchManagementTestBase { + protected static ResourceManager resourceManager; + protected static BatchManager batchManager; + + public static void createClients() { + // TODO - ans - Enabled code below after finding out why it does not work and remove authfile usage. + /* + ApplicationTokenCredentials credentials = new ApplicationTokenCredentials( + System.getenv("client-id"), + System.getenv("domain"), + System.getenv("secret"), + null); + */ + try { + ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(new File("D:/my.azureauth.txt")); + RestClient restClient = AzureEnvironment.AZURE.newRestClientBuilder() + .withCredentials(credentials) + .withLogLevel(HttpLoggingInterceptor.Level.BODY) + .build(); + + resourceManager = ResourceManager + .authenticate(restClient) + .withSubscription(System.getenv("subscription-id")); + + batchManager = BatchManager + .authenticate(restClient, System.getenv("subscription-id")); + } catch (IOException ex) { + + } + } +} diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java index 27ad41e5a9a07..f930147aca54c 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java @@ -91,8 +91,8 @@ public AvailabilitySetImpl withFaultDomainCount(int faultDomainCount) { } @Override - public Observable applyAsync() { - return this.createAsync(); + public Observable applyUpdateAsync() { + return this.createResourceAsync(); } // CreatorTaskGroup.ResourceCreator implementation diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index 3979d78faf831..e19c94c4cda73 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -155,8 +155,8 @@ public VirtualMachine refresh() throws Exception { } @Override - public Observable applyAsync() { - return this.createAsync(); + public Observable applyUpdateAsync() { + return this.createResourceAsync(); } @Override @@ -979,39 +979,6 @@ private void setHardwareProfileDefaults() { } } - private void handleStorageSettings() throws Exception { - StorageAccount storageAccount = null; - if (this.creatableStorageAccountKey != null) { - storageAccount = (StorageAccount) this.createdResource(this.creatableStorageAccountKey); - } else if (this.existingStorageAccountToAssociate != null) { - storageAccount = this.existingStorageAccountToAssociate; - } else if (osDiskRequiresImplicitStorageAccountCreation() - || dataDisksRequiresImplicitStorageAccountCreation()) { - storageAccount = this.storageManager.storageAccounts() - .define(this.namer.randomName("stg", 24)) - .withRegion(this.regionName()) - .withExistingResourceGroup(this.resourceGroupName()) - .create(); - } - - if (isInCreateMode()) { - if (isOSDiskFromImage(this.inner().storageProfile().osDisk())) { - String uri = this.inner() - .storageProfile() - .osDisk().vhd().uri() - .replaceFirst("\\{storage-base-url}", storageAccount.endPoints().primary().blob()); - this.inner().storageProfile().osDisk().vhd().withUri(uri); - } - DataDiskImpl.ensureDisksVhdUri(this.dataDisks, storageAccount, this.vmName); - } else { - if (storageAccount != null) { - DataDiskImpl.ensureDisksVhdUri(this.dataDisks, storageAccount, this.vmName); - } else { - DataDiskImpl.ensureDisksVhdUri(this.dataDisks, this.vmName); - } - } - } - private Observable handleStorageSettingsAsync() { final Func1 storageAccountFunc = new Func1() { @Override diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java index bfb4d8b762837..0764a015f0728 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java @@ -263,7 +263,7 @@ public VaultImpl refresh() throws Exception { } @Override - public Observable applyAsync() { + public Observable applyUpdateAsync() { return createAsync(); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java index e47cce47525ff..185dcdb96fedf 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancerImpl.java @@ -82,8 +82,8 @@ public LoadBalancerImpl refresh() throws Exception { } @Override - public Observable applyAsync() { - return createAsync(); + public Observable applyUpdateAsync() { + return createResourceAsync(); } // Helpers diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java index 8f3db154a9170..ff911af169f11 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkImpl.java @@ -64,8 +64,8 @@ public NetworkImpl refresh() throws Exception { } @Override - public Observable applyAsync() { - return createAsync(); + public Observable applyUpdateAsync() { + return createResourceAsync(); } // Helpers diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index fe4cdb84f90f2..8b393585bc74b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -87,8 +87,8 @@ public NetworkInterface refresh() throws Exception { } @Override - public Observable applyAsync() { - return createAsync(); + public Observable applyUpdateAsync() { + return createResourceAsync(); } // Setters (fluent) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java index 7696a2e1da4fb..3a8f1b276011c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java @@ -86,8 +86,8 @@ public NetworkSecurityGroupImpl refresh() throws Exception { } @Override - public Observable applyAsync() { - return createAsync(); + public Observable applyUpdateAsync() { + return createResourceAsync(); } // Setters (fluent) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index 12925b6316636..dd779815c4afe 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -38,8 +38,8 @@ class PublicIpAddressImpl // Verbs @Override - public Observable applyAsync() { - return this.createAsync(); + public Observable applyUpdateAsync() { + return this.createResourceAsync(); } @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ResourceImpl.java index 344862c126317..fc3a0ba6a72af 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ResourceImpl.java @@ -10,6 +10,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; +import rx.Observable; import java.util.ArrayList; import java.util.Collection; @@ -148,10 +149,37 @@ public final FluentModelImplT withRegion(Region region) { return this.withRegion(region.toString()); } + + @Override + public Observable applyAsync() { + if (super.creatorTaskGroup.isPreparer()) { + super.creatorTaskGroup.prepare(); + return super.creatorTaskGroup.executeAsync().last(); + } + throw new IllegalStateException("Internal Error: createAsync can be called only on preparer"); + } + + /** + * Execute the update request asynchronously. + * + * @return the handle to the REST call + */ + public abstract Observable applyUpdateAsync(); + + @Override + public Observable executeCreateOrUpdateAsync() { + if (this.isInCreateMode()) { + return createResourceAsync(); + } + else { + return applyUpdateAsync(); + } + } + /** * @return true if currently in define..create mode */ - protected boolean isInCreateMode() { + public boolean isInCreateMode() { return this.inner().id() == null; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java index f216e36b5c570..a2f8ad4ec969a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableImpl.java @@ -32,7 +32,7 @@ public abstract class CreatableImpl creatorTaskGroup; + protected CreatorTaskGroup creatorTaskGroup; protected CreatableImpl(String name, InnerModelT innerObject) { super(innerObject); @@ -112,6 +112,11 @@ public FluentModelT createResource() throws Exception { return this.createResourceAsync().toBlocking().last(); } + @Override + public Observable executeCreateOrUpdateAsync() { + return this.createResourceAsync(); + } + protected Func1 innerToFluentMap(final FluentModelImplT fluentModelImplT) { return new Func1() { @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java index 24d8d5c0e8b76..33380ab8fb8ec 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatableUpdatableImpl.java @@ -17,8 +17,14 @@ * @param the model inner type that the fluent model type wraps * @param the implementation type of the fluent model */ -public abstract class CreatableUpdatableImpl> - extends CreatableImpl +public abstract class CreatableUpdatableImpl< + FluentModelT, + InnerModelT, + FluentModelImplT extends IndexableRefreshableWrapperImpl> + extends CreatableImpl< + FluentModelT, + InnerModelT, + FluentModelImplT> implements Appliable { protected CreatableUpdatableImpl(String name, InnerModelT innerObject) { diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java index e099589edb62f..45f95dd391ab4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskGroup.java @@ -34,6 +34,13 @@ interface ResourceCreator { * @return Gets the task group. */ CreatorTaskGroup creatorTaskGroup(); + + /** + * Creates or updates the resource asynchronously. + * + * @return the observable reference + */ + Observable executeCreateOrUpdateAsync(); } /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskItem.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskItem.java index ae26ea92e2604..25a7c441b6b3e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskItem.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/model/implementation/CreatorTaskItem.java @@ -30,7 +30,7 @@ public ResourceT result() { @Override public Observable executeAsync() { - return this.resourceCreator.createResourceAsync() + return this.resourceCreator.executeCreateOrUpdateAsync() .subscribeOn(Schedulers.io()) .doOnNext(new Action1() { @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index 3049b256600b9..c6f96a68f3e6a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -128,8 +128,8 @@ public Observable createAsync() { } @Override - public Observable applyAsync() { - return createAsync(); + public Observable applyUpdateAsync() { + return createResourceAsync(); } // CreatorTaskGroup.ResourceCreator implementation diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java index 6c6c8ff49b2c2..83ab87579ca82 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountImpl.java @@ -190,7 +190,7 @@ public StorageAccountImpl update() { } @Override - public Observable applyAsync() { + public Observable applyUpdateAsync() { return client.updateAsync(resourceGroupName(), name(), updateParameters) .map(innerToFluentMap(this)); } diff --git a/azure/pom.xml b/azure/pom.xml index 43a027b79e7c0..cf2dfb434405b 100644 --- a/azure/pom.xml +++ b/azure/pom.xml @@ -81,6 +81,11 @@ azure-mgmt-keyvault 1.0.0-SNAPSHOT + + com.microsoft.azure + azure-mgmt-batch + 1.0.0-SNAPSHOT + junit junit @@ -98,6 +103,7 @@ 0.1.53 test + diff --git a/azure/src/main/java/com/microsoft/azure/Azure.java b/azure/src/main/java/com/microsoft/azure/Azure.java index b926f4da8fd8c..dee9d8a171036 100644 --- a/azure/src/main/java/com/microsoft/azure/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/Azure.java @@ -8,6 +8,8 @@ import com.microsoft.azure.credentials.ApplicationTokenCredentials; import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.batch.BatchAccounts; +import com.microsoft.azure.management.batch.implementation.BatchManager; import com.microsoft.azure.management.compute.AvailabilitySets; import com.microsoft.azure.management.compute.VirtualMachineImages; import com.microsoft.azure.management.compute.VirtualMachines; @@ -49,6 +51,7 @@ public final class Azure { private final ComputeManager computeManager; private final NetworkManager networkManager; private final KeyVaultManager keyVaultManager; + private final BatchManager batchManager; private final String subscriptionId; /** @@ -278,6 +281,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId) { this.computeManager = ComputeManager.authenticate(restClient, subscriptionId); this.networkManager = NetworkManager.authenticate(restClient, subscriptionId); this.keyVaultManager = KeyVaultManager.authenticate(restClient, tenantId, subscriptionId); + this.batchManager = BatchManager.authenticate(restClient, subscriptionId); this.subscriptionId = subscriptionId; } @@ -399,4 +403,12 @@ public NetworkInterfaces networkInterfaces() { public Vaults vaults() { return this.keyVaultManager.vaults(); } + + /** + * @return entry point to managing batch accounts. + */ + public BatchAccounts batchAccounts() { + return batchManager.batchAccounts(); + } + } diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index 03fa1e8b36d2e..443784b9a0a77 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -293,4 +293,14 @@ public void createStorageAccount() throws Exception { Assert.assertEquals(storageAccount.name(), "mystg123"); } + + @Test + public void testBatchAccount() throws Exception { + new TestBatch().runTest(azure.batchAccounts(), azure.resourceGroups()); + } + + @Test + public void testBatchAccountUpdateWithNewStorageAccount() throws Exception { + new TestBatchUpdateWithNewStorageAccount().runTest(azure.batchAccounts(), azure.resourceGroups()); + } } diff --git a/azure/src/test/java/com/microsoft/azure/TestBatch.java b/azure/src/test/java/com/microsoft/azure/TestBatch.java new file mode 100644 index 0000000000000..a91a101e63a76 --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/TestBatch.java @@ -0,0 +1,54 @@ +package com.microsoft.azure; + + +import com.google.common.util.concurrent.SettableFuture; +import com.microsoft.azure.management.batch.BatchAccount; +import com.microsoft.azure.management.batch.BatchAccounts; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import org.junit.Assert; +import rx.functions.Action1; + +public class TestBatch extends TestTemplate { + @Override + public BatchAccount createResource(BatchAccounts resources) throws Exception { + final String batchAccountName = "batch" + this.testId; + final BatchAccount[] batchAccounts = new BatchAccount[1]; + final SettableFuture future = SettableFuture.create(); + String storageAccountName = "batchsa" + this.testId; + resources.define(batchAccountName) + .withRegion(Region.US_EAST) + .withNewResourceGroup() + .withNewStorageAccount(storageAccountName) + .withTag("mytag", "testtag") + .createAsync() + .subscribe(new Action1() { + @Override + public void call(BatchAccount batchAccount) { + future.set(batchAccount); + } + }); + + batchAccounts[0] = future.get(); + + Assert.assertEquals(ResourceUtils.nameFromResourceId(batchAccounts[0].autoStorage().storageAccountId()), storageAccountName); + + return batchAccounts[0]; + } + + @Override + public BatchAccount updateResource(BatchAccount resource) throws Exception { + resource = resource.update() + .withoutStorageAccount() + .apply(); + + Assert.assertNull(resource.autoStorage()); + + return resource; + } + + @Override + public void print(BatchAccount resource) { + System.out.println(new StringBuilder().append("BatchAccount account: ").append(resource.id()).append(", Name: ").append(resource.name()).toString()); + } +} diff --git a/azure/src/test/java/com/microsoft/azure/TestBatchUpdateWithNewStorageAccount.java b/azure/src/test/java/com/microsoft/azure/TestBatchUpdateWithNewStorageAccount.java new file mode 100644 index 0000000000000..38f474e7c655f --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/TestBatchUpdateWithNewStorageAccount.java @@ -0,0 +1,20 @@ +package com.microsoft.azure; + +import com.microsoft.azure.management.batch.BatchAccount; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import org.junit.Assert; + +public class TestBatchUpdateWithNewStorageAccount extends TestBatch { + + @Override + public BatchAccount updateResource(BatchAccount resource) throws Exception { + String storageAccountName = "batch2sa" + this.testId; + resource = resource.update() + .withNewStorageAccount(storageAccountName) + .apply(); + + Assert.assertEquals(ResourceUtils.nameFromResourceId(resource.autoStorage().storageAccountId()), storageAccountName); + + return resource; + } +} From 224a27341617e8202c19390ebd9591d5e05e3fe2 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 15 Sep 2016 12:27:01 -0700 Subject: [PATCH 34/47] Addressing RC, simplifying logic --- .../VirtualMachineExtensionImpl.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java index e4dd4d818cfde..47c360fba1f12 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java @@ -248,20 +248,19 @@ public Observable call(VirtualMachineExtensionInner res if (inner().autoUpgradeMinorVersion() == null) { inner().withAutoUpgradeMinorVersion(resource.autoUpgradeMinorVersion()); } - if (resource.settings() != null) { - LinkedHashMap settings = - (LinkedHashMap) resource.settings(); - if (settings.size() > 0) { - if (inner().settings() == null) { - inner().withSettings(settings); - } else { - LinkedHashMap innerSettings = - (LinkedHashMap) inner().settings(); - for (Map.Entry entry : settings.entrySet()) { - if (!innerSettings.containsKey(entry.getKey())) { - innerSettings.put(entry.getKey(), entry.getValue()); - } - } + LinkedHashMap publicSettings = + (LinkedHashMap) resource.settings(); + if (publicSettings != null && publicSettings.size() > 0) { + LinkedHashMap innerPublicSettings = + (LinkedHashMap) inner().settings(); + if (innerPublicSettings == null) { + inner().withSettings(new LinkedHashMap()); + innerPublicSettings = (LinkedHashMap)inner().settings(); + } + + for (Map.Entry entry : publicSettings.entrySet()) { + if (!innerPublicSettings.containsKey(entry.getKey())) { + innerPublicSettings.put(entry.getKey(), entry.getValue()); } } } From c6fe61d63e622bedad634d1c0281a81a4bf0123b Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 15 Sep 2016 12:36:49 -0700 Subject: [PATCH 35/47] checkstyle fix --- .../compute/implementation/VirtualMachineExtensionImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java index 47c360fba1f12..6c645fdee69d2 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionImpl.java @@ -255,7 +255,7 @@ public Observable call(VirtualMachineExtensionInner res (LinkedHashMap) inner().settings(); if (innerPublicSettings == null) { inner().withSettings(new LinkedHashMap()); - innerPublicSettings = (LinkedHashMap)inner().settings(); + innerPublicSettings = (LinkedHashMap) inner().settings(); } for (Map.Entry entry : publicSettings.entrySet()) { From 8ec142efb3ed2f1a55f73c210bf2bc167ae4e26e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 13:37:28 -0700 Subject: [PATCH 36/47] fix for https://github.com/Azure/azure-sdk-for-java/issues/1079 --- .../network/implementation/PublicIpAddressImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index db0b9ca49916d..ae81be780f711 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -114,12 +114,20 @@ public IPVersion version() { @Override public String fqdn() { - return this.inner().dnsSettings().fqdn(); + if (this.inner().dnsSettings() != null) { + return this.inner().dnsSettings().fqdn(); + } else { + return null; + } } @Override public String reverseFqdn() { - return this.inner().dnsSettings().reverseFqdn(); + if (this.inner().dnsSettings() != null) { + return this.inner().dnsSettings().reverseFqdn(); + } else { + return null; + } } @Override From 9144fa407b326759cac0029c9168367f8bc73c78 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 16:26:32 -0700 Subject: [PATCH 37/47] A bit of clean up in graph --- .../implementation/GraphRbacManager.java | 36 +++++++++++++++++++ .../implementation/ServicePrincipalImpl.java | 7 ++-- .../graphrbac/implementation/UserImpl.java | 7 ++-- .../GraphRbacManagementTestBase.java | 12 ++----- .../management/graphrbac/GroupsTests.java | 35 ------------------ .../management/graphrbac/UsersTests.java | 7 ++-- 6 files changed, 51 insertions(+), 53 deletions(-) delete mode 100644 azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GroupsTests.java diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GraphRbacManager.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GraphRbacManager.java index 570cf9456c414..a4442db6c613a 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GraphRbacManager.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/GraphRbacManager.java @@ -8,6 +8,7 @@ import com.microsoft.azure.RequestIdHeaderInterceptor; import com.microsoft.azure.RestClient; +import com.microsoft.azure.credentials.AzureTokenCredentials; import com.microsoft.azure.management.graphrbac.ServicePrincipals; import com.microsoft.azure.management.graphrbac.Users; import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; @@ -18,6 +19,7 @@ * Entry point to Azure resource management. */ public final class GraphRbacManager { + private String tenantId; // The sdk clients private final GraphRbacManagementClientImpl graphRbacManagementClient; // The collections @@ -39,6 +41,20 @@ public static GraphRbacManager authenticate(ServiceClientCredentials credentials .build(), tenantId); } + /** + * Creates an instance of GraphRbacManager that exposes resource management API entry points. + * + * @param credentials the credentials to use + * @return the GraphRbacManager instance + */ + public static GraphRbacManager authenticate(AzureTokenCredentials credentials) { + return new GraphRbacManager(new RestClient.Builder() + .withBaseUrl("https://graph.windows.net") + .withInterceptor(new RequestIdHeaderInterceptor()) + .withCredentials(credentials) + .build(), credentials.getDomain()); + } + /** * Creates an instance of GraphRbacManager that exposes resource management API entry points. * @@ -71,6 +87,14 @@ public interface Configurable extends AzureConfigurable { * @return the interface exposing resource management API entry points that work across subscriptions */ GraphRbacManager authenticate(ServiceClientCredentials credentials, String tenantId); + + /** + * Creates an instance of GraphRbacManager that exposes resource management API entry points. + * + * @param credentials the credentials to use + * @return the interface exposing resource management API entry points that work across subscriptions + */ + GraphRbacManager authenticate(AzureTokenCredentials credentials); } /** @@ -86,10 +110,22 @@ protected ConfigurableImpl() { public GraphRbacManager authenticate(ServiceClientCredentials credentials, String tenantId) { return GraphRbacManager.authenticate(buildRestClient(credentials), tenantId); } + + public GraphRbacManager authenticate(AzureTokenCredentials credentials) { + return GraphRbacManager.authenticate(buildRestClient(credentials), credentials.getDomain()); + } } private GraphRbacManager(RestClient restClient, String tenantId) { this.graphRbacManagementClient = new GraphRbacManagementClientImpl(restClient).withTenantID(tenantId); + this.tenantId = tenantId; + } + + /** + * @return the tenant ID the graph client is associated with + */ + public String tenantId() { + return tenantId; } /** diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java index 0dbe0d5258fd6..ed4c40a229cf6 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java @@ -69,16 +69,17 @@ public ServicePrincipalImpl withAccountEnabled(boolean enabled) { @Override public ServicePrincipal refresh() { - return null; + setInner(client.list(String.format("servicePrincipalNames/any(c:c eq '%s')", name())).get(0)); + return this; } @Override public Observable createResourceAsync() { - return null; + throw new UnsupportedOperationException("Will be implemented in a next release"); } @Override public Observable applyAsync() { - return null; + throw new UnsupportedOperationException("Will be implemented in a next release"); } } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java index 9779e5c7fd706..42f03d039a2e9 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java @@ -102,16 +102,17 @@ public UserImpl withPassword(String password, boolean forceChangePasswordNextLog @Override public User refresh() { - return null; + setInner(client.get(name())); + return this; } @Override public Observable createResourceAsync() { - return null; + throw new UnsupportedOperationException("Will be implemented in a next release"); } @Override public Observable applyAsync() { - return null; + throw new UnsupportedOperationException("Will be implemented in a next release"); } } diff --git a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GraphRbacManagementTestBase.java b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GraphRbacManagementTestBase.java index dcf676ac78300..f418fbfd612ff 100644 --- a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GraphRbacManagementTestBase.java +++ b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GraphRbacManagementTestBase.java @@ -18,25 +18,17 @@ public abstract class GraphRbacManagementTestBase { protected static GraphRbacManager graphRbacManager; protected static void createClients() { -// ApplicationTokenCredentials credentials = new ApplicationTokenCredentials( -// System.getenv("client-id"), -// System.getenv("domain"), -// System.getenv("secret"), -// "https://graph.windows.net", -// null); UserTokenCredentials credentials = new UserTokenCredentials( - "1950a258-227b-4e31-a9cf-717495945fc2", + System.getenv("client-id"), System.getenv("domain"), System.getenv("username"), System.getenv("password"), - "https://graph.windows.net", - "https://graph.windows.net", AzureEnvironment.AZURE ); graphRbacManager = GraphRbacManager .configure() .withLogLevel(HttpLoggingInterceptor.Level.BODY) - .authenticate(credentials, "myorganization"); + .authenticate(credentials); } } diff --git a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GroupsTests.java b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GroupsTests.java deleted file mode 100644 index 37d0f0df6792b..0000000000000 --- a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/GroupsTests.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - */ - -package com.microsoft.azure.management.graphrbac; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -public class GroupsTests extends GraphRbacManagementTestBase { - private static final String RG_NAME = "javacsmrg350"; - private static final String APP_NAME = "app-javacsm350"; - - @BeforeClass - public static void setup() throws Exception { - createClients(); - } - - @AfterClass - public static void cleanup() throws Exception { - } - - @Test - public void getServicePrincipal() throws Exception { - List servicePrincipals = graphRbacManager.servicePrincipals().list(); - Assert.assertNotNull(servicePrincipals); - } - -} diff --git a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java index 19eb9a0eb3f09..ddc4efb01a079 100644 --- a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java +++ b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java @@ -31,11 +31,14 @@ public void canCRUDUser() throws Exception { //LIST List userList = graphRbacManager.users().list(); Assert.assertNotNull(userList); - User user = graphRbacManager.users().define("jeffrolfnlu@hotmail.com") + User user = graphRbacManager.users().define("azuresdk@outlook.com") .withDisplayName("Test User 309") .withPassword("Pa$$w0rd") - .withMailNickname("") + .withMailNickname(null) .create(); + Assert.assertNotNull(user); + Assert.assertEquals("Test User 309", user.displayName()); + Assert.assertEquals("azuresdk@outlook.com", user.mail()); } } From 05bedf4c0154ac32e8a101d358c1529ea8f022b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 16:45:41 -0700 Subject: [PATCH 38/47] ability to directly get the load balancer frontend associated with a public ip address, if any --- .../management/network/PublicIpAddress.java | 10 +++++++ .../implementation/PublicIpAddressImpl.java | 29 ++++++++++++++++++- .../microsoft/azure/TestPublicIpAddress.java | 17 ++++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index c8132dcc157ee..b955f6057996f 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -62,6 +62,16 @@ public interface PublicIpAddress extends */ int idleTimeoutInMinutes(); + /** + * @return the load balancer frontend that this public IP address is assigned to + */ + Frontend getAssignedLoadBalancerFrontend(); + + /** + * @return true if this public IP address is assigned to a load balancer frontend + */ + boolean hasAssignedLoadBalancerFrontend(); + /************************************************************** * Fluent interfaces for builder pattern **************************************************************/ diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index 1cb797ffd96a7..67346a8e21708 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -8,8 +8,11 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.IPAllocationMethod; import com.microsoft.azure.management.network.IPVersion; +import com.microsoft.azure.management.network.LoadBalancer; +import com.microsoft.azure.management.network.PublicFrontend; import com.microsoft.azure.management.network.PublicIPAddressDnsSettings; import com.microsoft.azure.management.network.PublicIpAddress; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import rx.Observable; @@ -160,4 +163,28 @@ public Observable createResourceAsync() { return this.client.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()) .map(innerToFluentMap(this)); } -} \ No newline at end of file + + @Override + public PublicFrontend getAssignedLoadBalancerFrontend() { + if (this.hasAssignedLoadBalancerFrontend()) { + final String refId = this.inner().ipConfiguration().id(); + final String loadBalancerId = ResourceUtils.parentResourcePathFromResourceId(refId); + final LoadBalancer lb = this.myManager.loadBalancers().getById(loadBalancerId); + final String frontendName = ResourceUtils.nameFromResourceId(refId); + return (PublicFrontend) lb.frontends().get(frontendName); + } else { + return null; + } + } + + @Override + public boolean hasAssignedLoadBalancerFrontend() { + if (this.inner().ipConfiguration() == null) { + return false; + } else { + final String refId = this.inner().ipConfiguration().id(); + final String resourceType = ResourceUtils.resourceTypeFromResourceId(refId); + return resourceType.equalsIgnoreCase("frontendIPConfigurations"); + } + } +} diff --git a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java index cfa7ec675cd05..10343ee2c03b9 100644 --- a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java +++ b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java @@ -52,8 +52,8 @@ public void print(PublicIpAddress pip) { } public static void printPIP(PublicIpAddress resource) { - System.out.println(new StringBuilder().append("Public IP Address: ").append(resource.id()) - .append("Name: ").append(resource.name()) + StringBuilder info = new StringBuilder().append("Public IP Address: ").append(resource.id()) + .append("\n\tName: ").append(resource.name()) .append("\n\tResource group: ").append(resource.resourceGroupName()) .append("\n\tRegion: ").append(resource.region()) .append("\n\tTags: ").append(resource.tags()) @@ -63,7 +63,16 @@ public static void printPIP(PublicIpAddress resource) { .append("\n\tReverse FQDN: ").append(resource.reverseFqdn()) .append("\n\tIdle timeout (minutes): ").append(resource.idleTimeoutInMinutes()) .append("\n\tIP allocation method: ").append(resource.ipAllocationMethod().toString()) - .append("\n\tIP version: ").append(resource.version().toString()) - .toString()); + .append("\n\tIP version: ").append(resource.version().toString()); + + // Show the associated load balancer frontend if any + info.append("\n\tAssociated load balancer frontend name: "); + if (resource.hasAssignedLoadBalancerFrontend()) { + info.append(resource.getAssignedLoadBalancerFrontend().name()); + } else { + info.append("(None)"); + } + + System.out.println(info.toString()); } } From 52ea2b3b0916c1dd6abb369307f663d2b26c3aed Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 17:09:12 -0700 Subject: [PATCH 39/47] making .parent() publicly available on child objects --- .../management/compute/VirtualMachineDataDisk.java | 2 +- .../compute/implementation/DataDiskImpl.java | 2 +- .../azure/management/keyvault/AccessPolicy.java | 2 +- .../keyvault/implementation/AccessPolicyImpl.java | 3 ++- .../microsoft/azure/management/network/Backend.java | 2 +- .../microsoft/azure/management/network/Frontend.java | 2 +- .../azure/management/network/InboundNatPool.java | 2 +- .../azure/management/network/InboundNatRule.java | 2 +- .../azure/management/network/LoadBalancingRule.java | 2 +- .../azure/management/network/NetworkSecurityRule.java | 2 +- .../azure/management/network/NicIpConfiguration.java | 2 +- .../com/microsoft/azure/management/network/Probe.java | 2 +- .../azure/management/network/PublicIpAddress.java | 4 ++-- .../com/microsoft/azure/management/network/Subnet.java | 2 +- .../management/network/implementation/BackendImpl.java | 2 +- .../network/implementation/FrontendImpl.java | 2 +- .../network/implementation/InboundNatPoolImpl.java | 2 +- .../network/implementation/InboundNatRuleImpl.java | 2 +- .../network/implementation/LoadBalancingRuleImpl.java | 2 +- .../implementation/NetworkSecurityRuleImpl.java | 2 +- .../network/implementation/NicIpConfigurationImpl.java | 2 +- .../management/network/implementation/ProbeImpl.java | 2 +- .../management/network/implementation/SubnetImpl.java | 2 +- .../resources/fluentcore/arm/models/ChildResource.java | 10 ++++++++-- .../arm/models/implementation/ChildResourceImpl.java | 5 +++-- .../java/com/microsoft/azure/TestLoadBalancer.java | 1 + .../java/com/microsoft/azure/TestPublicIpAddress.java | 9 +++++++-- 27 files changed, 44 insertions(+), 30 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineDataDisk.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineDataDisk.java index 8c463c5aceb16..23a1e8f499d46 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineDataDisk.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineDataDisk.java @@ -12,7 +12,7 @@ @LangDefinition(ContainerName = "~/") public interface VirtualMachineDataDisk extends Wrapper, - ChildResource { + ChildResource { // getters diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/DataDiskImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/DataDiskImpl.java index 9827edff9f261..15e9c9b3ef5ba 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/DataDiskImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/DataDiskImpl.java @@ -19,7 +19,7 @@ */ @LangDefinition class DataDiskImpl - extends ChildResourceImpl + extends ChildResourceImpl implements VirtualMachineDataDisk, VirtualMachineDataDisk.Definition, diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/AccessPolicy.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/AccessPolicy.java index 7e09d5331f9f0..17f2f9eacf81e 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/AccessPolicy.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/AccessPolicy.java @@ -21,7 +21,7 @@ * An immutable client-side representation of a key vault access policy. */ public interface AccessPolicy extends - ChildResource, + ChildResource, Wrapper { /** * @return The Azure Active Directory tenant ID that should be used for diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/AccessPolicyImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/AccessPolicyImpl.java index 62a6397fe7f9b..8d65a20890178 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/AccessPolicyImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/AccessPolicyImpl.java @@ -28,7 +28,8 @@ class AccessPolicyImpl extends ChildResourceImpl< AccessPolicyEntry, - VaultImpl> + VaultImpl, + Vault> implements AccessPolicy, AccessPolicy.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java index f97d203631fc6..8bd6a96260624 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Backend.java @@ -20,7 +20,7 @@ */ public interface Backend extends Wrapper, - ChildResource, + ChildResource, HasLoadBalancingRules { /** diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Frontend.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Frontend.java index b93364419c542..e0d80227c08d8 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Frontend.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Frontend.java @@ -17,7 +17,7 @@ */ public interface Frontend extends Wrapper, - ChildResource, + ChildResource, HasLoadBalancingRules { /** diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatPool.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatPool.java index e13ccb20c6aa7..6da91cc07785a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatPool.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatPool.java @@ -22,7 +22,7 @@ public interface InboundNatPool extends HasBackendPort, HasProtocol, Wrapper, - ChildResource { + ChildResource { /** * @return the starting frontend port number diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatRule.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatRule.java index cc5c3ad636e13..a09317219832a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatRule.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/InboundNatRule.java @@ -24,7 +24,7 @@ public interface InboundNatRule extends HasProtocol, HasFloatingIp, Wrapper, - ChildResource { + ChildResource { /** * @return the name of the IP configuration within the network interface associated with this NAT rule diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancingRule.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancingRule.java index 2fc8acbe2d3ca..26d58a62daaf1 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancingRule.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/LoadBalancingRule.java @@ -20,7 +20,7 @@ */ public interface LoadBalancingRule extends Wrapper, - ChildResource, + ChildResource, HasBackendPort, HasFrontend, HasFloatingIp, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityRule.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityRule.java index 086a7926d3ce2..778e718003051 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityRule.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityRule.java @@ -19,7 +19,7 @@ @LangDefinition() public interface NetworkSecurityRule extends Wrapper, - ChildResource { + ChildResource { /** * @return the direction of the network traffic that the network security rule applies to. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java index 3f9fd39d8a740..6b3d44b9e9876 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java @@ -15,7 +15,7 @@ @LangDefinition() public interface NicIpConfiguration extends Wrapper, - ChildResource, + ChildResource, HasPrivateIpAddress { // Getters diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Probe.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Probe.java index 5415524587a4a..dd926afb48f24 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Probe.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Probe.java @@ -16,7 +16,7 @@ */ public interface Probe extends Wrapper, - ChildResource, + ChildResource, HasLoadBalancingRules, HasProtocol { diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index b955f6057996f..4443a6ef33a4d 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -63,9 +63,9 @@ public interface PublicIpAddress extends int idleTimeoutInMinutes(); /** - * @return the load balancer frontend that this public IP address is assigned to + * @return the load balancer public frontend that this public IP address is assigned to */ - Frontend getAssignedLoadBalancerFrontend(); + PublicFrontend getAssignedLoadBalancerFrontend(); /** * @return true if this public IP address is assigned to a load balancer frontend diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java index 1706f48ebac88..3d3fe90ff3632 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Subnet.java @@ -18,7 +18,7 @@ @LangDefinition() public interface Subnet extends Wrapper, - ChildResource { + ChildResource { /** * @return the address space prefix, in CIDR notation, assigned to this subnet diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java index da2ad93ba31b9..d2d133377f6e5 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/BackendImpl.java @@ -24,7 +24,7 @@ * Implementation for {@link Backend}. */ class BackendImpl - extends ChildResourceImpl + extends ChildResourceImpl implements Backend, Backend.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendImpl.java index 8ba2ff449610e..c034669e2a2fe 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/FrontendImpl.java @@ -27,7 +27,7 @@ * Implementation for {@link PublicFrontend}. */ class FrontendImpl - extends ChildResourceImpl + extends ChildResourceImpl implements Frontend, PrivateFrontend, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java index 7a4a66dca6c7d..79ff88ebe00d0 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatPoolImpl.java @@ -17,7 +17,7 @@ * Implementation for {@link InboundNatRule}. */ class InboundNatPoolImpl - extends ChildResourceImpl + extends ChildResourceImpl implements InboundNatPool, InboundNatPool.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java index 862d3915e4d2e..580411c0336da 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/InboundNatRuleImpl.java @@ -17,7 +17,7 @@ * Implementation for {@link InboundNatRule}. */ class InboundNatRuleImpl - extends ChildResourceImpl + extends ChildResourceImpl implements InboundNatRule, InboundNatRule.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancingRuleImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancingRuleImpl.java index dbed9686939d8..e297d44dece12 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancingRuleImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancingRuleImpl.java @@ -20,7 +20,7 @@ * Implementation for {@link LoadBalancingRule}. */ class LoadBalancingRuleImpl - extends ChildResourceImpl + extends ChildResourceImpl implements LoadBalancingRule, LoadBalancingRule.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityRuleImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityRuleImpl.java index 4e2ba57137066..2767cd8cacf8a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityRuleImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityRuleImpl.java @@ -18,7 +18,7 @@ */ @LangDefinition class NetworkSecurityRuleImpl - extends ChildResourceImpl + extends ChildResourceImpl implements NetworkSecurityRule, NetworkSecurityRule.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java index 16ffde7d23195..8f9b825122352 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java @@ -22,7 +22,7 @@ @LangDefinition() class NicIpConfigurationImpl extends - ChildResourceImpl + ChildResourceImpl implements NicIpConfiguration, NicIpConfiguration.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ProbeImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ProbeImpl.java index 2542ae7bff832..c794ad3da2b19 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ProbeImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/ProbeImpl.java @@ -22,7 +22,7 @@ * Implementation for {@link TcpProbe} and its create and update interfaces. */ class ProbeImpl - extends ChildResourceImpl + extends ChildResourceImpl implements TcpProbe, TcpProbe.Definition, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java index 8f93d1292a419..f76ef954fa015 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/SubnetImpl.java @@ -17,7 +17,7 @@ */ @LangDefinition class SubnetImpl - extends ChildResourceImpl + extends ChildResourceImpl implements Subnet, Subnet.Definition, diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ChildResource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ChildResource.java index 4086d7f8e136d..36c0cba217784 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ChildResource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/ChildResource.java @@ -10,11 +10,17 @@ /** * Base interface used by child resources. + * @param parent interface */ @LangDefinition() -public interface ChildResource extends Indexable { +public interface ChildResource extends Indexable { /** - * @return the name of the child resource + * @return the name of this child object */ String name(); + + /** + * @return the parent of this child object + */ + ParentT parent(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ChildResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ChildResourceImpl.java index c0b59ebeed4f9..87b3619ba1788 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ChildResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ChildResourceImpl.java @@ -13,10 +13,11 @@ * (Internal use only) * @param Azure inner child class type * @param parent implementation + * @param parent interface */ -public abstract class ChildResourceImpl +public abstract class ChildResourceImpl extends IndexableWrapperImpl - implements ChildResource { + implements ChildResource { private final ParentImplT parent; diff --git a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java index 0ebb8e1cc75e3..d7b5715651f59 100644 --- a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java +++ b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java @@ -258,6 +258,7 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { // Verify frontends Assert.assertTrue(lb.frontends().containsKey("frontend1")); Assert.assertTrue(lb.frontends().size() == 1); + TestPublicIpAddress.printPIP(existingPips.get(0).refresh()); // Verify backends Assert.assertTrue(lb.backends().containsKey("backend1")); diff --git a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java index 10343ee2c03b9..9cc3802d0d9ce 100644 --- a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java +++ b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java @@ -7,6 +7,8 @@ import org.junit.Assert; +import com.microsoft.azure.management.network.LoadBalancer; +import com.microsoft.azure.management.network.PublicFrontend; import com.microsoft.azure.management.network.PublicIpAddress; import com.microsoft.azure.management.network.PublicIpAddresses; import com.microsoft.azure.management.resources.fluentcore.arm.Region; @@ -66,9 +68,12 @@ public static void printPIP(PublicIpAddress resource) { .append("\n\tIP version: ").append(resource.version().toString()); // Show the associated load balancer frontend if any - info.append("\n\tAssociated load balancer frontend name: "); + info.append("\n\tLoad balancer association: "); if (resource.hasAssignedLoadBalancerFrontend()) { - info.append(resource.getAssignedLoadBalancerFrontend().name()); + final PublicFrontend frontend = resource.getAssignedLoadBalancerFrontend(); + final LoadBalancer lb = frontend.parent(); + info.append("\n\t\tLoad balancer ID: ").append(lb.id()) + .append("\n\t\tFrontend name: ").append(frontend.name()); } else { info.append("(None)"); } From aed1b0b6d65a06ae3d971ce3e103585a5cf8e9e3 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 17:14:10 -0700 Subject: [PATCH 40/47] Address feedback --- .../graphrbac/implementation/ServicePrincipalImpl.java | 4 ++-- .../azure/management/graphrbac/implementation/UserImpl.java | 4 ++-- .../com/microsoft/azure/management/graphrbac/UsersTests.java | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java index ed4c40a229cf6..6fbcacecc3839 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalImpl.java @@ -75,11 +75,11 @@ public ServicePrincipal refresh() { @Override public Observable createResourceAsync() { - throw new UnsupportedOperationException("Will be implemented in a next release"); + throw new UnsupportedOperationException("not implemented yet"); } @Override public Observable applyAsync() { - throw new UnsupportedOperationException("Will be implemented in a next release"); + throw new UnsupportedOperationException("not implemented yet"); } } diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java index 42f03d039a2e9..1514858b8dad5 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UserImpl.java @@ -108,11 +108,11 @@ public User refresh() { @Override public Observable createResourceAsync() { - throw new UnsupportedOperationException("Will be implemented in a next release"); + throw new UnsupportedOperationException("not implemented yet"); } @Override public Observable applyAsync() { - throw new UnsupportedOperationException("Will be implemented in a next release"); + throw new UnsupportedOperationException("not implemented yet"); } } diff --git a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java index ddc4efb01a079..6dbb3691e3d8c 100644 --- a/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java +++ b/azure-mgmt-graph-rbac/src/main/test/java/com/microsoft/azure/management/graphrbac/UsersTests.java @@ -31,14 +31,13 @@ public void canCRUDUser() throws Exception { //LIST List userList = graphRbacManager.users().list(); Assert.assertNotNull(userList); - User user = graphRbacManager.users().define("azuresdk@outlook.com") + User user = graphRbacManager.users().define("newuser") .withDisplayName("Test User 309") .withPassword("Pa$$w0rd") .withMailNickname(null) .create(); Assert.assertNotNull(user); Assert.assertEquals("Test User 309", user.displayName()); - Assert.assertEquals("azuresdk@outlook.com", user.mail()); } } From 210d02f423366620f1a50dc84336a7821c3601d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 17:58:30 -0700 Subject: [PATCH 41/47] ability to get to the associated NIC IP config (if any) from a public IP address --- .../management/network/PublicIpAddress.java | 16 +++++--- .../implementation/PublicIpAddressImpl.java | 39 +++++++++++++++---- .../java/com/microsoft/azure/AzureTests.java | 2 +- .../com/microsoft/azure/TestLoadBalancer.java | 3 ++ .../microsoft/azure/TestPublicIpAddress.java | 17 +++++++- .../azure/TestVirtualMachineSsh.java | 24 +++++++++--- 6 files changed, 81 insertions(+), 20 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index 4443a6ef33a4d..076313f066b7c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -68,13 +68,19 @@ public interface PublicIpAddress extends PublicFrontend getAssignedLoadBalancerFrontend(); /** - * @return true if this public IP address is assigned to a load balancer frontend + * @return true if this public IP address is assigned to a load balancer */ - boolean hasAssignedLoadBalancerFrontend(); + boolean hasAssignedLoadBalancer(); - /************************************************************** - * Fluent interfaces for builder pattern - **************************************************************/ + /** + * @return the network interface IP configuration that this public IP address is assigned to + */ + NicIpConfiguration getAssignedNetworkInterfaceIpConfiguration(); + + /** + * @return true if this public IP address is assigned to a network interface + */ + boolean hasAssignedNetworkInterface(); /** * Container interface for all the definitions. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index 67346a8e21708..17588ee11c255 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -9,6 +9,8 @@ import com.microsoft.azure.management.network.IPAllocationMethod; import com.microsoft.azure.management.network.IPVersion; import com.microsoft.azure.management.network.LoadBalancer; +import com.microsoft.azure.management.network.NetworkInterface; +import com.microsoft.azure.management.network.NicIpConfiguration; import com.microsoft.azure.management.network.PublicFrontend; import com.microsoft.azure.management.network.PublicIPAddressDnsSettings; import com.microsoft.azure.management.network.PublicIpAddress; @@ -164,9 +166,25 @@ public Observable createResourceAsync() { .map(innerToFluentMap(this)); } + private boolean equalsResourceType(String resourceType) { + IPConfigurationInner ipConfig = this.inner().ipConfiguration(); + if (ipConfig == null || resourceType == null) { + return false; + } else { + final String refId = this.inner().ipConfiguration().id(); + final String resourceType2 = ResourceUtils.resourceTypeFromResourceId(refId); + return resourceType.equalsIgnoreCase(resourceType2); + } + } + + @Override + public boolean hasAssignedLoadBalancer() { + return equalsResourceType("frontendIPConfigurations"); + } + @Override public PublicFrontend getAssignedLoadBalancerFrontend() { - if (this.hasAssignedLoadBalancerFrontend()) { + if (this.hasAssignedLoadBalancer()) { final String refId = this.inner().ipConfiguration().id(); final String loadBalancerId = ResourceUtils.parentResourcePathFromResourceId(refId); final LoadBalancer lb = this.myManager.loadBalancers().getById(loadBalancerId); @@ -178,13 +196,20 @@ public PublicFrontend getAssignedLoadBalancerFrontend() { } @Override - public boolean hasAssignedLoadBalancerFrontend() { - if (this.inner().ipConfiguration() == null) { - return false; - } else { + public boolean hasAssignedNetworkInterface() { + return equalsResourceType("ipConfigurations"); + } + + @Override + public NicIpConfiguration getAssignedNetworkInterfaceIpConfiguration() { + if (this.hasAssignedNetworkInterface()) { final String refId = this.inner().ipConfiguration().id(); - final String resourceType = ResourceUtils.resourceTypeFromResourceId(refId); - return resourceType.equalsIgnoreCase("frontendIPConfigurations"); + final String parentId = ResourceUtils.parentResourcePathFromResourceId(refId); + final NetworkInterface nic = this.myManager.networkInterfaces().getById(parentId); + final String childName = ResourceUtils.nameFromResourceId(refId); + return nic.ipConfigurations().get(childName); + } else { + return null; } } } diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index ab85a9f609e01..a4d04150da287 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -257,7 +257,7 @@ public void testLoadBalancersInternalMinimum() throws Exception { } @Test public void testVirtualMachineSSh() throws Exception { - new TestVirtualMachineSsh() + new TestVirtualMachineSsh(azure.publicIpAddresses()) .runTest(azure.virtualMachines(), azure.resourceGroups()); } diff --git a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java index d7b5715651f59..c671fe684bca5 100644 --- a/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java +++ b/azure/src/test/java/com/microsoft/azure/TestLoadBalancer.java @@ -258,6 +258,9 @@ public LoadBalancer createResource(LoadBalancers resources) throws Exception { // Verify frontends Assert.assertTrue(lb.frontends().containsKey("frontend1")); Assert.assertTrue(lb.frontends().size() == 1); + + existingPips.get(0).refresh(); + Assert.assertTrue(existingPips.get(0).getAssignedLoadBalancerFrontend().name().equalsIgnoreCase("frontend1")); TestPublicIpAddress.printPIP(existingPips.get(0).refresh()); // Verify backends diff --git a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java index 9cc3802d0d9ce..bd14edd3a4718 100644 --- a/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java +++ b/azure/src/test/java/com/microsoft/azure/TestPublicIpAddress.java @@ -8,6 +8,8 @@ import org.junit.Assert; import com.microsoft.azure.management.network.LoadBalancer; +import com.microsoft.azure.management.network.NetworkInterface; +import com.microsoft.azure.management.network.NicIpConfiguration; import com.microsoft.azure.management.network.PublicFrontend; import com.microsoft.azure.management.network.PublicIpAddress; import com.microsoft.azure.management.network.PublicIpAddresses; @@ -67,9 +69,9 @@ public static void printPIP(PublicIpAddress resource) { .append("\n\tIP allocation method: ").append(resource.ipAllocationMethod().toString()) .append("\n\tIP version: ").append(resource.version().toString()); - // Show the associated load balancer frontend if any + // Show the associated load balancer if any info.append("\n\tLoad balancer association: "); - if (resource.hasAssignedLoadBalancerFrontend()) { + if (resource.hasAssignedLoadBalancer()) { final PublicFrontend frontend = resource.getAssignedLoadBalancerFrontend(); final LoadBalancer lb = frontend.parent(); info.append("\n\t\tLoad balancer ID: ").append(lb.id()) @@ -78,6 +80,17 @@ public static void printPIP(PublicIpAddress resource) { info.append("(None)"); } + // Show the associated NIC if any + info.append("\n\tNetwork interface association: "); + if (resource.hasAssignedNetworkInterface()) { + final NicIpConfiguration nicIp = resource.getAssignedNetworkInterfaceIpConfiguration(); + final NetworkInterface nic = nicIp.parent(); + info.append("\n\t\tNetwork interface ID: ").append(nic.id()) + .append("\n\t\tIP config name: ").append(nicIp.name()); + } else { + info.append("(None)"); + } + System.out.println(info.toString()); } } diff --git a/azure/src/test/java/com/microsoft/azure/TestVirtualMachineSsh.java b/azure/src/test/java/com/microsoft/azure/TestVirtualMachineSsh.java index a9897d3b60bdc..135bfb98aef27 100644 --- a/azure/src/test/java/com/microsoft/azure/TestVirtualMachineSsh.java +++ b/azure/src/test/java/com/microsoft/azure/TestVirtualMachineSsh.java @@ -11,24 +11,35 @@ import com.microsoft.azure.management.compute.KnownLinuxVirtualMachineImage; import com.microsoft.azure.management.compute.VirtualMachine; import com.microsoft.azure.management.compute.VirtualMachines; +import com.microsoft.azure.management.network.PublicIpAddress; +import com.microsoft.azure.management.network.PublicIpAddresses; import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; import com.microsoft.azure.management.resources.fluentcore.arm.Region; import org.junit.Assert; public class TestVirtualMachineSsh extends TestTemplate { - public TestVirtualMachineSsh() { + final PublicIpAddresses pips; + public TestVirtualMachineSsh(PublicIpAddresses pips) { + this.pips = pips; } @Override public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception { final String vmName = "vm" + this.testId; - final String sshKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfSPC2K7LZcFKEO+/t3dzmQYtrJFZNxOsbVgOVKietqHyvmYGHEC0J2wPdAqQ/63g/hhAEFRoyehM+rbeDri4txB3YFfnOK58jqdkyXzupWqXzOrlKY4Wz9SKjjN765+dqUITjKRIaAip1Ri137szRg71WnrmdP3SphTRlCx1Bk2nXqWPsclbRDCiZeF8QOTi4JqbmJyK5+0UqhqYRduun8ylAwKKQJ1NJt85sYIHn9f1Rfr6Tq2zS0wZ7DHbZL+zB5rSlAr8QyUdg/GQD+cmSs6LvPJKL78d6hMGk84ARtFo4A79ovwX/Fj01znDQkU6nJildfkaolH2rWFG/qttD azjava@javalib.com"; final String publicIpDnsLabel = vmName; + final String sshKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfSPC2K7LZcFKEO+/t3dzmQYtrJFZNxOsbVgOVKietqHyvmYGHEC0J2wPdAqQ/63g/hhAEFRoyehM+rbeDri4txB3YFfnOK58jqdkyXzupWqXzOrlKY4Wz9SKjjN765+dqUITjKRIaAip1Ri137szRg71WnrmdP3SphTRlCx1Bk2nXqWPsclbRDCiZeF8QOTi4JqbmJyK5+0UqhqYRduun8ylAwKKQJ1NJt85sYIHn9f1Rfr6Tq2zS0wZ7DHbZL+zB5rSlAr8QyUdg/GQD+cmSs6LvPJKL78d6hMGk84ARtFo4A79ovwX/Fj01znDQkU6nJildfkaolH2rWFG/qttD azjava@javalib.com"; + final String publicIpDnsLabel = vmName; + PublicIpAddress pip = pips.define(publicIpDnsLabel) + .withRegion(Region.US_EAST) + .withNewResourceGroup() + .withLeafDomainLabel(publicIpDnsLabel) + .create(); + VirtualMachine vm = virtualMachines.define(vmName) - .withRegion(Region.US_EAST) - .withNewResourceGroup() + .withRegion(pip.regionName()) + .withExistingResourceGroup(pip.resourceGroupName()) .withNewPrimaryNetwork("10.0.0.0/28") .withPrimaryPrivateIpAddressDynamic() - .withNewPrimaryPublicIpAddress(publicIpDnsLabel) + .withExistingPrimaryPublicIpAddress(pip) .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS) .withRootUserName("testuser") .withSsh(sshKey) @@ -36,6 +47,9 @@ public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exc .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2) .create(); + pip.refresh(); + Assert.assertTrue(pip.hasAssignedNetworkInterface()); + JSch jsch= new JSch(); Session session = null; try { From cb13f8a533336b0475036f091ef879fe9707dbff Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 15 Sep 2016 17:58:25 -0700 Subject: [PATCH 42/47] Regen Redis from updated swagger --- .../azure/management/redis/DayOfWeek.java | 76 ++- .../management/redis/RedisAccessKeys.java | 68 --- .../redis/RedisPatchSchedulesRequest.java | 47 -- ...duleEntryInner.java => ScheduleEntry.java} | 19 +- .../ExportRDBParametersInner.java | 2 +- .../implementation/PatchSchedulesInner.java | 88 ++- ...ltInner.java => RedisAccessKeysInner.java} | 12 +- .../RedisCreateParametersInner.java} | 112 ++-- .../redis/implementation/RedisInner.java | 517 ++++++++++++++---- ...nner.java => RedisPatchScheduleInner.java} | 23 +- .../implementation/RedisResourceInner.java | 168 ++---- .../RedisResourceWithAccessKeyInner.java | 368 ------------- ...r.java => RedisUpdateParametersInner.java} | 144 +++-- 13 files changed, 701 insertions(+), 943 deletions(-) delete mode 100644 azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java delete mode 100644 azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisPatchSchedulesRequest.java rename azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/{implementation/ScheduleEntryInner.java => ScheduleEntry.java} (77%) rename azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/{RedisListKeysResultInner.java => RedisAccessKeysInner.java} (79%) rename azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/{RedisProperties.java => implementation/RedisCreateParametersInner.java} (71%) rename azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/{RedisPatchSchedulesResponseInner.java => RedisPatchScheduleInner.java} (75%) delete mode 100644 azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceWithAccessKeyInner.java rename azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/{RedisCreateOrUpdateParametersInner.java => RedisUpdateParametersInner.java} (68%) diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DayOfWeek.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DayOfWeek.java index c5ec4ad5a1890..54586a3913509 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DayOfWeek.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DayOfWeek.java @@ -8,67 +8,61 @@ package com.microsoft.azure.management.redis; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; /** * Defines values for DayOfWeek. */ -public final class DayOfWeek { - /** Static value Monday for DayOfWeek. */ - public static final DayOfWeek MONDAY = new DayOfWeek("Monday"); +public enum DayOfWeek { + /** Enum value Monday. */ + MONDAY("Monday"), - /** Static value Tuesday for DayOfWeek. */ - public static final DayOfWeek TUESDAY = new DayOfWeek("Tuesday"); + /** Enum value Tuesday. */ + TUESDAY("Tuesday"), - /** Static value Wednesday for DayOfWeek. */ - public static final DayOfWeek WEDNESDAY = new DayOfWeek("Wednesday"); + /** Enum value Wednesday. */ + WEDNESDAY("Wednesday"), - /** Static value Thursday for DayOfWeek. */ - public static final DayOfWeek THURSDAY = new DayOfWeek("Thursday"); + /** Enum value Thursday. */ + THURSDAY("Thursday"), - /** Static value Friday for DayOfWeek. */ - public static final DayOfWeek FRIDAY = new DayOfWeek("Friday"); + /** Enum value Friday. */ + FRIDAY("Friday"), - /** Static value Saturday for DayOfWeek. */ - public static final DayOfWeek SATURDAY = new DayOfWeek("Saturday"); + /** Enum value Saturday. */ + SATURDAY("Saturday"), - /** Static value Sunday for DayOfWeek. */ - public static final DayOfWeek SUNDAY = new DayOfWeek("Sunday"); + /** Enum value Sunday. */ + SUNDAY("Sunday"); + /** The actual serialized value for a DayOfWeek instance. */ private String value; + DayOfWeek(String value) { + this.value = value; + } + /** - * Creates a custom value for DayOfWeek. - * @param value the custom value + * Parses a serialized value to a DayOfWeek instance. + * + * @param value the serialized value to parse. + * @return the parsed DayOfWeek object, or null if unable to parse. */ - public DayOfWeek(String value) { - this.value = value; + @JsonCreator + public static DayOfWeek fromString(String value) { + DayOfWeek[] items = DayOfWeek.values(); + for (DayOfWeek item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; } @JsonValue @Override public String toString() { - return value; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof DayOfWeek)) { - return false; - } - if (obj == this) { - return true; - } - DayOfWeek rhs = (DayOfWeek) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } + return this.value; } } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java deleted file mode 100644 index 906242791ef9a..0000000000000 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.redis; - - -/** - * Redis cache access keys. - */ -public class RedisAccessKeys { - /** - * The current primary key that clients can use to authenticate with redis - * cache. - */ - private String primaryKey; - - /** - * The current secondary key that clients can use to authenticate with - * redis cache. - */ - private String secondaryKey; - - /** - * Get the primaryKey value. - * - * @return the primaryKey value - */ - public String primaryKey() { - return this.primaryKey; - } - - /** - * Set the primaryKey value. - * - * @param primaryKey the primaryKey value to set - * @return the RedisAccessKeys object itself. - */ - public RedisAccessKeys withPrimaryKey(String primaryKey) { - this.primaryKey = primaryKey; - return this; - } - - /** - * Get the secondaryKey value. - * - * @return the secondaryKey value - */ - public String secondaryKey() { - return this.secondaryKey; - } - - /** - * Set the secondaryKey value. - * - * @param secondaryKey the secondaryKey value to set - * @return the RedisAccessKeys object itself. - */ - public RedisAccessKeys withSecondaryKey(String secondaryKey) { - this.secondaryKey = secondaryKey; - return this; - } - -} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisPatchSchedulesRequest.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisPatchSchedulesRequest.java deleted file mode 100644 index f57645eb3a736..0000000000000 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisPatchSchedulesRequest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.redis; - -import java.util.List; -import com.microsoft.azure.management.redis.implementation.ScheduleEntryInner; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; - -/** - * Parameters to set patch schedules for redis cache. - */ -@JsonFlatten -public class RedisPatchSchedulesRequest { - /** - * List of patch schedules for redis cache. - */ - @JsonProperty(value = "properties.scheduleEntries", required = true) - private List scheduleEntries; - - /** - * Get the scheduleEntries value. - * - * @return the scheduleEntries value - */ - public List scheduleEntries() { - return this.scheduleEntries; - } - - /** - * Set the scheduleEntries value. - * - * @param scheduleEntries the scheduleEntries value to set - * @return the RedisPatchSchedulesRequest object itself. - */ - public RedisPatchSchedulesRequest withScheduleEntries(List scheduleEntries) { - this.scheduleEntries = scheduleEntries; - return this; - } - -} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ScheduleEntryInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java similarity index 77% rename from azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ScheduleEntryInner.java rename to azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java index 7bf3c3f52cb41..363d8ed9db345 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ScheduleEntryInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java @@ -6,16 +6,15 @@ * Code generated by Microsoft (R) AutoRest Code Generator. */ -package com.microsoft.azure.management.redis.implementation; +package com.microsoft.azure.management.redis; -import com.microsoft.azure.management.redis.DayOfWeek; import org.joda.time.Period; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The ScheduleEntryInner model. + * The ScheduleEntry model. */ -public class ScheduleEntryInner { +public class ScheduleEntry { /** * Day of week when cache can be patched. Possible values include: * 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', @@ -48,9 +47,9 @@ public DayOfWeek dayOfWeek() { * Set the dayOfWeek value. * * @param dayOfWeek the dayOfWeek value to set - * @return the ScheduleEntryInner object itself. + * @return the ScheduleEntry object itself. */ - public ScheduleEntryInner withDayOfWeek(DayOfWeek dayOfWeek) { + public ScheduleEntry withDayOfWeek(DayOfWeek dayOfWeek) { this.dayOfWeek = dayOfWeek; return this; } @@ -68,9 +67,9 @@ public int startHourUtc() { * Set the startHourUtc value. * * @param startHourUtc the startHourUtc value to set - * @return the ScheduleEntryInner object itself. + * @return the ScheduleEntry object itself. */ - public ScheduleEntryInner withStartHourUtc(int startHourUtc) { + public ScheduleEntry withStartHourUtc(int startHourUtc) { this.startHourUtc = startHourUtc; return this; } @@ -88,9 +87,9 @@ public Period maintenanceWindow() { * Set the maintenanceWindow value. * * @param maintenanceWindow the maintenanceWindow value to set - * @return the ScheduleEntryInner object itself. + * @return the ScheduleEntry object itself. */ - public ScheduleEntryInner withMaintenanceWindow(Period maintenanceWindow) { + public ScheduleEntry withMaintenanceWindow(Period maintenanceWindow) { this.maintenanceWindow = maintenanceWindow; return this; } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ExportRDBParametersInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ExportRDBParametersInner.java index 06edd0ec055af..4463172ad33bb 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ExportRDBParametersInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/ExportRDBParametersInner.java @@ -20,7 +20,7 @@ public class ExportRDBParametersInner { private String format; /** - * Prifix to use for exported files. + * Prefix to use for exported files. */ @JsonProperty(required = true) private String prefix; diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java index a9c2ee749926c..d6540330fef03 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java @@ -12,13 +12,11 @@ import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.CloudException; -import com.microsoft.azure.management.redis.RedisPatchSchedulesRequest; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; import java.io.IOException; -import java.util.List; import okhttp3.ResponseBody; import retrofit2.http.Body; import retrofit2.http.GET; @@ -60,7 +58,7 @@ public PatchSchedulesInner(Retrofit retrofit, RedisManagementClientImpl client) interface PatchSchedulesService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default") - Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body RedisPatchSchedulesRequest parameters, @Header("User-Agent") String userAgent); + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisPatchScheduleInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/default", method = "DELETE", hasBody = true) @@ -77,11 +75,11 @@ interface PatchSchedulesService { * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param scheduleEntries List of patch schedules for redis cache. - * @return the RedisPatchSchedulesResponseInner object if successful. + * @param parameters Parameters to set patch schedules for redis cache. + * @return the RedisPatchScheduleInner object if successful. */ - public RedisPatchSchedulesResponseInner createOrUpdate(String resourceGroupName, String name, List scheduleEntries) { - return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, scheduleEntries).toBlocking().single().getBody(); + public RedisPatchScheduleInner createOrUpdate(String resourceGroupName, String name, RedisPatchScheduleInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } /** @@ -89,12 +87,12 @@ public RedisPatchSchedulesResponseInner createOrUpdate(String resourceGroupName, * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param scheduleEntries List of patch schedules for redis cache. + * @param parameters Parameters to set patch schedules for redis cache. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall createOrUpdateAsync(String resourceGroupName, String name, List scheduleEntries, final ServiceCallback serviceCallback) { - return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, name, scheduleEntries), serviceCallback); + public ServiceCall createOrUpdateAsync(String resourceGroupName, String name, RedisPatchScheduleInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** @@ -102,13 +100,13 @@ public ServiceCall createOrUpdateAsync(String * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param scheduleEntries List of patch schedules for redis cache. - * @return the observable to the RedisPatchSchedulesResponseInner object + * @param parameters Parameters to set patch schedules for redis cache. + * @return the observable to the RedisPatchScheduleInner object */ - public Observable createOrUpdateAsync(String resourceGroupName, String name, List scheduleEntries) { - return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, scheduleEntries).map(new Func1, RedisPatchSchedulesResponseInner>() { + public Observable createOrUpdateAsync(String resourceGroupName, String name, RedisPatchScheduleInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisPatchScheduleInner>() { @Override - public RedisPatchSchedulesResponseInner call(ServiceResponse response) { + public RedisPatchScheduleInner call(ServiceResponse response) { return response.getBody(); } }); @@ -119,10 +117,10 @@ public RedisPatchSchedulesResponseInner call(ServiceResponse> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String name, List scheduleEntries) { + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String name, RedisPatchScheduleInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -132,21 +130,19 @@ public Observable> createOrUpd if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - if (scheduleEntries == null) { - throw new IllegalArgumentException("Parameter scheduleEntries is required and cannot be null."); - } - Validator.validate(scheduleEntries); - RedisPatchSchedulesRequest parameters = new RedisPatchSchedulesRequest(); - parameters.withScheduleEntries(scheduleEntries); - return service.createOrUpdate(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + Validator.validate(parameters); + return service.createOrUpdate(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = createOrUpdateDelegate(response); + ServiceResponse clientResponse = createOrUpdateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -155,9 +151,9 @@ public Observable> call(Respon }); } - private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -245,9 +241,9 @@ private ServiceResponse deleteDelegate(Response response) th * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the RedisPatchSchedulesResponseInner object if successful. + * @return the RedisPatchScheduleInner object if successful. */ - public RedisPatchSchedulesResponseInner get(String resourceGroupName, String name) { + public RedisPatchScheduleInner get(String resourceGroupName, String name) { return getWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); } @@ -259,7 +255,7 @@ public RedisPatchSchedulesResponseInner get(String resourceGroupName, String nam * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall getAsync(String resourceGroupName, String name, final ServiceCallback serviceCallback) { + public ServiceCall getAsync(String resourceGroupName, String name, final ServiceCallback serviceCallback) { return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } @@ -268,12 +264,12 @@ public ServiceCall getAsync(String resourceGro * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the observable to the RedisPatchSchedulesResponseInner object + * @return the observable to the RedisPatchScheduleInner object */ - public Observable getAsync(String resourceGroupName, String name) { - return getWithServiceResponseAsync(resourceGroupName, name).map(new Func1, RedisPatchSchedulesResponseInner>() { + public Observable getAsync(String resourceGroupName, String name) { + return getWithServiceResponseAsync(resourceGroupName, name).map(new Func1, RedisPatchScheduleInner>() { @Override - public RedisPatchSchedulesResponseInner call(ServiceResponse response) { + public RedisPatchScheduleInner call(ServiceResponse response) { return response.getBody(); } }); @@ -284,9 +280,9 @@ public RedisPatchSchedulesResponseInner call(ServiceResponse> getWithServiceResponseAsync(String resourceGroupName, String name) { + public Observable> getWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -300,11 +296,11 @@ public Observable> getWithServ throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } return service.get(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = getDelegate(response); + ServiceResponse clientResponse = getDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -313,9 +309,9 @@ public Observable> call(Respon }); } - private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisListKeysResultInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java similarity index 79% rename from azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisListKeysResultInner.java rename to azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java index 0b2c75b7f473a..ba502319b59b5 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisListKeysResultInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java @@ -10,9 +10,9 @@ /** - * The response of redis list keys operation. + * Redis cache access keys. */ -public class RedisListKeysResultInner { +public class RedisAccessKeysInner { /** * The current primary key that clients can use to authenticate with redis * cache. @@ -38,9 +38,9 @@ public String primaryKey() { * Set the primaryKey value. * * @param primaryKey the primaryKey value to set - * @return the RedisListKeysResultInner object itself. + * @return the RedisAccessKeysInner object itself. */ - public RedisListKeysResultInner withPrimaryKey(String primaryKey) { + public RedisAccessKeysInner withPrimaryKey(String primaryKey) { this.primaryKey = primaryKey; return this; } @@ -58,9 +58,9 @@ public String secondaryKey() { * Set the secondaryKey value. * * @param secondaryKey the secondaryKey value to set - * @return the RedisListKeysResultInner object itself. + * @return the RedisAccessKeysInner object itself. */ - public RedisListKeysResultInner withSecondaryKey(String secondaryKey) { + public RedisAccessKeysInner withSecondaryKey(String secondaryKey) { this.secondaryKey = secondaryKey; return this; } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisProperties.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateParametersInner.java similarity index 71% rename from azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisProperties.java rename to azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateParametersInner.java index f151cf72f1675..a14b1a910692a 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisProperties.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateParametersInner.java @@ -6,48 +6,44 @@ * Code generated by Microsoft (R) AutoRest Code Generator. */ -package com.microsoft.azure.management.redis; +package com.microsoft.azure.management.redis.implementation; import java.util.Map; +import com.microsoft.azure.management.redis.Sku; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; /** - * Properties supplied to CreateOrUpdate redis operation. + * Parameters supplied to the Create Redis operation. */ -public class RedisProperties { - /** - * RedisVersion parameter has been deprecated. As such, it is no longer - * necessary to provide this parameter and any value specified is ignored. - */ - private String redisVersion; - - /** - * What sku of redis cache to deploy. - */ - @JsonProperty(required = true) - private Sku sku; - +@JsonFlatten +public class RedisCreateParametersInner extends Resource { /** * All Redis Settings. Few possible keys: * rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value * etc. */ + @JsonProperty(value = "properties.redisConfiguration") private Map redisConfiguration; /** * If the value is true, then the non-ssl redis server port (6379) will be * enabled. */ + @JsonProperty(value = "properties.enableNonSslPort") private Boolean enableNonSslPort; /** * tenantSettings. */ + @JsonProperty(value = "properties.tenantSettings") private Map tenantSettings; /** * The number of shards to be created on a Premium Cluster Cache. */ + @JsonProperty(value = "properties.shardCount") private Integer shardCount; /** @@ -55,53 +51,21 @@ public class RedisProperties { * redis cache in. Example format: * /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1. */ + @JsonProperty(value = "properties.subnetId") private String subnetId; /** * Required when deploying a redis cache inside an existing Azure Virtual * Network. */ + @JsonProperty(value = "properties.staticIP") private String staticIP; /** - * Get the redisVersion value. - * - * @return the redisVersion value - */ - public String redisVersion() { - return this.redisVersion; - } - - /** - * Set the redisVersion value. - * - * @param redisVersion the redisVersion value to set - * @return the RedisProperties object itself. - */ - public RedisProperties withRedisVersion(String redisVersion) { - this.redisVersion = redisVersion; - return this; - } - - /** - * Get the sku value. - * - * @return the sku value - */ - public Sku sku() { - return this.sku; - } - - /** - * Set the sku value. - * - * @param sku the sku value to set - * @return the RedisProperties object itself. + * What sku of redis cache to deploy. */ - public RedisProperties withSku(Sku sku) { - this.sku = sku; - return this; - } + @JsonProperty(value = "properties.sku", required = true) + private Sku sku; /** * Get the redisConfiguration value. @@ -116,9 +80,9 @@ public Map redisConfiguration() { * Set the redisConfiguration value. * * @param redisConfiguration the redisConfiguration value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withRedisConfiguration(Map redisConfiguration) { + public RedisCreateParametersInner withRedisConfiguration(Map redisConfiguration) { this.redisConfiguration = redisConfiguration; return this; } @@ -136,9 +100,9 @@ public Boolean enableNonSslPort() { * Set the enableNonSslPort value. * * @param enableNonSslPort the enableNonSslPort value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withEnableNonSslPort(Boolean enableNonSslPort) { + public RedisCreateParametersInner withEnableNonSslPort(Boolean enableNonSslPort) { this.enableNonSslPort = enableNonSslPort; return this; } @@ -156,9 +120,9 @@ public Map tenantSettings() { * Set the tenantSettings value. * * @param tenantSettings the tenantSettings value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withTenantSettings(Map tenantSettings) { + public RedisCreateParametersInner withTenantSettings(Map tenantSettings) { this.tenantSettings = tenantSettings; return this; } @@ -176,9 +140,9 @@ public Integer shardCount() { * Set the shardCount value. * * @param shardCount the shardCount value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withShardCount(Integer shardCount) { + public RedisCreateParametersInner withShardCount(Integer shardCount) { this.shardCount = shardCount; return this; } @@ -196,9 +160,9 @@ public String subnetId() { * Set the subnetId value. * * @param subnetId the subnetId value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withSubnetId(String subnetId) { + public RedisCreateParametersInner withSubnetId(String subnetId) { this.subnetId = subnetId; return this; } @@ -216,11 +180,31 @@ public String staticIP() { * Set the staticIP value. * * @param staticIP the staticIP value to set - * @return the RedisProperties object itself. + * @return the RedisCreateParametersInner object itself. */ - public RedisProperties withStaticIP(String staticIP) { + public RedisCreateParametersInner withStaticIP(String staticIP) { this.staticIP = staticIP; return this; } + /** + * Get the sku value. + * + * @return the sku value + */ + public Sku sku() { + return this.sku; + } + + /** + * Set the sku value. + * + * @param sku the sku value to set + * @return the RedisCreateParametersInner object itself. + */ + public RedisCreateParametersInner withSku(Sku sku) { + this.sku = sku; + return this; + } + } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java index e55d69c5f485b..4eb5289e465bb 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java @@ -30,6 +30,7 @@ import retrofit2.http.Header; import retrofit2.http.Headers; import retrofit2.http.HTTP; +import retrofit2.http.PATCH; import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; @@ -66,12 +67,28 @@ public RedisInner(Retrofit retrofit, RedisManagementClientImpl client) { interface RedisService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") - Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisCreateOrUpdateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisCreateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") + Observable> beginCreate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisCreateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisUpdateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") + Observable> beginUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisUpdateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", method = "DELETE", hasBody = true) Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", method = "DELETE", hasBody = true) + Observable> beginDelete(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers("Content-Type: application/json; charset=utf-8") @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @@ -98,19 +115,19 @@ interface RedisService { @Headers("Content-Type: application/json; charset=utf-8") @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/import") - Observable> importMethod(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> importData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/import") - Observable> beginImport(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> beginImportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/export") - Observable> export(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> exportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/export") - Observable> beginExport(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> beginExportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("{nextLink}") @@ -123,56 +140,216 @@ interface RedisService { } /** - * Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache. + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the RedisResourceInner object if successful. + */ + public RedisResourceInner create(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + return createWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the observable for the request + */ + public Observable createAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + return createWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisResourceInner>() { + @Override + public RedisResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the observable for the request + */ + public Observable> createWithServiceResponseAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + Observable> observable = service.create(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the RedisResourceInner object if successful. + */ + public RedisResourceInner beginCreate(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginCreateAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the observable to the RedisResourceInner object + */ + public Observable beginCreateAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisResourceInner>() { + @Override + public RedisResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or replace (overwrite/recreate, with potential downtime) an existing redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Create redis operation. + * @return the observable to the RedisResourceInner object + */ + public Observable> beginCreateWithServiceResponseAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginCreate(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginCreateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginCreateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(201, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param parameters Parameters supplied to the CreateOrUpdate redis operation. - * @return the RedisResourceWithAccessKeyInner object if successful. + * @param parameters Parameters supplied to the Update redis operation. + * @return the RedisResourceInner object if successful. */ - public RedisResourceWithAccessKeyInner createOrUpdate(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters) { - return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); + public RedisResourceInner update(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } /** - * Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache. + * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param parameters Parameters supplied to the CreateOrUpdate redis operation. + * @param parameters Parameters supplied to the Update redis operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall createOrUpdateAsync(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + public ServiceCall updateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** - * Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache. + * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param parameters Parameters supplied to the CreateOrUpdate redis operation. - * @return the observable to the RedisResourceWithAccessKeyInner object + * @param parameters Parameters supplied to the Update redis operation. + * @return the observable for the request */ - public Observable createOrUpdateAsync(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters) { - return createOrUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisResourceWithAccessKeyInner>() { + public Observable updateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisResourceInner>() { @Override - public RedisResourceWithAccessKeyInner call(ServiceResponse response) { + public RedisResourceInner call(ServiceResponse response) { return response.getBody(); } }); } /** - * Create a redis cache, or replace (overwrite/recreate, with potential downtime) an existing cache. + * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @param parameters Parameters supplied to the CreateOrUpdate redis operation. - * @return the observable to the RedisResourceWithAccessKeyInner object + * @param parameters Parameters supplied to the Update redis operation. + * @return the observable for the request */ - public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String name, RedisCreateOrUpdateParametersInner parameters) { + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -189,12 +366,83 @@ public Observable> createOrUpda throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - return service.createOrUpdate(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + Observable> observable = service.update(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Update an existing Redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Update redis operation. + * @return the RedisResourceInner object if successful. + */ + public RedisResourceInner beginUpdate(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { + return beginUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); + } + + /** + * Update an existing Redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Update redis operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginUpdateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginUpdateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + } + + /** + * Update an existing Redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Update redis operation. + * @return the observable to the RedisResourceInner object + */ + public Observable beginUpdateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { + return beginUpdateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, RedisResourceInner>() { + @Override + public RedisResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Update an existing Redis cache. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param parameters Parameters supplied to the Update redis operation. + * @return the observable to the RedisResourceInner object + */ + public Observable> beginUpdateWithServiceResponseAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginUpdate(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = createOrUpdateDelegate(response); + ServiceResponse clientResponse = beginUpdateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -203,10 +451,9 @@ public Observable> call(Respons }); } - private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(201, new TypeToken() { }.getType()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse beginUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -218,7 +465,7 @@ private ServiceResponse createOrUpdateDelegate( * @param name The name of the redis cache. */ public void delete(String resourceGroupName, String name) { - deleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); + deleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().last().getBody(); } /** @@ -238,7 +485,7 @@ public ServiceCall deleteAsync(String resourceGroupName, String name, fina * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the {@link ServiceResponse} object if successful. + * @return the observable for the request */ public Observable deleteAsync(String resourceGroupName, String name) { return deleteWithServiceResponseAsync(resourceGroupName, name).map(new Func1, Void>() { @@ -254,7 +501,7 @@ public Void call(ServiceResponse response) { * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the {@link ServiceResponse} object if successful. + * @return the observable for the request */ public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { @@ -269,12 +516,74 @@ public Observable> deleteWithServiceResponseAsync(String r if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - return service.delete(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + Observable> observable = service.delete(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Deletes a redis cache. This operation takes a while to complete. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + */ + public void beginDelete(String resourceGroupName, String name) { + beginDeleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().getBody(); + } + + /** + * Deletes a redis cache. This operation takes a while to complete. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginDeleteAsync(String resourceGroupName, String name, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginDeleteWithServiceResponseAsync(resourceGroupName, name), serviceCallback); + } + + /** + * Deletes a redis cache. This operation takes a while to complete. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable beginDeleteAsync(String resourceGroupName, String name) { + return beginDeleteWithServiceResponseAsync(resourceGroupName, name).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a redis cache. This operation takes a while to complete. + * + * @param resourceGroupName The name of the resource group. + * @param name The name of the redis cache. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> beginDeleteWithServiceResponseAsync(String resourceGroupName, String name) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (name == null) { + throw new IllegalArgumentException("Parameter name is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.beginDelete(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = deleteDelegate(response); + ServiceResponse clientResponse = beginDeleteDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -283,7 +592,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginDeleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(200, new TypeToken() { }.getType()) .register(204, new TypeToken() { }.getType()) @@ -583,9 +892,9 @@ private ServiceResponse> listDelegate(Response listKeysAsync(String resourceGroupName, String name, final ServiceCallback serviceCallback) { + public ServiceCall listKeysAsync(String resourceGroupName, String name, final ServiceCallback serviceCallback) { return ServiceCall.create(listKeysWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } @@ -606,12 +915,12 @@ public ServiceCall listKeysAsync(String resourceGroupN * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the observable to the RedisListKeysResultInner object + * @return the observable to the RedisAccessKeysInner object */ - public Observable listKeysAsync(String resourceGroupName, String name) { - return listKeysWithServiceResponseAsync(resourceGroupName, name).map(new Func1, RedisListKeysResultInner>() { + public Observable listKeysAsync(String resourceGroupName, String name) { + return listKeysWithServiceResponseAsync(resourceGroupName, name).map(new Func1, RedisAccessKeysInner>() { @Override - public RedisListKeysResultInner call(ServiceResponse response) { + public RedisAccessKeysInner call(ServiceResponse response) { return response.getBody(); } }); @@ -622,9 +931,9 @@ public RedisListKeysResultInner call(ServiceResponse r * * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. - * @return the observable to the RedisListKeysResultInner object + * @return the observable to the RedisAccessKeysInner object */ - public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String name) { + public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -638,11 +947,11 @@ public Observable> listKeysWithService throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } return service.listKeys(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = listKeysDelegate(response); + ServiceResponse clientResponse = listKeysDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -651,9 +960,9 @@ public Observable> call(Response listKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse listKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -664,9 +973,9 @@ private ServiceResponse listKeysDelegate(Response regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType, final ServiceCallback serviceCallback) { + public ServiceCall regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType, final ServiceCallback serviceCallback) { return ServiceCall.create(regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType), serviceCallback); } @@ -689,12 +998,12 @@ public ServiceCall regenerateKeyAsync(String resourceG * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param keyType Which redis access key to reset. Possible values include: 'Primary', 'Secondary' - * @return the observable to the RedisListKeysResultInner object + * @return the observable to the RedisAccessKeysInner object */ - public Observable regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType).map(new Func1, RedisListKeysResultInner>() { + public Observable regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType) { + return regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType).map(new Func1, RedisAccessKeysInner>() { @Override - public RedisListKeysResultInner call(ServiceResponse response) { + public RedisAccessKeysInner call(ServiceResponse response) { return response.getBody(); } }); @@ -706,9 +1015,9 @@ public RedisListKeysResultInner call(ServiceResponse r * @param resourceGroupName The name of the resource group. * @param name The name of the redis cache. * @param keyType Which redis access key to reset. Possible values include: 'Primary', 'Secondary' - * @return the observable to the RedisListKeysResultInner object + * @return the observable to the RedisAccessKeysInner object */ - public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String name, RedisKeyType keyType) { + public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String name, RedisKeyType keyType) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -727,11 +1036,11 @@ public Observable> regenerateKeyWithSe RedisRegenerateKeyParameters parameters = new RedisRegenerateKeyParameters(); parameters.withKeyType(keyType); return service.regenerateKey(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = regenerateKeyDelegate(response); + ServiceResponse clientResponse = regenerateKeyDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -740,9 +1049,9 @@ public Observable> call(Response regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -841,8 +1150,8 @@ private ServiceResponse forceRebootDelegate(Response respons * @param name The name of the redis cache. * @param parameters Parameters for redis import operation. */ - public void importMethod(String resourceGroupName, String name, ImportRDBParametersInner parameters) { - importMethodWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); + public void importData(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + importDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } /** @@ -854,8 +1163,8 @@ public void importMethod(String resourceGroupName, String name, ImportRDBParamet * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall importMethodAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(importMethodWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + public ServiceCall importDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(importDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** @@ -866,8 +1175,8 @@ public ServiceCall importMethodAsync(String resourceGroupName, String name * @param parameters Parameters for redis import operation. * @return the observable for the request */ - public Observable importMethodAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { - return importMethodWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { + public Observable importDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + return importDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -883,7 +1192,7 @@ public Void call(ServiceResponse response) { * @param parameters Parameters for redis import operation. * @return the observable for the request */ - public Observable> importMethodWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + public Observable> importDataWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -900,7 +1209,7 @@ public Observable> importMethodWithServiceResponseAsync(St throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - Observable> observable = service.importMethod(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + Observable> observable = service.importData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); } @@ -911,8 +1220,8 @@ public Observable> importMethodWithServiceResponseAsync(St * @param name The name of the redis cache. * @param parameters Parameters for redis import operation. */ - public void beginImport(String resourceGroupName, String name, ImportRDBParametersInner parameters) { - beginImportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); + public void beginImportData(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } /** @@ -924,8 +1233,8 @@ public void beginImport(String resourceGroupName, String name, ImportRDBParamete * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall beginImportAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(beginImportWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + public ServiceCall beginImportDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** @@ -936,8 +1245,8 @@ public ServiceCall beginImportAsync(String resourceGroupName, String name, * @param parameters Parameters for redis import operation. * @return the {@link ServiceResponse} object if successful. */ - public Observable beginImportAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { - return beginImportWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { + public Observable beginImportDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + return beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -953,7 +1262,7 @@ public Void call(ServiceResponse response) { * @param parameters Parameters for redis import operation. * @return the {@link ServiceResponse} object if successful. */ - public Observable> beginImportWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { + public Observable> beginImportDataWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -970,12 +1279,12 @@ public Observable> beginImportWithServiceResponseAsync(Str throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - return service.beginImport(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.beginImportData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = beginImportDelegate(response); + ServiceResponse clientResponse = beginImportDataDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -984,7 +1293,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse beginImportDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginImportDataDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(202, new TypeToken() { }.getType()) .build(response); @@ -997,8 +1306,8 @@ private ServiceResponse beginImportDelegate(Response respons * @param name The name of the redis cache. * @param parameters Parameters for redis export operation. */ - public void export(String resourceGroupName, String name, ExportRDBParametersInner parameters) { - exportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); + public void exportData(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().getBody(); } /** @@ -1010,8 +1319,8 @@ public void export(String resourceGroupName, String name, ExportRDBParametersInn * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall exportAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(exportWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + public ServiceCall exportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(exportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** @@ -1022,8 +1331,8 @@ public ServiceCall exportAsync(String resourceGroupName, String name, Expo * @param parameters Parameters for redis export operation. * @return the observable for the request */ - public Observable exportAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { - return exportWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { + public Observable exportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + return exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -1039,7 +1348,7 @@ public Void call(ServiceResponse response) { * @param parameters Parameters for redis export operation. * @return the observable for the request */ - public Observable> exportWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + public Observable> exportDataWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -1056,7 +1365,7 @@ public Observable> exportWithServiceResponseAsync(String r throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - Observable> observable = service.export(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + Observable> observable = service.exportData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); } @@ -1067,8 +1376,8 @@ public Observable> exportWithServiceResponseAsync(String r * @param name The name of the redis cache. * @param parameters Parameters for redis export operation. */ - public void beginExport(String resourceGroupName, String name, ExportRDBParametersInner parameters) { - beginExportWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); + public void beginExportData(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().getBody(); } /** @@ -1080,8 +1389,8 @@ public void beginExport(String resourceGroupName, String name, ExportRDBParamete * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall beginExportAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(beginExportWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); + public ServiceCall beginExportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** @@ -1092,8 +1401,8 @@ public ServiceCall beginExportAsync(String resourceGroupName, String name, * @param parameters Parameters for redis export operation. * @return the {@link ServiceResponse} object if successful. */ - public Observable beginExportAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { - return beginExportWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { + public Observable beginExportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + return beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -1109,7 +1418,7 @@ public Void call(ServiceResponse response) { * @param parameters Parameters for redis export operation. * @return the {@link ServiceResponse} object if successful. */ - public Observable> beginExportWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { + public Observable> beginExportDataWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -1126,12 +1435,12 @@ public Observable> beginExportWithServiceResponseAsync(Str throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - return service.beginExport(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.beginExportData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = beginExportDelegate(response); + ServiceResponse clientResponse = beginExportDataDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -1140,7 +1449,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse beginExportDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginExportDataDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(202, new TypeToken() { }.getType()) .build(response); diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchSchedulesResponseInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchScheduleInner.java similarity index 75% rename from azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchSchedulesResponseInner.java rename to azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchScheduleInner.java index 64bca8dc2c2dd..271369acdf062 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchSchedulesResponseInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisPatchScheduleInner.java @@ -9,6 +9,7 @@ package com.microsoft.azure.management.redis.implementation; import java.util.List; +import com.microsoft.azure.management.redis.ScheduleEntry; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; @@ -16,7 +17,7 @@ * Response to put/get patch schedules for redis cache. */ @JsonFlatten -public class RedisPatchSchedulesResponseInner { +public class RedisPatchScheduleInner { /** * Resource Id. */ @@ -38,13 +39,14 @@ public class RedisPatchSchedulesResponseInner { /** * Resource location. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String location; /** * List of patch schedules for redis cache. */ @JsonProperty(value = "properties.scheduleEntries", required = true) - private List scheduleEntries; + private List scheduleEntries; /** * Get the id value. @@ -82,23 +84,12 @@ public String location() { return this.location; } - /** - * Set the location value. - * - * @param location the location value to set - * @return the RedisPatchSchedulesResponseInner object itself. - */ - public RedisPatchSchedulesResponseInner withLocation(String location) { - this.location = location; - return this; - } - /** * Get the scheduleEntries value. * * @return the scheduleEntries value */ - public List scheduleEntries() { + public List scheduleEntries() { return this.scheduleEntries; } @@ -106,9 +97,9 @@ public List scheduleEntries() { * Set the scheduleEntries value. * * @param scheduleEntries the scheduleEntries value to set - * @return the RedisPatchSchedulesResponseInner object itself. + * @return the RedisPatchScheduleInner object itself. */ - public RedisPatchSchedulesResponseInner withScheduleEntries(List scheduleEntries) { + public RedisPatchScheduleInner withScheduleEntries(List scheduleEntries) { this.scheduleEntries = scheduleEntries; return this; } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceInner.java index cc52f50e2b5bb..f987470e1af0b 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceInner.java @@ -8,8 +8,8 @@ package com.microsoft.azure.management.redis.implementation; -import com.microsoft.azure.management.redis.Sku; import java.util.Map; +import com.microsoft.azure.management.redis.Sku; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; import com.microsoft.azure.Resource; @@ -20,17 +20,34 @@ @JsonFlatten public class RedisResourceInner extends Resource { /** - * RedisVersion parameter has been deprecated. As such, it is no longer - * necessary to provide this parameter and any value specified is ignored. + * Redis Version. */ - @JsonProperty(value = "properties.redisVersion") + @JsonProperty(value = "properties.redisVersion", access = JsonProperty.Access.WRITE_ONLY) private String redisVersion; /** - * What sku of redis cache to deploy. + * Redis instance provisioning status. */ - @JsonProperty(value = "properties.sku", required = true) - private Sku sku; + @JsonProperty(value = "properties.provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private String provisioningState; + + /** + * Redis host name. + */ + @JsonProperty(value = "properties.hostName", access = JsonProperty.Access.WRITE_ONLY) + private String hostName; + + /** + * Redis non-ssl port. + */ + @JsonProperty(value = "properties.port", access = JsonProperty.Access.WRITE_ONLY) + private Integer port; + + /** + * Redis ssl port. + */ + @JsonProperty(value = "properties.sslPort", access = JsonProperty.Access.WRITE_ONLY) + private Integer sslPort; /** * All Redis Settings. Few possible keys: @@ -75,28 +92,10 @@ public class RedisResourceInner extends Resource { private String staticIP; /** - * Redis instance provisioning status. - */ - @JsonProperty(value = "properties.provisioningState") - private String provisioningState; - - /** - * Redis host name. - */ - @JsonProperty(value = "properties.hostName") - private String hostName; - - /** - * Redis non-ssl port. - */ - @JsonProperty(value = "properties.port") - private Integer port; - - /** - * Redis ssl port. + * What sku of redis cache to deploy. */ - @JsonProperty(value = "properties.sslPort") - private Integer sslPort; + @JsonProperty(value = "properties.sku", required = true) + private Sku sku; /** * Get the redisVersion value. @@ -108,34 +107,39 @@ public String redisVersion() { } /** - * Set the redisVersion value. + * Get the provisioningState value. * - * @param redisVersion the redisVersion value to set - * @return the RedisResourceInner object itself. + * @return the provisioningState value */ - public RedisResourceInner withRedisVersion(String redisVersion) { - this.redisVersion = redisVersion; - return this; + public String provisioningState() { + return this.provisioningState; } /** - * Get the sku value. + * Get the hostName value. * - * @return the sku value + * @return the hostName value */ - public Sku sku() { - return this.sku; + public String hostName() { + return this.hostName; } /** - * Set the sku value. + * Get the port value. * - * @param sku the sku value to set - * @return the RedisResourceInner object itself. + * @return the port value */ - public RedisResourceInner withSku(Sku sku) { - this.sku = sku; - return this; + public Integer port() { + return this.port; + } + + /** + * Get the sslPort value. + * + * @return the sslPort value + */ + public Integer sslPort() { + return this.sslPort; } /** @@ -259,82 +263,22 @@ public RedisResourceInner withStaticIP(String staticIP) { } /** - * Get the provisioningState value. - * - * @return the provisioningState value - */ - public String provisioningState() { - return this.provisioningState; - } - - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the RedisResourceInner object itself. - */ - public RedisResourceInner withProvisioningState(String provisioningState) { - this.provisioningState = provisioningState; - return this; - } - - /** - * Get the hostName value. - * - * @return the hostName value - */ - public String hostName() { - return this.hostName; - } - - /** - * Set the hostName value. - * - * @param hostName the hostName value to set - * @return the RedisResourceInner object itself. - */ - public RedisResourceInner withHostName(String hostName) { - this.hostName = hostName; - return this; - } - - /** - * Get the port value. - * - * @return the port value - */ - public Integer port() { - return this.port; - } - - /** - * Set the port value. - * - * @param port the port value to set - * @return the RedisResourceInner object itself. - */ - public RedisResourceInner withPort(Integer port) { - this.port = port; - return this; - } - - /** - * Get the sslPort value. + * Get the sku value. * - * @return the sslPort value + * @return the sku value */ - public Integer sslPort() { - return this.sslPort; + public Sku sku() { + return this.sku; } /** - * Set the sslPort value. + * Set the sku value. * - * @param sslPort the sslPort value to set + * @param sku the sku value to set * @return the RedisResourceInner object itself. */ - public RedisResourceInner withSslPort(Integer sslPort) { - this.sslPort = sslPort; + public RedisResourceInner withSku(Sku sku) { + this.sku = sku; return this; } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceWithAccessKeyInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceWithAccessKeyInner.java deleted file mode 100644 index cb4722befac30..0000000000000 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisResourceWithAccessKeyInner.java +++ /dev/null @@ -1,368 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.redis.implementation; - -import com.microsoft.azure.management.redis.Sku; -import java.util.Map; -import com.microsoft.azure.management.redis.RedisAccessKeys; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.rest.serializer.JsonFlatten; -import com.microsoft.azure.Resource; - -/** - * A redis item in CreateOrUpdate Operation response. - */ -@JsonFlatten -public class RedisResourceWithAccessKeyInner extends Resource { - /** - * RedisVersion parameter has been deprecated. As such, it is no longer - * necessary to provide this parameter and any value specified is ignored. - */ - @JsonProperty(value = "properties.redisVersion") - private String redisVersion; - - /** - * What sku of redis cache to deploy. - */ - @JsonProperty(value = "properties.sku", required = true) - private Sku sku; - - /** - * All Redis Settings. Few possible keys: - * rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value - * etc. - */ - @JsonProperty(value = "properties.redisConfiguration") - private Map redisConfiguration; - - /** - * If the value is true, then the non-ssl redis server port (6379) will be - * enabled. - */ - @JsonProperty(value = "properties.enableNonSslPort") - private Boolean enableNonSslPort; - - /** - * tenantSettings. - */ - @JsonProperty(value = "properties.tenantSettings") - private Map tenantSettings; - - /** - * The number of shards to be created on a Premium Cluster Cache. - */ - @JsonProperty(value = "properties.shardCount") - private Integer shardCount; - - /** - * The full resource ID of a subnet in a virtual network to deploy the - * redis cache in. Example format: - * /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1. - */ - @JsonProperty(value = "properties.subnetId") - private String subnetId; - - /** - * Required when deploying a redis cache inside an existing Azure Virtual - * Network. - */ - @JsonProperty(value = "properties.staticIP") - private String staticIP; - - /** - * Redis instance provisioning status. - */ - @JsonProperty(value = "properties.provisioningState") - private String provisioningState; - - /** - * Redis host name. - */ - @JsonProperty(value = "properties.hostName") - private String hostName; - - /** - * Redis non-ssl port. - */ - @JsonProperty(value = "properties.port") - private Integer port; - - /** - * Redis ssl port. - */ - @JsonProperty(value = "properties.sslPort") - private Integer sslPort; - - /** - * Redis cache access keys. - */ - @JsonProperty(value = "properties.accessKeys") - private RedisAccessKeys accessKeys; - - /** - * Get the redisVersion value. - * - * @return the redisVersion value - */ - public String redisVersion() { - return this.redisVersion; - } - - /** - * Set the redisVersion value. - * - * @param redisVersion the redisVersion value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withRedisVersion(String redisVersion) { - this.redisVersion = redisVersion; - return this; - } - - /** - * Get the sku value. - * - * @return the sku value - */ - public Sku sku() { - return this.sku; - } - - /** - * Set the sku value. - * - * @param sku the sku value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withSku(Sku sku) { - this.sku = sku; - return this; - } - - /** - * Get the redisConfiguration value. - * - * @return the redisConfiguration value - */ - public Map redisConfiguration() { - return this.redisConfiguration; - } - - /** - * Set the redisConfiguration value. - * - * @param redisConfiguration the redisConfiguration value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withRedisConfiguration(Map redisConfiguration) { - this.redisConfiguration = redisConfiguration; - return this; - } - - /** - * Get the enableNonSslPort value. - * - * @return the enableNonSslPort value - */ - public Boolean enableNonSslPort() { - return this.enableNonSslPort; - } - - /** - * Set the enableNonSslPort value. - * - * @param enableNonSslPort the enableNonSslPort value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withEnableNonSslPort(Boolean enableNonSslPort) { - this.enableNonSslPort = enableNonSslPort; - return this; - } - - /** - * Get the tenantSettings value. - * - * @return the tenantSettings value - */ - public Map tenantSettings() { - return this.tenantSettings; - } - - /** - * Set the tenantSettings value. - * - * @param tenantSettings the tenantSettings value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withTenantSettings(Map tenantSettings) { - this.tenantSettings = tenantSettings; - return this; - } - - /** - * Get the shardCount value. - * - * @return the shardCount value - */ - public Integer shardCount() { - return this.shardCount; - } - - /** - * Set the shardCount value. - * - * @param shardCount the shardCount value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withShardCount(Integer shardCount) { - this.shardCount = shardCount; - return this; - } - - /** - * Get the subnetId value. - * - * @return the subnetId value - */ - public String subnetId() { - return this.subnetId; - } - - /** - * Set the subnetId value. - * - * @param subnetId the subnetId value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withSubnetId(String subnetId) { - this.subnetId = subnetId; - return this; - } - - /** - * Get the staticIP value. - * - * @return the staticIP value - */ - public String staticIP() { - return this.staticIP; - } - - /** - * Set the staticIP value. - * - * @param staticIP the staticIP value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withStaticIP(String staticIP) { - this.staticIP = staticIP; - return this; - } - - /** - * Get the provisioningState value. - * - * @return the provisioningState value - */ - public String provisioningState() { - return this.provisioningState; - } - - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withProvisioningState(String provisioningState) { - this.provisioningState = provisioningState; - return this; - } - - /** - * Get the hostName value. - * - * @return the hostName value - */ - public String hostName() { - return this.hostName; - } - - /** - * Set the hostName value. - * - * @param hostName the hostName value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withHostName(String hostName) { - this.hostName = hostName; - return this; - } - - /** - * Get the port value. - * - * @return the port value - */ - public Integer port() { - return this.port; - } - - /** - * Set the port value. - * - * @param port the port value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withPort(Integer port) { - this.port = port; - return this; - } - - /** - * Get the sslPort value. - * - * @return the sslPort value - */ - public Integer sslPort() { - return this.sslPort; - } - - /** - * Set the sslPort value. - * - * @param sslPort the sslPort value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withSslPort(Integer sslPort) { - this.sslPort = sslPort; - return this; - } - - /** - * Get the accessKeys value. - * - * @return the accessKeys value - */ - public RedisAccessKeys accessKeys() { - return this.accessKeys; - } - - /** - * Set the accessKeys value. - * - * @param accessKeys the accessKeys value to set - * @return the RedisResourceWithAccessKeyInner object itself. - */ - public RedisResourceWithAccessKeyInner withAccessKeys(RedisAccessKeys accessKeys) { - this.accessKeys = accessKeys; - return this; - } - -} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateOrUpdateParametersInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisUpdateParametersInner.java similarity index 68% rename from azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateOrUpdateParametersInner.java rename to azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisUpdateParametersInner.java index a014a5b67b5e7..2c01bebc8eeaa 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCreateOrUpdateParametersInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisUpdateParametersInner.java @@ -8,30 +8,16 @@ package com.microsoft.azure.management.redis.implementation; -import com.microsoft.azure.management.redis.Sku; import java.util.Map; +import com.microsoft.azure.management.redis.Sku; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; -import com.microsoft.azure.Resource; /** - * Parameters supplied to the CreateOrUpdate Redis operation. + * Parameters supplied to the Update Redis operation. */ @JsonFlatten -public class RedisCreateOrUpdateParametersInner extends Resource { - /** - * RedisVersion parameter has been deprecated. As such, it is no longer - * necessary to provide this parameter and any value specified is ignored. - */ - @JsonProperty(value = "properties.redisVersion") - private String redisVersion; - - /** - * What sku of redis cache to deploy. - */ - @JsonProperty(value = "properties.sku", required = true) - private Sku sku; - +public class RedisUpdateParametersInner { /** * All Redis Settings. Few possible keys: * rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta,maxmemory-policy,notify-keyspace-events,maxmemory-samples,slowlog-log-slower-than,slowlog-max-len,list-max-ziplist-entries,list-max-ziplist-value,hash-max-ziplist-entries,hash-max-ziplist-value,set-max-intset-entries,zset-max-ziplist-entries,zset-max-ziplist-value @@ -75,44 +61,22 @@ public class RedisCreateOrUpdateParametersInner extends Resource { private String staticIP; /** - * Get the redisVersion value. - * - * @return the redisVersion value - */ - public String redisVersion() { - return this.redisVersion; - } - - /** - * Set the redisVersion value. - * - * @param redisVersion the redisVersion value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * What sku of redis cache to deploy. */ - public RedisCreateOrUpdateParametersInner withRedisVersion(String redisVersion) { - this.redisVersion = redisVersion; - return this; - } + @JsonProperty(value = "properties.sku") + private Sku sku; /** - * Get the sku value. - * - * @return the sku value + * Resource location. */ - public Sku sku() { - return this.sku; - } + @JsonProperty(value = "properties.location") + private String location; /** - * Set the sku value. - * - * @param sku the sku value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * Resource tags. */ - public RedisCreateOrUpdateParametersInner withSku(Sku sku) { - this.sku = sku; - return this; - } + @JsonProperty(value = "properties.tags") + private Map tags; /** * Get the redisConfiguration value. @@ -127,9 +91,9 @@ public Map redisConfiguration() { * Set the redisConfiguration value. * * @param redisConfiguration the redisConfiguration value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withRedisConfiguration(Map redisConfiguration) { + public RedisUpdateParametersInner withRedisConfiguration(Map redisConfiguration) { this.redisConfiguration = redisConfiguration; return this; } @@ -147,9 +111,9 @@ public Boolean enableNonSslPort() { * Set the enableNonSslPort value. * * @param enableNonSslPort the enableNonSslPort value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withEnableNonSslPort(Boolean enableNonSslPort) { + public RedisUpdateParametersInner withEnableNonSslPort(Boolean enableNonSslPort) { this.enableNonSslPort = enableNonSslPort; return this; } @@ -167,9 +131,9 @@ public Map tenantSettings() { * Set the tenantSettings value. * * @param tenantSettings the tenantSettings value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withTenantSettings(Map tenantSettings) { + public RedisUpdateParametersInner withTenantSettings(Map tenantSettings) { this.tenantSettings = tenantSettings; return this; } @@ -187,9 +151,9 @@ public Integer shardCount() { * Set the shardCount value. * * @param shardCount the shardCount value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withShardCount(Integer shardCount) { + public RedisUpdateParametersInner withShardCount(Integer shardCount) { this.shardCount = shardCount; return this; } @@ -207,9 +171,9 @@ public String subnetId() { * Set the subnetId value. * * @param subnetId the subnetId value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withSubnetId(String subnetId) { + public RedisUpdateParametersInner withSubnetId(String subnetId) { this.subnetId = subnetId; return this; } @@ -227,11 +191,71 @@ public String staticIP() { * Set the staticIP value. * * @param staticIP the staticIP value to set - * @return the RedisCreateOrUpdateParametersInner object itself. + * @return the RedisUpdateParametersInner object itself. */ - public RedisCreateOrUpdateParametersInner withStaticIP(String staticIP) { + public RedisUpdateParametersInner withStaticIP(String staticIP) { this.staticIP = staticIP; return this; } + /** + * Get the sku value. + * + * @return the sku value + */ + public Sku sku() { + return this.sku; + } + + /** + * Set the sku value. + * + * @param sku the sku value to set + * @return the RedisUpdateParametersInner object itself. + */ + public RedisUpdateParametersInner withSku(Sku sku) { + this.sku = sku; + return this; + } + + /** + * Get the location value. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Set the location value. + * + * @param location the location value to set + * @return the RedisUpdateParametersInner object itself. + */ + public RedisUpdateParametersInner withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the RedisUpdateParametersInner object itself. + */ + public RedisUpdateParametersInner withTags(Map tags) { + this.tags = tags; + return this; + } + } From 465d6a1061eb851959bf8cad173a759d2c8fb565 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 18:10:44 -0700 Subject: [PATCH 43/47] renaming `NicIpConfiguration#publicIpAddress()` as `getPublicIpAddress()` because this is a separate method call to Azure, not a property of the NIC IP config. --- .../azure/management/network/NicIpConfiguration.java | 6 +----- .../network/implementation/NetworkInterfaceImpl.java | 2 +- .../network/implementation/NicIpConfigurationImpl.java | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java index 6b3d44b9e9876..e4c640fc64b55 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java @@ -27,13 +27,9 @@ public interface NicIpConfiguration extends String publicIpAddressId(); /** - * Gets the public IP address associated with this IP configuration. - *

- * This method makes a rest API call to fetch the public IP. - * * @return the public IP associated with this IP configuration or null if there is no public IP associated */ - PublicIpAddress publicIpAddress(); + PublicIpAddress getPublicIpAddress(); /** * @return the resource id of the virtual network subnet associated with this IP configuration. diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index 00b63b273f1b6..703c1dc91f32e 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -287,7 +287,7 @@ public List dnsServers() { @Override public PublicIpAddress primaryPublicIpAddress() { if (this.primaryPublicIp == null) { - this.primaryPublicIp = this.primaryIpConfiguration().publicIpAddress(); + this.primaryPublicIp = this.primaryIpConfiguration().getPublicIpAddress(); } return primaryPublicIp; } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java index 8f9b825122352..647c3b94e0829 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java @@ -90,14 +90,13 @@ public String publicIpAddressId() { } @Override - public PublicIpAddress publicIpAddress() { + public PublicIpAddress getPublicIpAddress() { String id = publicIpAddressId(); if (id == null) { return null; } - return this.networkManager.publicIpAddresses().getByGroup( - ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + return this.networkManager.publicIpAddresses().getById(id); } @Override From 1e3c84bba85b2df1815cfedc7e35a16a649a1e14 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 18:56:29 -0700 Subject: [PATCH 44/47] support for privateIpAddressVersion() on NIC IP configuration (new Networking feature) --- .../network/NicIpConfiguration.java | 23 +++++++++++++++++++ .../NicIpConfigurationImpl.java | 12 ++++++++++ .../microsoft/azure/TestNetworkInterface.java | 3 ++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java index e4c640fc64b55..8bb51cca2570b 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java @@ -45,6 +45,11 @@ public interface NicIpConfiguration extends */ Network network(); + /** + * @return private IP address version + */ + IPVersion privateIpAddressVersion(); + // Setters (fluent) /** @@ -130,6 +135,12 @@ interface WithNetwork { * @param the return type of the final {@link Attachable#attach()} */ interface WithPrivateIp extends HasPrivateIpAddress.DefinitionStages.WithPrivateIpAddress> { + /** + * Specifies the IP version for the private IP address. + * @param ipVersion an IP version + * @return the next stage of the definition + */ + WithAttach withPrivateIpVersion(IPVersion ipVersion); } /** @@ -290,6 +301,12 @@ interface WithNetwork { * @param the return type of the final {@link Attachable#attach()} */ interface WithPrivateIp extends HasPrivateIpAddress.UpdateDefinitionStages.WithPrivateIpAddress> { + /** + * Specifies the IP version for the private IP address. + * @param ipVersion an IP version + * @return the next stage of the definition + */ + WithAttach withPrivateIpVersion(IPVersion ipVersion); } /** @@ -403,6 +420,12 @@ interface WithSubnet { * The stage of the network interface IP configuration update allowing to specify private IP. */ interface WithPrivateIp extends HasPrivateIpAddress.UpdateStages.WithPrivateIpAddress { + /** + * Specifies the IP version for the private IP address. + * @param ipVersion an IP version + * @return the next stage of the update + */ + Update withPrivateIpVersion(IPVersion ipVersion); } /** diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java index 647c3b94e0829..552cbf94cc541 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java @@ -3,6 +3,7 @@ import com.microsoft.azure.SubResource; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.network.IPAllocationMethod; +import com.microsoft.azure.management.network.IPVersion; import com.microsoft.azure.management.network.LoadBalancer; import com.microsoft.azure.management.network.Network; import com.microsoft.azure.management.network.NetworkInterface; @@ -81,6 +82,11 @@ public String name() { return inner().name(); } + @Override + public IPVersion privateIpAddressVersion() { + return this.inner().privateIPAddressVersion(); + } + @Override public String publicIpAddressId() { if (this.inner().publicIPAddress() == null) { @@ -336,4 +342,10 @@ private SubResource publicIpToAssociate() { } return null; } + + @Override + public NicIpConfigurationImpl withPrivateIpVersion(IPVersion ipVersion) { + this.inner().withPrivateIPAddressVersion(ipVersion); + return this; + } } diff --git a/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java b/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java index f289d149cb716..0ae873a569186 100644 --- a/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java +++ b/azure/src/test/java/com/microsoft/azure/TestNetworkInterface.java @@ -73,7 +73,8 @@ public void print(NetworkInterface resource) { for (NicIpConfiguration ipConfig : resource.ipConfigurations().values()) { info.append("\n\t\tName: ").append(ipConfig.name()) .append("\n\t\tPrivate IP: ").append(ipConfig.privateIpAddress()) - .append("\n\t\tPrivate IP allocation method: ").append(ipConfig.privateIpAllocationMethod()) + .append("\n\t\tPrivate IP allocation method: ").append(ipConfig.privateIpAllocationMethod().toString()) + .append("\n\t\tPrivate IP version: ").append(ipConfig.privateIpAddressVersion().toString()) .append("\n\t\tPIP id: ").append(ipConfig.publicIpAddressId()) .append("\n\t\tSubnet ID: ").append(ipConfig.subnetId()); } From f03f1bc782d7ec127192a17b0ae7784006012b04 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 19:03:28 -0700 Subject: [PATCH 45/47] renaming NicIpConfiguration#network() to getNetwork() because it's a method call to Azure, not a direct property of the NIC IP config --- .../azure/management/network/NicIpConfiguration.java | 6 +----- .../network/implementation/NetworkInterfaceImpl.java | 2 +- .../network/implementation/NicIpConfigurationImpl.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java index 8bb51cca2570b..2bc722b22f857 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NicIpConfiguration.java @@ -37,13 +37,9 @@ public interface NicIpConfiguration extends String subnetId(); /** - * Gets the virtual network associated with this IP configuration. - *

- * This method makes a rest API call to fetch the public IP. - * * @return the virtual network associated with this this IP configuration. */ - Network network(); + Network getNetwork(); /** * @return private IP address version diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java index 703c1dc91f32e..f96daad74c7c0 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfaceImpl.java @@ -300,7 +300,7 @@ public String primarySubnetId() { @Override public Network primaryNetwork() { if (this.primaryNetwork == null) { - this.primaryNetwork = this.primaryIpConfiguration().network(); + this.primaryNetwork = this.primaryIpConfiguration().getNetwork(); } return this.primaryNetwork; } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java index 552cbf94cc541..dfee7acc92326 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NicIpConfigurationImpl.java @@ -111,7 +111,7 @@ public String subnetId() { } @Override - public Network network() { + public Network getNetwork() { String id = subnetId(); return this.networkManager.networks().getByGroup(ResourceUtils.groupFromResourceId(id), ResourceUtils.extractFromResourceId(id, "virtualNetworks")); From 5d2e6ab74f25d3988af595bdce31543707facf4d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2016 20:16:11 -0700 Subject: [PATCH 46/47] support for NetworkSecurityGroup#listAssociatedSubnets() --- .../network/NetworkSecurityGroup.java | 5 ++++ .../NetworkSecurityGroupImpl.java | 27 +++++++++++++++++++ .../java/com/microsoft/azure/TestNSG.java | 27 ++++++++++++++++--- .../java/com/microsoft/azure/TestNetwork.java | 11 +++++++- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroup.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroup.java index 5f4cc42c0643c..936b9b996633d 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroup.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroup.java @@ -47,6 +47,11 @@ public interface NetworkSecurityGroup extends */ List networkInterfaceIds(); + /** + * @return virtual networks associated with this security group, + * indexed by the names of the specific subnets referencing this security group + */ + List listAssociatedSubnets(); // Fluent interfaces for creating NSGs diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java index c12a3656792de..14833e8d68c6e 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupImpl.java @@ -6,13 +6,17 @@ package com.microsoft.azure.management.network.implementation; import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.network.Network; import com.microsoft.azure.management.network.NetworkSecurityGroup; import com.microsoft.azure.management.network.NetworkSecurityRule; +import com.microsoft.azure.management.network.Subnet; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl; import rx.Observable; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -92,6 +96,29 @@ public Observable applyUpdateAsync() { return createResourceAsync(); } + @Override + public List listAssociatedSubnets() { + final List subnetRefs = this.inner().subnets(); + final Map networks = new HashMap<>(); + final List subnets = new ArrayList<>(); + + if (subnetRefs != null) { + for (SubnetInner subnetRef : subnetRefs) { + String networkId = ResourceUtils.parentResourcePathFromResourceId(subnetRef.id()); + Network network = networks.get(networkId); + if (network == null) { + network = this.myManager.networks().getById(networkId); + networks.put(networkId, network); + } + + String subnetName = ResourceUtils.nameFromResourceId(subnetRef.id()); + subnets.add(network.subnets().get(subnetName)); + } + } + + return subnets; + } + // Setters (fluent) @Override diff --git a/azure/src/test/java/com/microsoft/azure/TestNSG.java b/azure/src/test/java/com/microsoft/azure/TestNSG.java index d29c555db7846..427f53434c812 100644 --- a/azure/src/test/java/com/microsoft/azure/TestNSG.java +++ b/azure/src/test/java/com/microsoft/azure/TestNSG.java @@ -11,8 +11,12 @@ import com.microsoft.azure.management.network.NetworkSecurityGroups; import com.microsoft.azure.management.network.NetworkSecurityRule; import com.microsoft.azure.management.network.SecurityRuleProtocol; +import com.microsoft.azure.management.network.Subnet; import com.microsoft.azure.management.resources.fluentcore.arm.Region; import okhttp3.logging.HttpLoggingInterceptor; + +import java.util.List; + import org.junit.Assert; import org.junit.Test; import rx.Subscriber; @@ -102,7 +106,7 @@ public NetworkSecurityGroup updateResource(NetworkSecurityGroup resource) throws return resource; } - private StringBuilder printRule(NetworkSecurityRule rule, StringBuilder info) { + private static StringBuilder printRule(NetworkSecurityRule rule, StringBuilder info) { info.append("\n\t\tRule: ").append(rule.name()) .append("\n\t\t\tAccess: ").append(rule.access()) .append("\n\t\t\tDirection: ").append(rule.direction()) @@ -116,8 +120,7 @@ private StringBuilder printRule(NetworkSecurityRule rule, StringBuilder info) { return info; } - @Override - public void print(NetworkSecurityGroup resource) { + public static void printNSG(NetworkSecurityGroup resource) { StringBuilder info = new StringBuilder(); info.append("NSG: ").append(resource.id()) .append("Name: ").append(resource.name()) @@ -137,11 +140,29 @@ public void print(NetworkSecurityGroup resource) { info = printRule(rule, info); } + // Output associated NIC IDs info.append("\n\tNICs: ").append(resource.networkInterfaceIds()); + // Output associated subnets + info.append("\n\tAssociated subnets: "); + List subnets = resource.listAssociatedSubnets(); + if (subnets == null || subnets.size() == 0) { + info.append("(None)"); + } else { + for (Subnet subnet : subnets) { + info.append("\n\t\tNetwork ID: ").append(subnet.parent().id()) + .append("\n\t\tSubnet name: ").append(subnet.name()); + } + } + System.out.println(info.toString()); } + @Override + public void print(NetworkSecurityGroup resource) { + printNSG(resource); + } + @Test public void run() throws Exception { ApplicationTokenCredentials credentials = new ApplicationTokenCredentials( diff --git a/azure/src/test/java/com/microsoft/azure/TestNetwork.java b/azure/src/test/java/com/microsoft/azure/TestNetwork.java index 09245becc922b..d04cdbc130e10 100644 --- a/azure/src/test/java/com/microsoft/azure/TestNetwork.java +++ b/azure/src/test/java/com/microsoft/azure/TestNetwork.java @@ -5,6 +5,8 @@ */ package com.microsoft.azure; +import java.util.List; + import org.junit.Assert; import com.microsoft.azure.management.network.Network; @@ -37,7 +39,7 @@ public Network createResource(Networks networks) throws Exception { .create(); // Create a network - return networks.define(newName) + final Network network = networks.define(newName) .withRegion(region) .withNewResourceGroup(groupName) .withAddressSpace("10.0.0.0/28") @@ -47,6 +49,13 @@ public Network createResource(Networks networks) throws Exception { .withExistingNetworkSecurityGroup(nsg) .attach() .create(); + + List subnets = nsg.refresh().listAssociatedSubnets(); + Assert.assertTrue(subnets.size() == 1); + Subnet subnet = subnets.get(0); + Assert.assertTrue(subnet.name().equalsIgnoreCase("subnetB")); + Assert.assertTrue(subnet.parent().name().equalsIgnoreCase(newName)); + return network; } @Override From fe116edf73201648062d4c028e474983f30fc836 Mon Sep 17 00:00:00 2001 From: Anudeep Sharma Date: Thu, 15 Sep 2016 16:29:00 -0700 Subject: [PATCH 47/47] Added annotations for Batch --- azure-mgmt-batch/pom.xml | 23 +++++++++++++++++++ .../azure/management/batch/BatchAccount.java | 11 +++++++++ .../management/batch/BatchAccountKeys.java | 5 +++- .../azure/management/batch/BatchAccounts.java | 2 ++ .../implementation/BatchAccountImpl.java | 2 ++ .../implementation/BatchAccountsImpl.java | 2 ++ .../batch/implementation/BatchManager.java | 2 +- 7 files changed, 45 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-batch/pom.xml b/azure-mgmt-batch/pom.xml index b85dcd5018f22..0ccc35671bad4 100644 --- a/azure-mgmt-batch/pom.xml +++ b/azure-mgmt-batch/pom.xml @@ -72,6 +72,11 @@ azure-mgmt-storage 1.0.0-SNAPSHOT + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + @@ -116,6 +121,24 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java index 98e7848fdb3e8..028b6278e3d1a 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java @@ -6,6 +6,9 @@ package com.microsoft.azure.management.batch; +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.apigeneration.LangMethodDefinition; +import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType; import com.microsoft.azure.management.batch.implementation.AccountResourceInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; @@ -19,6 +22,7 @@ /** * An immutable client-side representation of an Azure batch account. */ +@LangDefinition(ContainerName = "~/") public interface BatchAccount extends GroupableResource, Refreshable, @@ -60,11 +64,13 @@ public interface BatchAccount extends /** * @return the access keys for this batch account */ + @LangMethodDefinition(AsType = LangMethodType.Method) BatchAccountKeys keys(); /** * @return the access keys for this batch account */ + @LangMethodDefinition(AsType = LangMethodType.Method) BatchAccountKeys refreshKeys(); /** @@ -73,6 +79,7 @@ public interface BatchAccount extends * @param keyType either primary or secondary key to be regenerated * @return the access keys for this batch account */ + @LangMethodDefinition(AsType = LangMethodType.Method) BatchAccountKeys regenerateKeys(AccountKeyType keyType); /** @@ -87,6 +94,7 @@ public interface BatchAccount extends /** * Container interface for all the definitions that need to be implemented. */ + @LangDefinition(ContainerName = "~/BatchAccount.Definition") interface Definition extends DefinitionStages.Blank, DefinitionStages.WithGroup, @@ -96,6 +104,7 @@ interface Definition extends /** * Grouping of all the storage account definition stages. */ + @LangDefinition(ContainerName = "~/BatchAccount.Definition", ContainerFileName = "IDefinition", IsContainerOnly = true) interface DefinitionStages { /** * The first stage of the batch account definition. @@ -147,6 +156,7 @@ interface WithCreate extends /** * The template for a storage account update operation, containing all the settings that can be modified. */ + @LangDefinition(ContainerName = "~/BatchAccount.Update") interface Update extends Appliable, Resource.UpdateWithTags, @@ -156,6 +166,7 @@ interface Update extends /** * Grouping of all the storage account update stages. */ + @LangDefinition(ContainerName = "~/BatchAccount.Update", ContainerFileName = "IUpdate", IsContainerOnly = true) interface UpdateStages { /** * The stage of the batch account update definition allowing to specify storage account. diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java index 395d3365360b7..22d765f49afb9 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java @@ -1,8 +1,11 @@ package com.microsoft.azure.management.batch; +import com.microsoft.azure.management.apigeneration.LangDefinition; + /** - * Created by ans on 9/13/2016. + * This class represents the access keys for the batch account. */ +@LangDefinition public class BatchAccountKeys { /** * The primary key associated with the account. diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java index 128e536515738..f6dd57abcb450 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java @@ -1,5 +1,6 @@ package com.microsoft.azure.management.batch; +import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; @@ -12,6 +13,7 @@ /** * Entry point to batch account management API. */ +@LangDefinition(ContainerName = "~/") public interface BatchAccounts extends SupportsCreating, SupportsListing, diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java index 8dd6da9db9edd..da0b1b5f64994 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.management.batch.implementation; +import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.batch.AccountKeyType; import com.microsoft.azure.management.batch.AccountProvisioningState; import com.microsoft.azure.management.batch.AutoStorageBaseProperties; @@ -16,6 +17,7 @@ /** * Implementation for BatchAccount and its parent interfaces. */ +@LangDefinition public class BatchAccountImpl extends GroupableResourceImpl< diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java index 335c20ada689c..29f91e147749c 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java @@ -1,6 +1,7 @@ package com.microsoft.azure.management.batch.implementation; import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.batch.BatchAccount; import com.microsoft.azure.management.batch.BatchAccounts; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; @@ -10,6 +11,7 @@ /** * Implementation for BatchAccounts and its parent interfaces. */ +@LangDefinition public class BatchAccountsImpl extends GroupableResourcesImpl implements BatchAccounts { diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java index 47d4344ee006d..cae261798119d 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java @@ -10,7 +10,7 @@ import com.microsoft.rest.credentials.ServiceClientCredentials; /** - * Entry point to Azure batch account resource management. + * Entry point to Azure Batch Account resource management. */ public class BatchManager extends Manager {