diff --git a/UpdateCustomChildClassesForBackwardsCompatibility.bash b/UpdateCustomChildClassesForBackwardsCompatibility.bash deleted file mode 100644 index 786572a9e473c..0000000000000 --- a/UpdateCustomChildClassesForBackwardsCompatibility.bash +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -custom_folder_name="custom" -search_dir="azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/$custom_folder_name/" -custom_package_name="com.microsoft.azure.keyvault.models.$custom_folder_name." -model_name_regex="models\/([a-zA-Z]+).java" - -for entry in "$search_dir"* -do - model_file_name=${entry/${custom_folder_name}\//} - [[ $model_file_name =~ $model_name_regex ]] - model_name=${BASH_REMATCH[1]} - echo $model_name - if ! grep -q "extends $custom_package_name" "$model_file_name"; then - sed -i "s/public class ${model_name}/public class ${model_name} extends ${custom_package_name}${model_name}/g" $model_file_name - fi -done - -echo "Extended for backwards compatibility...DONE" diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientBase.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientBase.java index d7ece6ace169e..4e35066562eff 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientBase.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientBase.java @@ -33,7 +33,12 @@ 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.webkey.JsonWebKey; import com.microsoft.azure.keyvault.models.JsonWebKeyCurveName; +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.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; @@ -62,11 +67,6 @@ import java.util.List; import java.util.Map; import rx.Observable; -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; /** * The interface for KeyVaultClientBase class. @@ -3814,6 +3814,7 @@ public interface KeyVaultClientBase { * @return the BackupCertificateResult object if successful. */ BackupCertificateResult backupCertificate(String vaultBaseUrl, String certificateName); + /** * Backs up the specified certificate. * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission. @@ -3825,6 +3826,7 @@ public interface KeyVaultClientBase { * @return the {@link ServiceFuture} object */ ServiceFuture backupCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback); + /** * Backs up the specified certificate. * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission. @@ -3835,6 +3837,7 @@ public interface KeyVaultClientBase { * @return the observable to the BackupCertificateResult object */ Observable backupCertificateAsync(String vaultBaseUrl, String certificateName); + /** * Backs up the specified certificate. * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission. @@ -3845,6 +3848,7 @@ public interface KeyVaultClientBase { * @return the observable to the BackupCertificateResult object */ Observable> backupCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName); + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -3857,6 +3861,7 @@ public interface KeyVaultClientBase { * @return the CertificateBundle object if successful. */ CertificateBundle restoreCertificate(String vaultBaseUrl, byte[] certificateBundleBackup); + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -3868,6 +3873,7 @@ public interface KeyVaultClientBase { * @return the {@link ServiceFuture} object */ ServiceFuture restoreCertificateAsync(String vaultBaseUrl, byte[] certificateBundleBackup, final ServiceCallback serviceCallback); + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -3878,6 +3884,7 @@ public interface KeyVaultClientBase { * @return the observable to the CertificateBundle object */ Observable restoreCertificateAsync(String vaultBaseUrl, byte[] certificateBundleBackup); + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -3888,6 +3895,7 @@ public interface KeyVaultClientBase { * @return the observable to the CertificateBundle object */ Observable> restoreCertificateWithServiceResponseAsync(String vaultBaseUrl, byte[] certificateBundleBackup); + /** * Lists the deleted certificates in the specified vault currently available for recovery. * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state and ready for recovery or purging. This operation includes deletion-specific information. This operation requires the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. 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 e2d082710b890..8e684337321ec 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 @@ -1374,9 +1374,9 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param keyName The name of the key. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { @@ -1589,8 +1589,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { @@ -3119,8 +3119,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { @@ -3342,9 +3342,9 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param secretName The name of the secret. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @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) { @@ -3557,8 +3557,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { @@ -4067,8 +4067,8 @@ public Observable>> call(ServiceResp /** * List certificate issuers for a specified key vault. * - ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { @@ -5192,9 +5192,9 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - ServiceResponse> * @param certificateName The name of the certificate. - ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @param vaultBaseUrl The vault name, for example 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 PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { @@ -6167,7 +6167,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { @@ -6271,7 +6271,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { @@ -6375,7 +6375,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { @@ -6479,7 +6479,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { @@ -6583,7 +6583,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { @@ -6687,7 +6687,7 @@ public Observable>> call(ServiceResp /** * List certificate issuers for a specified key vault. * - ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { @@ -6791,7 +6791,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java index ac7b3b1ca2826..921eb57bcbb2d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java @@ -46,7 +46,12 @@ 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.webkey.JsonWebKey; import com.microsoft.azure.keyvault.models.JsonWebKeyCurveName; +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.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyCreateParameters; @@ -108,11 +113,6 @@ import retrofit2.Response; import rx.functions.Func1; import rx.Observable; -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; /** * Initializes a new instance of the KeyVaultClientBaseImpl class. @@ -481,9 +481,11 @@ interface KeyVaultClientBaseService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClientBase backupCertificate" }) @POST("certificates/{certificate-name}/backup") Observable> backupCertificate(@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", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClientBase restoreCertificate" }) @POST("certificates/restore") Observable> restoreCertificate(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClientBase getDeletedCertificates" }) @GET("deletedcertificates") Observable> getDeletedCertificates(@Query("maxresults") Integer maxresults, @Query("includePending") Boolean includePending, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @@ -4597,8 +4599,8 @@ public Observable>> call(ServiceResponse * Lists deleted secrets for the specified vault. * The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled for soft-delete. This operation requires the secrets/list permission. * - * @param vaultBaseUrl The vault name, for example 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. + * @param vaultBaseUrl The vault name, for example 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. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<DeletedSecretItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -5853,8 +5855,8 @@ public Observable>> call(ServiceResp * List certificate issuers for a specified key vault. * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission. * - * @param vaultBaseUrl The vault name, for example 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. + * @param vaultBaseUrl The vault name, for example 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. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -8117,6 +8119,7 @@ private ServiceResponse mergeCertificateDelegate(Response backupCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return ServiceFuture.fromResponse(backupCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } + /** * Backs up the specified certificate. * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission. @@ -8147,6 +8151,7 @@ public BackupCertificateResult call(ServiceResponse res } }); } + /** * Backs up the specified certificate. * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission. @@ -8180,12 +8185,14 @@ public Observable> call(Response backupCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -8200,6 +8207,7 @@ private ServiceResponse backupCertificateDelegate(Respo public CertificateBundle restoreCertificate(String vaultBaseUrl, byte[] certificateBundleBackup) { return restoreCertificateWithServiceResponseAsync(vaultBaseUrl, certificateBundleBackup).toBlocking().single().body(); } + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -8213,6 +8221,7 @@ public CertificateBundle restoreCertificate(String vaultBaseUrl, byte[] certific public ServiceFuture restoreCertificateAsync(String vaultBaseUrl, byte[] certificateBundleBackup, final ServiceCallback serviceCallback) { return ServiceFuture.fromResponse(restoreCertificateWithServiceResponseAsync(vaultBaseUrl, certificateBundleBackup), serviceCallback); } + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -8230,6 +8239,7 @@ public CertificateBundle call(ServiceResponse response) { } }); } + /** * Restores a backed up certificate to a vault. * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. @@ -8265,12 +8275,14 @@ public Observable> call(Response restoreCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } + /** * Lists the deleted certificates in the specified vault currently available for recovery. * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state and ready for recovery or purging. This operation includes deletion-specific information. This operation requires the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. @@ -12350,7 +12362,7 @@ public Observable>> call(ServiceResponse * Lists deleted secrets for the specified vault. * The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled for soft-delete. This operation requires the secrets/list permission. * - * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<DeletedSecretItem> object wrapped in {@link ServiceResponse} if successful. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/DeletionRecoveryLevel.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/DeletionRecoveryLevel.java index 8a282c86c8738..9dc34d400cfed 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/DeletionRecoveryLevel.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/DeletionRecoveryLevel.java @@ -8,58 +8,40 @@ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; /** * Defines values for DeletionRecoveryLevel. */ -public final class DeletionRecoveryLevel { +public final class DeletionRecoveryLevel extends ExpandableStringEnum { /** Static value Purgeable for DeletionRecoveryLevel. */ - public static final DeletionRecoveryLevel PURGEABLE = new DeletionRecoveryLevel("Purgeable"); + public static final DeletionRecoveryLevel PURGEABLE = fromString("Purgeable"); /** Static value Recoverable+Purgeable for DeletionRecoveryLevel. */ - public static final DeletionRecoveryLevel RECOVERABLE_PURGEABLE = new DeletionRecoveryLevel("Recoverable+Purgeable"); + public static final DeletionRecoveryLevel RECOVERABLE_PURGEABLE = fromString("Recoverable+Purgeable"); /** Static value Recoverable for DeletionRecoveryLevel. */ - public static final DeletionRecoveryLevel RECOVERABLE = new DeletionRecoveryLevel("Recoverable"); + public static final DeletionRecoveryLevel RECOVERABLE = fromString("Recoverable"); /** Static value Recoverable+ProtectedSubscription for DeletionRecoveryLevel. */ - public static final DeletionRecoveryLevel RECOVERABLE_PROTECTED_SUBSCRIPTION = new DeletionRecoveryLevel("Recoverable+ProtectedSubscription"); - - private String value; + public static final DeletionRecoveryLevel RECOVERABLE_PROTECTED_SUBSCRIPTION = fromString("Recoverable+ProtectedSubscription"); /** - * Creates a custom value for DeletionRecoveryLevel. - * @param value the custom value + * Creates or finds a DeletionRecoveryLevel from its string representation. + * @param name a name to look for + * @return the corresponding DeletionRecoveryLevel */ - public DeletionRecoveryLevel(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; + @JsonCreator + public static DeletionRecoveryLevel fromString(String name) { + return fromString(name, DeletionRecoveryLevel.class); } - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof DeletionRecoveryLevel)) { - return false; - } - if (obj == this) { - return true; - } - DeletionRecoveryLevel rhs = (DeletionRecoveryLevel) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } + /** + * @return known DeletionRecoveryLevel values + */ + public static Collection values() { + return values(DeletionRecoveryLevel.class); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java index 1c1c0f68544f2..f73058423bd39 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java @@ -27,6 +27,13 @@ public class IssuerParameters { @JsonProperty(value = "cty") private String certificateType; + /** + * Indicates if the certificates generated under this policy should be + * published to certificate transparency logs. + */ + @JsonProperty(value = "cert_transparency") + private Boolean certificateTransparency; + /** * Get the name value. * @@ -67,4 +74,24 @@ public IssuerParameters withCertificateType(String certificateType) { return this; } + /** + * Get the certificateTransparency value. + * + * @return the certificateTransparency value + */ + public Boolean certificateTransparency() { + return this.certificateTransparency; + } + + /** + * Set the certificateTransparency value. + * + * @param certificateTransparency the certificateTransparency value to set + * @return the IssuerParameters object itself. + */ + public IssuerParameters withCertificateTransparency(Boolean certificateTransparency) { + this.certificateTransparency = certificateTransparency; + return this; + } + } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyCurveName.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyCurveName.java index b4e6a5f99033f..3c998f4feed7c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyCurveName.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyCurveName.java @@ -8,58 +8,40 @@ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; /** * Defines values for JsonWebKeyCurveName. */ -public final class JsonWebKeyCurveName { +public final class JsonWebKeyCurveName extends ExpandableStringEnum { /** Static value P-256 for JsonWebKeyCurveName. */ - public static final JsonWebKeyCurveName P_256 = new JsonWebKeyCurveName("P-256"); + public static final JsonWebKeyCurveName P_256 = fromString("P-256"); /** Static value P-384 for JsonWebKeyCurveName. */ - public static final JsonWebKeyCurveName P_384 = new JsonWebKeyCurveName("P-384"); + public static final JsonWebKeyCurveName P_384 = fromString("P-384"); /** Static value P-521 for JsonWebKeyCurveName. */ - public static final JsonWebKeyCurveName P_521 = new JsonWebKeyCurveName("P-521"); + public static final JsonWebKeyCurveName P_521 = fromString("P-521"); /** Static value SECP256K1 for JsonWebKeyCurveName. */ - public static final JsonWebKeyCurveName SECP256K1 = new JsonWebKeyCurveName("SECP256K1"); - - private String value; + public static final JsonWebKeyCurveName SECP256K1 = fromString("SECP256K1"); /** - * Creates a custom value for JsonWebKeyCurveName. - * @param value the custom value + * Creates or finds a JsonWebKeyCurveName from its string representation. + * @param name a name to look for + * @return the corresponding JsonWebKeyCurveName */ - public JsonWebKeyCurveName(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; + @JsonCreator + public static JsonWebKeyCurveName fromString(String name) { + return fromString(name, JsonWebKeyCurveName.class); } - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JsonWebKeyCurveName)) { - return false; - } - if (obj == this) { - return true; - } - JsonWebKeyCurveName rhs = (JsonWebKeyCurveName) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } + /** + * @return known JsonWebKeyCurveName values + */ + public static Collection values() { + return values(JsonWebKeyCurveName.class); } } 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 28330b5110f94..e896912059a34 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 @@ -8,9 +8,9 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.azure.keyvault.webkey.JsonWebKey; /** * A KeyBundle consisting of a WebKey plus its attributes. 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 6716a587f4807..f3a03b328cd09 100644 --- 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 @@ -8,11 +8,11 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; 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. 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 d46af972b648d..17032b0f79533 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 @@ -8,9 +8,9 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; 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/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index f7eeea6ac253f..cd14ebb7ac237 100644 --- 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 @@ -8,10 +8,10 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; 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. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java index 316286608217f..488386fac59b8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -8,73 +8,55 @@ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; /** * Defines values for KeyUsageType. */ -public final class KeyUsageType { +public final class KeyUsageType extends ExpandableStringEnum { /** Static value digitalSignature for KeyUsageType. */ - public static final KeyUsageType DIGITAL_SIGNATURE = new KeyUsageType("digitalSignature"); + public static final KeyUsageType DIGITAL_SIGNATURE = fromString("digitalSignature"); /** Static value nonRepudiation for KeyUsageType. */ - public static final KeyUsageType NON_REPUDIATION = new KeyUsageType("nonRepudiation"); + public static final KeyUsageType NON_REPUDIATION = fromString("nonRepudiation"); /** Static value keyEncipherment for KeyUsageType. */ - public static final KeyUsageType KEY_ENCIPHERMENT = new KeyUsageType("keyEncipherment"); + public static final KeyUsageType KEY_ENCIPHERMENT = fromString("keyEncipherment"); /** Static value dataEncipherment for KeyUsageType. */ - public static final KeyUsageType DATA_ENCIPHERMENT = new KeyUsageType("dataEncipherment"); + public static final KeyUsageType DATA_ENCIPHERMENT = fromString("dataEncipherment"); /** Static value keyAgreement for KeyUsageType. */ - public static final KeyUsageType KEY_AGREEMENT = new KeyUsageType("keyAgreement"); + public static final KeyUsageType KEY_AGREEMENT = fromString("keyAgreement"); /** Static value keyCertSign for KeyUsageType. */ - public static final KeyUsageType KEY_CERT_SIGN = new KeyUsageType("keyCertSign"); + public static final KeyUsageType KEY_CERT_SIGN = fromString("keyCertSign"); /** Static value cRLSign for KeyUsageType. */ - public static final KeyUsageType C_RLSIGN = new KeyUsageType("cRLSign"); + public static final KeyUsageType C_RLSIGN = fromString("cRLSign"); /** Static value encipherOnly for KeyUsageType. */ - public static final KeyUsageType ENCIPHER_ONLY = new KeyUsageType("encipherOnly"); + public static final KeyUsageType ENCIPHER_ONLY = fromString("encipherOnly"); /** Static value decipherOnly for KeyUsageType. */ - public static final KeyUsageType DECIPHER_ONLY = new KeyUsageType("decipherOnly"); - - private String value; + public static final KeyUsageType DECIPHER_ONLY = fromString("decipherOnly"); /** - * Creates a custom value for KeyUsageType. - * @param value the custom value + * Creates or finds a KeyUsageType from its string representation. + * @param name a name to look for + * @return the corresponding KeyUsageType */ - public KeyUsageType(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; + @JsonCreator + public static KeyUsageType fromString(String name) { + return fromString(name, KeyUsageType.class); } - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof KeyUsageType)) { - return false; - } - if (obj == this) { - return true; - } - KeyUsageType rhs = (KeyUsageType) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } + /** + * @return known KeyUsageType values + */ + public static Collection values() { + return values(KeyUsageType.class); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SasTokenType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SasTokenType.java index 9e39e7370fd01..8a7c0e88cdf1a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SasTokenType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SasTokenType.java @@ -8,52 +8,34 @@ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; /** * Defines values for SasTokenType. */ -public final class SasTokenType { +public final class SasTokenType extends ExpandableStringEnum { /** Static value account for SasTokenType. */ - public static final SasTokenType ACCOUNT = new SasTokenType("account"); + public static final SasTokenType ACCOUNT = fromString("account"); /** Static value service for SasTokenType. */ - public static final SasTokenType SERVICE = new SasTokenType("service"); - - private String value; + public static final SasTokenType SERVICE = fromString("service"); /** - * Creates a custom value for SasTokenType. - * @param value the custom value + * Creates or finds a SasTokenType from its string representation. + * @param name a name to look for + * @return the corresponding SasTokenType */ - public SasTokenType(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; + @JsonCreator + public static SasTokenType fromString(String name) { + return fromString(name, SasTokenType.class); } - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof SasTokenType)) { - return false; - } - if (obj == this) { - return true; - } - SasTokenType rhs = (SasTokenType) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } + /** + * @return known SasTokenType values + */ + public static Collection values() { + return values(SasTokenType.class); } } 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 74e5f194e9bc9..ad09b2943573d 100644 --- 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 @@ -45,12 +45,6 @@ public class X509CertificateProperties { @JsonProperty(value = "validity_months") private Integer validityInMonths; - /** - * Indicates if the certificates generated under this policy should be - * published to certificate transparency logs. - */ - @JsonProperty(value = "cert_transparency") - private Boolean certificateTransparency; /** * Get the subject value. * @@ -151,22 +145,4 @@ public X509CertificateProperties withValidityInMonths(Integer validityInMonths) return this; } - /** - * Get the certificateTransparency value. - * - * @return the certificateTransparency value - */ - public Boolean certificateTransparency() { - return this.certificateTransparency; - } - /** - * Set the certificateTransparency value. - * - * @param certificateTransparency the certificateTransparency value to set - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties withCertificateTransparency(Boolean certificateTransparency) { - this.certificateTransparency = certificateTransparency; - return this; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index f08140f306f95..9056e793a7855 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -2,12 +2,10 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. +// Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the classes for KeyVaultClient. + * This package contains the classes for KeyVaultClientBase. * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault; diff --git a/regenerate_and_fix_sdk.py b/regenerate_and_fix_sdk.py new file mode 100644 index 0000000000000..eeb644fc3dd6a --- /dev/null +++ b/regenerate_and_fix_sdk.py @@ -0,0 +1,124 @@ +import os, sys, subprocess, re +from distutils.dir_util import copy_tree, remove_tree + +# Need python 3.6 for new subprocess API +MIN_PYTHON = (3, 6) +if sys.version_info < MIN_PYTHON: + sys.exit("Python %s.%s or later is required.\n" % MIN_PYTHON) + +# Configuration +verbose = True +autorest_target_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "tmp") +swagger_source_branch = "keyvault_preview" # Source branch in swagger repo to generate from +autorest_tag = "package-7.0-preview" # Autorest tag to use, if any +run_autorest = True # If false, assumes that we just need to repair generated code that is already in tree! +fix_generated_code = True # if false, assumes that we just need to run autorest +source_rest_spec = "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/%s/specification/keyvault/data-plane/readme.md" % swagger_source_branch # Builds the URL to Swagger readme from branch +autorest_cmd = "autorest --java %s --azure-libraries-for-java-folder=%s" % (source_rest_spec, autorest_target_dir) + +if autorest_tag is not None: + autorest_cmd += " --tag=%s" % autorest_tag + +# Constant values +CODE_TARGET_DIRECTORY = os.path.join(os.path.dirname(os.path.realpath(__file__)), "azure-keyvault", "src", "main", "java", "com", "microsoft", "azure", "keyvault") +CUSTOM_MODEL_DIR = os.path.join(CODE_TARGET_DIRECTORY, "models", "custom") +WEBKEY_REPLACE_MODELS = ['JsonWebKey', 'JsonWebKeyEncryptionAlgorithm', 'JsonWebKeyOperation', 'JsonWebKeySignatureAlgorithm', 'JsonWebKeyType'] +WEBKEY_NAMESPACE = 'com.microsoft.azure.keyvault.webkey' +CUSTOM_MODEL_NAMESPACE = 'com.microsoft.azure.keyvault.models.custom' +MODEL_NAMESPACE = 'com.microsoft.azure.keyvault.models' +FILES_TO_REMOVE = [ + 'azure-keyvault/models/%s.java' % model for model in WEBKEY_REPLACE_MODELS +] +FILES_TO_REMOVE.append('azure-keyvault/implementation/package-info.java') + +# Method definitions +def move_generated_code(autorest_target_dir, verbose): + # Remove JWK models, since those are in a separate non-generated package for now + print("Removing generated JWK models/package info") + for fn in FILES_TO_REMOVE: + + path = os.path.join(autorest_target_dir, fn) + if os.path.exists(path): + if verbose: + print("Removing %s" % path) + os.remove(path) + + # move (gen_directory)\azure-keyvault\* --> ./azure-keyvault\src\main\java\com\microsoft\azure\keyvault + print("Replacing old generated code") + copy_tree(os.path.join(autorest_target_dir, "azure-keyvault"), CODE_TARGET_DIRECTORY) + + print("Removing temporary generated files") + remove_tree(autorest_target_dir) + print("Done with generation process") + +# Fixes an individual source file +def correct_file(file, verbose): + if not file.endswith(".java"): + return + + with open(file) as f: + code = f.read() + + # Fix webkey models + for model in WEBKEY_REPLACE_MODELS: + code = code.replace("import %s.%s;" % (MODEL_NAMESPACE, model), "import %s.%s;" % (WEBKEY_NAMESPACE, model)) + + # Fix broken javadoc + jdocre = re.compile(r'([a-z|A-Z|0-9]*\<.*?\>)( \* \@param)') + code = jdocre.sub(r'\2', code) + + + classre = re.compile(r'public class ([a-z|A-Z|0-9]*?)[ \n\r\t]*{') + + # If this is a model class and not a custom model class, extend our custom code if necessary - additionally add back potentially nuked imports + dir, fn = os.path.split(file) + if os.path.split(dir)[1] == "models": + classes = classre.search(code) + if classes is not None: + classname = classes.group(1) + # check for corresponding custom class + if os.path.exists(os.path.join(CUSTOM_MODEL_DIR, classname + ".java")): + if verbose: + print("Updating generated '%s' to extend custom '%s'" % (classname, classname)) + code = classre.sub(r'public class \1 extends %s.\1 {' % CUSTOM_MODEL_NAMESPACE, code) + + # Add back webkey imports which may have been nuked + class_usage_re = re.compile(r'[ \t<](' + '|'.join(WEBKEY_REPLACE_MODELS) + ')[ \t>]') + needed_classes = list(set(class_usage_re.findall(code))) + if len(needed_classes) > 0: + if verbose: + print("Adding webkey imports for %s to %s" % ( ",".join(needed_classes), fn )) + potential_imports = ["import %s.%s;" % (WEBKEY_NAMESPACE, needed) for needed in needed_classes] + imports = [] + + for i in potential_imports: + if i not in code: + imports.append(i) + + if len(imports) > 0: + # find package statement at beginning of code, splice and add the imports in between + package_re = re.compile(r'package (.+?);\n\n') + package = package_re.search(code).group(0) + before, after = code.split(package, 2) + code = before + package + "\n".join(imports) + "\n" + after + + + # Write back to disk + with open(file, 'w') as f: + f.write(code) + + +if run_autorest: + print("Running autorest..") + if verbose: + print(autorest_cmd) + subprocess.run(autorest_cmd, check=True, shell=True) + move_generated_code(autorest_target_dir, verbose) + +if fix_generated_code: + print("Fixing generated code..") + for path, dirs, files in os.walk(CODE_TARGET_DIRECTORY): + if path == CUSTOM_MODEL_DIR: # skip custom code + continue + for file in files: + correct_file(os.path.join(path, file), verbose) \ No newline at end of file