From 87b09e6f58e7cea97f566c65406f5edc7c037748 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 15:38:15 -0800 Subject: [PATCH 01/13] Removed exposure of implementation package and any usage of KeyVaultErrorException from public APIs. --- .../KeyVaultAccessControlAsyncClient.java | 19 ++- .../KeyVaultBackupAsyncClient.java | 156 +++++++++++------- .../src/main/java/module-info.java | 4 - .../KeyVaultAccessControlAsyncClientTest.java | 5 +- .../KeyVaultAccessControlClientTest.java | 5 +- .../KeyVaultBackupAsyncClientTest.java | 4 +- .../KeyVaultBackupClientTest.java | 4 +- 7 files changed, 124 insertions(+), 73 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index c84e917b59829..6d2f6a4c66107 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -367,14 +367,17 @@ Mono> createRoleAssignmentWithResponse(KeyVault RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters() .setProperties(roleAssignmentProperties); - - return clientImpl.getRoleAssignments() - .createWithResponseAsync(vaultUrl, roleScope.toString(), name.toString(), parameters, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) - .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) - .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentResponse); + try { + return clientImpl.getRoleAssignments() + .createWithResponseAsync(vaultUrl, roleScope.toString(), name.toString(), parameters, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentResponse); + } catch (RuntimeException e) { + return monoError(logger, e); + } } /** diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index b0c011462aec5..016ce57dc8030 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -21,7 +21,6 @@ import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import com.azure.security.keyvault.administration.implementation.models.Error; import com.azure.security.keyvault.administration.implementation.models.FullBackupOperation; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; import com.azure.security.keyvault.administration.implementation.models.RestoreOperation; import com.azure.security.keyvault.administration.implementation.models.RestoreOperationParameters; import com.azure.security.keyvault.administration.implementation.models.SASTokenParameter; @@ -142,23 +141,26 @@ public PollerFlux beginBackup(String blobStorag * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PollerFlux} polling on the {@link KeyVaultBackupOperation backup operation} status. - * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> backupWithResponse(String blobStorageUrl, String sasToken, Context context) { SASTokenParameter sasTokenParameter = new SASTokenParameter() .setStorageResourceUri(blobStorageUrl) .setToken(sasToken); - return clientImpl.fullBackupWithResponseAsync(vaultUrl, sasTokenParameter, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Backing up at URL - {}", blobStorageUrl)) - .doOnSuccess(response -> logger.info("Backed up at URL - {}", - response.getValue().getAzureStorageBlobContainerUri())) - .doOnError(error -> logger.warning("Failed to backup at URL - {}", blobStorageUrl, error)) - .map(backupOperationResponse -> - new SimpleResponse<>(backupOperationResponse.getRequest(), backupOperationResponse.getStatusCode(), - backupOperationResponse.getHeaders(), - (KeyVaultBackupOperation) transformToLongRunningOperation(backupOperationResponse.getValue()))); + try { + return clientImpl.fullBackupWithResponseAsync(vaultUrl, sasTokenParameter, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Backing up at URL - {}", blobStorageUrl)) + .doOnSuccess(response -> logger.info("Backed up at URL - {}", + response.getValue().getAzureStorageBlobContainerUri())) + .doOnError(error -> logger.warning("Failed to backup at URL - {}", blobStorageUrl, error)) + .map(backupOperationResponse -> + new SimpleResponse<>(backupOperationResponse.getRequest(), backupOperationResponse.getStatusCode(), + backupOperationResponse.getHeaders(), + (KeyVaultBackupOperation) transformToLongRunningOperation(backupOperationResponse.getValue()))); + } catch (RuntimeException e) { + return monoError(logger, e); + } } private Function, Mono> backupActivationOperation(String blobStorageUrl, String sasToken) { @@ -204,19 +206,25 @@ private Function, Mono(LongRunningOperationStatus.FAILED, null)); + } catch (RuntimeException e) { + return monoError(logger, e); } }; } private Function, Mono> backupFetchOperation() { return (pollingContext) -> { - String blobContainerUri = - pollingContext.getLatestResponse().getValue().getAzureStorageBlobContainerUri(); + try { + String blobContainerUri = + pollingContext.getLatestResponse().getValue().getAzureStorageBlobContainerUri(); - if (blobContainerUri == null) { - return Mono.empty(); - } else { - return Mono.just(blobContainerUri); + if (blobContainerUri == null) { + return Mono.empty(); + } else { + return Mono.just(blobContainerUri); + } + } catch (RuntimeException e) { + return monoError(logger, e); } }; } @@ -263,13 +271,23 @@ public PollerFlux getBackupOperation(String job } private Function, Mono>> backupStatusPollOperation(String jobId) { - return (pollingContext) -> - withContext(context -> clientImpl.fullBackupStatusWithResponseAsync(vaultUrl, jobId, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) - .map(response -> - new SimpleResponse<>(response, - (KeyVaultBackupOperation) transformToLongRunningOperation(response.getValue()))) - .flatMap(KeyVaultBackupAsyncClient::processBackupOperationResponse); + return (pollingContext) -> { + try { + return withContext(context -> clientImpl.fullBackupStatusWithResponseAsync(vaultUrl, jobId, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) + .map(response -> + new SimpleResponse<>(response, + (KeyVaultBackupOperation) transformToLongRunningOperation(response.getValue()))) + .flatMap(KeyVaultBackupAsyncClient::processBackupOperationResponse); + } catch (HttpResponseException e) { + //noinspection ThrowableNotThrown + logger.logExceptionAsError(e); + + return Mono.just(new PollResponse<>(LongRunningOperationStatus.FAILED, null)); + } catch (RuntimeException e) { + return monoError(logger, e); + } + }; } /** @@ -323,7 +341,6 @@ public PollerFlux beginRestore(String backupFold * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. - * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> restoreWithResponse(String backupFolderUrl, String sasToken, Context context) { String[] segments = backupFolderUrl.split("/"); @@ -338,16 +355,22 @@ Mono> restoreWithResponse(String backupFolder .setSasTokenParameters(sasTokenParameter) .setFolderToRestore(folderName); - return clientImpl.fullRestoreOperationWithResponseAsync(vaultUrl, restoreOperationParameters, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Restoring from location - {}", backupFolderUrl)) - .doOnSuccess(response -> logger.info("Restored from location - {}", backupFolderUrl)) - .doOnError(error -> - logger.warning("Failed to restore from location - {}", backupFolderUrl, error)) - .map(restoreOperationResponse -> - new SimpleResponse<>(restoreOperationResponse.getRequest(), restoreOperationResponse.getStatusCode(), - restoreOperationResponse.getHeaders(), - (KeyVaultRestoreOperation) transformToLongRunningOperation(restoreOperationResponse.getValue()))); + try { + return clientImpl.fullRestoreOperationWithResponseAsync(vaultUrl, restoreOperationParameters, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Restoring from location - {}", backupFolderUrl)) + .doOnSuccess(response -> logger.info("Restored from location - {}", backupFolderUrl)) + .doOnError(error -> + logger.warning("Failed to restore from location - {}", backupFolderUrl, error)) + .map(restoreOperationResponse -> + new SimpleResponse<>(restoreOperationResponse.getRequest(), + restoreOperationResponse.getStatusCode(), + restoreOperationResponse.getHeaders(), + (KeyVaultRestoreOperation) transformToLongRunningOperation( + restoreOperationResponse.getValue()))); + } catch (RuntimeException e) { + return monoError(logger, e); + } } private Function, Mono> restoreActivationOperation(String backupFolderUrl, String sasToken) { @@ -394,6 +417,8 @@ private Function, Mono(LongRunningOperationStatus.FAILED, null)); + } catch (RuntimeException e) { + return monoError(logger, e); } }; } @@ -426,13 +451,23 @@ public PollerFlux getRestoreOperation(String job } private Function, Mono>> restoreStatusPollOperation(String jobId) { - return (pollingContext) -> - withContext(context -> clientImpl.restoreStatusWithResponseAsync(vaultUrl, jobId, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) - .map(response -> - new SimpleResponse<>(response, - (KeyVaultRestoreOperation) transformToLongRunningOperation(response.getValue()))) - .flatMap(KeyVaultBackupAsyncClient::processRestoreOperationResponse); + return (pollingContext) -> { + try { + return withContext(context -> clientImpl.restoreStatusWithResponseAsync(vaultUrl, jobId, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) + .map(response -> + new SimpleResponse<>(response, + (KeyVaultRestoreOperation) transformToLongRunningOperation(response.getValue()))) + .flatMap(KeyVaultBackupAsyncClient::processRestoreOperationResponse); + } catch (HttpResponseException e) { + //noinspection ThrowableNotThrown + logger.logExceptionAsError(e); + + return Mono.just(new PollResponse<>(LongRunningOperationStatus.FAILED, null)); + } catch (RuntimeException e) { + return monoError(logger, e); + } + }; } /** @@ -497,7 +532,6 @@ public PollerFlux beginSelectiveRestore(String k * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. - * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> selectiveRestoreWithResponse(String keyName, String backupFolderUrl, String sasToken, Context context) { String[] segments = backupFolderUrl.split("/"); @@ -513,19 +547,25 @@ Mono> selectiveRestoreWithResponse(String key .setSasTokenParameters(sasTokenParameter) .setFolder(folderName); - return clientImpl.selectiveKeyRestoreOperationWithResponseAsync(vaultUrl, keyName, - selectiveKeyRestoreOperationParameters, context.addData(AZ_TRACING_NAMESPACE_KEY, - KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> - logger.info("Restoring key \"{}\" from location - {}", keyName, backupFolderUrl)) - .doOnSuccess(response -> - logger.info("Restored key \"{}\" from location - {}", keyName, backupFolderUrl)) - .doOnError(error -> - logger.warning("Failed to restore key \"{}\" from location - {}", keyName, backupFolderUrl, error)) - .map(restoreOperationResponse -> - new SimpleResponse<>(restoreOperationResponse.getRequest(), restoreOperationResponse.getStatusCode(), - restoreOperationResponse.getHeaders(), - (KeyVaultRestoreOperation) transformToLongRunningOperation(restoreOperationResponse.getValue()))); + try { + return clientImpl.selectiveKeyRestoreOperationWithResponseAsync(vaultUrl, keyName, + selectiveKeyRestoreOperationParameters, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> + logger.info("Restoring key \"{}\" from location - {}", keyName, backupFolderUrl)) + .doOnSuccess(response -> + logger.info("Restored key \"{}\" from location - {}", keyName, backupFolderUrl)) + .doOnError(error -> + logger.warning("Failed to restore key \"{}\" from location - {}", keyName, backupFolderUrl, error)) + .map(restoreOperationResponse -> + new SimpleResponse<>(restoreOperationResponse.getRequest(), + restoreOperationResponse.getStatusCode(), + restoreOperationResponse.getHeaders(), + (KeyVaultRestoreOperation) transformToLongRunningOperation( + restoreOperationResponse.getValue()))); + } catch (RuntimeException e) { + return monoError(logger, e); + } } private Function, Mono> selectiveRestoreActivationOperation(String keyName, String backupFolderUrl, String sasToken) { @@ -572,6 +612,8 @@ private Function, Mono(LongRunningOperationStatus.FAILED, null)); + } catch (RuntimeException e) { + return monoError(logger, e); } }; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index 8bd509800fd72..c0f6f282ab9d9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -6,11 +6,7 @@ exports com.azure.security.keyvault.administration; exports com.azure.security.keyvault.administration.models; - exports com.azure.security.keyvault.administration.implementation; - exports com.azure.security.keyvault.administration.implementation.models; opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; - opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; - opens com.azure.security.keyvault.administration.implementation.models to com.fasterxml.jackson.databind; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java index 42638b8dec3a8..b6279bd77894b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java @@ -17,7 +17,10 @@ import java.util.List; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class KeyVaultAccessControlAsyncClientTest extends KeyVaultAccessControlClientTestBase { private KeyVaultAccessControlAsyncClient asyncClient; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java index 78db4e4cc8f5b..4ad6dade53b47 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java @@ -16,7 +16,10 @@ import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class KeyVaultAccessControlClientTest extends KeyVaultAccessControlClientTestBase { private KeyVaultAccessControlClient client; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java index 09e1066fc6e97..e8cac01c182bd 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java @@ -13,7 +13,9 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class KeyVaultBackupAsyncClientTest extends KeyVaultBackupClientTestBase { private KeyVaultBackupAsyncClient asyncClient; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java index ea980612b55d1..16bacdfafac6a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java @@ -13,7 +13,9 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class KeyVaultBackupClientTest extends KeyVaultBackupClientTestBase { private KeyVaultBackupClient client; From 46089c81a924795e6ecfae0c426048f4185d7922 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 15:52:54 -0800 Subject: [PATCH 02/13] Renamed KeyVaultRoleAssignmentScope to KeyVaultRoleScope. Changed the name type from UUID to String in role assignment APIs. --- .../KeyVaultAccessControlAsyncClient.java | 215 ++++++++---------- .../KeyVaultAccessControlClient.java | 115 +++++----- .../models/KeyVaultRoleAssignment.java | 12 +- .../models/KeyVaultRoleAssignmentScope.java | 36 --- .../models/KeyVaultRoleScope.java | 36 +++ .../AccessControlHelloWorld.java | 12 +- .../AccessControlHelloWorldAsync.java | 12 +- ...eateRoleAssignmentsForDifferentScopes.java | 6 +- .../KeyVaultAccessControlAsyncClientTest.java | 35 ++- .../KeyVaultAccessControlClientTest.java | 34 +-- 10 files changed, 251 insertions(+), 262 deletions(-) delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 6d2f6a4c66107..ce96090a4a666 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -28,7 +28,7 @@ import com.azure.security.keyvault.administration.models.KeyVaultPermission; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinitionProperties; import reactor.core.publisher.Mono; @@ -96,16 +96,16 @@ public String getVaultUrl() { /** * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role * definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope) { + public PagedFlux listRoleDefinitions(KeyVaultRoleScope roleScope) { return new PagedFlux<>( () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, roleScope, context)), continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); @@ -113,16 +113,16 @@ public PagedFlux listRoleDefinitions(KeyVaultRoleAssignm /** * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role * definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ - PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, Context context) { + PagedFlux listRoleDefinitions(KeyVaultRoleScope roleScope, Context context) { return new PagedFlux<>( () -> listRoleDefinitionsFirstPage(vaultUrl, roleScope, context), continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); @@ -130,16 +130,16 @@ PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScop /** * Lists all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * for the given {@link KeyVaultRoleScope roleScope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ - Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleAssignmentScope roleScope, Context context) { + Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope roleScope, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -161,13 +161,13 @@ Mono> listRoleDefinitionsFirstPage(String /** * Lists all {@link KeyVaultRoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved * from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleAssignmentScope, Context)}. + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleScope, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the next page of results. + * for the given {@link KeyVaultRoleScope roleScope} from the next page of results. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -186,15 +186,15 @@ Mono> listRoleDefinitionsNextPage(String c /** * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope roleScope) { + public PagedFlux listRoleAssignments(KeyVaultRoleScope roleScope) { return new PagedFlux<>( () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, roleScope, context)), continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); @@ -202,15 +202,15 @@ public PagedFlux listRoleAssignments(KeyVaultRoleAssignm /** * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ - PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, Context context) { + PagedFlux listRoleAssignments(KeyVaultRoleScope roleScope, Context context) { return new PagedFlux<>( () -> listRoleAssignmentsFirstPage(vaultUrl, roleScope, context), continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); @@ -218,16 +218,16 @@ PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScop /** * Lists all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at - * the given {@link KeyVaultRoleAssignmentScope roleScope} and above. + * the given {@link KeyVaultRoleScope roleScope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * in the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * in the given {@link KeyVaultRoleScope roleScope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ - Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleAssignmentScope roleScope, Context context) { + Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleScope roleScope, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -249,13 +249,13 @@ Mono> listRoleAssignmentsFirstPage(String /** * Lists all {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was * retrieved from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleAssignmentScope)}. + * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listKeyVaultRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. + * for the given {@link KeyVaultRoleScope roleScope} from the first page of results. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { @@ -273,89 +273,76 @@ Mono> listRoleAssignmentsNextPage(String c } /** - * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. + * Creates a {@link KeyVaultRoleAssignment} with a randomly generated name. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignment(roleScope, UUID.randomUUID(), properties); + public Mono createRoleAssignment(KeyVaultRoleScope roleScope, KeyVaultRoleAssignmentProperties properties) { + return createRoleAssignment(roleScope, UUID.randomUUID().toString(), properties); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any + * valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, name, properties).flatMap(FluxUtil::toMono); - } - - /** - * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. - * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created - * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties); + public Mono createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties).flatMap(FluxUtil::toMono); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any + * valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return withContext(context -> createRoleAssignmentWithResponse(roleScope, name, properties, context)); + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { + return withContext(context -> createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, context)); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any + * valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { + Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); - Objects.requireNonNull(name, + Objects.requireNonNull(roleAssignmentName, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'name'")); + "'roleAssignmentName'")); Objects.requireNonNull(properties, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'properties'")); @@ -369,11 +356,11 @@ Mono> createRoleAssignmentWithResponse(KeyVault .setProperties(roleAssignmentProperties); try { return clientImpl.getRoleAssignments() - .createWithResponseAsync(vaultUrl, roleScope.toString(), name.toString(), parameters, + .createWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName, parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", roleAssignmentName)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", roleAssignmentName, error)) .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -383,58 +370,58 @@ Mono> createRoleAssignmentWithResponse(KeyVault /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name used of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { - return getRoleAssignmentWithResponse(roleScope, name).flatMap(FluxUtil::toMono); + public Mono getRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return getRoleAssignmentWithResponse(roleScope, roleAssignmentName).flatMap(FluxUtil::toMono); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name) { - return withContext(context -> getRoleAssignmentWithResponse(roleScope, name, context)); + public Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return withContext(context -> getRoleAssignmentWithResponse(roleScope, roleAssignmentName, context)); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ - Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { + Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); - Objects.requireNonNull(name, + Objects.requireNonNull(roleAssignmentName, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'name'")); + "'roleAssignmentName'")); try { return clientImpl.getRoleAssignments() - .getWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + .getWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Retrieving role assignment - {}", name)) + .doOnRequest(ignored -> logger.info("Retrieving role assignment - {}", roleAssignmentName)) .doOnSuccess(response -> logger.info("Retrieved role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to retrieved role assignment - {}", name, error)) + .doOnError(error -> logger.warning("Failed to retrieved role assignment - {}", roleAssignmentName, error)) .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -444,58 +431,58 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { - return deleteRoleAssignmentWithResponse(roleScope, name).flatMap(FluxUtil::toMono); + public Mono deleteRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return deleteRoleAssignmentWithResponse(roleScope, roleAssignmentName).flatMap(FluxUtil::toMono); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name) { - return withContext(context -> deleteRoleAssignmentWithResponse(roleScope, name, context)); + public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return withContext(context -> deleteRoleAssignmentWithResponse(roleScope, roleAssignmentName, context)); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { + Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); - Objects.requireNonNull(name, + Objects.requireNonNull(roleAssignmentName, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'name'")); + "'roleAssignmentName'")); try { return clientImpl.getRoleAssignments() - .deleteWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + .deleteWithResponseAsync(vaultUrl, roleScope.toString(), roleAssignmentName, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Deleting role assignment - {}", name)) + .doOnRequest(ignored -> logger.info("Deleting role assignment - {}", roleAssignmentName)) .doOnSuccess(response -> logger.info("Deleted role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to delete role assignment - {}", name, error)) + .doOnError(error -> logger.warning("Failed to delete role assignment - {}", roleAssignmentName, error)) .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -549,7 +536,7 @@ private static KeyVaultRoleAssignment roleAssignmentToKeyVaultRoleAssignment(Rol return new KeyVaultRoleAssignment(roleAssignment.getId(), roleAssignment.getName(), roleAssignment.getType(), new KeyVaultRoleAssignmentProperties(propertiesWithScope.getRoleDefinitionId(), - propertiesWithScope.getPrincipalId()), KeyVaultRoleAssignmentScope.fromString(propertiesWithScope.getScope())); + propertiesWithScope.getPrincipalId()), KeyVaultRoleScope.fromString(propertiesWithScope.getScope())); } private static final class TransformedPagedResponse, T, U> implements PagedResponse { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java index 97044d618c6a2..e326ea87a6322 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java @@ -11,7 +11,7 @@ import com.azure.core.util.Context; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import reactor.core.publisher.Mono; @@ -47,168 +47,171 @@ public String getVaultUrl() { /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role * definitions}. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope) { + public PagedIterable listRoleDefinitions(KeyVaultRoleScope roleScope) { return new PagedIterable<>(asyncClient.listRoleDefinitions(roleScope, Context.NONE)); } /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role * definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, Context context) { + public PagedIterable listRoleDefinitions(KeyVaultRoleScope roleScope, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(roleScope, context)); } /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope) { + public PagedIterable listRoleAssignments(KeyVaultRoleScope roleScope) { return new PagedIterable<>(asyncClient.listRoleAssignments(roleScope, Context.NONE)); } /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * {@link KeyVaultRoleScope roleScope} and above. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, Context context) { + public PagedIterable listRoleAssignments(KeyVaultRoleScope roleScope, Context context) { return new PagedIterable<>(asyncClient.listRoleAssignments(roleScope, context)); } /** - * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. + * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link String name}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties, Context.NONE).getValue(); + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, KeyVaultRoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID().toString(), properties, Context.NONE) + .getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any + * valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, name, properties, Context.NONE).getValue(); + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any + * valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { - return asyncClient.createRoleAssignmentWithResponse(roleScope, name, properties, context).block(); + public Response createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties, Context context) { + return asyncClient.createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, context).block(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { - return getRoleAssignmentWithResponse(roleScope, name, Context.NONE).getValue(); + public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return getRoleAssignmentWithResponse(roleScope, roleAssignmentName, Context.NONE).getValue(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { - return asyncClient.getRoleAssignmentWithResponse(roleScope, name, context).block(); + public Response getRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { + return asyncClient.getRoleAssignmentWithResponse(roleScope, roleAssignmentName, context).block(); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { - return deleteRoleAssignmentWithResponse(roleScope, name, Context.NONE).getValue(); + public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName) { + return deleteRoleAssignmentWithResponse(roleScope, roleAssignmentName, Context.NONE).getValue(); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { - return asyncClient.deleteRoleAssignmentWithResponse(roleScope, name, context).block(); + public Response deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { + return asyncClient.deleteRoleAssignmentWithResponse(roleScope, roleAssignmentName, context).block(); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index bf4cc805e1c41..b0467d9b82483 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -11,7 +11,7 @@ public final class KeyVaultRoleAssignment { private final String name; private final String type; private final KeyVaultRoleAssignmentProperties properties; - private final KeyVaultRoleAssignmentScope scope; + private final KeyVaultRoleScope scope; /** * Creates a new {@link KeyVaultRoleAssignment role assignment} with the specified details. @@ -21,10 +21,10 @@ public final class KeyVaultRoleAssignment { * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. * @param properties {@link KeyVaultRoleAssignmentProperties properties} of this {@link KeyVaultRoleAssignment * role assignment}. - * @param roleScope The {@link KeyVaultRoleAssignmentScope scope} of this {@link KeyVaultRoleAssignment role + * @param roleScope The {@link KeyVaultRoleScope scope} of this {@link KeyVaultRoleAssignment role * assignment}. */ - public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, KeyVaultRoleAssignmentScope roleScope) { + public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, KeyVaultRoleScope roleScope) { this.id = id; this.name = name; this.type = type; @@ -69,11 +69,11 @@ public KeyVaultRoleAssignmentProperties getProperties() { } /** - * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentScope scope}. + * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. * - * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentScope scope}. + * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. */ - public KeyVaultRoleAssignmentScope getScope() { + public KeyVaultRoleScope getScope() { return scope; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java deleted file mode 100644 index 0356d3fde614f..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.administration.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.net.URI; - -/** - * A class that defines the scope of a role. - */ -public final class KeyVaultRoleAssignmentScope extends ExpandableStringEnum { - public static final KeyVaultRoleAssignmentScope GLOBAL = fromString("/"); - public static final KeyVaultRoleAssignmentScope KEYS = fromString("/keys"); - - /** - * Creates or finds a {@link KeyVaultRoleAssignmentScope} from its string representation. - * - * @param name A name to look for. - * @return The corresponding {@link KeyVaultRoleAssignmentScope} - */ - public static KeyVaultRoleAssignmentScope fromString(String name) { - return fromString(name, KeyVaultRoleAssignmentScope.class); - } - - /** - * Creates or finds a {@link KeyVaultRoleAssignmentScope} from its string representation. - * - * @param uri A URI to look for. - * @return The corresponding {@link KeyVaultRoleAssignmentScope} - */ - public static KeyVaultRoleAssignmentScope fromUri(URI uri) { - return fromString(uri.getRawPath(), KeyVaultRoleAssignmentScope.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java new file mode 100644 index 0000000000000..391df5993d8b3 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import com.azure.core.util.ExpandableStringEnum; + +import java.net.URI; + +/** + * A class that defines the scope of a role. + */ +public final class KeyVaultRoleScope extends ExpandableStringEnum { + public static final KeyVaultRoleScope GLOBAL = fromString("/"); + public static final KeyVaultRoleScope KEYS = fromString("/keys"); + + /** + * Creates or finds a {@link KeyVaultRoleScope} from its string representation. + * + * @param name A name to look for. + * @return The corresponding {@link KeyVaultRoleScope} + */ + public static KeyVaultRoleScope fromString(String name) { + return fromString(name, KeyVaultRoleScope.class); + } + + /** + * Creates or finds a {@link KeyVaultRoleScope} from its string representation. + * + * @param uri A URI to look for. + * @return The corresponding {@link KeyVaultRoleScope} + */ + public static KeyVaultRoleScope fromUri(URI uri) { + return fromString(uri.getRawPath(), KeyVaultRoleScope.class); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java index e8063d4ee061e..e83326de75b06 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java @@ -6,7 +6,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import java.util.ArrayList; @@ -38,13 +38,13 @@ public static void main(String[] args) { Let's get all of them. */ List roleDefinitions = new ArrayList<>(); - for (KeyVaultRoleDefinition roleDefinition : accessControlClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL)) { + for (KeyVaultRoleDefinition roleDefinition : accessControlClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL)) { roleDefinitions.add(roleDefinition); System.out.printf("Retrieved role definition with name: %s %n", roleDefinition.getName()); } // Before assigning any new roles, let's list all the current role assignments. - for (KeyVaultRoleAssignment roleAssignment : accessControlClient.listRoleAssignments(KeyVaultRoleAssignmentScope.GLOBAL)) { + for (KeyVaultRoleAssignment roleAssignment : accessControlClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL)) { System.out.printf("Retrieved role assignment with name: %s %n", roleAssignment.getName()); } @@ -61,21 +61,21 @@ See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyv KeyVaultRoleAssignmentProperties assignmentProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), servicePrincipalId); KeyVaultRoleAssignment createdRoleAssignment = - accessControlClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, assignmentProperties); + accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, assignmentProperties); System.out.printf("Created role assignment with name: %s %n", createdRoleAssignment.getName()); /* To get an existing role assignment, we'll need the 'name' property from an existing assignment. Let's use the createdAssignment from the previous example. */ KeyVaultRoleAssignment retrievedRoleAssignment = - accessControlClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdRoleAssignment.getName()); + accessControlClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, createdRoleAssignment.getName()); System.out.printf("Retrieved role assignment with name: %s %n", retrievedRoleAssignment.getName()); /* To remove a role assignment from a service principal, the role assignment must be deleted. Let's delete the createdAssignment from the previous example. */ KeyVaultRoleAssignment deletedRoleAssignment = - accessControlClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdRoleAssignment.getName()); + accessControlClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, createdRoleAssignment.getName()); System.out.printf("Deleted role assignment with name: %s %n", deletedRoleAssignment.getName()); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java index 522efde9d02b3..130c60e1d41a1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java @@ -6,7 +6,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import java.util.ArrayList; @@ -38,7 +38,7 @@ public static void main(String[] args) throws InterruptedException { Let's get all of them. */ List roleDefinitions = new ArrayList<>(); - accessControlAsyncClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL) + accessControlAsyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL) .doOnNext((roleDefinition) -> { roleDefinitions.add(roleDefinition); System.out.printf("Retrieved role definition with name: %s %n", roleDefinition.getName()); @@ -46,7 +46,7 @@ public static void main(String[] args) throws InterruptedException { .blockLast(); // Before assigning any new roles, let's get all the current role assignments. - accessControlAsyncClient.listRoleAssignments(KeyVaultRoleAssignmentScope.GLOBAL) + accessControlAsyncClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL) .doOnNext((roleAssignment -> System.out.printf("Retrieved role assignment with name: %s %n", roleAssignment.getName()))) .blockLast(); @@ -64,21 +64,21 @@ See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyv KeyVaultRoleAssignmentProperties assignmentProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), servicePrincipalId); KeyVaultRoleAssignment createdRoleAssignment = - accessControlAsyncClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, assignmentProperties) + accessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, assignmentProperties) .block(); /* To get an existing role assignment, we'll need the 'name' property from an existing assignment. Let's use the createdAssignment from the previous example. */ assert createdRoleAssignment != null; - accessControlAsyncClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdRoleAssignment.getName()) + accessControlAsyncClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, createdRoleAssignment.getName()) .doOnSuccess((retrievedRoleAssignment) -> System.out.printf("Retrieved role assignment with name: %s %n", retrievedRoleAssignment.getName())) .block(); /* To remove a role assignment from a service principal, the role assignment must be deleted. Let's delete the createdAssignment from the previous example. */ - accessControlAsyncClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdRoleAssignment.getName()) + accessControlAsyncClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, createdRoleAssignment.getName()) .doOnSuccess((deletedRoleAssignment) -> System.out.printf("Retrieved role assignment with name: %s %n", deletedRoleAssignment.getName())) .block(); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java index c604e48ac445d..2ed04f87fc643 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java @@ -6,7 +6,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; /** * This sample demonstrates how to create role assignments in the key vault for different scopes. @@ -46,7 +46,7 @@ of the role definitions returned from listRoleDefinitions(). Alternatively, you new KeyVaultRoleAssignmentProperties(roleDefinitionId, servicePrincipalId); KeyVaultRoleAssignment roleAssignmentForAllKeys = - accessControlClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentProperties); + accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentProperties); System.out.printf("Created role assignment with name: %s %n", roleAssignmentForAllKeys.getName()); @@ -56,7 +56,7 @@ of the role definitions returned from listRoleDefinitions(). Alternatively, you String keyId = ""; KeyVaultRoleAssignment roleAssignmentForSingleKey = - accessControlClient.createRoleAssignment(KeyVaultRoleAssignmentScope.fromString(keyId), + accessControlClient.createRoleAssignment(KeyVaultRoleScope.fromString(keyId), roleAssignmentProperties); System.out.printf("Created role assignment with name: %s %n", roleAssignmentForSingleKey.getName()); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java index b6279bd77894b..71cc107a81955 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java @@ -7,7 +7,7 @@ import com.azure.core.test.TestMode; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinitionProperties; import org.junit.jupiter.params.ParameterizedTest; @@ -46,7 +46,7 @@ public void listRoleDefinitions(HttpClient httpClient) { List roleDefinitions = new ArrayList<>(); - asyncClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL).subscribe(roleDefinitions::add); + asyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL).subscribe(roleDefinitions::add); assertTrue(roleDefinitions.iterator().hasNext()); @@ -82,7 +82,7 @@ public void listRoleAssignments(HttpClient httpClient) { List roleAssignments = new ArrayList<>(); - asyncClient.listRoleAssignments(KeyVaultRoleAssignmentScope.GLOBAL).subscribe(roleAssignments::add); + asyncClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL).subscribe(roleAssignments::add); sleepInLiveOrRecordMode(5000); for (KeyVaultRoleAssignment roleAssignment : roleAssignments) { @@ -114,7 +114,7 @@ public void createRoleAssignment(HttpClient httpClient) { List roleDefinitions = new ArrayList<>(); - asyncClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL).subscribe(roleDefinitions::add); + asyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL).subscribe(roleDefinitions::add); sleepInLiveOrRecordMode(5000); KeyVaultRoleDefinition roleDefinition = null; @@ -127,19 +127,19 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("d0bedeb4-7431-407d-81cd-278929c98218"); + String roleAssignmentName = "d0bedeb4-7431-407d-81cd-278929c98218"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment. KeyVaultRoleAssignment roleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties).block(); assertNotNull(roleAssignment); assertNotNull(roleAssignment.getId()); - assertEquals(roleAssignment.getName(), roleAssignmentName.toString()); + assertEquals(roleAssignment.getName(), roleAssignmentName); assertNotNull(roleAssignment.getType()); assertNotNull(roleAssignment.getScope()); @@ -153,7 +153,7 @@ public void createRoleAssignment(HttpClient httpClient) { // Clean up the role assignment. KeyVaultAccessControlAsyncClient cleanupClient = getClientBuilder(httpClient, true).buildAsyncClient(); - cleanupClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + cleanupClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); } } } @@ -174,7 +174,7 @@ public void getRoleAssignment(HttpClient httpClient) { List roleDefinitions = new ArrayList<>(); - asyncClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL).subscribe(roleDefinitions::add); + asyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL).subscribe(roleDefinitions::add); sleepInLiveOrRecordMode(5000); KeyVaultRoleDefinition roleDefinition = null; @@ -187,21 +187,21 @@ public void getRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("658d6c14-98c2-4a53-a523-be8609eb7f8b"); + String roleAssignmentName = "658d6c14-98c2-4a53-a523-be8609eb7f8b"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment to retrieve. KeyVaultRoleAssignment createdRoleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties).block(); assertNotNull(createdRoleAssignment); // Get the role assignment. KeyVaultRoleAssignment retrievedRoleAssignment = - asyncClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()) + asyncClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName) .block(); assertNotNull(retrievedRoleAssignment); @@ -220,7 +220,7 @@ public void getRoleAssignment(HttpClient httpClient) { // Clean up the role assignment. KeyVaultAccessControlAsyncClient cleanupClient = getClientBuilder(httpClient, true).buildAsyncClient(); - cleanupClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + cleanupClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); } } } @@ -241,7 +241,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { List roleDefinitions = new ArrayList<>(); - asyncClient.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL).subscribe(roleDefinitions::add); + asyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL).subscribe(roleDefinitions::add); sleepInLiveOrRecordMode(5000); KeyVaultRoleDefinition roleDefinition = null; @@ -254,21 +254,20 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("33785c35-4196-46b5-9d99-d5bcb2b9ca1d"); + String roleAssignmentName = "33785c35-4196-46b5-9d99-d5bcb2b9ca1d"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); // Create a role assignment to delete. KeyVaultRoleAssignment createdRoleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties).block(); assertNotNull(createdRoleAssignment); // Delete the role assignment. KeyVaultRoleAssignment deletedRoleAssignment = - asyncClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()).block(); - //client.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, "df0c4b30-93b9-4142-9523-ef3ec26ac99f"); + asyncClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName).block(); assertNotNull(deletedRoleAssignment); assertEquals(createdRoleAssignment.getId(), deletedRoleAssignment.getId()); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java index 4ad6dade53b47..9d265d93ba97d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java @@ -8,7 +8,7 @@ import com.azure.core.test.TestMode; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinitionProperties; import org.junit.jupiter.params.ParameterizedTest; @@ -44,7 +44,7 @@ public void listRoleDefinitions(HttpClient httpClient) { client = getClientBuilder(httpClient, false).buildClient(); PagedIterable roleDefinitions = - client.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL); + client.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); assertTrue(roleDefinitions.iterator().hasNext()); @@ -79,7 +79,7 @@ public void listRoleAssignments(HttpClient httpClient) { client = getClientBuilder(httpClient, false).buildClient(); PagedIterable roleAssignments = - client.listRoleAssignments(KeyVaultRoleAssignmentScope.GLOBAL); + client.listRoleAssignments(KeyVaultRoleScope.GLOBAL); assertTrue(roleAssignments.iterator().hasNext()); @@ -111,7 +111,7 @@ public void createRoleAssignment(HttpClient httpClient) { client = getClientBuilder(httpClient, false).buildClient(); PagedIterable roleDefinitions = - client.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL); + client.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); KeyVaultRoleDefinition roleDefinition = null; @@ -124,18 +124,18 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("d0bedeb4-7431-407d-81cd-278929c98218"); + String roleAssignmentName = "d0bedeb4-7431-407d-81cd-278929c98218"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); assertNotNull(createdRoleAssignment); assertNotNull(createdRoleAssignment.getId()); - assertEquals(createdRoleAssignment.getName(), roleAssignmentName.toString()); + assertEquals(createdRoleAssignment.getName(), roleAssignmentName); assertNotNull(createdRoleAssignment.getType()); assertNotNull(createdRoleAssignment.getScope()); @@ -149,7 +149,7 @@ public void createRoleAssignment(HttpClient httpClient) { // Clean up the role assignment. KeyVaultAccessControlClient cleanupClient = getClientBuilder(httpClient, true).buildClient(); - cleanupClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + cleanupClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); } } } @@ -169,7 +169,7 @@ public void getRoleAssignment(HttpClient httpClient) { client = getClientBuilder(httpClient, false).buildClient(); PagedIterable roleDefinitions = - client.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL); + client.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); KeyVaultRoleDefinition roleDefinition = null; @@ -181,18 +181,18 @@ public void getRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("658d6c14-98c2-4a53-a523-be8609eb7f8b"); + String roleAssignmentName = "658d6c14-98c2-4a53-a523-be8609eb7f8b"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment to retrieve. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); // Get the role assignment. KeyVaultRoleAssignment retrievedRoleAssignment = - client.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + client.getRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); assertNotNull(retrievedRoleAssignment); assertEquals(createdRoleAssignment.getId(), retrievedRoleAssignment.getId()); @@ -210,7 +210,7 @@ public void getRoleAssignment(HttpClient httpClient) { // Clean up the role assignment. KeyVaultAccessControlClient cleanupClient = getClientBuilder(httpClient, true).buildClient(); - cleanupClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + cleanupClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); } } } @@ -230,7 +230,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { client = getClientBuilder(httpClient, false).buildClient(); PagedIterable roleDefinitions = - client.listRoleDefinitions(KeyVaultRoleAssignmentScope.GLOBAL); + client.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); KeyVaultRoleDefinition roleDefinition = null; @@ -242,17 +242,17 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); - UUID roleAssignmentName = UUID.fromString("33785c35-4196-46b5-9d99-d5bcb2b9ca1d"); + String roleAssignmentName = "33785c35-4196-46b5-9d99-d5bcb2b9ca1d"; KeyVaultRoleAssignmentProperties creationProperties = new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); // Create a role assignment to delete. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); // Delete the role assignment. KeyVaultRoleAssignment deletedRoleAssignment = - client.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, roleAssignmentName.toString()); + client.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); assertNotNull(deletedRoleAssignment); assertEquals(createdRoleAssignment.getId(), deletedRoleAssignment.getId()); From 2bb49f9fe930e1693b31b934950990c3b9d90837 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 15:59:05 -0800 Subject: [PATCH 03/13] Renamed APIs for re-hydrating LROs. --- .../KeyVaultBackupAsyncClient.java | 28 ++++++++++----- .../administration/KeyVaultBackupClient.java | 34 +++++++++++++------ .../ResumeBackupAndRestore.java | 4 +-- .../ResumeBackupAndRestoreAsync.java | 4 +-- .../KeyVaultBackupAsyncClientTest.java | 4 +-- .../KeyVaultBackupClientTest.java | 4 +-- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index 016ce57dc8030..179e1e3f253cc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -255,10 +255,10 @@ private static LongRunningOperationStatus toLongRunningOperationStatus(String op * * @param jobId The operation identifier. * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link PollerFlux} polling on the {@link KeyVaultBackupOperation backup operation} status. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux getBackupOperation(String jobId) { + public PollerFlux beginBackup(String jobId) { Objects.requireNonNull(jobId, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'jobId'")); @@ -297,7 +297,7 @@ private Function, Mono beginRestore(String backupFold * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param pollingInterval The interval at which the operation status will be polled for. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code backupFolderUrl} or {@code sasToken} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -431,14 +431,14 @@ private static Mono> processRestoreOperat } /** - * Gets a pending {@link KeyVaultRestoreOperation full or selective restore operation} from the Key Vault. + * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. * * @param jobId The operation identifier. * @throws NullPointerException if the {@code jobId} is null. * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux getRestoreOperation(String jobId) { + public PollerFlux beginRestore(String jobId) { Objects.requireNonNull(jobId, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'jobId'")); @@ -479,7 +479,7 @@ private Function, Mono beginSelectiveRestore(String k * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param pollingInterval The interval at which the operation status will be polled for. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code keyName}, {@code backupFolderUrl} or {@code sasToken} are {@code * null}. */ @@ -521,6 +521,18 @@ public PollerFlux beginSelectiveRestore(String k (pollingContext) -> Mono.empty()); } + /** + * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PollerFlux beginSelectiveRestore(String jobId) { + return beginRestore(jobId); + } + /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java index 63d221657edee..0462cf54e21b2 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java @@ -71,11 +71,11 @@ public SyncPoller beginBackup(String blobStorag * * @param jobId The operation identifier. * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the backup operation status. + * @return A {@link SyncPoller} polling on the {@link KeyVaultBackupOperation backup operation} status. */ @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller getBackupOperation(String jobId) { - return asyncClient.getBackupOperation(jobId).getSyncPoller(); + public SyncPoller beginBackup(String jobId) { + return asyncClient.beginBackup(jobId).getSyncPoller(); } /** @@ -85,7 +85,7 @@ public SyncPoller getBackupOperation(String job * the blob container where the backup resides. This would be the exact value that is returned as the result of a * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. - * @return A {@link SyncPoller} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code backupFolderUrl} or {@code sasToken} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -101,7 +101,7 @@ public SyncPoller beginRestore(String backupFold * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param pollingInterval The interval at which the operation status will be polled for. - * @return A {@link SyncPoller} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code backupFolderUrl} or {@code sasToken} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -110,15 +110,15 @@ public SyncPoller beginRestore(String backupFold } /** - * Gets a pending {@link KeyVaultRestoreOperation full or selective restore operation} from the Key Vault. + * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. * * @param jobId The operation identifier. * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the restore operation status. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. */ @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller getRestoreOperation(String jobId) { - return asyncClient.getRestoreOperation(jobId).getSyncPoller(); + public SyncPoller beginRestore(String jobId) { + return asyncClient.beginRestore(jobId).getSyncPoller(); } /** @@ -130,7 +130,7 @@ public SyncPoller getRestoreOperation(String job * the blob container where the backup resides. This would be the exact value that is returned as the result of a * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code keyName}, {@code backupFolderUrl} or {@code sasToken} are {@code * null}. */ @@ -149,7 +149,7 @@ public SyncPoller beginSelectiveRestore(String k * backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. * @param pollingInterval The interval at which the operation status will be polled for. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation backup operation} status. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. * @throws NullPointerException if the {@code keyName}, {@code backupFolderUrl} or {@code sasToken} are {@code * null}. */ @@ -157,4 +157,16 @@ public SyncPoller beginSelectiveRestore(String k public SyncPoller beginSelectiveRestore(String keyName, String backupFolderUrl, String sasToken, Duration pollingInterval) { return asyncClient.beginSelectiveRestore(keyName, backupFolderUrl, sasToken, pollingInterval).getSyncPoller(); } + + /** + * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller beginSelectiveRestore(String jobId) { + return asyncClient.beginSelectiveRestore(jobId).getSyncPoller(); + } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java index c9f91e4d6b12e..e69186485c157 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java @@ -45,7 +45,7 @@ public static void main(String[] args) { /* At some later time, another client can use the persisted operation ID, check the status and retrieve the result of a previously started backup operation. */ SyncPoller anotherBackupPoller = - backupClient.getBackupOperation(backupJobId); + backupClient.beginBackup(backupJobId); anotherBackupPoller.waitForCompletion(); @@ -61,7 +61,7 @@ public static void main(String[] args) { /* Similarly to as with backup operations, you can check the status and retrieve the result of a previously started restore operation. */ SyncPoller anotherRestorePoller = - backupClient.getRestoreOperation(restoreJobId); + backupClient.beginRestore(restoreJobId); anotherRestorePoller.waitForCompletion(); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java index e2b0c2e6dea79..e4e1bd005897d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java @@ -46,7 +46,7 @@ public static void main(String[] args) { /* At some later time, another client can use the persisted operation ID, check the status and retrieve the result of a previously started backup operation. */ Mono> backupMono = - backupAsyncClient.getBackupOperation(backupJobId) + backupAsyncClient.beginBackup(backupJobId) .doOnNext(pollResponse -> { System.out.println("-----------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); @@ -65,7 +65,7 @@ public static void main(String[] args) { /* Similarly to as with backup operations, you can check the status and retrieve the result of a previously started restore operation. */ - backupAsyncClient.getRestoreOperation(restoreJobId) + backupAsyncClient.beginRestore(restoreJobId) .doOnNext(pollResponse -> { System.out.println("-----------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java index e8cac01c182bd..8f82adb259f9e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java @@ -71,7 +71,7 @@ public void getBackupStatus(HttpClient httpClient) { asyncClient.beginBackup(blobStorageUrl, sasToken); String jobId = backupPollerFlux.blockFirst().getValue().getJobId(); - PollerFlux backupStatusPollerFlux = asyncClient.getBackupOperation(jobId); + PollerFlux backupStatusPollerFlux = asyncClient.beginBackup(jobId); AsyncPollResponse backupPollResponse = backupPollerFlux.blockLast(); AsyncPollResponse backupStatusPollResponse = @@ -142,7 +142,7 @@ public void getRestoreStatus(HttpClient httpClient) { // Get job status via its ID String jobId = restorePollerFlux.blockFirst().getValue().getJobId(); - PollerFlux restoreStatusPollerFlux = asyncClient.getRestoreOperation(jobId); + PollerFlux restoreStatusPollerFlux = asyncClient.beginRestore(jobId); AsyncPollResponse restorePollResponse = restorePollerFlux.blockLast(); AsyncPollResponse restoreStatusPollResponse = diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java index 16bacdfafac6a..0117eb44944bd 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java @@ -69,7 +69,7 @@ public void getBackupStatus(HttpClient httpClient) { SyncPoller backupPoller = client.beginBackup(blobStorageUrl, sasToken); String jobId = backupPoller.poll().getValue().getJobId(); - SyncPoller backupStatusPoller = client.getBackupOperation(jobId); + SyncPoller backupStatusPoller = client.beginBackup(jobId); KeyVaultBackupOperation backupOperation = backupPoller.waitForCompletion().getValue(); KeyVaultBackupOperation backupStatusOperation = backupStatusPoller.waitForCompletion().getValue(); @@ -137,7 +137,7 @@ public void getRestoreStatus(HttpClient httpClient) { // Get job status via its ID String jobId = restorePoller.poll().getValue().getJobId(); - SyncPoller restoreStatusPoller = client.getRestoreOperation(jobId); + SyncPoller restoreStatusPoller = client.beginRestore(jobId); KeyVaultRestoreOperation restoreOperation = restorePoller.waitForCompletion().getValue(); KeyVaultRestoreOperation restoreStatusOperation = restoreStatusPoller.waitForCompletion().getValue(); From 11ee6872725eb4d52999a4aa177aeb97db44b6f6 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 16:53:06 -0800 Subject: [PATCH 04/13] Added ServiceVersion support in the clients and their builders. Internally this will not be used until some changes in the code generation tool are applied. --- .../KeyVaultAccessControlAsyncClient.java | 10 ++++-- .../KeyVaultAccessControlClientBuilder.java | 25 +++++++++++-- .../KeyVaultAdministrationServiceVersion.java | 35 +++++++++++++++++++ .../KeyVaultBackupAsyncClient.java | 10 ++++-- .../KeyVaultBackupClientBuilder.java | 24 +++++++++++-- 5 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index ce96090a4a666..b206cec6b4bf0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -67,18 +67,24 @@ public final class KeyVaultAccessControlAsyncClient { private final KeyVaultAccessControlClientImpl clientImpl; /** - * The Kay Vault URL this client is associated to. + * The Key Vault URL this client is associated to. */ private final String vaultUrl; + /** + * The Key Vault Administration Service version to use with this client. + */ + private final String serviceVersion; + /** * Package private constructor to be used by {@link KeyVaultAccessControlClientBuilder}. */ - KeyVaultAccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline) { + KeyVaultAccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline, KeyVaultAdministrationServiceVersion serviceVersion) { Objects.requireNonNull(vaultUrl, KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); this.vaultUrl = vaultUrl.toString(); + this.serviceVersion = serviceVersion.getVersion(); clientImpl = new KeyVaultAccessControlClientImplBuilder() .pipeline(httpPipeline) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java index 98278f2d16ba7..8252bc970a75d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java @@ -21,6 +21,7 @@ import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; +import com.azure.core.util.ServiceVersion; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.administration.implementation.KeyVaultCredentialPolicy; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; @@ -74,6 +75,7 @@ public final class KeyVaultAccessControlClientBuilder { private RetryPolicy retryPolicy; private Configuration configuration; private ClientOptions clientOptions; + private KeyVaultAdministrationServiceVersion serviceVersion; /** * Creates a {@link KeyVaultAccessControlClientBuilder} instance that is able to configure and construct @@ -125,8 +127,10 @@ public KeyVaultAccessControlAsyncClient buildAsyncClient() { KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); } + serviceVersion = serviceVersion != null ? serviceVersion : KeyVaultAdministrationServiceVersion.getLatest(); + if (pipeline != null) { - return new KeyVaultAccessControlAsyncClient(vaultUrl, pipeline); + return new KeyVaultAccessControlAsyncClient(vaultUrl, pipeline, serviceVersion); } // Closest to API goes first, closest to wire goes last. @@ -158,7 +162,7 @@ public KeyVaultAccessControlAsyncClient buildAsyncClient() { .httpClient(httpClient) .build(); - return new KeyVaultAccessControlAsyncClient(vaultUrl, buildPipeline); + return new KeyVaultAccessControlAsyncClient(vaultUrl, buildPipeline, serviceVersion); } /** @@ -295,13 +299,28 @@ public KeyVaultAccessControlClientBuilder retryPolicy(RetryPolicy retryPolicy) { *

More About Azure Core: Telemetry policy * * @param clientOptions the {@link ClientOptions} to be set on the client. - * @return The updated KeyVaultAccessControlClientBuilder object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. */ public KeyVaultAccessControlClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; } + /** + * Sets the {@link KeyVaultAdministrationServiceVersion} that is used when making API requests. + *

+ * If a service version is not provided, the service version that will be used will be the latest known service + * version based on the version of the client library being used. If no service version is specified, updating to a + * newer version the client library will have the result of potentially moving to a newer service version. + * + * @param serviceVersion {@link KeyVaultAdministrationServiceVersion} of the service API used when making requests. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. + */ + public KeyVaultAccessControlClientBuilder serviceVersion(KeyVaultAdministrationServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + private URL getBuildEndpoint(Configuration configuration) { if (vaultUrl != null) { return vaultUrl; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java new file mode 100644 index 0000000000000..058afaa680fba --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration; + +import com.azure.core.util.ServiceVersion; + +/** + * The versions of Azure Key Vault Administration service supported by this client library. + */ +public enum KeyVaultAdministrationServiceVersion implements ServiceVersion { + V7_0("7.0"), + V7_1("7.1"), + V7_2_PREVIEW("7.2-preview"); + + private final String version; + + KeyVaultAdministrationServiceVersion(String version) { + this.version = version; + } + + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link KeyVaultAdministrationServiceVersion}. + */ + public static KeyVaultAdministrationServiceVersion getLatest() { + return V7_2_PREVIEW; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index 179e1e3f253cc..8301145325de6 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -65,10 +65,15 @@ public final class KeyVaultBackupAsyncClient { private final KeyVaultBackupClientImpl clientImpl; /** - * The Kay Vault URL this client is associated to. + * The Key Vault URL this client is associated to. */ private final String vaultUrl; + /** + * The Key Vault Administration Service version to use with this client. + */ + private final String serviceVersion; + Duration getDefaultPollingInterval() { return DEFAULT_POLLING_INTERVAL; } @@ -76,11 +81,12 @@ Duration getDefaultPollingInterval() { /** * Package private constructor to be used by {@link KeyVaultBackupClientBuilder}. */ - KeyVaultBackupAsyncClient(URL vaultUrl, HttpPipeline httpPipeline) { + KeyVaultBackupAsyncClient(URL vaultUrl, HttpPipeline httpPipeline, KeyVaultAdministrationServiceVersion serviceVersion) { Objects.requireNonNull(vaultUrl, KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); this.vaultUrl = vaultUrl.toString(); + this.serviceVersion = serviceVersion.getVersion(); clientImpl = new KeyVaultBackupClientImplBuilder() .pipeline(httpPipeline) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java index 623e854ee85cc..5cfabc774a16c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java @@ -73,6 +73,7 @@ public final class KeyVaultBackupClientBuilder { private RetryPolicy retryPolicy; private Configuration configuration; private ClientOptions clientOptions; + private KeyVaultAdministrationServiceVersion serviceVersion; /** * Creates a {@link KeyVaultBackupClientBuilder} instance that is able to configure and construct instances of @@ -124,8 +125,10 @@ public KeyVaultBackupAsyncClient buildAsyncClient() { KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); } + serviceVersion = serviceVersion != null ? serviceVersion : KeyVaultAdministrationServiceVersion.getLatest(); + if (pipeline != null) { - return new KeyVaultBackupAsyncClient(vaultUrl, pipeline); + return new KeyVaultBackupAsyncClient(vaultUrl, pipeline, serviceVersion); } // Closest to API goes first, closest to wire goes last. @@ -157,7 +160,7 @@ public KeyVaultBackupAsyncClient buildAsyncClient() { .httpClient(httpClient) .build(); - return new KeyVaultBackupAsyncClient(vaultUrl, buildPipeline); + return new KeyVaultBackupAsyncClient(vaultUrl, buildPipeline, serviceVersion); } /** @@ -295,13 +298,28 @@ public KeyVaultBackupClientBuilder retryPolicy(RetryPolicy retryPolicy) { *

More About Azure Core: Telemetry policy * * @param clientOptions the {@link ClientOptions} to be set on the client. - * @return The updated KeyVaultBackupClientBuilder object. + * @return The updated {@link KeyVaultBackupClientBuilder} object. */ public KeyVaultBackupClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; } + /** + * Sets the {@link KeyVaultAdministrationServiceVersion} that is used when making API requests. + *

+ * If a service version is not provided, the service version that will be used will be the latest known service + * version based on the version of the client library being used. If no service version is specified, updating to a + * newer version the client library will have the result of potentially moving to a newer service version. + * + * @param serviceVersion {@link KeyVaultAdministrationServiceVersion} of the service API used when making requests. + * @return The updated {@link KeyVaultBackupClientBuilder} object. + */ + public KeyVaultBackupClientBuilder serviceVersion(KeyVaultAdministrationServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + private URL getBuildEndpoint(Configuration configuration) { if (vaultUrl != null) { return vaultUrl; From 66ab2cb6545b8288736f46362dec662fca877047 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 16:55:09 -0800 Subject: [PATCH 05/13] Annotated read-only classes with @Immutable. Added the "allowed" prefix to some KeyVaultPermission properties. Change the type of `startTime` and `endTime` in KeyVaultLongRunningOperation from Long to OffsetDateTime. --- .../models/KeyVaultBackupOperation.java | 3 +++ .../administration/models/KeyVaultError.java | 3 +++ .../models/KeyVaultLongRunningOperation.java | 23 +++++++++++------ .../models/KeyVaultPermission.java | 25 +++++++++++-------- .../models/KeyVaultRestoreOperation.java | 3 +++ .../models/KeyVaultRoleAssignment.java | 3 +++ .../KeyVaultRoleAssignmentProperties.java | 2 ++ .../models/KeyVaultRoleDefinition.java | 3 +++ .../KeyVaultRoleDefinitionProperties.java | 3 +++ 9 files changed, 49 insertions(+), 19 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java index c95a5765a6aee..14d0cc1cf746c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java @@ -3,9 +3,12 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + /** * A class that contains the details of a backup operation. */ +@Immutable public final class KeyVaultBackupOperation extends KeyVaultLongRunningOperation { private final String azureStorageBlobContainerUri; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultError.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultError.java index 16f98eba519ad..a57d6aeeaf74e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultError.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultError.java @@ -3,9 +3,12 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + /** * A class that represents an error occurred in a Key Vault operation. */ +@Immutable public final class KeyVaultError { private final String code; private final String message; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java index 0c39d6ed4231f..3953d8995f0f6 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java @@ -3,16 +3,23 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + /** * A class that contains the details of a long running operation. */ +@Immutable public class KeyVaultLongRunningOperation { private final String status; private final String statusDetails; private final KeyVaultError error; private final String jobId; - private final Long startTime; - private final Long endTime; + private final OffsetDateTime startTime; + private final OffsetDateTime endTime; /** * Creates an object containing the details of a {@link KeyVaultLongRunningOperation}. @@ -20,16 +27,16 @@ public class KeyVaultLongRunningOperation { * @param status Status of the {@link KeyVaultLongRunningOperation}. * @param statusDetails The status details of the {@link KeyVaultLongRunningOperation}. * @param error Error encountered, if any, during the {@link KeyVaultLongRunningOperation}. - * @param startTime The start time of the {@link KeyVaultLongRunningOperation} in UTC. - * @param endTime The end time of the {@link KeyVaultLongRunningOperation} in UTC. + * @param startTime The start time of the {@link KeyVaultLongRunningOperation} in seconds for the UTC timezone. + * @param endTime The end time of the {@link KeyVaultLongRunningOperation} in seconds for the UTC timezone. * @param jobId Identifier for the full {@link KeyVaultLongRunningOperation}. */ public KeyVaultLongRunningOperation(String status, String statusDetails, KeyVaultError error, String jobId, Long startTime, Long endTime) { this.status = status; this.statusDetails = statusDetails; this.error = error; - this.startTime = startTime; - this.endTime = endTime; + this.startTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(startTime), ZoneOffset.UTC); + this.endTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(endTime), ZoneOffset.UTC); this.jobId = jobId; } @@ -65,7 +72,7 @@ public KeyVaultError getError() { * * @return The start time in UTC. */ - public Long getStartTime() { + public OffsetDateTime getStartTime() { return startTime; } @@ -74,7 +81,7 @@ public Long getStartTime() { * * @return The end time in UTC. */ - public Long getEndTime() { + public OffsetDateTime getEndTime() { return endTime; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java index 4ab5eaa738342..7bcae4cdb6f35 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java @@ -3,29 +3,32 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + import java.util.List; /** * A class describing allowed and denied actions and data actions of a {@link KeyVaultRoleDefinition}. */ +@Immutable public final class KeyVaultPermission { - private final List actions; + private final List allowedActions; private final List deniedActions; - private final List dataActions; + private final List allowedDataActions; private final List deniedDataActions; /** * Creates a new {@link KeyVaultPermission} with the specified allowed and denied actions and data actions. * - * @param actions The actions this {@link KeyVaultPermission permission} allows. + * @param allowedActions The actions this {@link KeyVaultPermission permission} allows. * @param deniedActions The actions this {@link KeyVaultPermission permission} denies. - * @param dataActions The data actions this {@link KeyVaultPermission permission} allows. + * @param allowedDataActions The data actions this {@link KeyVaultPermission permission} allows. * @param deniedDataActions The data actions this {@link KeyVaultPermission permission} denies. */ - public KeyVaultPermission(List actions, List deniedActions, List dataActions, List deniedDataActions) { - this.actions = actions; + public KeyVaultPermission(List allowedActions, List deniedActions, List allowedDataActions, List deniedDataActions) { + this.allowedActions = allowedActions; this.deniedActions = deniedActions; - this.dataActions = dataActions; + this.allowedDataActions = allowedDataActions; this.deniedDataActions = deniedDataActions; } @@ -34,8 +37,8 @@ public KeyVaultPermission(List actions, List deniedActions, List * * @return The allowed actions. */ - public List getActions() { - return actions; + public List getAllowedActions() { + return allowedActions; } /** @@ -52,8 +55,8 @@ public List getDeniedActions() { * * @return The allowed data actions. */ - public List getDataActions() { - return dataActions; + public List getAllowedDataActions() { + return allowedDataActions; } /** diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java index 3949c121d48d9..29f498095f00f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java @@ -3,9 +3,12 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + /** * A class that contains the details of a restore operation. */ +@Immutable public final class KeyVaultRestoreOperation extends KeyVaultLongRunningOperation { /** * Creates an object containing the details of a {@link KeyVaultRestoreOperation}. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index b0467d9b82483..54cb371139206 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -3,9 +3,12 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + /** * A class that defines a role assignment. */ +@Immutable public final class KeyVaultRoleAssignment { private final String id; private final String name; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java index b35c645231664..a8c7be118cf2b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java @@ -3,6 +3,7 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import java.util.Objects; @@ -10,6 +11,7 @@ /** * A class that defines a role assignment's properties. */ +@Immutable public final class KeyVaultRoleAssignmentProperties { private final String roleDefinitionId; private final String principalId; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java index 832e29fc587ec..8e5ff31250ada 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java @@ -3,9 +3,12 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + /** * A class that defines a role. */ +@Immutable public final class KeyVaultRoleDefinition { private final String id; private final String name; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java index fb71bfa77954f..35163cf06ec12 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java @@ -3,11 +3,14 @@ package com.azure.security.keyvault.administration.models; +import com.azure.core.annotation.Immutable; + import java.util.List; /** * A class that defines a role definition's properties. */ +@Immutable public final class KeyVaultRoleDefinitionProperties { private final String roleName; private final String description; From 9cb2d97806db2ffde29209b89800219439d4d8a3 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 17:13:23 -0800 Subject: [PATCH 06/13] Changed the KeyVaultRoleScope enum from using URI to URL and added an overload that takes a the string representation of a URL. --- .../models/KeyVaultRoleScope.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java index 391df5993d8b3..9df45e9a0304c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java @@ -5,7 +5,8 @@ import com.azure.core.util.ExpandableStringEnum; -import java.net.URI; +import java.net.MalformedURLException; +import java.net.URL; /** * A class that defines the scope of a role. @@ -18,7 +19,7 @@ public final class KeyVaultRoleScope extends ExpandableStringEnum Date: Fri, 6 Nov 2020 17:20:37 -0800 Subject: [PATCH 07/13] Added overloads that allow passing a custom polling interval to LROs. --- .../KeyVaultBackupAsyncClient.java | 45 +++++++++++++++++-- .../administration/KeyVaultBackupClient.java | 39 ++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index 8301145325de6..ee38ded654572 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -74,7 +74,7 @@ public final class KeyVaultBackupAsyncClient { */ private final String serviceVersion; - Duration getDefaultPollingInterval() { + static Duration getDefaultPollingInterval() { return DEFAULT_POLLING_INTERVAL; } @@ -265,11 +265,24 @@ private static LongRunningOperationStatus toLongRunningOperationStatus(String op */ @ServiceMethod(returns = ReturnType.SINGLE) public PollerFlux beginBackup(String jobId) { + return beginBackup(jobId, getDefaultPollingInterval()); + } + + /** + * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link PollerFlux} polling on the {@link KeyVaultBackupOperation backup operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PollerFlux beginBackup(String jobId, Duration pollingInterval) { Objects.requireNonNull(jobId, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'jobId'")); - return new PollerFlux<>(Duration.ofSeconds(1), + return new PollerFlux<>(pollingInterval, (pollingContext) -> Mono.empty(), backupStatusPollOperation(jobId), (pollingContext, firstResponse) -> Mono.error(new RuntimeException("Cancellation is not supported")), @@ -445,11 +458,24 @@ private static Mono> processRestoreOperat */ @ServiceMethod(returns = ReturnType.SINGLE) public PollerFlux beginRestore(String jobId) { + return beginRestore(jobId, getDefaultPollingInterval()); + } + + /** + * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PollerFlux beginRestore(String jobId, Duration pollingInterval) { Objects.requireNonNull(jobId, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'jobId'")); - return new PollerFlux<>(Duration.ofSeconds(1), + return new PollerFlux<>(pollingInterval, (pollingContext) -> Mono.empty(), restoreStatusPollOperation(jobId), (pollingContext, firstResponse) -> Mono.error(new RuntimeException("Cancellation is not supported")), @@ -539,6 +565,19 @@ public PollerFlux beginSelectiveRestore(String j return beginRestore(jobId); } + /** + * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PollerFlux beginSelectiveRestore(String jobId, Duration pollingInterval) { + return beginRestore(jobId, pollingInterval); + } + /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java index 0462cf54e21b2..8df1971ac5060 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java @@ -78,6 +78,19 @@ public SyncPoller beginBackup(String jobId) { return asyncClient.beginBackup(jobId).getSyncPoller(); } + /** + * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link SyncPoller} polling on the {@link KeyVaultBackupOperation backup operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller beginBackup(String jobId, Duration pollingInterval) { + return asyncClient.beginBackup(jobId, pollingInterval).getSyncPoller(); + } + /** * Initiates a full restore of the Key Vault. * @@ -121,6 +134,19 @@ public SyncPoller beginRestore(String jobId) { return asyncClient.beginRestore(jobId).getSyncPoller(); } + /** + * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller beginRestore(String jobId, Duration pollingInterval) { + return asyncClient.beginRestore(jobId, pollingInterval).getSyncPoller(); + } + /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. @@ -169,4 +195,17 @@ public SyncPoller beginSelectiveRestore(String k public SyncPoller beginSelectiveRestore(String jobId) { return asyncClient.beginSelectiveRestore(jobId).getSyncPoller(); } + + /** + * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. + * + * @param jobId The operation identifier. + * @param pollingInterval The interval at which the operation status will be polled for. + * @throws NullPointerException if the {@code jobId} is null. + * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SyncPoller beginSelectiveRestore(String jobId, Duration pollingInterval) { + return asyncClient.beginSelectiveRestore(jobId, pollingInterval).getSyncPoller(); + } } From 4dae4b876a3f71ea0c515470707cf52d101a7677 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 18:14:25 -0800 Subject: [PATCH 08/13] Removed the use of KeyVaultRoleAssignmentProperties in clients' public APIs in favor of using the `roleDefinitionId` and `servicePrincipalId` values directly. --- .../KeyVaultAccessControlAsyncClient.java | 53 +++++++++++-------- .../KeyVaultAccessControlClient.java | 30 ++++++----- .../AccessControlHelloWorld.java | 5 +- .../AccessControlHelloWorldAsync.java | 6 +-- ...eateRoleAssignmentsForDifferentScopes.java | 9 ++-- .../KeyVaultAccessControlAsyncClientTest.java | 31 +++++------ .../KeyVaultAccessControlClientTest.java | 28 ++++------ 7 files changed, 77 insertions(+), 85 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index b206cec6b4bf0..87b08403412a0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -283,14 +283,15 @@ Mono> listRoleAssignmentsNextPage(String c * * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignment(roleScope, UUID.randomUUID().toString(), properties); + public Mono createRoleAssignment(KeyVaultRoleScope roleScope, String roleDefinitionId, String principalId) { + return createRoleAssignment(roleScope, UUID.randomUUID().toString(), roleDefinitionId, principalId); } /** @@ -300,14 +301,15 @@ public Mono createRoleAssignment(KeyVaultRoleScope roleS * create. * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any * valid UUID. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties).flatMap(FluxUtil::toMono); + public Mono createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId) { + return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, principalId).flatMap(FluxUtil::toMono); } /** @@ -317,15 +319,16 @@ public Mono createRoleAssignment(KeyVaultRoleScope roleS * create. * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any * valid UUID. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { - return withContext(context -> createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, context)); + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId) { + return withContext(context -> createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, principalId, context)); } /** @@ -335,28 +338,32 @@ public Mono> createRoleAssignmentWithResponse(K * create. * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any * valid UUID. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties, Context context) { + Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); Objects.requireNonNull(roleAssignmentName, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleAssignmentName'")); - Objects.requireNonNull(properties, + Objects.requireNonNull(principalId, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'properties'")); + "'principalId'")); + Objects.requireNonNull(roleDefinitionId, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'roleDefinitionId'")); RoleAssignmentProperties roleAssignmentProperties = new RoleAssignmentProperties() - .setRoleDefinitionId(properties.getRoleDefinitionId()) - .setPrincipalId(properties.getPrincipalId()); + .setRoleDefinitionId(roleDefinitionId) + .setPrincipalId(principalId); RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters() .setProperties(roleAssignmentProperties); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java index e326ea87a6322..e8453f3c35f11 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java @@ -110,15 +110,16 @@ public PagedIterable listRoleAssignments(KeyVaultRoleSco * * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to * create. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. - * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. + * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. + * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID().toString(), properties, Context.NONE) - .getValue(); + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, String roleDefinitionId, String principalId) { + return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID().toString(), roleDefinitionId, principalId, + Context.NONE).getValue(); } /** @@ -128,14 +129,16 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, * create. * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any * valid UUID. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return The created {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, Context.NONE).getValue(); + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId) { + return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleAssignmentName, principalId, + Context.NONE).getValue(); } /** @@ -145,7 +148,8 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, * create. * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any * valid UUID. - * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. @@ -153,8 +157,8 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, KeyVaultRoleAssignmentProperties properties, Context context) { - return asyncClient.createRoleAssignmentWithResponse(roleScope, roleAssignmentName, properties, context).block(); + public Response createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId, Context context) { + return asyncClient.createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, principalId, context).block(); } /** diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java index e83326de75b06..3b7c1be72a1ee 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java @@ -58,10 +58,9 @@ See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyv az ad signed-in-user show --query objectId */ String servicePrincipalId = ""; KeyVaultRoleDefinition roleDefinition = roleDefinitions.get(0); - KeyVaultRoleAssignmentProperties assignmentProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), servicePrincipalId); KeyVaultRoleAssignment createdRoleAssignment = - accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, assignmentProperties); + accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleDefinition.getId(), + servicePrincipalId); System.out.printf("Created role assignment with name: %s %n", createdRoleAssignment.getName()); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java index 130c60e1d41a1..0c468ded6ea19 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java @@ -61,11 +61,9 @@ See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyv az ad signed-in-user show --query objectId */ String servicePrincipalId = ""; KeyVaultRoleDefinition roleDefinition = roleDefinitions.get(0); - KeyVaultRoleAssignmentProperties assignmentProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), servicePrincipalId); KeyVaultRoleAssignment createdRoleAssignment = - accessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, assignmentProperties) - .block(); + accessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleDefinition.getId(), + servicePrincipalId).block(); /* To get an existing role assignment, we'll need the 'name' property from an existing assignment. Let's use the createdAssignment from the previous example. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java index 2ed04f87fc643..5ecd1d75f3d42 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java @@ -42,11 +42,8 @@ of the role definitions returned from listRoleDefinitions(). Alternatively, you String roleDefinitionId = ""; String servicePrincipalId = ""; - KeyVaultRoleAssignmentProperties roleAssignmentProperties = - new KeyVaultRoleAssignmentProperties(roleDefinitionId, servicePrincipalId); - KeyVaultRoleAssignment roleAssignmentForAllKeys = - accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentProperties); + accessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleDefinitionId, servicePrincipalId); System.out.printf("Created role assignment with name: %s %n", roleAssignmentForAllKeys.getName()); @@ -56,8 +53,8 @@ of the role definitions returned from listRoleDefinitions(). Alternatively, you String keyId = ""; KeyVaultRoleAssignment roleAssignmentForSingleKey = - accessControlClient.createRoleAssignment(KeyVaultRoleScope.fromString(keyId), - roleAssignmentProperties); + accessControlClient.createRoleAssignment(KeyVaultRoleScope.fromString(keyId), roleDefinitionId, + servicePrincipalId); System.out.printf("Created role assignment with name: %s %n", roleAssignmentForSingleKey.getName()); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java index 71cc107a81955..05c4d0a86f5df 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -128,14 +127,12 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "d0bedeb4-7431-407d-81cd-278929c98218"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment. KeyVaultRoleAssignment roleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, - creationProperties).block(); + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), + clientId).block(); assertNotNull(roleAssignment); assertNotNull(roleAssignment.getId()); @@ -146,8 +143,8 @@ public void createRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties properties = roleAssignment.getProperties(); assertNotNull(properties); - assertEquals(creationProperties.getPrincipalId(), properties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), properties.getRoleDefinitionId()); + assertEquals(clientId, properties.getPrincipalId()); + assertEquals(roleDefinition.getId(), properties.getRoleDefinitionId()); } finally { if (getTestMode() != TestMode.PLAYBACK) { // Clean up the role assignment. @@ -188,14 +185,12 @@ public void getRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "658d6c14-98c2-4a53-a523-be8609eb7f8b"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment to retrieve. KeyVaultRoleAssignment createdRoleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, - creationProperties).block(); + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), + clientId).block(); assertNotNull(createdRoleAssignment); @@ -213,8 +208,8 @@ public void getRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties retrievedProperties = retrievedRoleAssignment.getProperties(); assertNotNull(retrievedProperties); - assertEquals(creationProperties.getPrincipalId(), retrievedProperties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), retrievedProperties.getRoleDefinitionId()); + assertEquals(clientId, retrievedProperties.getPrincipalId()); + assertEquals(roleDefinition.getId(), retrievedProperties.getRoleDefinitionId()); } finally { if (getTestMode() != TestMode.PLAYBACK) { // Clean up the role assignment. @@ -255,13 +250,11 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "33785c35-4196-46b5-9d99-d5bcb2b9ca1d"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); // Create a role assignment to delete. KeyVaultRoleAssignment createdRoleAssignment = - asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, - creationProperties).block(); + asyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), + clientId).block(); assertNotNull(createdRoleAssignment); @@ -278,7 +271,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties retrievedProperties = deletedRoleAssignment.getProperties(); assertNotNull(retrievedProperties); - assertEquals(creationProperties.getPrincipalId(), retrievedProperties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), retrievedProperties.getRoleDefinitionId()); + assertEquals(clientId, retrievedProperties.getPrincipalId()); + assertEquals(roleDefinition.getId(), retrievedProperties.getRoleDefinitionId()); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java index 9d265d93ba97d..ad802de16919f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java @@ -14,8 +14,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import java.util.UUID; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -125,13 +123,12 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "d0bedeb4-7431-407d-81cd-278929c98218"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), + clientId); assertNotNull(createdRoleAssignment); assertNotNull(createdRoleAssignment.getId()); @@ -142,8 +139,8 @@ public void createRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties properties = createdRoleAssignment.getProperties(); assertNotNull(properties); - assertEquals(creationProperties.getPrincipalId(), properties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), properties.getRoleDefinitionId()); + assertEquals(clientId, properties.getPrincipalId()); + assertEquals(roleDefinition.getId(), properties.getRoleDefinitionId()); } finally { if (getTestMode() != TestMode.PLAYBACK) { // Clean up the role assignment. @@ -182,13 +179,12 @@ public void getRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "658d6c14-98c2-4a53-a523-be8609eb7f8b"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); try { // Create a role assignment to retrieve. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), + clientId); // Get the role assignment. KeyVaultRoleAssignment retrievedRoleAssignment = @@ -203,8 +199,8 @@ public void getRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties retrievedProperties = retrievedRoleAssignment.getProperties(); assertNotNull(retrievedProperties); - assertEquals(creationProperties.getPrincipalId(), retrievedProperties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), retrievedProperties.getRoleDefinitionId()); + assertEquals(clientId, retrievedProperties.getPrincipalId()); + assertEquals(roleDefinition.getId(), retrievedProperties.getRoleDefinitionId()); } finally { if (getTestMode() != TestMode.PLAYBACK) { // Clean up the role assignment. @@ -243,12 +239,10 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertNotNull(roleDefinition); String roleAssignmentName = "33785c35-4196-46b5-9d99-d5bcb2b9ca1d"; - KeyVaultRoleAssignmentProperties creationProperties = - new KeyVaultRoleAssignmentProperties(roleDefinition.getId(), clientId); // Create a role assignment to delete. KeyVaultRoleAssignment createdRoleAssignment = - client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, creationProperties); + client.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName, roleDefinition.getId(), clientId); // Delete the role assignment. KeyVaultRoleAssignment deletedRoleAssignment = @@ -263,7 +257,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { KeyVaultRoleAssignmentProperties retrievedProperties = deletedRoleAssignment.getProperties(); assertNotNull(retrievedProperties); - assertEquals(creationProperties.getPrincipalId(), retrievedProperties.getPrincipalId()); - assertEquals(creationProperties.getRoleDefinitionId(), retrievedProperties.getRoleDefinitionId()); + assertEquals(clientId, retrievedProperties.getPrincipalId()); + assertEquals(roleDefinition.getId(), retrievedProperties.getRoleDefinitionId()); } } From 103b3667fea5e83390eec18e23e23e8db11123d9 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 19:18:13 -0800 Subject: [PATCH 09/13] Fixed Javadoc and test issues. --- .../administration/models/KeyVaultLongRunningOperation.java | 6 ++++-- .../keyvault/administration/models/KeyVaultRoleScope.java | 1 + .../src/main/java/module-info.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java index 3953d8995f0f6..c8ef8cc2cc730 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java @@ -35,8 +35,10 @@ public KeyVaultLongRunningOperation(String status, String statusDetails, KeyVaul this.status = status; this.statusDetails = statusDetails; this.error = error; - this.startTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(startTime), ZoneOffset.UTC); - this.endTime = OffsetDateTime.ofInstant(Instant.ofEpochSecond(endTime), ZoneOffset.UTC); + this.startTime = startTime == null ? null + : OffsetDateTime.ofInstant(Instant.ofEpochSecond(startTime), ZoneOffset.UTC); + this.endTime = endTime == null ? null + : OffsetDateTime.ofInstant(Instant.ofEpochSecond(endTime), ZoneOffset.UTC); this.jobId = jobId; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java index 9df45e9a0304c..ae654c7dda0dd 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java @@ -30,6 +30,7 @@ public static KeyVaultRoleScope fromString(String name) { * * @param url A string representing a URL containing the name of the scope to look for. * @return The corresponding {@link KeyVaultRoleScope}. + * @throws MalformedURLException If the given {@link String URL String} is malformed. */ public static KeyVaultRoleScope fromUrl(String url) throws MalformedURLException { return fromString(new URL(url).getPath(), KeyVaultRoleScope.class); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index c0f6f282ab9d9..b774368e84470 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -7,6 +7,10 @@ exports com.azure.security.keyvault.administration; exports com.azure.security.keyvault.administration.models; + exports com.azure.security.keyvault.administration.implementation.models to com.azure.core; + opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.implementation.models to com.fasterxml.jackson.databind; } From 2d1bba8f99d499c4582c56b86e785c6abe2ad53f Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 6 Nov 2020 20:16:11 -0800 Subject: [PATCH 10/13] Fixed checkstyle issues. --- .../administration/KeyVaultAccessControlClientBuilder.java | 1 - .../security/keyvault/administration/KeyVaultBackupClient.java | 1 - .../AccessControlHelloWorld.java | 1 - .../AccessControlHelloWorldAsync.java | 1 - .../CreateRoleAssignmentsForDifferentScopes.java | 1 - 5 files changed, 5 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java index 8252bc970a75d..373a6af60656b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java @@ -21,7 +21,6 @@ import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; -import com.azure.core.util.ServiceVersion; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.administration.implementation.KeyVaultCredentialPolicy; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java index 8df1971ac5060..12dce860884c9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; -import com.azure.core.util.polling.PollerFlux; import com.azure.core.util.polling.SyncPoller; import com.azure.security.keyvault.administration.models.KeyVaultBackupOperation; import com.azure.security.keyvault.administration.models.KeyVaultRestoreOperation; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java index 3b7c1be72a1ee..6870ea6f34f63 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorld.java @@ -5,7 +5,6 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java index 0c468ded6ea19..c66d4004a243c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/AccessControlHelloWorldAsync.java @@ -5,7 +5,6 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import com.azure.security.keyvault.administration.models.KeyVaultRoleDefinition; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java index 5ecd1d75f3d42..d3a456822c0f9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/CreateRoleAssignmentsForDifferentScopes.java @@ -5,7 +5,6 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment; -import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties; import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; /** From c3b3072f1b2e0d541fecb3cce34cb796929c104a Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 11 Nov 2020 02:12:54 -0800 Subject: [PATCH 11/13] Applied arch board meeting and PR feedback: * Renamed parameters containing the 'Uri' suffix to 'Url'. * Changed the type of `startTime` and `endTime` in the constructor of KeyVaultLongRunningOperation and its subtypes from `Long` to `OffsetDateTime`. * Removed unnecessary versions from KeyVaultAdministrationServiceVersion. Additional changes: * Renamed `scope` in KeyVaultRoleAssignment to `roleScope` to align with the access client APIs. * Polished Javadoc --- .../KeyVaultAccessControlAsyncClient.java | 124 ++++++++---------- .../KeyVaultAccessControlClient.java | 51 ++++--- .../KeyVaultAdministrationServiceVersion.java | 2 - .../KeyVaultBackupAsyncClient.java | 24 +++- .../models/KeyVaultBackupOperation.java | 18 +-- .../models/KeyVaultLongRunningOperation.java | 22 ++-- .../models/KeyVaultRestoreOperation.java | 8 +- .../models/KeyVaultRoleAssignment.java | 11 +- .../KeyVaultRoleDefinitionProperties.java | 4 +- .../BackupAndRestoreHelloWorldAsync.java | 4 +- .../ResumeBackupAndRestoreAsync.java | 2 +- .../KeyVaultAccessControlAsyncClientTest.java | 6 +- .../KeyVaultAccessControlClientTest.java | 6 +- 13 files changed, 137 insertions(+), 145 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 87b08403412a0..feb4ad90cb7bc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -102,13 +102,12 @@ public String getVaultUrl() { /** * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope role scope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleDefinitions(KeyVaultRoleScope roleScope) { @@ -119,14 +118,13 @@ public PagedFlux listRoleDefinitions(KeyVaultRoleScope r /** * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope role scope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ PagedFlux listRoleDefinitions(KeyVaultRoleScope roleScope, Context context) { return new PagedFlux<>( @@ -136,14 +134,14 @@ PagedFlux listRoleDefinitions(KeyVaultRoleScope roleScop /** * Lists all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleScope roleScope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * for the given {@link KeyVaultRoleScope role scope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope roleScope, Context context) { Objects.requireNonNull(roleScope, @@ -173,7 +171,7 @@ Mono> listRoleDefinitionsFirstPage(String * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleScope roleScope} from the next page of results. + * for the given {@link KeyVaultRoleScope role scope} from the next page of results. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -192,12 +190,12 @@ Mono> listRoleDefinitionsNextPage(String c /** * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope role scope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleAssignments(KeyVaultRoleScope roleScope) { @@ -208,13 +206,13 @@ public PagedFlux listRoleAssignments(KeyVaultRoleScope r /** * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleScope roleScope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * {@link KeyVaultRoleScope role scope}. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ PagedFlux listRoleAssignments(KeyVaultRoleScope roleScope, Context context) { return new PagedFlux<>( @@ -223,15 +221,15 @@ PagedFlux listRoleAssignments(KeyVaultRoleScope roleScop } /** - * Lists all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at - * the given {@link KeyVaultRoleScope roleScope} and above. + * Lists all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at the given + * {@link KeyVaultRoleScope role scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * in the given {@link KeyVaultRoleScope roleScope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. + * in the given {@link KeyVaultRoleScope role scope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} is {@code null}. */ Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleScope roleScope, Context context) { Objects.requireNonNull(roleScope, @@ -254,14 +252,13 @@ Mono> listRoleAssignmentsFirstPage(String /** * Lists all {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was - * retrieved from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleScope)}. + * retrieved from a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listKeyVaultRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * for the given {@link KeyVaultRoleScope roleScope} from the first page of results. + * for the given {@link KeyVaultRoleScope role scope} from the first page of results. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { @@ -281,12 +278,11 @@ Mono> listRoleAssignmentsNextPage(String c /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated name. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope}, {@link String roleAssignmentName}, * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -297,14 +293,12 @@ public Mono createRoleAssignment(KeyVaultRoleScope roleS /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any - * valid UUID. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleAssignmentName The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope}, {@link String roleAssignmentName}, * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -315,15 +309,13 @@ public Mono createRoleAssignment(KeyVaultRoleScope roleS /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any - * valid UUID. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleAssignmentName The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope}, {@link String roleAssignmentName}, * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -334,16 +326,14 @@ public Mono> createRoleAssignmentWithResponse(K /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any - * valid UUID. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleAssignmentName The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope}, {@link String roleAssignmentName}, + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope}, {@link String roleAssignmentName}, * {@link String roleDefinitionId} or {@link String principalId} are {@code null}. */ Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId, Context context) { @@ -383,10 +373,10 @@ Mono> createRoleAssignmentWithResponse(KeyVault /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName used of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -397,11 +387,11 @@ public Mono getRoleAssignment(KeyVaultRoleScope roleScop /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -412,12 +402,12 @@ public Mono> getRoleAssignmentWithResponse(KeyV /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { @@ -444,10 +434,10 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -458,11 +448,11 @@ public Mono deleteRoleAssignment(KeyVaultRoleScope roleS /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -473,12 +463,12 @@ public Mono> deleteRoleAssignmentWithResponse(K /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are + * @throws NullPointerException if the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are * {@code null}. */ Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, Context context) { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java index e8453f3c35f11..c8cf21bb97e5f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java @@ -47,7 +47,7 @@ public String getVaultUrl() { /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role * definitions}. @@ -62,10 +62,9 @@ public PagedIterable listRoleDefinitions(KeyVaultRoleSco /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. + * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleScope roleScope}. @@ -78,9 +77,9 @@ public PagedIterable listRoleDefinitions(KeyVaultRoleSco /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} is {@code null}. @@ -92,9 +91,9 @@ public PagedIterable listRoleAssignments(KeyVaultRoleSco /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleScope roleScope} and above. + * {@link KeyVaultRoleScope role scope} and above. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleScope roleScope}. @@ -108,8 +107,7 @@ public PagedIterable listRoleAssignments(KeyVaultRoleSco /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link String name}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. @@ -125,10 +123,8 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any - * valid UUID. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleAssignmentName The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @return The created {@link KeyVaultRoleAssignment}. @@ -137,17 +133,15 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId) { - return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleAssignmentName, principalId, + return createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, principalId, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param roleAssignmentName The roleAssignmentName used to create the {@link KeyVaultRoleAssignment}. It can be any - * valid UUID. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleAssignmentName The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID for the role assignment. * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. * @param context Additional context that is passed through the HTTP pipeline during the service call. @@ -158,14 +152,15 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createRoleAssignmentWithResponse(KeyVaultRoleScope roleScope, String roleAssignmentName, String roleDefinitionId, String principalId, Context context) { - return asyncClient.createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, principalId, context).block(); + return asyncClient.createRoleAssignmentWithResponse(roleScope, roleAssignmentName, roleDefinitionId, + principalId, context).block(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. @@ -178,8 +173,8 @@ public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope roleScope, Str /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are @@ -193,8 +188,8 @@ public Response getRoleAssignmentWithResponse(KeyVaultRo /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are * {@code null}. @@ -207,8 +202,8 @@ public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope roleScope, /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param roleAssignmentName The roleAssignmentName of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}. + * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java index 058afaa680fba..a8d4d1f74ac8e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java @@ -9,8 +9,6 @@ * The versions of Azure Key Vault Administration service supported by this client library. */ public enum KeyVaultAdministrationServiceVersion implements ServiceVersion { - V7_0("7.0"), - V7_1("7.1"), V7_2_PREVIEW("7.2-preview"); private final String version; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index ee38ded654572..b988ea8afa993 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -34,6 +34,9 @@ import java.net.URL; import java.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.util.Locale; import java.util.Objects; import java.util.function.Function; @@ -222,7 +225,7 @@ private Function, Mono> backupFe return (pollingContext) -> { try { String blobContainerUri = - pollingContext.getLatestResponse().getValue().getAzureStorageBlobContainerUri(); + pollingContext.getLatestResponse().getValue().getAzureStorageBlobContainerUrl(); if (blobContainerUri == null) { return Mono.empty(); @@ -679,24 +682,26 @@ private static KeyVaultLongRunningOperation transformToLongRunningOperation( if (operation instanceof RestoreOperation) { RestoreOperation restoreOperation = (RestoreOperation) operation; - return new KeyVaultRestoreOperation(restoreOperation.getStatus(), - restoreOperation.getStatusDetails(), + return new KeyVaultRestoreOperation(restoreOperation.getStatus(), restoreOperation.getStatusDetails(), createKeyVaultErrorFromError(restoreOperation.getError()), restoreOperation.getJobId(), - restoreOperation.getStartTime(), restoreOperation.getEndTime()); + longToOffsetDateTime(restoreOperation.getStartTime()), + longToOffsetDateTime(restoreOperation.getEndTime())); } else if (operation instanceof SelectiveKeyRestoreOperation) { SelectiveKeyRestoreOperation selectiveKeyRestoreOperation = (SelectiveKeyRestoreOperation) operation; return new KeyVaultRestoreOperation(selectiveKeyRestoreOperation.getStatus(), selectiveKeyRestoreOperation.getStatusDetails(), createKeyVaultErrorFromError(selectiveKeyRestoreOperation.getError()), - selectiveKeyRestoreOperation.getJobId(), selectiveKeyRestoreOperation.getStartTime(), - selectiveKeyRestoreOperation.getEndTime()); + selectiveKeyRestoreOperation.getJobId(), + longToOffsetDateTime(selectiveKeyRestoreOperation.getStartTime()), + longToOffsetDateTime(selectiveKeyRestoreOperation.getEndTime())); } else if (operation instanceof FullBackupOperation) { FullBackupOperation fullBackupOperation = (FullBackupOperation) operation; return new KeyVaultBackupOperation(fullBackupOperation.getStatus(), fullBackupOperation.getStatusDetails(), createKeyVaultErrorFromError(fullBackupOperation.getError()), fullBackupOperation.getJobId(), - fullBackupOperation.getStartTime(), fullBackupOperation.getEndTime(), + longToOffsetDateTime(fullBackupOperation.getStartTime()), + longToOffsetDateTime(fullBackupOperation.getEndTime()), fullBackupOperation.getAzureStorageBlobContainerUri()); } else { throw new UnsupportedOperationException(); @@ -711,4 +716,9 @@ private static KeyVaultError createKeyVaultErrorFromError(Error error) { return new KeyVaultError(error.getCode(), error.getMessage(), createKeyVaultErrorFromError(error.getInnerError())); } + + private static OffsetDateTime longToOffsetDateTime(Long epochInSeconds) { + return epochInSeconds == null ? null + : OffsetDateTime.ofInstant(Instant.ofEpochSecond(epochInSeconds), ZoneOffset.UTC); + } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java index 14d0cc1cf746c..adb8dac2a396b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultBackupOperation.java @@ -5,12 +5,14 @@ import com.azure.core.annotation.Immutable; +import java.time.OffsetDateTime; + /** * A class that contains the details of a backup operation. */ @Immutable public final class KeyVaultBackupOperation extends KeyVaultLongRunningOperation { - private final String azureStorageBlobContainerUri; + private final String azureStorageBlobContainerUrl; /** * Creates an object containing the details of a {@link KeyVaultBackupOperation}. @@ -18,14 +20,14 @@ public final class KeyVaultBackupOperation extends KeyVaultLongRunningOperation * @param status Status of the {@link KeyVaultBackupOperation}. * @param statusDetails The status details of the {@link KeyVaultBackupOperation}. * @param error Error encountered, if any, during the {@link KeyVaultBackupOperation}. - * @param startTime The start time of the {@link KeyVaultBackupOperation} in UTC. - * @param endTime The end time of the {@link KeyVaultBackupOperation} in UTC. + * @param startTime The start time of the {@link KeyVaultBackupOperation}. + * @param endTime The end time of the {@link KeyVaultBackupOperation}. * @param jobId Identifier for the full {@link KeyVaultBackupOperation}. - * @param azureStorageBlobContainerUri The Azure blob storage container URI which contains the backup. + * @param azureStorageBlobContainerUrl The Azure blob storage container URI which contains the backup. */ - public KeyVaultBackupOperation(String status, String statusDetails, KeyVaultError error, String jobId, Long startTime, Long endTime, String azureStorageBlobContainerUri) { + public KeyVaultBackupOperation(String status, String statusDetails, KeyVaultError error, String jobId, OffsetDateTime startTime, OffsetDateTime endTime, String azureStorageBlobContainerUrl) { super(status, statusDetails, error, jobId, startTime, endTime); - this.azureStorageBlobContainerUri = azureStorageBlobContainerUri; + this.azureStorageBlobContainerUrl = azureStorageBlobContainerUrl; } /** @@ -33,7 +35,7 @@ public KeyVaultBackupOperation(String status, String statusDetails, KeyVaultErro * * @return The backup URI in {@link String} form. */ - public String getAzureStorageBlobContainerUri() { - return azureStorageBlobContainerUri; + public String getAzureStorageBlobContainerUrl() { + return azureStorageBlobContainerUrl; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java index c8ef8cc2cc730..d4696456175c7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultLongRunningOperation.java @@ -5,9 +5,7 @@ import com.azure.core.annotation.Immutable; -import java.time.Instant; import java.time.OffsetDateTime; -import java.time.ZoneOffset; /** * A class that contains the details of a long running operation. @@ -27,18 +25,16 @@ public class KeyVaultLongRunningOperation { * @param status Status of the {@link KeyVaultLongRunningOperation}. * @param statusDetails The status details of the {@link KeyVaultLongRunningOperation}. * @param error Error encountered, if any, during the {@link KeyVaultLongRunningOperation}. - * @param startTime The start time of the {@link KeyVaultLongRunningOperation} in seconds for the UTC timezone. - * @param endTime The end time of the {@link KeyVaultLongRunningOperation} in seconds for the UTC timezone. + * @param startTime The start time of the {@link KeyVaultLongRunningOperation}. + * @param endTime The end time of the {@link KeyVaultLongRunningOperation}. * @param jobId Identifier for the full {@link KeyVaultLongRunningOperation}. */ - public KeyVaultLongRunningOperation(String status, String statusDetails, KeyVaultError error, String jobId, Long startTime, Long endTime) { + public KeyVaultLongRunningOperation(String status, String statusDetails, KeyVaultError error, String jobId, OffsetDateTime startTime, OffsetDateTime endTime) { this.status = status; this.statusDetails = statusDetails; this.error = error; - this.startTime = startTime == null ? null - : OffsetDateTime.ofInstant(Instant.ofEpochSecond(startTime), ZoneOffset.UTC); - this.endTime = endTime == null ? null - : OffsetDateTime.ofInstant(Instant.ofEpochSecond(endTime), ZoneOffset.UTC); + this.startTime = startTime; + this.endTime = endTime; this.jobId = jobId; } @@ -70,18 +66,18 @@ public KeyVaultError getError() { } /** - * Get the start time of the {@link KeyVaultLongRunningOperation} in UTC. + * Get the start time of the {@link KeyVaultLongRunningOperation}. * - * @return The start time in UTC. + * @return The start time. */ public OffsetDateTime getStartTime() { return startTime; } /** - * Get the end time of the {@link KeyVaultLongRunningOperation} in UTC. + * Get the end time of the {@link KeyVaultLongRunningOperation}. * - * @return The end time in UTC. + * @return The end time. */ public OffsetDateTime getEndTime() { return endTime; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java index 29f498095f00f..a7e0d38575883 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRestoreOperation.java @@ -5,6 +5,8 @@ import com.azure.core.annotation.Immutable; +import java.time.OffsetDateTime; + /** * A class that contains the details of a restore operation. */ @@ -16,11 +18,11 @@ public final class KeyVaultRestoreOperation extends KeyVaultLongRunningOperation * @param status Status of the {@link KeyVaultRestoreOperation}. * @param statusDetails The status details of the {@link KeyVaultRestoreOperation}. * @param error Error encountered, if any, during the {@link KeyVaultRestoreOperation}. - * @param startTime The start time of the {@link KeyVaultRestoreOperation} in UTC. - * @param endTime The end time of the {@link KeyVaultRestoreOperation} in UTC. + * @param startTime The start time of the {@link KeyVaultRestoreOperation}. + * @param endTime The end time of the {@link KeyVaultRestoreOperation}. * @param jobId Identifier for the full {@link KeyVaultRestoreOperation}. */ - public KeyVaultRestoreOperation(String status, String statusDetails, KeyVaultError error, String jobId, Long startTime, Long endTime) { + public KeyVaultRestoreOperation(String status, String statusDetails, KeyVaultError error, String jobId, OffsetDateTime startTime, OffsetDateTime endTime) { super(status, statusDetails, error, jobId, startTime, endTime); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index 54cb371139206..b6f12bb48272e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -14,7 +14,7 @@ public final class KeyVaultRoleAssignment { private final String name; private final String type; private final KeyVaultRoleAssignmentProperties properties; - private final KeyVaultRoleScope scope; + private final KeyVaultRoleScope roleScope; /** * Creates a new {@link KeyVaultRoleAssignment role assignment} with the specified details. @@ -24,15 +24,14 @@ public final class KeyVaultRoleAssignment { * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. * @param properties {@link KeyVaultRoleAssignmentProperties properties} of this {@link KeyVaultRoleAssignment * role assignment}. - * @param roleScope The {@link KeyVaultRoleScope scope} of this {@link KeyVaultRoleAssignment role - * assignment}. + * @param roleScope The {@link KeyVaultRoleScope scope} of this {@link KeyVaultRoleAssignment role assignment}. */ public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, KeyVaultRoleScope roleScope) { this.id = id; this.name = name; this.type = type; this.properties = properties; - this.scope = roleScope; + this.roleScope = roleScope; } /** @@ -76,7 +75,7 @@ public KeyVaultRoleAssignmentProperties getProperties() { * * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. */ - public KeyVaultRoleScope getScope() { - return scope; + public KeyVaultRoleScope getRoleScope() { + return roleScope; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java index 35163cf06ec12..219e35cd60fcc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java @@ -25,8 +25,8 @@ public final class KeyVaultRoleDefinitionProperties { * @param roleName The name of the role. * @param roleDescription The description of the role. * @param roleType The type of the role. - * @param permissions The {@link KeyVaultPermission permissions} the {@link KeyVaultRoleDefinition role - * definition} has. + * @param permissions The {@link KeyVaultPermission permissions} the {@link KeyVaultRoleDefinition role definition} + * has. * @param assignableScopes The assignable scopes of the {@link KeyVaultRoleDefinition role definition}. */ public KeyVaultRoleDefinitionProperties(String roleName, String roleDescription, String roleType, List permissions, List assignableScopes) { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/BackupAndRestoreHelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/BackupAndRestoreHelloWorldAsync.java index ecb06400cdd6b..9f658cbb68105 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/BackupAndRestoreHelloWorldAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/BackupAndRestoreHelloWorldAsync.java @@ -17,7 +17,7 @@ public class BackupAndRestoreHelloWorldAsync { * @param args Unused. Arguments to the program. * @throws IllegalArgumentException when an invalid key vault URL is passed. */ - public static void main(String[] args) throws InterruptedException { + public static void main(String[] args) { /* Instantiate a KeyVaultAccessControlClient that will be used to call the service. Notice that the client is using default Azure credentials. To make default credentials work, ensure that environment variables 'AZURE_CLIENT_ID', 'AZURE_CLIENT_KEY' and 'AZURE_TENANT_ID' are set with the service principal credentials. @@ -47,7 +47,7 @@ Alternatively, it is possible to generate a SAS token in Storage Explorer (https /* Now let's restore the entire collection of keys from the backup. We will need the get the URI for the location the backup, as well as Shared Access Signature for accessing it. */ - String backupFolderUrl = backupPollResponse.getValue().getAzureStorageBlobContainerUri(); + String backupFolderUrl = backupPollResponse.getValue().getAzureStorageBlobContainerUrl(); backupAsyncClient.beginRestore(backupFolderUrl, sasToken).blockLast(); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java index e4e1bd005897d..ff852c1472735 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java @@ -56,7 +56,7 @@ public static void main(String[] args) { .last(); // Get the backup URI to begin a restore operation at some point. - String backupFolderUrl = backupMono.block().getValue().getAzureStorageBlobContainerUri(); + String backupFolderUrl = backupMono.block().getValue().getAzureStorageBlobContainerUrl(); PollerFlux originalRestorePollerFlux = backupAsyncClient.beginRestore(backupFolderUrl, sasToken); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java index 05c4d0a86f5df..3b552f831dde1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClientTest.java @@ -138,7 +138,7 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(roleAssignment.getId()); assertEquals(roleAssignment.getName(), roleAssignmentName); assertNotNull(roleAssignment.getType()); - assertNotNull(roleAssignment.getScope()); + assertNotNull(roleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties properties = roleAssignment.getProperties(); @@ -203,7 +203,7 @@ public void getRoleAssignment(HttpClient httpClient) { assertEquals(createdRoleAssignment.getId(), retrievedRoleAssignment.getId()); assertEquals(createdRoleAssignment.getName(), retrievedRoleAssignment.getName()); assertEquals(createdRoleAssignment.getType(), retrievedRoleAssignment.getType()); - assertEquals(createdRoleAssignment.getScope(), retrievedRoleAssignment.getScope()); + assertEquals(createdRoleAssignment.getRoleScope(), retrievedRoleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties retrievedProperties = retrievedRoleAssignment.getProperties(); @@ -266,7 +266,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertEquals(createdRoleAssignment.getId(), deletedRoleAssignment.getId()); assertEquals(createdRoleAssignment.getName(), deletedRoleAssignment.getName()); assertEquals(createdRoleAssignment.getType(), deletedRoleAssignment.getType()); - assertEquals(createdRoleAssignment.getScope(), deletedRoleAssignment.getScope()); + assertEquals(createdRoleAssignment.getRoleScope(), deletedRoleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties retrievedProperties = deletedRoleAssignment.getProperties(); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java index ad802de16919f..c05c1b8081a34 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientTest.java @@ -134,7 +134,7 @@ public void createRoleAssignment(HttpClient httpClient) { assertNotNull(createdRoleAssignment.getId()); assertEquals(createdRoleAssignment.getName(), roleAssignmentName); assertNotNull(createdRoleAssignment.getType()); - assertNotNull(createdRoleAssignment.getScope()); + assertNotNull(createdRoleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties properties = createdRoleAssignment.getProperties(); @@ -194,7 +194,7 @@ public void getRoleAssignment(HttpClient httpClient) { assertEquals(createdRoleAssignment.getId(), retrievedRoleAssignment.getId()); assertEquals(createdRoleAssignment.getName(), retrievedRoleAssignment.getName()); assertEquals(createdRoleAssignment.getType(), retrievedRoleAssignment.getType()); - assertEquals(createdRoleAssignment.getScope(), retrievedRoleAssignment.getScope()); + assertEquals(createdRoleAssignment.getRoleScope(), retrievedRoleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties retrievedProperties = retrievedRoleAssignment.getProperties(); @@ -252,7 +252,7 @@ public void deleteRoleAssignment(HttpClient httpClient) { assertEquals(createdRoleAssignment.getId(), deletedRoleAssignment.getId()); assertEquals(createdRoleAssignment.getName(), deletedRoleAssignment.getName()); assertEquals(createdRoleAssignment.getType(), deletedRoleAssignment.getType()); - assertEquals(createdRoleAssignment.getScope(), deletedRoleAssignment.getScope()); + assertEquals(createdRoleAssignment.getRoleScope(), deletedRoleAssignment.getRoleScope()); KeyVaultRoleAssignmentProperties retrievedProperties = deletedRoleAssignment.getProperties(); From 33b05388461012b219909402a881a27180607571 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 11 Nov 2020 02:18:49 -0800 Subject: [PATCH 12/13] Removed APIs to refresh LROs based on PR feedback. --- .../KeyVaultBackupAsyncClient.java | 131 ---------- .../administration/KeyVaultBackupClient.java | 75 ------ .../ResumeBackupAndRestore.java | 68 ----- .../ResumeBackupAndRestoreAsync.java | 82 ------ .../KeyVaultBackupAsyncClientTest.java | 75 ------ .../KeyVaultBackupClientTest.java | 64 ----- .../session-records/getBackupStatus.json | 135 ---------- .../session-records/getRestoreStatus.json | 240 ------------------ 8 files changed, 870 deletions(-) delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getBackupStatus.json delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getRestoreStatus.json diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index b988ea8afa993..ab170d67e7833 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -259,59 +259,6 @@ private static LongRunningOperationStatus toLongRunningOperationStatus(String op } } - /** - * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultBackupOperation backup operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginBackup(String jobId) { - return beginBackup(jobId, getDefaultPollingInterval()); - } - - /** - * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultBackupOperation backup operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginBackup(String jobId, Duration pollingInterval) { - Objects.requireNonNull(jobId, - String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'jobId'")); - - return new PollerFlux<>(pollingInterval, - (pollingContext) -> Mono.empty(), - backupStatusPollOperation(jobId), - (pollingContext, firstResponse) -> Mono.error(new RuntimeException("Cancellation is not supported")), - backupFetchOperation()); - } - - private Function, Mono>> backupStatusPollOperation(String jobId) { - return (pollingContext) -> { - try { - return withContext(context -> clientImpl.fullBackupStatusWithResponseAsync(vaultUrl, jobId, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) - .map(response -> - new SimpleResponse<>(response, - (KeyVaultBackupOperation) transformToLongRunningOperation(response.getValue()))) - .flatMap(KeyVaultBackupAsyncClient::processBackupOperationResponse); - } catch (HttpResponseException e) { - //noinspection ThrowableNotThrown - logger.logExceptionAsError(e); - - return Mono.just(new PollResponse<>(LongRunningOperationStatus.FAILED, null)); - } catch (RuntimeException e) { - return monoError(logger, e); - } - }; - } - /** * Initiates a full restore of the Key Vault. * @@ -452,59 +399,6 @@ private static Mono> processRestoreOperat toLongRunningOperationStatus(operationStatus.toLowerCase(Locale.US)), response.getValue())); } - /** - * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginRestore(String jobId) { - return beginRestore(jobId, getDefaultPollingInterval()); - } - - /** - * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginRestore(String jobId, Duration pollingInterval) { - Objects.requireNonNull(jobId, - String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'jobId'")); - - return new PollerFlux<>(pollingInterval, - (pollingContext) -> Mono.empty(), - restoreStatusPollOperation(jobId), - (pollingContext, firstResponse) -> Mono.error(new RuntimeException("Cancellation is not supported")), - (pollingContext) -> Mono.empty()); - } - - private Function, Mono>> restoreStatusPollOperation(String jobId) { - return (pollingContext) -> { - try { - return withContext(context -> clientImpl.restoreStatusWithResponseAsync(vaultUrl, jobId, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE))) - .map(response -> - new SimpleResponse<>(response, - (KeyVaultRestoreOperation) transformToLongRunningOperation(response.getValue()))) - .flatMap(KeyVaultBackupAsyncClient::processRestoreOperationResponse); - } catch (HttpResponseException e) { - //noinspection ThrowableNotThrown - logger.logExceptionAsError(e); - - return Mono.just(new PollResponse<>(LongRunningOperationStatus.FAILED, null)); - } catch (RuntimeException e) { - return monoError(logger, e); - } - }; - } - /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. @@ -556,31 +450,6 @@ public PollerFlux beginSelectiveRestore(String k (pollingContext) -> Mono.empty()); } - /** - * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginSelectiveRestore(String jobId) { - return beginRestore(jobId); - } - - /** - * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link PollerFlux} polling on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PollerFlux beginSelectiveRestore(String jobId, Duration pollingInterval) { - return beginRestore(jobId, pollingInterval); - } - /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java index 12dce860884c9..3f58baa9126ca 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java @@ -65,31 +65,6 @@ public SyncPoller beginBackup(String blobStorag return asyncClient.beginBackup(blobStorageUrl, sasToken, pollingInterval).getSyncPoller(); } - /** - * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} polling on the {@link KeyVaultBackupOperation backup operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginBackup(String jobId) { - return asyncClient.beginBackup(jobId).getSyncPoller(); - } - - /** - * Gets a pending {@link KeyVaultBackupOperation backup operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} polling on the {@link KeyVaultBackupOperation backup operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginBackup(String jobId, Duration pollingInterval) { - return asyncClient.beginBackup(jobId, pollingInterval).getSyncPoller(); - } - /** * Initiates a full restore of the Key Vault. * @@ -121,31 +96,6 @@ public SyncPoller beginRestore(String backupFold return asyncClient.beginRestore(backupFolderUrl, sasToken, pollingInterval).getSyncPoller(); } - /** - * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginRestore(String jobId) { - return asyncClient.beginRestore(jobId).getSyncPoller(); - } - - /** - * Gets a pending {@link KeyVaultRestoreOperation full restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginRestore(String jobId, Duration pollingInterval) { - return asyncClient.beginRestore(jobId, pollingInterval).getSyncPoller(); - } - /** * Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob * storage backup folder. @@ -182,29 +132,4 @@ public SyncPoller beginSelectiveRestore(String k public SyncPoller beginSelectiveRestore(String keyName, String backupFolderUrl, String sasToken, Duration pollingInterval) { return asyncClient.beginSelectiveRestore(keyName, backupFolderUrl, sasToken, pollingInterval).getSyncPoller(); } - - /** - * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginSelectiveRestore(String jobId) { - return asyncClient.beginSelectiveRestore(jobId).getSyncPoller(); - } - - /** - * Gets a pending {@link KeyVaultRestoreOperation selective restore operation} from the Key Vault. - * - * @param jobId The operation identifier. - * @param pollingInterval The interval at which the operation status will be polled for. - * @throws NullPointerException if the {@code jobId} is null. - * @return A {@link SyncPoller} to poll on the {@link KeyVaultRestoreOperation restore operation} status. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SyncPoller beginSelectiveRestore(String jobId, Duration pollingInterval) { - return asyncClient.beginSelectiveRestore(jobId, pollingInterval).getSyncPoller(); - } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java deleted file mode 100644 index e69186485c157..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestore.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.administration; - -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.administration.models.KeyVaultBackupOperation; -import com.azure.security.keyvault.administration.models.KeyVaultRestoreOperation; - -/** - * This sample demonstrates how to selectively restore a key from key vault backup synchronously. - */ -public class ResumeBackupAndRestore { - /** - * Authenticates with the key vault and shows how to re-hydrate long running synchronous operations such as backup - * and restore. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when an invalid key vault URL is passed. - */ - public static void main(String[] args) { - /* Instantiate a KeyVaultAccessControlClient that will be used to call the service. Notice that the client is - using default Azure credentials. To make default credentials work, ensure that environment variables - 'AZURE_CLIENT_ID', 'AZURE_CLIENT_KEY' and 'AZURE_TENANT_ID' are set with the service principal credentials. - - To get started, you'll need a URI to an Azure Key Vault. See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyvault/azure-security-keyvault-administration/README.md) - for links and instructions. */ - KeyVaultBackupClient backupClient = new KeyVaultBackupClientBuilder() - .vaultUrl("https://{YOUR_VAULT_NAME}.vault.azure.net") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - /* The ID from a started backup operation on one client can be saved to persistent storage instead of waiting - for completion immediately. */ - String blobStorageUrl = ""; - String sasToken = ""; - - SyncPoller originalBackupPoller = - backupClient.beginBackup(blobStorageUrl, sasToken); - - KeyVaultBackupOperation originalBackupOperation = originalBackupPoller.poll().getValue(); - String backupJobId = originalBackupOperation.getJobId(); - - /* At some later time, another client can use the persisted operation ID, check the status and retrieve the - result of a previously started backup operation. */ - SyncPoller anotherBackupPoller = - backupClient.beginBackup(backupJobId); - - anotherBackupPoller.waitForCompletion(); - - // Get the backup URL to begin a restore operation at some point. - String backupFolderUrl = anotherBackupPoller.getFinalResult(); - - SyncPoller originalRestorePoller = - backupClient.beginRestore(backupFolderUrl, sasToken); - - KeyVaultRestoreOperation originalRestoreOperation = originalRestorePoller.poll().getValue(); - String restoreJobId = originalRestoreOperation.getJobId(); - - /* Similarly to as with backup operations, you can check the status and retrieve the result of a previously - started restore operation. */ - SyncPoller anotherRestorePoller = - backupClient.beginRestore(restoreJobId); - - anotherRestorePoller.waitForCompletion(); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java deleted file mode 100644 index ff852c1472735..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com.azure.security.keyvault.administration/ResumeBackupAndRestoreAsync.java +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.administration; - -import com.azure.core.util.polling.AsyncPollResponse; -import com.azure.core.util.polling.PollerFlux; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.administration.models.KeyVaultBackupOperation; -import com.azure.security.keyvault.administration.models.KeyVaultRestoreOperation; -import reactor.core.publisher.Mono; - -/** - * This sample demonstrates how to selectively restore a key from key vault backup asynchronously. - */ -public class ResumeBackupAndRestoreAsync { - /** - * Authenticates with the key vault and shows how to re-hydrate long running asynchronous operations such as backup - * and restore. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when an invalid key vault URL is passed. - */ - public static void main(String[] args) { - /* Instantiate a KeyVaultAccessControlClient that will be used to call the service. Notice that the client is - using default Azure credentials. To make default credentials work, ensure that environment variables - 'AZURE_CLIENT_ID', 'AZURE_CLIENT_KEY' and 'AZURE_TENANT_ID' are set with the service principal credentials. - - To get started, you'll need a URI to an Azure Key Vault. See the README (https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/keyvault/azure-security-keyvault-administration/README.md) - for links and instructions. */ - KeyVaultBackupAsyncClient backupAsyncClient = new KeyVaultBackupClientBuilder() - .vaultUrl("https://{YOUR_VAULT_NAME}.vault.azure.net") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - /* The ID from a started backup operation on one client can be saved to persistent storage instead of waiting - for completion immediately. */ - String blobStorageUrl = ""; - String sasToken = ""; - - PollerFlux originalBackupPollerFlux = - backupAsyncClient.beginBackup(blobStorageUrl, sasToken); - - String backupJobId = originalBackupPollerFlux.blockFirst().getValue().getJobId(); - - /* At some later time, another client can use the persisted operation ID, check the status and retrieve the - result of a previously started backup operation. */ - Mono> backupMono = - backupAsyncClient.beginBackup(backupJobId) - .doOnNext(pollResponse -> { - System.out.println("-----------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }) - .last(); - - // Get the backup URI to begin a restore operation at some point. - String backupFolderUrl = backupMono.block().getValue().getAzureStorageBlobContainerUrl(); - - PollerFlux originalRestorePollerFlux = - backupAsyncClient.beginRestore(backupFolderUrl, sasToken); - - String restoreJobId = originalRestorePollerFlux.blockFirst().getValue().getJobId(); - - /* Similarly to as with backup operations, you can check the status and retrieve the result of a previously - started restore operation. */ - backupAsyncClient.beginRestore(restoreJobId) - .doOnNext(pollResponse -> { - System.out.println("-----------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }) - .blockLast(); - - /* NOTE: block(), blockFirst() and blockLast() will block until all the above operations on are completed. This - is strongly discouraged for use in production as it eliminates the benefits of asynchronous IO. It is used here - for the sake of explaining where to get the jobId and backupFolderUrl parameters and to ensure the sample runs - to completion. */ - } -} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java index 8f82adb259f9e..86b8857f51ba5 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java @@ -52,42 +52,6 @@ public void beginBackup(HttpClient httpClient) { assertTrue(backupBlobUri.startsWith(blobStorageUrl)); } - /** - * Tests that a backup operation can be obtained by using its {@code jobId}. - */ - @SuppressWarnings("ConstantConditions") - @ParameterizedTest(name = DISPLAY_NAME) - @MethodSource("com.azure.security.keyvault.administration.KeyVaultAdministrationClientTestBase#createHttpClients") - public void getBackupStatus(HttpClient httpClient) { - if (getTestMode() != TestMode.PLAYBACK) { - // Currently there is no Managed HSM environment for pipeline testing. - // TODO: Remove once there is a proper cloud environment available. - return; - } - - asyncClient = getClientBuilder(httpClient, false).buildAsyncClient(); - - PollerFlux backupPollerFlux = - asyncClient.beginBackup(blobStorageUrl, sasToken); - String jobId = backupPollerFlux.blockFirst().getValue().getJobId(); - - PollerFlux backupStatusPollerFlux = asyncClient.beginBackup(jobId); - - AsyncPollResponse backupPollResponse = backupPollerFlux.blockLast(); - AsyncPollResponse backupStatusPollResponse = - backupStatusPollerFlux.blockLast(); - - KeyVaultBackupOperation backupOperation = backupPollResponse.getValue(); - KeyVaultBackupOperation backupStatusOperation = backupStatusPollResponse.getValue(); - - String backupBlobUri = backupPollResponse.getFinalResult().block(); - String backupStatusBlobUri = backupStatusPollResponse.getFinalResult().block(); - - assertEquals(backupBlobUri, backupStatusBlobUri); - assertEquals(backupOperation.getStartTime(), backupStatusOperation.getStartTime()); - assertEquals(backupOperation.getEndTime(), backupStatusOperation.getEndTime()); - } - /** * Tests that a Key Vault can be restored from a backup. */ @@ -116,45 +80,6 @@ public void beginRestore(HttpClient httpClient) { assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, restorePollResponse.getStatus()); } - /** - * Tests that a restore operation can be obtained by using its {@code jobId}. - */ - @SuppressWarnings("ConstantConditions") - @ParameterizedTest(name = DISPLAY_NAME) - @MethodSource("com.azure.security.keyvault.administration.KeyVaultAdministrationClientTestBase#createHttpClients") - public void getRestoreStatus(HttpClient httpClient) { - if (getTestMode() != TestMode.PLAYBACK) { - // Currently there is no Managed HSM environment for pipeline testing. - // TODO: Remove once there is a proper cloud environment available. - return; - } - - asyncClient = getClientBuilder(httpClient, false).buildAsyncClient(); - - // Create a backup - AsyncPollResponse backupPollResponse = - asyncClient.beginBackup(blobStorageUrl, sasToken).blockLast(); - - // Restore the backup - String backupFolderUrl = backupPollResponse.getFinalResult().block(); - PollerFlux restorePollerFlux = - asyncClient.beginRestore(backupFolderUrl, sasToken); - - // Get job status via its ID - String jobId = restorePollerFlux.blockFirst().getValue().getJobId(); - PollerFlux restoreStatusPollerFlux = asyncClient.beginRestore(jobId); - - AsyncPollResponse restorePollResponse = restorePollerFlux.blockLast(); - AsyncPollResponse restoreStatusPollResponse = - restoreStatusPollerFlux.blockLast(); - - KeyVaultRestoreOperation backupOperation = restorePollResponse.getValue(); - KeyVaultRestoreOperation backupStatusOperation = restoreStatusPollResponse.getValue(); - - assertEquals(backupOperation.getStartTime(), backupStatusOperation.getStartTime()); - assertEquals(backupOperation.getEndTime(), backupStatusOperation.getEndTime()); - } - /** * Tests that a key can be restored from a backup. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java index 0117eb44944bd..c31cdd96a4a98 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupClientTest.java @@ -52,36 +52,6 @@ public void beginBackup(HttpClient httpClient) { assertTrue(backupBlobUri.startsWith(blobStorageUrl)); } - /** - * Tests that a backup operation can be obtained by using its {@code jobId}. - */ - @ParameterizedTest(name = DISPLAY_NAME) - @MethodSource("com.azure.security.keyvault.administration.KeyVaultAdministrationClientTestBase#createHttpClients") - public void getBackupStatus(HttpClient httpClient) { - if (getTestMode() != TestMode.PLAYBACK) { - // Currently there is no Managed HSM environment for pipeline testing. - // TODO: Remove once there is a proper cloud environment available. - return; - } - - client = getClientBuilder(httpClient, false).buildClient(); - - SyncPoller backupPoller = client.beginBackup(blobStorageUrl, sasToken); - String jobId = backupPoller.poll().getValue().getJobId(); - - SyncPoller backupStatusPoller = client.beginBackup(jobId); - - KeyVaultBackupOperation backupOperation = backupPoller.waitForCompletion().getValue(); - KeyVaultBackupOperation backupStatusOperation = backupStatusPoller.waitForCompletion().getValue(); - - String backupBlobUri = backupPoller.getFinalResult(); - String backupStatusBlobUri = backupStatusPoller.getFinalResult(); - - assertEquals(backupBlobUri, backupStatusBlobUri); - assertEquals(backupOperation.getStartTime(), backupStatusOperation.getStartTime()); - assertEquals(backupOperation.getEndTime(), backupStatusOperation.getEndTime()); - } - /** * Tests that a Key Vault can be restored from a backup. */ @@ -112,40 +82,6 @@ public void beginRestore(HttpClient httpClient) { assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, restoreResponse.getStatus()); } - /** - * Tests that a restore operation can be obtained by using its {@code jobId}. - */ - @ParameterizedTest(name = DISPLAY_NAME) - @MethodSource("com.azure.security.keyvault.administration.KeyVaultAdministrationClientTestBase#createHttpClients") - public void getRestoreStatus(HttpClient httpClient) { - if (getTestMode() != TestMode.PLAYBACK) { - // Currently there is no Managed HSM environment for pipeline testing. - // TODO: Remove once there is a proper cloud environment available. - return; - } - - client = getClientBuilder(httpClient, false).buildClient(); - - // Create a backup - SyncPoller backupPoller = client.beginBackup(blobStorageUrl, sasToken); - - backupPoller.waitForCompletion(); - - // Restore the backup - String backupFolderUrl = backupPoller.getFinalResult(); - SyncPoller restorePoller = client.beginRestore(backupFolderUrl, sasToken); - - // Get job status via its ID - String jobId = restorePoller.poll().getValue().getJobId(); - SyncPoller restoreStatusPoller = client.beginRestore(jobId); - - KeyVaultRestoreOperation restoreOperation = restorePoller.waitForCompletion().getValue(); - KeyVaultRestoreOperation restoreStatusOperation = restoreStatusPoller.waitForCompletion().getValue(); - - assertEquals(restoreOperation.getStartTime(), restoreStatusOperation.getStartTime()); - assertEquals(restoreOperation.getEndTime(), restoreStatusOperation.getEndTime()); - } - /** * Tests that a key can be restored from a backup. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getBackupStatus.json b/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getBackupStatus.json deleted file mode 100644 index 81c1d464c827b..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getBackupStatus.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 01:44:06 GMT", - "server" : "Kestrel", - "content-length" : "216", - "x-frame-options" : "SAMEORIGIN", - "retry-after" : "0", - "StatusCode" : "202", - "x-ms-server-latency" : "4663", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "5a8f20bc-eee5-11ea-bf6e-0242ac120003", - "Body" : "{\"status\":\"InProgress\",\"statusDetails\":null,\"error\":{\"code\":null,\"message\":null,\"innererror\":null},\"startTime\":1599270244,\"endTime\":null,\"jobId\":\"bff4961da63f44e0ae9cdf6924b37243\",\"azureStorageBlobContainerUri\":null}", - "azure-asyncoperation" : "https://eastus2.chriss-eu2.managedhsm-int.azure-int.net/backup/bff4961da63f44e0ae9cdf6924b37243/pending" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/bff4961da63f44e0ae9cdf6924b37243/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 01:44:07 GMT", - "server" : "Kestrel", - "content-length" : "216", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "580", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "5a8f20bc-eee5-11ea-bf6e-0242ac120003", - "Body" : "{\"azureStorageBlobContainerUri\":null,\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"bff4961da63f44e0ae9cdf6924b37243\",\"startTime\":1599270244,\"status\":\"InProgress\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/bff4961da63f44e0ae9cdf6924b37243/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 01:44:07 GMT", - "server" : "Kestrel", - "content-length" : "216", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "580", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "5a8f20bc-eee5-11ea-bf6e-0242ac120003", - "Body" : "{\"azureStorageBlobContainerUri\":null,\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"bff4961da63f44e0ae9cdf6924b37243\",\"startTime\":1599270244,\"status\":\"InProgress\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/bff4961da63f44e0ae9cdf6924b37243/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 01:44:19 GMT", - "server" : "Kestrel", - "content-length" : "263", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "461", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "5a8f20bc-eee5-11ea-bf6e-0242ac120003", - "Body" : "{\"azureStorageBlobContainerUri\":\"https://testaccount.blob.core.windows.net/backup/testKeyVault\",\"endTime\":1599270258,\"error\":null,\"jobId\":\"bff4961da63f44e0ae9cdf6924b37243\",\"startTime\":1599270244,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/bff4961da63f44e0ae9cdf6924b37243/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 01:44:19 GMT", - "server" : "Kestrel", - "content-length" : "263", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "461", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "5a8f20bc-eee5-11ea-bf6e-0242ac120003", - "Body" : "{\"azureStorageBlobContainerUri\":\"https://testaccount.blob.core.windows.net/backup/testKeyVault\",\"endTime\":1599270258,\"error\":null,\"jobId\":\"bff4961da63f44e0ae9cdf6924b37243\",\"startTime\":1599270244,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }], - "variables" : [ ] -} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getRestoreStatus.json b/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getRestoreStatus.json deleted file mode 100644 index 789a15de56dbf..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/resources/session-records/getRestoreStatus.json +++ /dev/null @@ -1,240 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:10:42 GMT", - "server" : "Kestrel", - "content-length" : "216", - "x-frame-options" : "SAMEORIGIN", - "retry-after" : "0", - "StatusCode" : "202", - "x-ms-server-latency" : "956", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"status\":\"InProgress\",\"statusDetails\":null,\"error\":{\"code\":null,\"message\":null,\"innererror\":null},\"startTime\":1599271842,\"endTime\":null,\"jobId\":\"41b6e77196cb46f8a1eafe715312d672\",\"azureStorageBlobContainerUri\":null}", - "azure-asyncoperation" : "https://eastus2.chriss-eu2.managedhsm-int.azure-int.net/backup/41b6e77196cb46f8a1eafe715312d672/pending" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/41b6e77196cb46f8a1eafe715312d672/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:10:43 GMT", - "server" : "Kestrel", - "content-length" : "216", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "669", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"azureStorageBlobContainerUri\":null,\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"41b6e77196cb46f8a1eafe715312d672\",\"startTime\":1599271842,\"status\":\"InProgress\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/backup/41b6e77196cb46f8a1eafe715312d672/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:10:52 GMT", - "server" : "Kestrel", - "content-length" : "263", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "586", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"azureStorageBlobContainerUri\":\"https://testaccount.blob.core.windows.net/backup/testKeyVault\",\"endTime\":1599271853,\"error\":null,\"jobId\":\"41b6e77196cb46f8a1eafe715312d672\",\"startTime\":1599271842,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "PUT", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:04 GMT", - "server" : "Kestrel", - "content-length" : "180", - "x-frame-options" : "SAMEORIGIN", - "retry-after" : "0", - "StatusCode" : "202", - "x-ms-server-latency" : "722", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"InProgress\",\"statusDetails\":null}", - "azure-asyncoperation" : "https://eastus2.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:06 GMT", - "server" : "Kestrel", - "content-length" : "180", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "600", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"InProgress\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:06 GMT", - "server" : "Kestrel", - "content-length" : "180", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "600", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":null,\"error\":{\"code\":null,\"innererror\":null,\"message\":null},\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"InProgress\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:23 GMT", - "server" : "Kestrel", - "content-length" : "143", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "558", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":1599271882,\"error\":null,\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:23 GMT", - "server" : "Kestrel", - "content-length" : "143", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "543", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":1599271882,\"error\":null,\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }, { - "Method" : "GET", - "Uri" : "https://REDACTED.chriss-eu2.managedhsm-int.azure-int.net/restore/39009818fe314387916f1513179d12cd/pending?api-version=7.2-preview", - "Headers" : { - "User-Agent" : "azsdk-java-client_name/client_version (11.0.6; Windows 10; 10.0)" - }, - "Response" : { - "date" : "Sat, 05 Sep 2020 02:11:23 GMT", - "server" : "Kestrel", - "content-length" : "143", - "x-frame-options" : "SAMEORIGIN", - "x-ms-build-version" : "1.0.20200904-1-42b8eab8-develop", - "retry-after" : "0", - "StatusCode" : "200", - "strict-transport-security" : "max-age=31536000; includeSubDomains", - "x-ms-server-latency" : "558", - "content-security-policy" : "default-src 'self'", - "x-content-type-options" : "nosniff", - "x-ms-keyvault-region" : "EASTUS", - "content-type" : "application/json; charset=utf-8", - "x-ms-keyvault-network-info" : "addr=174.127.169.154", - "cache-control" : "no-cache", - "x-ms-request-id" : "0a92d500-eeee-11ea-ad45-0242ac120005", - "Body" : "{\"endTime\":1599271882,\"error\":null,\"jobId\":\"39009818fe314387916f1513179d12cd\",\"startTime\":1599271865,\"status\":\"Succeeded\",\"statusDetails\":null}" - }, - "Exception" : null - }], - "variables" : [ ] -} From 08c01ce107024bedc6806f86e08568b515a0679e Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 11 Nov 2020 03:18:38 -0800 Subject: [PATCH 13/13] Removed unused import in KeyVaultBackupAsyncClientTest. --- .../keyvault/administration/KeyVaultBackupAsyncClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java index 86b8857f51ba5..0787eb497e376 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/test/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClientTest.java @@ -7,7 +7,6 @@ import com.azure.core.test.TestMode; import com.azure.core.util.polling.AsyncPollResponse; import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollerFlux; import com.azure.security.keyvault.administration.models.KeyVaultBackupOperation; import com.azure.security.keyvault.administration.models.KeyVaultRestoreOperation; import org.junit.jupiter.params.ParameterizedTest;