diff --git a/sdk/keyvault/azure-security-keyvault-keys/checkstyle-suppressions.xml b/sdk/keyvault/azure-security-keyvault-keys/checkstyle-suppressions.xml index 7366f67094446..d36abc98e84c7 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/checkstyle-suppressions.xml +++ b/sdk/keyvault/azure-security-keyvault-keys/checkstyle-suppressions.xml @@ -3,6 +3,7 @@ + diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java index b5024f5102851..c5c063693e49b 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java @@ -15,6 +15,7 @@ import com.azure.core.http.rest.PagedResponseBase; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.BinaryData; import com.azure.core.util.CoreUtils; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; @@ -26,10 +27,19 @@ import com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder; import com.azure.security.keyvault.keys.implementation.KeyClientImpl; import com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils; +import com.azure.security.keyvault.keys.implementation.models.BackupKeyResult; +import com.azure.security.keyvault.keys.implementation.models.DeletedKeyBundle; import com.azure.security.keyvault.keys.implementation.models.DeletedKeyItem; +import com.azure.security.keyvault.keys.implementation.models.GetRandomBytesRequest; +import com.azure.security.keyvault.keys.implementation.models.KeyBundle; +import com.azure.security.keyvault.keys.implementation.models.KeyCreateParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyImportParameters; import com.azure.security.keyvault.keys.implementation.models.KeyItem; -import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.keys.implementation.models.KeyReleaseParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyRestoreParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyUpdateParameters; import com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils; +import com.azure.security.keyvault.keys.implementation.models.RandomBytes; import com.azure.security.keyvault.keys.models.CreateEcKeyOptions; import com.azure.security.keyvault.keys.models.CreateKeyOptions; import com.azure.security.keyvault.keys.models.CreateOctKeyOptions; @@ -58,6 +68,7 @@ import static com.azure.core.util.FluxUtil.monoError; import static com.azure.core.util.FluxUtil.withContext; +import static com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils.EMPTY_OPTIONS; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createDeletedKey; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createKeyAttributes; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createKeyVaultKey; @@ -336,21 +347,27 @@ public Mono> createKeyWithResponse(CreateKeyOptions create return monoError(LOGGER, new NullPointerException("'createKeyOptions' cannot be null.")); } + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createKeyOptions.getKeyType()).setKeyOps(createKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createKeyOptions)) + .setTags(createKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createKeyOptions.getReleasePolicy())); + return implClient - .createKeyWithResponseAsync(vaultUrl, createKeyOptions.getName(), createKeyOptions.getKeyType(), null, - null, createKeyOptions.getKeyOperations(), createKeyAttributes(createKeyOptions), - createKeyOptions.getTags(), null, mapKeyReleasePolicy(createKeyOptions.getReleasePolicy())) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapCreateKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .createKeyWithResponseAsync(createKeyOptions.getName(), BinaryData.fromObject(keyCreateParameters), + EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapCreateKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapCreateKeyException(KeyVaultErrorException exception) { - return (exception.getResponse().getStatusCode() == 400) - ? new ResourceModifiedException(exception.getMessage(), exception.getResponse(), exception.getValue()) - : exception; + static HttpResponseException mapCreateKeyException(HttpResponseException e) { + return (e.getResponse().getStatusCode() == 400) + ? new ResourceModifiedException(e.getMessage(), e.getResponse(), e.getValue()) + : e; } /** @@ -500,13 +517,20 @@ public Mono> createRsaKeyWithResponse(CreateRsaKeyOptions return monoError(LOGGER, new NullPointerException("'createRsaKeyOptions' cannot be null.")); } + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createRsaKeyOptions.getKeyType()).setKeySize(createRsaKeyOptions.getKeySize()) + .setPublicExponent(createRsaKeyOptions.getPublicExponent()) + .setKeyOps(createRsaKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createRsaKeyOptions)) + .setTags(createRsaKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createRsaKeyOptions.getReleasePolicy())); + return implClient - .createKeyWithResponseAsync(vaultUrl, createRsaKeyOptions.getName(), createRsaKeyOptions.getKeyType(), - createRsaKeyOptions.getKeySize(), createRsaKeyOptions.getPublicExponent(), - createRsaKeyOptions.getKeyOperations(), createKeyAttributes(createRsaKeyOptions), - createRsaKeyOptions.getTags(), null, mapKeyReleasePolicy(createRsaKeyOptions.getReleasePolicy())) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapCreateKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .createKeyWithResponseAsync(createRsaKeyOptions.getName(), BinaryData.fromObject(keyCreateParameters), + EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapCreateKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -614,13 +638,19 @@ public Mono> createEcKeyWithResponse(CreateEcKeyOptions cr return monoError(LOGGER, new NullPointerException("'createEcKeyOptions' cannot be null.")); } + KeyCreateParameters keyCreateParameters = new KeyCreateParameters(createEcKeyOptions.getKeyType()) + .setKeyOps(createEcKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createEcKeyOptions)) + .setTags(createEcKeyOptions.getTags()) + .setCurve(createEcKeyOptions.getCurveName()) + .setReleasePolicy(mapKeyReleasePolicy(createEcKeyOptions.getReleasePolicy())); + return implClient - .createKeyWithResponseAsync(vaultUrl, createEcKeyOptions.getName(), createEcKeyOptions.getKeyType(), - null, null, createEcKeyOptions.getKeyOperations(), createKeyAttributes(createEcKeyOptions), - createEcKeyOptions.getTags(), createEcKeyOptions.getCurveName(), - mapKeyReleasePolicy(createEcKeyOptions.getReleasePolicy())) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapCreateKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .createKeyWithResponseAsync(createEcKeyOptions.getName(), BinaryData.fromObject(keyCreateParameters), + EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapCreateKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -719,13 +749,19 @@ public Mono> createOctKeyWithResponse(CreateOctKeyOptions return monoError(LOGGER, new NullPointerException("'createOctKeyOptions' cannot be null.")); } + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createOctKeyOptions.getKeyType()).setKeySize(createOctKeyOptions.getKeySize()) + .setKeyOps(createOctKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createOctKeyOptions)) + .setTags(createOctKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createOctKeyOptions.getReleasePolicy())); + return implClient - .createKeyWithResponseAsync(vaultUrl, createOctKeyOptions.getName(), createOctKeyOptions.getKeyType(), - createOctKeyOptions.getKeySize(), null, createOctKeyOptions.getKeyOperations(), - createKeyAttributes(createOctKeyOptions), createOctKeyOptions.getTags(), null, - mapKeyReleasePolicy(createOctKeyOptions.getReleasePolicy())) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapCreateKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .createKeyWithResponseAsync(createOctKeyOptions.getName(), BinaryData.fromObject(keyCreateParameters), + EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapCreateKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -846,12 +882,17 @@ public Mono> importKeyWithResponse(ImportKeyOptions import return monoError(LOGGER, new RuntimeException("'importKeyOptions' cannot be null.")); } + KeyImportParameters keyImportParameters = new KeyImportParameters(mapJsonWebKey(importKeyOptions.getKey())) + .setHsm(importKeyOptions.isHardwareProtected()) + .setKeyAttributes(createKeyAttributes(importKeyOptions)) + .setTags(importKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(importKeyOptions.getReleasePolicy())); + return implClient - .importKeyWithResponseAsync(vaultUrl, importKeyOptions.getName(), - mapJsonWebKey(importKeyOptions.getKey()), importKeyOptions.isHardwareProtected(), - createKeyAttributes(importKeyOptions), importKeyOptions.getTags(), - mapKeyReleasePolicy(importKeyOptions.getReleasePolicy())) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .importKeyWithResponseAsync(importKeyOptions.getName(), BinaryData.fromObject(keyImportParameters), + EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -926,14 +967,27 @@ public Mono getKey(String name, String version) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getKeyWithResponse(String name, String version) { try { - return implClient.getKeyWithResponseAsync(vaultUrl, name, version) - .onErrorMap(KeyVaultErrorException.class, KeyVaultKeysUtils::mapGetKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + return implClient.getKeyWithResponseAsync(name, version, EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapGetKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } + /** + * Maps a {@link HttpResponseException} to an {@link HttpResponseException} for get key operations. + * + * @param e The {@link HttpResponseException} to map. + * @return The {@link HttpResponseException} that maps from the {@link HttpResponseException}. + */ + public static HttpResponseException mapGetKeyException(HttpResponseException e) { + return e.getResponse().getStatusCode() == 403 + ? new ResourceModifiedException(e.getMessage(), e.getResponse(), e.getValue()) + : e; + } + /** * Gets the public part of the specified {@link KeyVaultKey key} and key version. The get key operation is * applicable to all {@link KeyType key types} and it requires the {@code keys/get} permission. @@ -1009,16 +1063,23 @@ public Mono getKey(String name) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateKeyPropertiesWithResponse(KeyProperties keyProperties, KeyOperation... keyOperations) { + try { if (keyProperties == null) { return monoError(LOGGER, new NullPointerException("'keyProperties' cannot be null.")); } + KeyUpdateParameters keyUpdateParameters + = new KeyUpdateParameters().setKeyOps(keyOperations == null ? null : Arrays.asList(keyOperations)) + .setKeyAttributes(createKeyAttributes(keyProperties)) + .setTags(keyProperties.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(keyProperties.getReleasePolicy())); + return implClient - .updateKeyWithResponseAsync(vaultUrl, keyProperties.getName(), keyProperties.getVersion(), - keyOperations == null ? null : Arrays.asList(keyOperations), createKeyAttributes(keyProperties), - keyProperties.getTags(), mapKeyReleasePolicy(keyProperties.getReleasePolicy())) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + .updateKeyWithResponseAsync(keyProperties.getName(), keyProperties.getVersion(), + BinaryData.fromObject(keyUpdateParameters), EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -1107,23 +1168,16 @@ public PollerFlux beginDeleteKey(String name) { } private Function, Mono> deleteActivationOperation(String name) { - return pollingContext -> implClient.deleteKeyAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapDeleteKeyException) - .map(KeyVaultKeysModelsUtils::createDeletedKey); - } - - static HttpResponseException mapDeleteKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; + return pollingContext -> implClient.deleteKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> createDeletedKey(response.getValue().toObject(DeletedKeyBundle.class))); } private Function, Mono>> deletePollOperation(String name) { - return pollingContext -> implClient.getDeletedKeyAsync(vaultUrl, name) - .map(bundle -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createDeletedKey(bundle))) - .onErrorResume(HttpResponseException.class, ex -> { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return pollingContext -> implClient.getDeletedKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, + createDeletedKey(response.getValue().toObject(DeletedKeyBundle.class)))) + .onErrorResume(HttpResponseException.class, e -> { + if (e.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Mono.just(new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, pollingContext.getLatestResponse().getValue())); } else { @@ -1196,20 +1250,14 @@ public Mono getDeletedKey(String name) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDeletedKeyWithResponse(String name) { try { - return implClient.getDeletedKeyWithResponseAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapGetDeletedKeyException) - .map(response -> new SimpleResponse<>(response, createDeletedKey(response.getValue()))); + return implClient.getDeletedKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + createDeletedKey(response.getValue().toObject(DeletedKeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapGetDeletedKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Permanently deletes the specified {@link KeyVaultKey key} without the possibility of recovery. The purge * deleted key operation is applicable for soft-delete enabled vaults. This operation requires the @@ -1265,19 +1313,12 @@ public Mono purgeDeletedKey(String name) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> purgeDeletedKeyWithResponse(String name) { try { - return implClient.purgeDeletedKeyWithResponseAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapPurgeDeletedKeyException); + return implClient.purgeDeletedKeyWithResponseAsync(name, EMPTY_OPTIONS); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapPurgeDeletedKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Recovers the {@link KeyVaultKey deleted key} in the key vault to its latest version and can only be performed * on a soft-delete enabled vault. An attempt to recover an {@link KeyVaultKey non-deleted key} will return an @@ -1312,24 +1353,18 @@ public PollerFlux beginRecoverDeletedKey(String name) { } private Function, Mono> recoverActivationOperation(String name) { - return pollingContext -> implClient.recoverDeletedKeyAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapRecoverDeletedKeyException) - .map(KeyVaultKeysModelsUtils::createKeyVaultKey); - } - - static HttpResponseException mapRecoverDeletedKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; + return pollingContext -> implClient.recoverDeletedKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> KeyVaultKeysModelsUtils.createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } private Function, Mono>> recoverPollOperation(String keyName) { - return pollingContext -> implClient.getKeyAsync(vaultUrl, keyName, null) - .map(keyResponse -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createKeyVaultKey(keyResponse))) - .onErrorResume(KeyVaultErrorException.class, ex -> { - if (ex.getResponse().getStatusCode() == 404) { + + return pollingContext -> implClient.getKeyWithResponseAsync(keyName, null, EMPTY_OPTIONS) + .map(response -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))) + .onErrorResume(HttpResponseException.class, e -> { + if (e.getResponse().getStatusCode() == 404) { return Mono.just(new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, pollingContext.getLatestResponse().getValue())); } else { @@ -1418,20 +1453,14 @@ public Mono backupKey(String name) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> backupKeyWithResponse(String name) { try { - return implClient.backupKeyWithResponseAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapBackupKeyException) - .map(response -> new SimpleResponse<>(response, response.getValue().getValue())); + return implClient.backupKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + response.getValue().toObject(BackupKeyResult.class).getValue())); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapBackupKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Restores a backed up {@link KeyVaultKey key} to a vault. Imports a previously backed up {@link KeyVaultKey key} * into Azure Key Vault, restoring the {@link KeyVaultKey key}, its key identifier, attributes and access control @@ -1507,18 +1536,21 @@ public Mono restoreKeyBackup(byte[] backup) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> restoreKeyBackupWithResponse(byte[] backup) { try { - return implClient.restoreKeyWithResponseAsync(vaultUrl, backup) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapRestoreKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + KeyRestoreParameters keyRestoreParameters = new KeyRestoreParameters(backup); + + return implClient.restoreKeyWithResponseAsync(BinaryData.fromObject(keyRestoreParameters), EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapRestoreKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapRestoreKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 400) - ? new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; + static HttpResponseException mapRestoreKeyException(HttpResponseException e) { + return (e.getResponse().getStatusCode() == 400) + ? new ResourceModifiedException(e.getMessage(), e.getResponse(), e.getValue()) + : e; } /** @@ -1549,21 +1581,26 @@ static HttpResponseException mapRestoreKeyException(KeyVaultErrorException ex) { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listPropertiesOfKeys() { - return new PagedFlux<>( - maxResults -> implClient.getKeysSinglePageAsync(vaultUrl, maxResults) - .map(KeyAsyncClient::mapKeyItemPagedResponse), - (continuationToken, maxResults) -> implClient.getKeysNextSinglePageAsync(continuationToken, vaultUrl) - .map(KeyAsyncClient::mapKeyItemPagedResponse)); + PagedFlux pagedFlux = implClient.getKeysAsync(EMPTY_OPTIONS); + + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> pagedResponseFlux = (continuationTokenParam == null) + ? pagedFlux.byPage().take(1) + : pagedFlux.byPage(continuationTokenParam).take(1); + + return pagedResponseFlux.map(pagedResponse -> mapPagedResponse(pagedResponse, + binaryData -> KeyVaultKeysModelsUtils.createKeyProperties(binaryData.toObject(KeyItem.class)))); + }); } - static PagedResponse mapKeyItemPagedResponse(PagedResponse page) { - List properties = new ArrayList<>(page.getValue().size()); + private static PagedResponse mapPagedResponse(PagedResponse page, Function itemMapper) { + List mappedValues = new ArrayList<>(page.getValue().size()); - for (KeyItem keyItem : page.getValue()) { - properties.add(KeyVaultKeysModelsUtils.createKeyProperties(keyItem)); + for (T item : page.getValue()) { + mappedValues.add(itemMapper.apply(item)); } - return new PagedResponseBase<>(page.getRequest(), page.getStatusCode(), page.getHeaders(), properties, + return new PagedResponseBase<>(page.getRequest(), page.getStatusCode(), page.getHeaders(), mappedValues, page.getContinuationToken(), null); } @@ -1589,22 +1626,16 @@ static PagedResponse mapKeyItemPagedResponse(PagedResponse listDeletedKeys() { - return new PagedFlux<>( - maxResults -> implClient.getDeletedKeysSinglePageAsync(vaultUrl, maxResults) - .map(KeyAsyncClient::mapDeletedKeyItemPagedResponse), - (continuationToken, maxResults) -> implClient.getDeletedKeysNextSinglePageAsync(continuationToken, vaultUrl) - .map(KeyAsyncClient::mapDeletedKeyItemPagedResponse)); - } + PagedFlux pagedFlux = implClient.getDeletedKeysAsync(EMPTY_OPTIONS); - static PagedResponse mapDeletedKeyItemPagedResponse(PagedResponse page) { - List properties = new ArrayList<>(page.getValue().size()); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> pagedResponseFlux = (continuationTokenParam == null) + ? pagedFlux.byPage().take(1) + : pagedFlux.byPage(continuationTokenParam).take(1); - for (DeletedKeyItem keyItem : page.getValue()) { - properties.add(KeyVaultKeysModelsUtils.createDeletedKey(keyItem)); - } - - return new PagedResponseBase<>(page.getRequest(), page.getStatusCode(), page.getHeaders(), properties, - page.getContinuationToken(), null); + return pagedResponseFlux.map(pagedResponse -> mapPagedResponse(pagedResponse, + binaryData -> createDeletedKey(binaryData.toObject(DeletedKeyItem.class)))); + }); } /** @@ -1639,11 +1670,16 @@ static PagedResponse mapDeletedKeyItemPagedResponse(PagedResponse listPropertiesOfKeyVersions(String name) { - return new PagedFlux<>( - maxResults -> implClient.getKeyVersionsSinglePageAsync(vaultUrl, name, maxResults) - .map(KeyAsyncClient::mapKeyItemPagedResponse), - (continuationToken, maxResults) -> implClient.getKeyVersionsNextSinglePageAsync(continuationToken, vaultUrl) - .map(KeyAsyncClient::mapKeyItemPagedResponse)); + PagedFlux pagedFlux = implClient.getKeyVersionsAsync(name, EMPTY_OPTIONS); + + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> pagedResponseFlux = (continuationTokenParam == null) + ? pagedFlux.byPage().take(1) + : pagedFlux.byPage(continuationTokenParam).take(1); + + return pagedResponseFlux.map(pagedResponse -> mapPagedResponse(pagedResponse, + binaryData -> KeyVaultKeysModelsUtils.createKeyProperties(binaryData.toObject(KeyItem.class)))); + }); } /** @@ -1693,8 +1729,12 @@ public Mono getRandomBytes(int count) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRandomBytesWithResponse(int count) { try { - return withContext(context -> implClient.getRandomBytesWithResponseAsync(vaultUrl, count)) - .map(response -> new SimpleResponse<>(response, response.getValue().getValue())); + GetRandomBytesRequest getRandomBytesRequest = new GetRandomBytesRequest(count); + + return withContext(context -> implClient + .getRandomBytesWithResponseAsync(BinaryData.fromObject(getRandomBytesRequest), EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + response.getValue().toObject(RandomBytes.class).getValue()))); } catch (RuntimeException e) { return monoError(LOGGER, e); } @@ -1808,6 +1848,7 @@ public Mono releaseKey(String name, String version, String tar @ServiceMethod(returns = ReturnType.SINGLE) public Mono> releaseKeyWithResponse(String name, String version, String targetAttestationToken, ReleaseKeyOptions releaseKeyOptions) { + try { if (CoreUtils.isNullOrEmpty(name) || CoreUtils.isNullOrEmpty(targetAttestationToken)) { return monoError(LOGGER, @@ -1818,20 +1859,18 @@ public Mono> releaseKeyWithResponse(String name, Stri KeyExportEncryptionAlgorithm algorithm = releaseKeyOptions == null ? null : releaseKeyOptions.getAlgorithm(); + KeyReleaseParameters keyReleaseParameters + = new KeyReleaseParameters(targetAttestationToken).setNonce(nonce).setEnc(algorithm); + return implClient - .releaseWithResponseAsync(vaultUrl, name, version, targetAttestationToken, nonce, algorithm) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapReleaseKeyException); + .releaseWithResponseAsync(name, version, BinaryData.fromObject(keyReleaseParameters), EMPTY_OPTIONS) + .map(binaryData -> new SimpleResponse<>(binaryData, + binaryData.getValue().toObject(ReleaseKeyResult.class))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapReleaseKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Rotates a {@link KeyVaultKey key}. The rotate key operation will do so based on * {@link KeyRotationPolicy key's rotation policy}. This operation requires the {@code keys/rotate} permission. @@ -1889,20 +1928,14 @@ public Mono rotateKey(String name) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rotateKeyWithResponse(String name) { try { - return implClient.rotateKeyWithResponseAsync(vaultUrl, name) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapRotateKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + return implClient.rotateKeyWithResponseAsync(name, EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapRotateKeyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Gets the {@link KeyRotationPolicy} for the {@link KeyVaultKey key} with the provided name. This operation * requires the {@code keys/get} permission. @@ -1960,20 +1993,14 @@ public Mono getKeyRotationPolicy(String keyName) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getKeyRotationPolicyWithResponse(String keyName) { try { - return implClient.getKeyRotationPolicyWithResponseAsync(vaultUrl, keyName) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapGetKeyRotationPolicyException) - .map(response -> new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue()))); + return implClient.getKeyRotationPolicyWithResponseAsync(keyName, EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue() + .toObject(com.azure.security.keyvault.keys.implementation.models.KeyRotationPolicy.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - static HttpResponseException mapGetKeyRotationPolicyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - /** * Updates the {@link KeyRotationPolicy} of the key with the provided name. This operation requires the * {@code keys/update} permission. @@ -2060,18 +2087,14 @@ public Mono updateKeyRotationPolicy(String keyName, KeyRotati public Mono> updateKeyRotationPolicyWithResponse(String keyName, KeyRotationPolicy keyRotationPolicy) { try { + return implClient - .updateKeyRotationPolicyWithResponseAsync(vaultUrl, keyName, mapKeyRotationPolicy(keyRotationPolicy)) - .onErrorMap(KeyVaultErrorException.class, KeyAsyncClient::mapUpdateKeyRotationPolicyException) - .map(response -> new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue()))); + .updateKeyRotationPolicyWithResponseAsync(keyName, + BinaryData.fromObject(mapKeyRotationPolicy(keyRotationPolicy)), EMPTY_OPTIONS) + .map(response -> new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue() + .toObject(com.azure.security.keyvault.keys.implementation.models.KeyRotationPolicy.class)))); } catch (RuntimeException e) { return monoError(LOGGER, e); } } - - static HttpResponseException mapUpdateKeyRotationPolicyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java index 14c7f6e48fb16..dc7fe0429af09 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java @@ -11,8 +11,10 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.HttpPipeline; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; @@ -26,8 +28,16 @@ import com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils; import com.azure.security.keyvault.keys.implementation.models.BackupKeyResult; import com.azure.security.keyvault.keys.implementation.models.DeletedKeyBundle; +import com.azure.security.keyvault.keys.implementation.models.DeletedKeyItem; +import com.azure.security.keyvault.keys.implementation.models.GetRandomBytesRequest; import com.azure.security.keyvault.keys.implementation.models.KeyBundle; -import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.keys.implementation.models.KeyCreateParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyImportParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyItem; +import com.azure.security.keyvault.keys.implementation.models.KeyReleaseParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyRestoreParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyUpdateParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils; import com.azure.security.keyvault.keys.implementation.models.RandomBytes; import com.azure.security.keyvault.keys.models.CreateEcKeyOptions; import com.azure.security.keyvault.keys.models.CreateKeyOptions; @@ -51,8 +61,7 @@ import java.util.Arrays; import java.util.function.Function; -import static com.azure.security.keyvault.keys.KeyAsyncClient.mapDeletedKeyItemPagedResponse; -import static com.azure.security.keyvault.keys.KeyAsyncClient.mapKeyItemPagedResponse; +import static com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils.EMPTY_OPTIONS; import static com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils.callWithMappedException; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createDeletedKey; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createKeyAttributes; @@ -368,13 +377,19 @@ public Response createKeyWithResponse(CreateKeyOptions createKeyOpt throw LOGGER.logExceptionAsError(new NullPointerException("'createKeyOptions' cannot be null.")); } - Response response = callWithMappedException( - () -> implClient.createKeyWithResponse(vaultUrl, createKeyOptions.getName(), createKeyOptions.getKeyType(), - null, null, createKeyOptions.getKeyOperations(), createKeyAttributes(createKeyOptions), - createKeyOptions.getTags(), null, mapKeyReleasePolicy(createKeyOptions.getReleasePolicy()), context), + KeyCreateParameters keyCreateParameters = new KeyCreateParameters(createKeyOptions.getKeyType()) + .setKeyAttributes(createKeyAttributes(createKeyOptions)) + .setKeyOps(createKeyOptions.getKeyOperations()) + .setReleasePolicy(mapKeyReleasePolicy(createKeyOptions.getReleasePolicy())) + .setTags(createKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createKeyOptions.getReleasePolicy())); + + Response response = callWithMappedException( + () -> implClient.createKeyWithResponse(createKeyOptions.getName(), + BinaryData.fromObject(keyCreateParameters), new RequestOptions().setContext(context)), KeyAsyncClient::mapCreateKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -470,15 +485,20 @@ public Response createRsaKeyWithResponse(CreateRsaKeyOptions create throw LOGGER.logExceptionAsError(new NullPointerException("'createRsaKeyOptions' cannot be null.")); } - Response response = callWithMappedException( - () -> implClient.createKeyWithResponse(vaultUrl, createRsaKeyOptions.getName(), - createRsaKeyOptions.getKeyType(), createRsaKeyOptions.getKeySize(), - createRsaKeyOptions.getPublicExponent(), createRsaKeyOptions.getKeyOperations(), - createKeyAttributes(createRsaKeyOptions), createRsaKeyOptions.getTags(), null, - mapKeyReleasePolicy(createRsaKeyOptions.getReleasePolicy()), context), + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createRsaKeyOptions.getKeyType()).setKeySize(createRsaKeyOptions.getKeySize()) + .setPublicExponent(createRsaKeyOptions.getPublicExponent()) + .setKeyOps(createRsaKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createRsaKeyOptions)) + .setTags(createRsaKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createRsaKeyOptions.getReleasePolicy())); + + Response response = callWithMappedException( + () -> implClient.createKeyWithResponse(createRsaKeyOptions.getName(), + BinaryData.fromObject(keyCreateParameters), new RequestOptions().setContext(context)), KeyAsyncClient::mapCreateKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -577,14 +597,19 @@ public Response createEcKeyWithResponse(CreateEcKeyOptions createEc throw LOGGER.logExceptionAsError(new NullPointerException("'createEcKeyOptions' cannot be null.")); } - Response response = callWithMappedException( - () -> implClient.createKeyWithResponse(vaultUrl, createEcKeyOptions.getName(), - createEcKeyOptions.getKeyType(), null, null, createEcKeyOptions.getKeyOperations(), - createKeyAttributes(createEcKeyOptions), createEcKeyOptions.getTags(), - createEcKeyOptions.getCurveName(), mapKeyReleasePolicy(createEcKeyOptions.getReleasePolicy()), context), + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createEcKeyOptions.getKeyType()).setKeyOps(createEcKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createEcKeyOptions)) + .setTags(createEcKeyOptions.getTags()) + .setCurve(createEcKeyOptions.getCurveName()) + .setReleasePolicy(mapKeyReleasePolicy(createEcKeyOptions.getReleasePolicy())); + + Response response = callWithMappedException( + () -> implClient.createKeyWithResponse(createEcKeyOptions.getName(), + BinaryData.fromObject(keyCreateParameters), new RequestOptions().setContext(context)), KeyAsyncClient::mapCreateKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -674,13 +699,19 @@ public Response createOctKeyWithResponse(CreateOctKeyOptions create throw LOGGER.logExceptionAsError(new NullPointerException("'createOctKeyOptions' cannot be null.")); } - Response response = callWithMappedException(() -> implClient.createKeyWithResponse(vaultUrl, - createOctKeyOptions.getName(), createOctKeyOptions.getKeyType(), createOctKeyOptions.getKeySize(), null, - createOctKeyOptions.getKeyOperations(), createKeyAttributes(createOctKeyOptions), - createOctKeyOptions.getTags(), null, mapKeyReleasePolicy(createOctKeyOptions.getReleasePolicy()), context), + KeyCreateParameters keyCreateParameters + = new KeyCreateParameters(createOctKeyOptions.getKeyType()).setKeySize(createOctKeyOptions.getKeySize()) + .setKeyOps(createOctKeyOptions.getKeyOperations()) + .setKeyAttributes(createKeyAttributes(createOctKeyOptions)) + .setTags(createOctKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(createOctKeyOptions.getReleasePolicy())); + + Response response = callWithMappedException( + () -> implClient.createKeyWithResponse(createOctKeyOptions.getName(), + BinaryData.fromObject(keyCreateParameters), new RequestOptions().setContext(context)), KeyAsyncClient::mapCreateKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -798,12 +829,16 @@ public Response importKeyWithResponse(ImportKeyOptions importKeyOpt throw LOGGER.logExceptionAsError(new RuntimeException("'importKeyOptions' cannot be null.")); } - Response response = implClient.importKeyWithResponse(vaultUrl, importKeyOptions.getName(), - mapJsonWebKey(importKeyOptions.getKey()), importKeyOptions.isHardwareProtected(), - createKeyAttributes(importKeyOptions), importKeyOptions.getTags(), - mapKeyReleasePolicy(importKeyOptions.getReleasePolicy()), context); + KeyImportParameters keyImportParameters = new KeyImportParameters(mapJsonWebKey(importKeyOptions.getKey())) + .setHsm(importKeyOptions.isHardwareProtected()) + .setKeyAttributes(createKeyAttributes(importKeyOptions)) + .setTags(importKeyOptions.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(importKeyOptions.getReleasePolicy())); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + Response response = implClient.importKeyWithResponse(importKeyOptions.getName(), + BinaryData.fromObject(keyImportParameters), new RequestOptions().setContext(context)); + + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -875,11 +910,11 @@ public KeyVaultKey getKey(String name, String version) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getKeyWithResponse(String name, String version, Context context) { - Response response - = callWithMappedException(() -> implClient.getKeyWithResponse(vaultUrl, name, version, context), - KeyVaultKeysUtils::mapGetKeyException); + Response response = callWithMappedException( + () -> implClient.getKeyWithResponse(name, version, new RequestOptions().setContext(context)), + KeyAsyncClient::mapGetKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -995,16 +1030,22 @@ public KeyVaultKey updateKeyProperties(KeyProperties keyProperties, KeyOperation @ServiceMethod(returns = ReturnType.SINGLE) public Response updateKeyPropertiesWithResponse(KeyProperties keyProperties, Context context, KeyOperation... keyOperations) { + if (keyProperties == null) { throw LOGGER.logExceptionAsError(new NullPointerException("'keyProperties' cannot be null.")); } - Response response - = implClient.updateKeyWithResponse(vaultUrl, keyProperties.getName(), keyProperties.getVersion(), - keyOperations == null ? null : Arrays.asList(keyOperations), createKeyAttributes(keyProperties), - keyProperties.getTags(), mapKeyReleasePolicy(keyProperties.getReleasePolicy()), context); + KeyUpdateParameters keyUpdateParameters + = new KeyUpdateParameters().setKeyOps(keyOperations == null ? null : Arrays.asList(keyOperations)) + .setKeyAttributes(createKeyAttributes(keyProperties)) + .setTags(keyProperties.getTags()) + .setReleasePolicy(mapKeyReleasePolicy(keyProperties.getReleasePolicy())); + + Response response + = implClient.updateKeyWithResponse(keyProperties.getName(), keyProperties.getVersion(), + BinaryData.fromObject(keyUpdateParameters), new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -1051,17 +1092,19 @@ public SyncPoller beginDeleteKey(String name) { } private Function, PollResponse> deleteActivationOperation(String name) { - return pollingContext -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, callWithMappedException( - () -> createDeletedKey(implClient.deleteKey(vaultUrl, name)), KeyAsyncClient::mapDeleteKeyException)); + return pollingContext -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, createDeletedKey( + implClient.deleteKeyWithResponse(name, EMPTY_OPTIONS).getValue().toObject(DeletedKeyBundle.class))); } private Function, PollResponse> deletePollOperation(String name) { return pollingContext -> { try { return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createDeletedKey(implClient.getDeletedKey(vaultUrl, name))); - } catch (KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + createDeletedKey(implClient.getDeletedKeyWithResponse(name, EMPTY_OPTIONS) + .getValue() + .toObject(DeletedKeyBundle.class))); + } catch (HttpResponseException e) { + if (e.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, pollingContext.getLatestResponse().getValue()); } else { @@ -1071,7 +1114,7 @@ private Function, PollResponse> deletePol return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, pollingContext.getLatestResponse().getValue()); } - } catch (RuntimeException ex) { + } catch (RuntimeException e) { // This means either vault has soft-delete disabled or permission is not granted for the get deleted key // operation. In both cases deletion operation was successful when activation operation succeeded before // reaching here. @@ -1135,11 +1178,10 @@ public DeletedKey getDeletedKey(String name) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getDeletedKeyWithResponse(String name, Context context) { - Response response - = callWithMappedException(() -> implClient.getDeletedKeyWithResponse(vaultUrl, name, context), - KeyAsyncClient::mapGetDeletedKeyException); + Response response + = implClient.getDeletedKeyWithResponse(name, new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, createDeletedKey(response.getValue())); + return new SimpleResponse<>(response, createDeletedKey(response.getValue().toObject(DeletedKeyBundle.class))); } /** @@ -1192,8 +1234,7 @@ public void purgeDeletedKey(String name) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response purgeDeletedKeyWithResponse(String name, Context context) { - return callWithMappedException(() -> implClient.purgeDeletedKeyWithResponse(vaultUrl, name, context), - KeyAsyncClient::mapPurgeDeletedKeyException); + return implClient.purgeDeletedKeyWithResponse(name, new RequestOptions().setContext(context)); } /** @@ -1234,18 +1275,17 @@ public SyncPoller beginRecoverDeletedKey(String name) { } private Function, PollResponse> recoverActivationOperation(String name) { - return pollingContext -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, - createKeyVaultKey(callWithMappedException(() -> implClient.recoverDeletedKey(vaultUrl, name), - KeyAsyncClient::mapRecoverDeletedKeyException))); + return pollingContext -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, createKeyVaultKey( + implClient.recoverDeletedKeyWithResponse(name, EMPTY_OPTIONS).getValue().toObject(KeyBundle.class))); } private Function, PollResponse> recoverPollOperation(String keyName) { return pollingContext -> { try { - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createKeyVaultKey(implClient.getKey(vaultUrl, keyName, null))); - } catch (KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 404) { + return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, createKeyVaultKey( + implClient.getKeyWithResponse(keyName, null, EMPTY_OPTIONS).getValue().toObject(KeyBundle.class))); + } catch (HttpResponseException e) { + if (e.getResponse().getStatusCode() == 404) { return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, pollingContext.getLatestResponse().getValue()); } else { @@ -1254,7 +1294,7 @@ private Function, PollResponse> recover return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, pollingContext.getLatestResponse().getValue()); } - } catch (RuntimeException ex) { + } catch (RuntimeException e) { // This means permission is not granted for the get deleted key operation. In both cases deletion // operation was successful when activation operation succeeded before reaching here. return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, @@ -1333,10 +1373,10 @@ public byte[] backupKey(String name) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response backupKeyWithResponse(String name, Context context) { - Response response = callWithMappedException( - () -> implClient.backupKeyWithResponse(vaultUrl, name, context), KeyAsyncClient::mapBackupKeyException); + Response response + = implClient.backupKeyWithResponse(name, new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, response.getValue().getValue()); + return new SimpleResponse<>(response, response.getValue().toObject(BackupKeyResult.class).getValue()); } /** @@ -1411,10 +1451,14 @@ public KeyVaultKey restoreKeyBackup(byte[] backup) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response restoreKeyBackupWithResponse(byte[] backup, Context context) { - Response response = callWithMappedException( - () -> implClient.restoreKeyWithResponse(vaultUrl, backup, context), KeyAsyncClient::mapRestoreKeyException); + KeyRestoreParameters keyRestoreParameters = new KeyRestoreParameters(backup); + + Response response = callWithMappedException( + () -> implClient.restoreKeyWithResponse(BinaryData.fromObject(keyRestoreParameters), + new RequestOptions().setContext(context)), + KeyAsyncClient::mapRestoreKeyException); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -1514,10 +1558,8 @@ public PagedIterable listPropertiesOfKeys() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listPropertiesOfKeys(Context context) { - return new PagedIterable<>( - maxResults -> mapKeyItemPagedResponse(implClient.getKeysSinglePage(vaultUrl, maxResults, context)), - (continuationToken, maxResults) -> mapKeyItemPagedResponse( - implClient.getKeysNextSinglePage(continuationToken, vaultUrl, context))); + return implClient.getKeys(new RequestOptions().setContext(context)) + .mapPage(binaryData -> KeyVaultKeysModelsUtils.createKeyProperties(binaryData.toObject(KeyItem.class))); } /** @@ -1596,11 +1638,8 @@ public PagedIterable listDeletedKeys() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listDeletedKeys(Context context) { - return new PagedIterable<>( - maxResults -> mapDeletedKeyItemPagedResponse( - implClient.getDeletedKeysSinglePage(vaultUrl, maxResults, context)), - (continuationToken, maxResults) -> mapDeletedKeyItemPagedResponse( - implClient.getDeletedKeysNextSinglePage(continuationToken, vaultUrl, context))); + return implClient.getDeletedKeys(new RequestOptions().setContext(context)) + .mapPage(binaryData -> KeyVaultKeysModelsUtils.createDeletedKey(binaryData.toObject(DeletedKeyItem.class))); } /** @@ -1699,11 +1738,8 @@ public PagedIterable listPropertiesOfKeyVersions(String name) { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listPropertiesOfKeyVersions(String name, Context context) { - return new PagedIterable<>( - maxResults -> mapKeyItemPagedResponse( - implClient.getKeyVersionsSinglePage(vaultUrl, name, maxResults, context)), - (continuationToken, maxResults) -> mapKeyItemPagedResponse( - implClient.getKeyVersionsNextSinglePage(continuationToken, vaultUrl, context))); + return implClient.getKeyVersions(name, new RequestOptions().setContext(context)) + .mapPage(binaryData -> KeyVaultKeysModelsUtils.createKeyProperties(binaryData.toObject(KeyItem.class))); } /** @@ -1756,9 +1792,12 @@ public byte[] getRandomBytes(int count) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getRandomBytesWithResponse(int count, Context context) { - Response response = implClient.getRandomBytesWithResponse(vaultUrl, count, context); + GetRandomBytesRequest getRandomBytesRequest = new GetRandomBytesRequest(count); + + Response response = implClient.getRandomBytesWithResponse( + BinaryData.fromObject(getRandomBytesRequest), new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, response.getValue().getValue()); + return new SimpleResponse<>(response, response.getValue().toObject(RandomBytes.class).getValue()); } /** @@ -1878,9 +1917,13 @@ public Response releaseKeyWithResponse(String name, String ver String nonce = releaseKeyOptions == null ? null : releaseKeyOptions.getNonce(); KeyExportEncryptionAlgorithm algorithm = releaseKeyOptions == null ? null : releaseKeyOptions.getAlgorithm(); + KeyReleaseParameters keyReleaseParameters + = new KeyReleaseParameters(targetAttestationToken).setEnc(algorithm).setNonce(nonce); - return callWithMappedException(() -> implClient.releaseWithResponse(vaultUrl, name, version, - targetAttestationToken, nonce, algorithm, context), KeyAsyncClient::mapReleaseKeyException); + Response response = implClient.releaseWithResponse(name, version, + BinaryData.fromObject(keyReleaseParameters), new RequestOptions().setContext(context)); + + return new SimpleResponse<>(response, response.getValue().toObject(ReleaseKeyResult.class)); } /** @@ -1941,10 +1984,10 @@ public KeyVaultKey rotateKey(String name) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rotateKeyWithResponse(String name, Context context) { - Response response = callWithMappedException( - () -> implClient.rotateKeyWithResponse(vaultUrl, name, context), KeyAsyncClient::mapRotateKeyException); + Response response + = implClient.rotateKeyWithResponse(name, new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } /** @@ -2003,11 +2046,11 @@ public KeyRotationPolicy getKeyRotationPolicy(String keyName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getKeyRotationPolicyWithResponse(String keyName, Context context) { - Response response - = callWithMappedException(() -> implClient.getKeyRotationPolicyWithResponse(vaultUrl, keyName, context), - KeyAsyncClient::mapGetKeyRotationPolicyException); + Response response + = implClient.getKeyRotationPolicyWithResponse(keyName, new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue())); + return new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue() + .toObject(com.azure.security.keyvault.keys.implementation.models.KeyRotationPolicy.class))); } /** @@ -2096,12 +2139,11 @@ public KeyRotationPolicy updateKeyRotationPolicy(String keyName, KeyRotationPoli @ServiceMethod(returns = ReturnType.SINGLE) public Response updateKeyRotationPolicyWithResponse(String keyName, KeyRotationPolicy keyRotationPolicy, Context context) { - Response response - = callWithMappedException( - () -> implClient.updateKeyRotationPolicyWithResponse(vaultUrl, keyName, - mapKeyRotationPolicy(keyRotationPolicy), context), - KeyAsyncClient::mapUpdateKeyRotationPolicyException); - return new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue())); + Response response = implClient.updateKeyRotationPolicyWithResponse(keyName, + BinaryData.fromObject(mapKeyRotationPolicy(keyRotationPolicy)), new RequestOptions().setContext(context)); + + return new SimpleResponse<>(response, mapKeyRotationPolicyImpl(response.getValue() + .toObject(com.azure.security.keyvault.keys.implementation.models.KeyRotationPolicy.class))); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java index 2756c32164cf7..9446237314d35 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java @@ -98,7 +98,7 @@ public final class KeyClientBuilder implements TokenCredentialTrait properties = CoreUtils.getProperties("azure-key-vault-keys.properties"); + Map properties = CoreUtils.getProperties("azure-security-keyvault-keys.properties"); CLIENT_NAME = properties.getOrDefault("name", "UnknownName"); CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion"); } @@ -150,7 +150,7 @@ public KeyClientBuilder() { * and {@link #retryPolicy(RetryPolicy)} have been set. */ public KeyClient buildClient() { - return new KeyClient(buildInnerClient(), vaultUrl, version != null ? version : KeyServiceVersion.getLatest()); + return new KeyClient(buildClientImpl(), vaultUrl, version); } /** @@ -171,11 +171,10 @@ public KeyClient buildClient() { * and {@link #retryPolicy(RetryPolicy)} have been set. */ public KeyAsyncClient buildAsyncClient() { - return new KeyAsyncClient(buildInnerClient(), vaultUrl, - version != null ? version : KeyServiceVersion.getLatest()); + return new KeyAsyncClient(buildClientImpl(), vaultUrl, version); } - private KeyClientImpl buildInnerClient() { + private KeyClientImpl buildClientImpl() { Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : configuration; String buildEndpoint = getBuildEndpoint(buildConfiguration); @@ -185,10 +184,12 @@ private KeyClientImpl buildInnerClient() { .logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); } - KeyServiceVersion serviceVersion = version != null ? version : KeyServiceVersion.getLatest(); + if (version == null) { + version = KeyServiceVersion.getLatest(); + } if (pipeline != null) { - return new KeyClientImpl(pipeline, serviceVersion.getVersion()); + return new KeyClientImpl(pipeline, vaultUrl, version); } if (credential == null) { @@ -228,13 +229,13 @@ private KeyClientImpl buildInnerClient() { Tracer tracer = TracerProvider.getDefaultProvider() .createTracer(CLIENT_NAME, CLIENT_VERSION, KEYVAULT_TRACING_NAMESPACE_VALUE, tracingOptions); - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + HttpPipeline builtPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .tracer(tracer) .clientOptions(localClientOptions) .build(); - return new KeyClientImpl(pipeline, serviceVersion.getVersion()); + return new KeyClientImpl(builtPipeline, vaultUrl, version); } /** diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java index 5f7a136fbb3b5..e80da595489a8 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java @@ -124,7 +124,7 @@ public final class CryptographyClientBuilder implements TokenCredentialTrait properties = CoreUtils.getProperties("azure-key-vault-keys.properties"); + Map properties = CoreUtils.getProperties("azure-security-keyvault-keys.properties"); CLIENT_NAME = properties.getOrDefault("name", "UnknownName"); CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion"); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/implementation/CryptographyClientImpl.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/implementation/CryptographyClientImpl.java index 46684f48ad4ae..ac4236b2316f5 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/implementation/CryptographyClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/implementation/CryptographyClientImpl.java @@ -3,11 +3,16 @@ package com.azure.security.keyvault.keys.cryptography.implementation; +import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; +import com.azure.security.keyvault.keys.KeyAsyncClient; +import com.azure.security.keyvault.keys.KeyServiceVersion; import com.azure.security.keyvault.keys.cryptography.CryptographyServiceVersion; import com.azure.security.keyvault.keys.cryptography.models.DecryptParameters; import com.azure.security.keyvault.keys.cryptography.models.DecryptResult; @@ -21,11 +26,12 @@ import com.azure.security.keyvault.keys.cryptography.models.VerifyResult; import com.azure.security.keyvault.keys.cryptography.models.WrapResult; import com.azure.security.keyvault.keys.implementation.KeyClientImpl; -import com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils; import com.azure.security.keyvault.keys.implementation.SecretMinClientImpl; import com.azure.security.keyvault.keys.implementation.models.KeyBundle; import com.azure.security.keyvault.keys.implementation.models.KeyOperationResult; -import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.keys.implementation.models.KeyOperationsParameters; +import com.azure.security.keyvault.keys.implementation.models.KeySignParameters; +import com.azure.security.keyvault.keys.implementation.models.KeyVerifyParameters; import com.azure.security.keyvault.keys.implementation.models.KeyVerifyResult; import com.azure.security.keyvault.keys.implementation.models.SecretKey; import com.azure.security.keyvault.keys.implementation.models.SecretRequestAttributes; @@ -44,7 +50,7 @@ import static com.azure.security.keyvault.keys.cryptography.implementation.CryptographyUtils.mapWrapAlgorithm; import static com.azure.security.keyvault.keys.cryptography.implementation.CryptographyUtils.transformSecretKey; import static com.azure.security.keyvault.keys.cryptography.implementation.CryptographyUtils.unpackAndValidateId; -import static com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils.callWithMappedException; +import static com.azure.security.keyvault.keys.implementation.KeyVaultKeysUtils.EMPTY_OPTIONS; import static com.azure.security.keyvault.keys.implementation.models.KeyVaultKeysModelsUtils.createKeyVaultKey; public final class CryptographyClientImpl { @@ -72,7 +78,7 @@ public CryptographyClientImpl(String keyId, HttpPipeline pipeline, CryptographyS this.keyId = keyId; - this.keyClient = new KeyClientImpl(pipeline, serviceVersion.getVersion()); + this.keyClient = new KeyClientImpl(pipeline, vaultUrl, KeyServiceVersion.valueOf(serviceVersion.toString())); this.secretClient = new SecretMinClientImpl(pipeline, serviceVersion.getVersion()); } @@ -85,27 +91,21 @@ public String getKeyCollection() { } public Mono> getKeyAsync() { - return keyClient.getKeyWithResponseAsync(vaultUrl, keyName, keyVersion) - .doOnRequest(ignored -> LOGGER.verbose("Retrieving key - {}", keyName)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved key - {}", keyName)) - .doOnError(error -> LOGGER.warning("Failed to get key - {}", keyName, error)) - .onErrorMap(KeyVaultErrorException.class, KeyVaultKeysUtils::mapGetKeyException) - .map(response -> new SimpleResponse<>(response, createKeyVaultKey(response.getValue()))); + return keyClient.getKeyWithResponseAsync(keyName, keyVersion, EMPTY_OPTIONS) + .onErrorMap(HttpResponseException.class, KeyAsyncClient::mapGetKeyException) + .map(response -> new SimpleResponse<>(response, + createKeyVaultKey(response.getValue().toObject(KeyBundle.class)))); } public Response getKey(Context context) { - Response response - = callWithMappedException(() -> keyClient.getKeyWithResponse(vaultUrl, keyName, keyVersion, context), - KeyVaultKeysUtils::mapGetKeyException); + Response response + = keyClient.getKeyWithResponse(keyName, keyVersion, new RequestOptions().setContext(context)); - return new SimpleResponse<>(response, createKeyVaultKey(response.getValue())); + return new SimpleResponse<>(response, createKeyVaultKey(response.getValue().toObject(KeyBundle.class))); } public Mono getSecretKeyAsync() { return withContext(context -> secretClient.getSecretWithResponseAsync(vaultUrl, keyName, keyVersion, context)) - .doOnRequest(ignored -> LOGGER.verbose("Retrieving key - {}", keyName)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved key - {}", response.getValue().getName())) - .doOnError(error -> LOGGER.warning("Failed to get key - {}", keyName, error)) .map(response -> transformSecretKey(response.getValue())); } @@ -117,12 +117,9 @@ public JsonWebKey getSecretKey() { public Mono> setSecretKeyAsync(SecretKey secret, Context context) { Objects.requireNonNull(secret, "The secret key cannot be null."); - return secretClient - .setSecretWithResponseAsync(vaultUrl, secret.getName(), secret.getValue(), secret.getProperties().getTags(), - secret.getProperties().getContentType(), new SecretRequestAttributes(secret.getProperties()), context) - .doOnRequest(ignored -> LOGGER.verbose("Setting secret - {}", secret.getName())) - .doOnSuccess(response -> LOGGER.verbose("Set secret - {}", response.getValue().getName())) - .doOnError(error -> LOGGER.warning("Failed to set secret - {}", secret.getName(), error)); + return secretClient.setSecretWithResponseAsync(vaultUrl, secret.getName(), secret.getValue(), + secret.getProperties().getTags(), secret.getProperties().getContentType(), + new SecretRequestAttributes(secret.getProperties()), context); } public Response setSecretKey(SecretKey secret, Context context) { @@ -149,14 +146,19 @@ public Mono encryptAsync(EncryptParameters encryptParameters, Con private Mono encryptAsync(EncryptionAlgorithm algorithm, byte[] plainText, byte[] iv, byte[] additionalAuthenticatedData, Context context) { + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapKeyEncryptionAlgorithm(algorithm), plainText).setIv(iv) + .setAad(additionalAuthenticatedData); + return keyClient - .encryptAsync(vaultUrl, keyName, keyVersion, mapKeyEncryptionAlgorithm(algorithm), plainText, iv, - additionalAuthenticatedData, null, context) - .doOnRequest(ignored -> LOGGER.verbose("Encrypting content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved encrypted content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to encrypt content with algorithm - {}", algorithm, error)) - .map(result -> new EncryptResult(result.getResult(), algorithm, keyId, result.getIv(), - result.getAuthenticationTag(), result.getAdditionalAuthenticatedData())); + .encryptWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyOperationResult result = response.getValue().toObject(KeyOperationResult.class); + + return new EncryptResult(result.getResult(), algorithm, keyId, result.getIv(), + result.getAuthenticationTag(), result.getAdditionalAuthenticatedData()); + }); } public EncryptResult encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, Context context) { @@ -175,11 +177,16 @@ public EncryptResult encrypt(EncryptParameters encryptParameters, Context contex private EncryptResult encrypt(EncryptionAlgorithm algorithm, byte[] plainText, byte[] iv, byte[] additionalAuthenticatedData, Context context) { + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapKeyEncryptionAlgorithm(algorithm), plainText).setIv(iv) + .setAad(additionalAuthenticatedData); + KeyOperationResult result = keyClient - .encryptWithResponse(vaultUrl, keyName, keyVersion, mapKeyEncryptionAlgorithm(algorithm), plainText, iv, - additionalAuthenticatedData, null, context) - .getValue(); + .encryptWithResponse(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyOperationResult.class); return new EncryptResult(result.getResult(), algorithm, keyId, result.getIv(), result.getAuthenticationTag(), result.getAdditionalAuthenticatedData()); @@ -202,13 +209,20 @@ public Mono decryptAsync(DecryptParameters decryptParameters, Con private Mono decryptAsync(EncryptionAlgorithm algorithm, byte[] ciphertext, byte[] iv, byte[] additionalAuthenticatedData, byte[] authenticationTag, Context context) { + + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapKeyEncryptionAlgorithm(algorithm), ciphertext).setIv(iv) + .setAad(additionalAuthenticatedData) + .setTag(authenticationTag); + return keyClient - .decryptAsync(vaultUrl, keyName, keyVersion, mapKeyEncryptionAlgorithm(algorithm), ciphertext, iv, - additionalAuthenticatedData, authenticationTag, context) - .map(result -> new DecryptResult(result.getResult(), algorithm, keyId)) - .doOnRequest(ignored -> LOGGER.verbose("Decrypting content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved decrypted content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to decrypt content with algorithm - {}", algorithm, error)); + .decryptWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyOperationResult result = response.getValue().toObject(KeyOperationResult.class); + + return new DecryptResult(result.getResult(), algorithm, keyId); + }); } public DecryptResult decrypt(EncryptionAlgorithm algorithm, byte[] ciphertext, Context context) { @@ -227,11 +241,18 @@ public DecryptResult decrypt(DecryptParameters decryptParameters, Context contex private DecryptResult decrypt(EncryptionAlgorithm algorithm, byte[] ciphertext, byte[] iv, byte[] additionalAuthenticatedData, byte[] authenticationTag, Context context) { + + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapKeyEncryptionAlgorithm(algorithm), ciphertext).setIv(iv) + .setAad(additionalAuthenticatedData) + .setTag(authenticationTag); + KeyOperationResult result = keyClient - .decryptWithResponse(vaultUrl, keyName, keyVersion, mapKeyEncryptionAlgorithm(algorithm), ciphertext, - iv, additionalAuthenticatedData, authenticationTag, context) - .getValue(); + .decryptWithResponse(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyOperationResult.class); return new DecryptResult(result.getResult(), algorithm, keyId); } @@ -240,20 +261,30 @@ public Mono signAsync(SignatureAlgorithm algorithm, byte[] digest, C Objects.requireNonNull(algorithm, "Signature algorithm cannot be null."); Objects.requireNonNull(digest, "Digest content cannot be null."); - return keyClient.signAsync(vaultUrl, keyName, keyVersion, mapKeySignatureAlgorithm(algorithm), digest, context) - .map(result -> new SignResult(result.getResult(), algorithm, keyId)) - .doOnRequest(ignored -> LOGGER.verbose("Signing content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved signed content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to sign content with algorithm - {}", algorithm, error)); + KeySignParameters keyOperationsParameters = new KeySignParameters(mapKeySignatureAlgorithm(algorithm), digest); + + return keyClient + .signWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyOperationResult result = response.getValue().toObject(KeyOperationResult.class); + + return new SignResult(result.getResult(), algorithm, keyId); + }); } public SignResult sign(SignatureAlgorithm algorithm, byte[] digest, Context context) { Objects.requireNonNull(algorithm, "Signature algorithm cannot be null."); Objects.requireNonNull(digest, "Digest content cannot be null."); - KeyOperationResult result = keyClient - .signWithResponse(vaultUrl, keyName, keyVersion, mapKeySignatureAlgorithm(algorithm), digest, context) - .getValue(); + KeySignParameters keyOperationsParameters = new KeySignParameters(mapKeySignatureAlgorithm(algorithm), digest); + + KeyOperationResult result + = keyClient + .signWithResponse(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyOperationResult.class); return new SignResult(result.getResult(), algorithm, keyId); } @@ -264,12 +295,17 @@ public Mono verifyAsync(SignatureAlgorithm algorithm, byte[] diges Objects.requireNonNull(digest, "Digest content cannot be null."); Objects.requireNonNull(signature, "Signature to be verified cannot be null."); + KeyVerifyParameters keyVerifyParameters + = new KeyVerifyParameters(mapKeySignatureAlgorithm(algorithm), digest, signature); + return keyClient - .verifyAsync(vaultUrl, keyName, keyVersion, mapKeySignatureAlgorithm(algorithm), digest, signature, context) - .map(result -> new VerifyResult(result.isValue(), algorithm, keyId)) - .doOnRequest(ignored -> LOGGER.verbose("Verifying content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved verified content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to verify content with algorithm - {}", algorithm, error)); + .verifyWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyVerifyParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyVerifyResult result = response.getValue().toObject(KeyVerifyResult.class); + + return new VerifyResult(result.isValue(), algorithm, keyId); + }); } public VerifyResult verify(SignatureAlgorithm algorithm, byte[] digest, byte[] signature, Context context) { @@ -277,11 +313,15 @@ public VerifyResult verify(SignatureAlgorithm algorithm, byte[] digest, byte[] s Objects.requireNonNull(digest, "Digest content cannot be null."); Objects.requireNonNull(signature, "Signature to be verified cannot be null."); + KeyVerifyParameters keyVerifyParameters + = new KeyVerifyParameters(mapKeySignatureAlgorithm(algorithm), digest, signature); + KeyVerifyResult result = keyClient - .verifyWithResponse(vaultUrl, keyName, keyVersion, mapKeySignatureAlgorithm(algorithm), digest, - signature, context) - .getValue(); + .verifyWithResponse(keyName, keyVersion, BinaryData.fromObject(keyVerifyParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyVerifyResult.class); return new VerifyResult(result.isValue(), algorithm, keyId); } @@ -290,23 +330,30 @@ public Mono wrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] key, Con Objects.requireNonNull(algorithm, "Key wrap algorithm cannot be null."); Objects.requireNonNull(key, "Key content to be wrapped cannot be null."); + KeyOperationsParameters keyOperationsParameters = new KeyOperationsParameters(mapWrapAlgorithm(algorithm), key); + return keyClient - .wrapKeyAsync(vaultUrl, keyName, keyVersion, mapWrapAlgorithm(algorithm), key, null, null, null, context) - .map(result -> new WrapResult(result.getResult(), algorithm, keyId)) - .doOnRequest(ignored -> LOGGER.verbose("Wrapping key content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved wrapped key content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to verify content with algorithm - {}", algorithm, error)); + .wrapKeyWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyOperationResult result = response.getValue().toObject(KeyOperationResult.class); + + return new WrapResult(result.getResult(), algorithm, keyId); + }); } public WrapResult wrapKey(KeyWrapAlgorithm algorithm, byte[] key, Context context) { Objects.requireNonNull(algorithm, "Key wrap algorithm cannot be null."); Objects.requireNonNull(key, "Key content to be wrapped cannot be null."); + KeyOperationsParameters keyOperationsParameters = new KeyOperationsParameters(mapWrapAlgorithm(algorithm), key); + KeyOperationResult result = keyClient - .wrapKeyWithResponse(vaultUrl, keyName, keyVersion, mapWrapAlgorithm(algorithm), key, null, null, null, - context) - .getValue(); + .wrapKeyWithResponse(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyOperationResult.class); return new WrapResult(result.getResult(), algorithm, keyId); } @@ -315,23 +362,32 @@ public Mono unwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encr Objects.requireNonNull(algorithm, "Key wrap algorithm cannot be null."); Objects.requireNonNull(encryptedKey, "Encrypted key content to be unwrapped cannot be null."); + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapWrapAlgorithm(algorithm), encryptedKey); + return keyClient - .unwrapKeyAsync(vaultUrl, keyName, keyVersion, mapWrapAlgorithm(algorithm), encryptedKey, null, null, null, - context) - .map(result -> new UnwrapResult(result.getResult(), algorithm, keyId)) - .doOnRequest(ignored -> LOGGER.verbose("Unwrapping key content with algorithm - {}", algorithm)) - .doOnSuccess(response -> LOGGER.verbose("Retrieved unwrapped key content with algorithm - {}", algorithm)) - .doOnError(error -> LOGGER.warning("Failed to unwrap key content with algorithm - {}", algorithm, error)); + .unwrapKeyWithResponseAsync(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .map(response -> { + KeyOperationResult result = response.getValue().toObject(KeyOperationResult.class); + + return new UnwrapResult(result.getResult(), algorithm, keyId); + }); } public UnwrapResult unwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, Context context) { Objects.requireNonNull(algorithm, "Key wrap algorithm cannot be null."); Objects.requireNonNull(encryptedKey, "Encrypted key content to be unwrapped cannot be null."); - KeyOperationResult result = keyClient - .unwrapKeyWithResponse(vaultUrl, keyName, keyVersion, mapWrapAlgorithm(algorithm), encryptedKey, null, null, - null, context) - .getValue(); + KeyOperationsParameters keyOperationsParameters + = new KeyOperationsParameters(mapWrapAlgorithm(algorithm), encryptedKey); + + KeyOperationResult result + = keyClient + .unwrapKeyWithResponse(keyName, keyVersion, BinaryData.fromObject(keyOperationsParameters), + new RequestOptions().setContext(context)) + .getValue() + .toObject(KeyOperationResult.class); return new UnwrapResult(result.getResult(), algorithm, keyId); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyClientImpl.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyClientImpl.java index 2f370bbc639a2..b7a8d62d50fbd 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyClientImpl.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation; import com.azure.core.annotation.BodyParam; @@ -20,6 +19,10 @@ import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.policy.RetryPolicy; @@ -28,68 +31,55 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import com.azure.security.keyvault.keys.implementation.models.BackupKeyResult; -import com.azure.security.keyvault.keys.implementation.models.DeletedKeyBundle; -import com.azure.security.keyvault.keys.implementation.models.DeletedKeyItem; -import com.azure.security.keyvault.keys.implementation.models.DeletedKeyListResult; -import com.azure.security.keyvault.keys.implementation.models.GetRandomBytesRequest; -import com.azure.security.keyvault.keys.implementation.models.JsonWebKey; -import com.azure.security.keyvault.keys.implementation.models.JsonWebKeyEncryptionAlgorithm; -import com.azure.security.keyvault.keys.implementation.models.JsonWebKeySignatureAlgorithm; -import com.azure.security.keyvault.keys.implementation.models.KeyAttributes; -import com.azure.security.keyvault.keys.implementation.models.KeyBundle; -import com.azure.security.keyvault.keys.implementation.models.KeyCreateParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyImportParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyItem; -import com.azure.security.keyvault.keys.implementation.models.KeyListResult; -import com.azure.security.keyvault.keys.implementation.models.KeyOperationResult; -import com.azure.security.keyvault.keys.implementation.models.KeyOperationsParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyReleaseParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyReleasePolicy; -import com.azure.security.keyvault.keys.implementation.models.KeyRestoreParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyRotationPolicy; -import com.azure.security.keyvault.keys.implementation.models.KeySignParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyUpdateParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.keys.implementation.models.KeyVerifyParameters; -import com.azure.security.keyvault.keys.implementation.models.KeyVerifyResult; -import com.azure.security.keyvault.keys.implementation.models.RandomBytes; -import com.azure.security.keyvault.keys.models.KeyCurveName; -import com.azure.security.keyvault.keys.models.KeyExportEncryptionAlgorithm; -import com.azure.security.keyvault.keys.models.KeyOperation; -import com.azure.security.keyvault.keys.models.KeyType; -import com.azure.security.keyvault.keys.models.ReleaseKeyResult; +import com.azure.security.keyvault.keys.KeyServiceVersion; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import reactor.core.publisher.Mono; /** * Initializes a new instance of the KeyClient type. */ public final class KeyClientImpl { + /** * The proxy service used to perform REST calls. */ private final KeyClientService service; /** - * Api Version. */ - private final String apiVersion; + private final String vaultBaseUrl; /** - * Gets Api Version. - * - * @return the apiVersion value. + * Gets. + * + * @return the vaultBaseUrl value. + */ + public String getVaultBaseUrl() { + return this.vaultBaseUrl; + } + + /** + * Service version. + */ + private final KeyServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. */ - public String getApiVersion() { - return this.apiVersion; + public KeyServiceVersion getServiceVersion() { + return this.serviceVersion; } /** @@ -99,7 +89,7 @@ public String getApiVersion() { /** * Gets The HTTP pipeline to send requests through. - * + * * @return the httpPipeline value. */ public HttpPipeline getHttpPipeline() { @@ -113,7 +103,7 @@ public HttpPipeline getHttpPipeline() { /** * Gets The serializer to serialize an object into a string. - * + * * @return the serializerAdapter value. */ public SerializerAdapter getSerializerAdapter() { @@ -122,35 +112,40 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of KeyClient client. - * - * @param apiVersion Api Version. + * + * @param vaultBaseUrl + * @param serviceVersion Service version. */ - public KeyClientImpl(String apiVersion) { + public KeyClientImpl(String vaultBaseUrl, KeyServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), apiVersion); + JacksonAdapter.createDefaultSerializerAdapter(), vaultBaseUrl, serviceVersion); } /** * Initializes an instance of KeyClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. - * @param apiVersion Api Version. + * @param vaultBaseUrl + * @param serviceVersion Service version. */ - public KeyClientImpl(HttpPipeline httpPipeline, String apiVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), apiVersion); + public KeyClientImpl(HttpPipeline httpPipeline, String vaultBaseUrl, KeyServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), vaultBaseUrl, serviceVersion); } /** * Initializes an instance of KeyClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param apiVersion Api Version. + * @param vaultBaseUrl + * @param serviceVersion Service version. */ - public KeyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String apiVersion) { + public KeyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String vaultBaseUrl, + KeyServiceVersion serviceVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; - this.apiVersion = apiVersion; + this.vaultBaseUrl = vaultBaseUrl; + this.serviceVersion = serviceVersion; this.service = RestProxy.create(KeyClientService.class, this.httpPipeline, this.getSerializerAdapter()); } @@ -160,1733 +155,2153 @@ public KeyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdap @Host("{vaultBaseUrl}") @ServiceInterface(name = "KeyClient") public interface KeyClientService { + @Post("/keys/{key-name}/create") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> createKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyCreateParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData parameters, RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/create") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response createKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyCreateParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData parameters, RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/rotate") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> rotateKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rotateKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/rotate") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response rotateKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rotateKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/keys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> importKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyImportParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> importKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData parameters, RequestOptions requestOptions, Context context); @Put("/keys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response importKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyImportParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response importKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData parameters, RequestOptions requestOptions, Context context); @Delete("/keys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> deleteKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Delete("/keys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response deleteKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Patch("/keys/{key-name}/{key-version}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeyUpdateParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Patch("/keys/{key-name}/{key-version}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeyUpdateParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/{key-version}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/{key-version}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/versions") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKeyVersions(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("maxresults") Integer maxresults, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKeyVersions(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/versions") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeyVersionsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("maxresults") Integer maxresults, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeyVersionsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/keys") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKeys(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKeys(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/keys") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeysSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeysSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/backup") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> backupKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> backupKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/backup") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response backupKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response backupKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/keys/restore") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> restoreKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyRestoreParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> restoreKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/restore") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response restoreKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyRestoreParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response restoreKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/encrypt") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> encrypt(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> encrypt(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/encrypt") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response encryptSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response encryptSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/decrypt") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> decrypt(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> decrypt(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/decrypt") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response decryptSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response decryptSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/sign") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> sign(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeySignParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sign(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/sign") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response signSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeySignParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response signSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/verify") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> verify(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeyVerifyParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> verify(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/verify") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response verifySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") KeyVerifyParameters parameters, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response verifySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/wrapkey") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> wrapKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> wrapKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/wrapkey") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response wrapKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response wrapKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/unwrapkey") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> unwrapKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unwrapKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/unwrapkey") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response unwrapKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyOperationsParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unwrapKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/release") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> release(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyReleaseParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> release(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/keys/{key-name}/{key-version}/release") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response releaseSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @PathParam("key-version") String keyVersion, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyReleaseParameters parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response releaseSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @PathParam("key-version") String keyVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Get("/deletedkeys") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedKeys(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDeletedKeys(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/deletedkeys") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedKeysSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDeletedKeysSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/deletedkeys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDeletedKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/deletedkeys/{key-name}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDeletedKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Delete("/deletedkeys/{key-name}") @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> purgeDeletedKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Delete("/deletedkeys/{key-name}") @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) Response purgeDeletedKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/deletedkeys/{key-name}/recover") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> recoverDeletedKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> recoverDeletedKey(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/deletedkeys/{key-name}/recover") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response recoverDeletedKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response recoverDeletedKeySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/rotationpolicy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKeyRotationPolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKeyRotationPolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/keys/{key-name}/rotationpolicy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeyRotationPolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeyRotationPolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/keys/{key-name}/rotationpolicy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateKeyRotationPolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyRotationPolicy keyRotationPolicy, @HeaderParam("Accept") String accept, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateKeyRotationPolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData keyRotationPolicy, RequestOptions requestOptions, Context context); @Put("/keys/{key-name}/rotationpolicy") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateKeyRotationPolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("key-name") String keyName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyRotationPolicy keyRotationPolicy, @HeaderParam("Accept") String accept, + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateKeyRotationPolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @PathParam("key-name") String keyName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData keyRotationPolicy, RequestOptions requestOptions, Context context); @Post("/rng") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getRandomBytes(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") GetRandomBytesRequest parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRandomBytes(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Post("/rng") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getRandomBytesSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") GetRandomBytesRequest parameters, @HeaderParam("Accept") String accept, - Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRandomBytesSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData parameters, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKeyVersionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKeyVersionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeyVersionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeyVersionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getKeysNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKeysNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getKeysNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKeysNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedKeysNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDeletedKeysNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedKeysNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - } - - /** - * Creates a new key, stores it, then returns key parameters and attributes to the client. - * - * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, - * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new key. The value you - * provide may be copied globally for the purpose of running the service. The value provided should not include - * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createKeyWithResponseAsync(String vaultBaseUrl, String keyName, KeyType kty, - Integer keySize, Integer publicExponent, List keyOps, KeyAttributes keyAttributes, - Map tags, KeyCurveName crv, KeyReleasePolicy releasePolicy) { - return FluxUtil.withContext(context -> createKeyWithResponseAsync(vaultBaseUrl, keyName, kty, keySize, - publicExponent, keyOps, keyAttributes, tags, crv, releasePolicy, context)); + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDeletedKeysNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** * Creates a new key, stores it, then returns key parameters and attributes to the client. - * + * * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Required)
+     *     key_size: Integer (Optional)
+     *     public_exponent: Integer (Optional)
+     *     key_ops (Optional): [
+     *         String(encrypt/decrypt/sign/verify/wrapKey/unwrapKey/import/export) (Optional)
+     *     ]
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name for the new key. The system will generate the version name for the new key. The value you * provide may be copied globally for the purpose of running the service. The value provided should not include * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters to create a key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createKeyWithResponseAsync(String vaultBaseUrl, String keyName, KeyType kty, - Integer keySize, Integer publicExponent, List keyOps, KeyAttributes keyAttributes, - Map tags, KeyCurveName crv, KeyReleasePolicy releasePolicy, Context context) { + public Mono> createKeyWithResponseAsync(String keyName, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(keySize); - parameters.setPublicExponent(publicExponent); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setCrv(crv); - parameters.setReleasePolicy(releasePolicy); - return service.createKey(vaultBaseUrl, keyName, this.getApiVersion(), parameters, accept, context); - } - - /** - * Creates a new key, stores it, then returns key parameters and attributes to the client. - * - * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, - * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new key. The value you - * provide may be copied globally for the purpose of running the service. The value provided should not include - * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createKeyAsync(String vaultBaseUrl, String keyName, KeyType kty, Integer keySize, - Integer publicExponent, List keyOps, KeyAttributes keyAttributes, Map tags, - KeyCurveName crv, KeyReleasePolicy releasePolicy) { - return createKeyWithResponseAsync(vaultBaseUrl, keyName, kty, keySize, publicExponent, keyOps, keyAttributes, - tags, crv, releasePolicy).flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil.withContext(context -> service.createKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, contentType, accept, parameters, requestOptions, context)); } /** * Creates a new key, stores it, then returns key parameters and attributes to the client. - * - * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, - * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new key. The value you - * provide may be copied globally for the purpose of running the service. The value provided should not include - * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createKeyAsync(String vaultBaseUrl, String keyName, KeyType kty, Integer keySize, - Integer publicExponent, List keyOps, KeyAttributes keyAttributes, Map tags, - KeyCurveName crv, KeyReleasePolicy releasePolicy, Context context) { - return createKeyWithResponseAsync(vaultBaseUrl, keyName, kty, keySize, publicExponent, keyOps, keyAttributes, - tags, crv, releasePolicy, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a new key, stores it, then returns key parameters and attributes to the client. - * + * * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Required)
+     *     key_size: Integer (Optional)
+     *     public_exponent: Integer (Optional)
+     *     key_ops (Optional): [
+     *         String(encrypt/decrypt/sign/verify/wrapKey/unwrapKey/import/export) (Optional)
+     *     ]
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name for the new key. The system will generate the version name for the new key. The value you * provide may be copied globally for the purpose of running the service. The value provided should not include * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters to create a key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createKeyWithResponse(String vaultBaseUrl, String keyName, KeyType kty, Integer keySize, - Integer publicExponent, List keyOps, KeyAttributes keyAttributes, Map tags, - KeyCurveName crv, KeyReleasePolicy releasePolicy, Context context) { + public Response createKeyWithResponse(String keyName, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(keySize); - parameters.setPublicExponent(publicExponent); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setCrv(crv); - parameters.setReleasePolicy(releasePolicy); - return service.createKeySync(vaultBaseUrl, keyName, this.getApiVersion(), parameters, accept, context); - } - - /** - * Creates a new key, stores it, then returns key parameters and attributes to the client. - * - * The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, - * Azure Key Vault creates a new version of the key. It requires the keys/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new key. The value you - * provide may be copied globally for the purpose of running the service. The value provided should not include - * personally identifiable or sensitive information. - * @param kty JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * @param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * @param publicExponent The public exponent for a RSA key. - * @param keyOps The keyOps parameter. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param crv Elliptic curve name. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle createKey(String vaultBaseUrl, String keyName, KeyType kty, Integer keySize, - Integer publicExponent, List keyOps, KeyAttributes keyAttributes, Map tags, - KeyCurveName crv, KeyReleasePolicy releasePolicy) { - return createKeyWithResponse(vaultBaseUrl, keyName, kty, keySize, publicExponent, keyOps, keyAttributes, tags, - crv, releasePolicy, Context.NONE).getValue(); - } - - /** - * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * - * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rotateKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> rotateKeyWithResponseAsync(vaultBaseUrl, keyName, context)); + return service.createKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * + * * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> rotateKeyWithResponseAsync(String vaultBaseUrl, String keyName, Context context) { + public Mono> rotateKeyWithResponseAsync(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.rotateKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * - * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono rotateKeyAsync(String vaultBaseUrl, String keyName) { - return rotateKeyWithResponseAsync(vaultBaseUrl, keyName).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * - * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono rotateKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return rotateKeyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil.withContext(context -> service.rotateKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * + * * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response rotateKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { + public Response rotateKeyWithResponse(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.rotateKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Creates a new key version, stores it, then returns key parameters, attributes and policy to the client. - * - * The operation will rotate the key based on the key policy. It requires the keys/rotate permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to be rotated. The system will generate a new version in the specified key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle rotateKey(String vaultBaseUrl, String keyName) { - return rotateKeyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); - } - - /** - * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * - * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already - * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> importKeyWithResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, - Boolean hsm, KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy) { - return FluxUtil.withContext(context -> importKeyWithResponseAsync(vaultBaseUrl, keyName, key, hsm, - keyAttributes, tags, releasePolicy, context)); + return service.rotateKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, accept, + requestOptions, Context.NONE); } /** * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * + * * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Hsm: Boolean (Optional)
+     *     key (Required): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters to import a key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> importKeyWithResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, - Boolean hsm, KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy, - Context context) { + public Mono> importKeyWithResponseAsync(String keyName, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(hsm); - parameters.setKey(key); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setReleasePolicy(releasePolicy); - return service.importKey(vaultBaseUrl, keyName, this.getApiVersion(), parameters, accept, context); - } - - /** - * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * - * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already - * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, - KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy) { - return importKeyWithResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags, releasePolicy) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * - * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already - * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, - KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy, Context context) { - return importKeyWithResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags, releasePolicy, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil.withContext(context -> service.importKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, contentType, accept, parameters, requestOptions, context)); } /** * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * + * * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Hsm: Boolean (Optional)
+     *     key (Required): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters to import a key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response importKeyWithResponse(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, - KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy, Context context) { + public Response importKeyWithResponse(String keyName, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(hsm); - parameters.setKey(key); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setReleasePolicy(releasePolicy); - return service.importKeySync(vaultBaseUrl, keyName, this.getApiVersion(), parameters, accept, context); - } - - /** - * Imports an externally created key, stores it, and returns key parameters and attributes to the client. - * - * The import key operation may be used to import any key type into an Azure Key Vault. If the named key already - * exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param key The Json web key. - * @param hsm Whether to import as a hardware key (HSM) or software key. - * @param keyAttributes The key management attributes. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, - KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy) { - return importKeyWithResponse(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags, releasePolicy, Context.NONE) - .getValue(); + return service.importKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Deletes a key of any type from storage in Azure Key Vault. - * - * The delete key operation cannot be used to remove individual versions of a key. This operation removes the - * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or - * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with - * {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> deleteKeyWithResponseAsync(vaultBaseUrl, keyName, context)); - } - - /** - * Deletes a key of any type from storage in Azure Key Vault. - * + * * The delete key operation cannot be used to remove individual versions of a key. This operation removes the * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key to delete. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with * {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteKeyWithResponseAsync(String vaultBaseUrl, String keyName, - Context context) { + public Mono> deleteKeyWithResponseAsync(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.deleteKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Deletes a key of any type from storage in Azure Key Vault. - * - * The delete key operation cannot be used to remove individual versions of a key. This operation removes the - * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or - * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info on successful completion - * of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteKeyAsync(String vaultBaseUrl, String keyName) { - return deleteKeyWithResponseAsync(vaultBaseUrl, keyName).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes a key of any type from storage in Azure Key Vault. - * - * The delete key operation cannot be used to remove individual versions of a key. This operation removes the - * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or - * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info on successful completion - * of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return deleteKeyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil.withContext(context -> service.deleteKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** * Deletes a key of any type from storage in Azure Key Vault. - * + * * The delete key operation cannot be used to remove individual versions of a key. This operation removes the * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key to delete. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with * {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { + public Response deleteKeyWithResponse(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.deleteKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Deletes a key of any type from storage in Azure Key Vault. - * - * The delete key operation cannot be used to remove individual versions of a key. This operation removes the - * cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or - * Encrypt/Decrypt operations. This operation requires the keys/delete permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DeletedKeyBundle deleteKey(String vaultBaseUrl, String keyName) { - return deleteKeyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); + return service.deleteKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, accept, + requestOptions, Context.NONE); } /** * The update key operation changes specified attributes of a stored key and can be applied to any key type and key * version stored in Azure Key Vault. - * + * * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     key_ops (Optional): [
+     *         String(encrypt/decrypt/sign/verify/wrapKey/unwrapKey/import/export) (Optional)
+     *     ]
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of key to update. * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters of the key to update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateKeyWithResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, - List keyOps, KeyAttributes keyAttributes, Map tags, - KeyReleasePolicy releasePolicy) { - return FluxUtil.withContext(context -> updateKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, - keyAttributes, tags, releasePolicy, context)); + public Mono> updateKeyWithResponseAsync(String keyName, String keyVersion, + BinaryData parameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.updateKey(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * The update key operation changes specified attributes of a stored key and can be applied to any key type and key * version stored in Azure Key Vault. - * + * * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     key_ops (Optional): [
+     *         String(encrypt/decrypt/sign/verify/wrapKey/unwrapKey/import/export) (Optional)
+     *     ]
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of key to update. * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. + * @param parameters The parameters of the key to update. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateKeyWithResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, - List keyOps, KeyAttributes keyAttributes, Map tags, - KeyReleasePolicy releasePolicy, Context context) { + public Response updateKeyWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setReleasePolicy(releasePolicy); - return service.updateKey(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * The update key operation changes specified attributes of a stored key and can be applied to any key type and key - * version stored in Azure Key Vault. - * - * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material - * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - List keyOps, KeyAttributes keyAttributes, Map tags, - KeyReleasePolicy releasePolicy) { - return updateKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags, releasePolicy) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The update key operation changes specified attributes of a stored key and can be applied to any key type and key - * version stored in Azure Key Vault. - * - * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material - * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - List keyOps, KeyAttributes keyAttributes, Map tags, - KeyReleasePolicy releasePolicy, Context context) { - return updateKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags, releasePolicy, - context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * The update key operation changes specified attributes of a stored key and can be applied to any key type and key - * version stored in Azure Key Vault. - * - * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material - * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateKeyWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - List keyOps, KeyAttributes keyAttributes, Map tags, - KeyReleasePolicy releasePolicy, Context context) { - final String accept = "application/json"; - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - parameters.setReleasePolicy(releasePolicy); - return service.updateKeySync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * The update key operation changes specified attributes of a stored key and can be applied to any key type and key - * version stored in Azure Key Vault. - * - * In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material - * of a key itself cannot be changed. This operation requires the keys/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes The attributes of a key managed by the key vault service. - * @param tags Application specific metadata in the form of key-value pairs. - * @param releasePolicy The policy rules under which the key can be exported. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, - KeyAttributes keyAttributes, Map tags, KeyReleasePolicy releasePolicy) { - return updateKeyWithResponse(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags, releasePolicy, - Context.NONE).getValue(); - } - - /** - * Gets the public part of a stored key. - * - * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is - * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is - * optional. If not specified, the latest version of the key is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyWithResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { - return FluxUtil.withContext(context -> getKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, context)); - } - - /** - * Gets the public part of a stored key. - * - * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is - * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is - * optional. If not specified, the latest version of the key is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyWithResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, - Context context) { - final String accept = "application/json"; - return service.getKey(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), accept, context); - } - - /** - * Gets the public part of a stored key. - * - * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is - * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is - * optional. If not specified, the latest version of the key is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { - return getKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets the public part of a stored key. - * - * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is - * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is - * optional. If not specified, the latest version of the key is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, Context context) { - return getKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return service.updateKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Gets the public part of a stored key. - * + * * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key to get. * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is * optional. If not specified, the latest version of the key is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the public part of a stored key. + * + * The get key operation is applicable to all key types along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getKeyWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - Context context) { + public Mono> getKeyWithResponseAsync(String keyName, String keyVersion, + RequestOptions requestOptions) { final String accept = "application/json"; - return service.getKeySync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), accept, context); + return FluxUtil.withContext(context -> service.getKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, keyVersion, accept, requestOptions, context)); } /** * Gets the public part of a stored key. - * + * * The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is * released in the response. This operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key to get. * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI fragment is * optional. If not specified, the latest version of the key is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) { - return getKeyWithResponse(vaultBaseUrl, keyName, keyVersion, Context.NONE).getValue(); - } - - /** - * Retrieves a list of individual key versions with the same key name. - * - * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the public part of a stored key. + * + * The get key operation is applicable to all key types along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyVersionsSinglePageAsync(String vaultBaseUrl, String keyName, - Integer maxresults) { + public Response getKeyWithResponse(String keyName, String keyVersion, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.getKeyVersions(vaultBaseUrl, keyName, maxresults, this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + return service.getKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + accept, requestOptions, Context.NONE); } /** * Retrieves a list of individual key versions with the same key name. - * + * * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyVersionsSinglePageAsync(String vaultBaseUrl, String keyName, - Integer maxresults, Context context) { + private Mono> getKeyVersionsSinglePageAsync(String keyName, + RequestOptions requestOptions) { final String accept = "application/json"; - return service.getKeyVersions(vaultBaseUrl, keyName, maxresults, this.getApiVersion(), accept, context) + return FluxUtil + .withContext(context -> service.getKeyVersions(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Retrieves a list of individual key versions with the same key name. - * - * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getKeyVersionsAsync(String vaultBaseUrl, String keyName, Integer maxresults) { - return new PagedFlux<>(() -> getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), - nextLink -> getKeyVersionsNextSinglePageAsync(nextLink, vaultBaseUrl)); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** * Retrieves a list of individual key versions with the same key name. - * + * * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result as paginated response with {@link PagedFlux}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getKeyVersionsAsync(String vaultBaseUrl, String keyName, Integer maxresults, - Context context) { - return new PagedFlux<>(() -> getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults, context), - nextLink -> getKeyVersionsNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * Retrieves a list of individual key versions with the same key name. - * - * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeyVersionsSinglePage(String vaultBaseUrl, String keyName, Integer maxresults) { - final String accept = "application/json"; - Response res - = service.getKeyVersionsSync(vaultBaseUrl, keyName, maxresults, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + public PagedFlux getKeyVersionsAsync(String keyName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> getKeyVersionsSinglePageAsync(keyName, requestOptions), + nextLink -> getKeyVersionsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); } /** * Retrieves a list of individual key versions with the same key name. - * + * * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeyVersionsSinglePage(String vaultBaseUrl, String keyName, Integer maxresults, - Context context) { + private PagedResponse getKeyVersionsSinglePage(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.getKeyVersionsSync(vaultBaseUrl, keyName, maxresults, this.getApiVersion(), accept, context); + Response res = service.getKeyVersionsSync(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, Context.NONE); return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Retrieves a list of individual key versions with the same key name. - * - * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getKeyVersions(String vaultBaseUrl, String keyName, Integer maxresults) { - return new PagedIterable<>(() -> getKeyVersionsSinglePage(vaultBaseUrl, keyName, maxresults, Context.NONE), - nextLink -> getKeyVersionsNextSinglePage(nextLink, vaultBaseUrl)); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } /** * Retrieves a list of individual key versions with the same key name. - * + * * The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getKeyVersions(String vaultBaseUrl, String keyName, Integer maxresults, - Context context) { - return new PagedIterable<>(() -> getKeyVersionsSinglePage(vaultBaseUrl, keyName, maxresults, context), - nextLink -> getKeyVersionsNextSinglePage(nextLink, vaultBaseUrl, context)); + public PagedIterable getKeyVersions(String keyName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> getKeyVersionsSinglePage(keyName, requestOptions), + nextLink -> getKeyVersionsNextSinglePage(nextLink, requestOptionsForNextPage)); } /** * List keys in the specified vault. - * + * * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and * tags are provided in the response. Individual versions of a key are not listed in the response. This operation * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeysSinglePageAsync(String vaultBaseUrl, Integer maxresults) { + private Mono> getKeysSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.getKeys(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored - * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and - * tags are provided in the response. Individual versions of a key are not listed in the response. This operation - * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeysSinglePageAsync(String vaultBaseUrl, Integer maxresults, - Context context) { - final String accept = "application/json"; - return service.getKeys(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context) + .withContext(context -> service.getKeys(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + accept, requestOptions, context)) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored - * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and - * tags are provided in the response. Individual versions of a key are not listed in the response. This operation - * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getKeysAsync(String vaultBaseUrl, Integer maxresults) { - return new PagedFlux<>(() -> getKeysSinglePageAsync(vaultBaseUrl, maxresults), - nextLink -> getKeysNextSinglePageAsync(nextLink, vaultBaseUrl)); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** * List keys in the specified vault. - * + * * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and * tags are provided in the response. Individual versions of a key are not listed in the response. This operation * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result as paginated response with {@link PagedFlux}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getKeysAsync(String vaultBaseUrl, Integer maxresults, Context context) { - return new PagedFlux<>(() -> getKeysSinglePageAsync(vaultBaseUrl, maxresults, context), - nextLink -> getKeysNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * List keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored - * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and - * tags are provided in the response. Individual versions of a key are not listed in the response. This operation - * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeysSinglePage(String vaultBaseUrl, Integer maxresults) { - final String accept = "application/json"; - Response res - = service.getKeysSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + public PagedFlux getKeysAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> getKeysSinglePageAsync(requestOptions), + nextLink -> getKeysNextSinglePageAsync(nextLink, requestOptionsForNextPage)); } /** * List keys in the specified vault. - * + * * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and * tags are provided in the response. Individual versions of a key are not listed in the response. This operation * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeysSinglePage(String vaultBaseUrl, Integer maxresults, Context context) { + private PagedResponse getKeysSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.getKeysSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context); + Response res = service.getKeysSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + accept, requestOptions, Context.NONE); return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored - * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and - * tags are provided in the response. Individual versions of a key are not listed in the response. This operation - * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getKeys(String vaultBaseUrl, Integer maxresults) { - return new PagedIterable<>(() -> getKeysSinglePage(vaultBaseUrl, maxresults, Context.NONE), - nextLink -> getKeysNextSinglePage(nextLink, vaultBaseUrl)); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } /** * List keys in the specified vault. - * + * * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored * key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and * tags are provided in the response. Individual versions of a key are not listed in the response. This operation * requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getKeys(String vaultBaseUrl, Integer maxresults, Context context) { - return new PagedIterable<>(() -> getKeysSinglePage(vaultBaseUrl, maxresults, context), - nextLink -> getKeysNextSinglePage(nextLink, vaultBaseUrl, context)); + public PagedIterable getKeys(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> getKeysSinglePage(requestOptions), + nextLink -> getKeysNextSinglePage(nextLink, requestOptionsForNextPage)); } /** * Requests that a backup of the specified key be downloaded to the client. - * + * * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to @@ -1896,23 +2311,35 @@ public PagedIterable getKeys(String vaultBaseUrl, Integer maxresults, C * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the backup key result, containing the backup blob along with {@link Response} on successful completion of * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> backupKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> backupKeyWithResponseAsync(vaultBaseUrl, keyName, context)); + public Mono> backupKeyWithResponseAsync(String keyName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.backupKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** * Requests that a backup of the specified key be downloaded to the client. - * + * * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to @@ -1922,156 +2349,34 @@ public Mono> backupKeyWithResponseAsync(String vaultBa * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup key result, containing the backup blob along with {@link Response} on successful completion of - * {@link Mono}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the backup key result, containing the backup blob along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> backupKeyWithResponseAsync(String vaultBaseUrl, String keyName, - Context context) { + public Response backupKeyWithResponse(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.backupKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Requests that a backup of the specified key be downloaded to the client. - * - * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does - * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material - * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to - * allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into - * another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type - * from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within - * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another - * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical - * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup key result, containing the backup blob on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono backupKeyAsync(String vaultBaseUrl, String keyName) { - return backupKeyWithResponseAsync(vaultBaseUrl, keyName).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Requests that a backup of the specified key be downloaded to the client. - * - * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does - * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material - * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to - * allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into - * another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type - * from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within - * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another - * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical - * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup key result, containing the backup blob on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono backupKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return backupKeyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Requests that a backup of the specified key be downloaded to the client. - * - * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does - * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material - * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to - * allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into - * another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type - * from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within - * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another - * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical - * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup key result, containing the backup blob along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response backupKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { - final String accept = "application/json"; - return service.backupKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Requests that a backup of the specified key be downloaded to the client. - * - * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does - * NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material - * is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to - * allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into - * another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type - * from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within - * geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another - * geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical - * area. This operation requires the key/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup key result, containing the backup blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) { - return backupKeyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); - } - - /** - * Restores a backed up key to a vault. - * - * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and - * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual - * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when - * it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be - * rejected. While the key name is retained during restore, the final key identifier will change if the key is - * restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE - * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure - * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This - * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreKeyWithResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup) { - return FluxUtil.withContext(context -> restoreKeyWithResponseAsync(vaultBaseUrl, keyBundleBackup, context)); + return service.backupKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, accept, + requestOptions, Context.NONE); } /** * Restores a backed up key to a vault. - * + * * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when @@ -2081,81 +2386,86 @@ public Mono> restoreKeyWithResponseAsync(String vaultBaseUrl * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param parameters The parameters to restore the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreKeyWithResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup, - Context context) { + public Mono> restoreKeyWithResponseAsync(BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.setKeyBundleBackup(keyBundleBackup); - return service.restoreKey(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); - } - - /** - * Restores a backed up key to a vault. - * - * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and - * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual - * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when - * it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be - * rejected. While the key name is retained during restore, the final key identifier will change if the key is - * restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE - * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure - * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This - * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { - return restoreKeyWithResponseAsync(vaultBaseUrl, keyBundleBackup) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Restores a backed up key to a vault. - * - * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and - * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual - * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when - * it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be - * rejected. While the key name is retained during restore, the final key identifier will change if the key is - * restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE - * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure - * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This - * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, Context context) { - return restoreKeyWithResponseAsync(vaultBaseUrl, keyBundleBackup, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil.withContext(context -> service.restoreKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), contentType, accept, parameters, requestOptions, context)); } /** * Restores a backed up key to a vault. - * + * * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when @@ -2165,82 +2475,84 @@ public Mono restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBack * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param parameters The parameters to restore the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response restoreKeyWithResponse(String vaultBaseUrl, byte[] keyBundleBackup, Context context) { + public Response restoreKeyWithResponse(BinaryData parameters, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.setKeyBundleBackup(keyBundleBackup); - return service.restoreKeySync(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); - } - - /** - * Restores a backed up key to a vault. - * - * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and - * access control policies. The RESTORE operation may be used to import a previously backed up key. Individual - * versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when - * it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be - * rejected. While the key name is retained during restore, the final key identifier will change if the key is - * restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE - * operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure - * Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This - * operation requires the keys/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) { - return restoreKeyWithResponse(vaultBaseUrl, keyBundleBackup, Context.NONE).getValue(); - } - - /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * - * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key - * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on - * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for - * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public - * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a - * key-reference but do not have access to the public key material. This operation requires the keys/encrypt - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> encryptWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return FluxUtil.withContext(context -> encryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, - value, iv, aad, tag, context)); + return service.restoreKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), contentType, + accept, parameters, requestOptions, Context.NONE); } /** * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * + * * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for @@ -2248,101 +2560,57 @@ public Mono> encryptWithResponseAsync(String vaultB * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a * key-reference but do not have access to the public key material. This operation requires the keys/encrypt * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for the encryption operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> encryptWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, - Context context) { + public Mono> encryptWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.encrypt(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * - * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key - * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on - * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for - * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public - * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a - * key-reference but do not have access to the public key material. This operation requires the keys/encrypt - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return encryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * - * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key - * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on - * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for - * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public - * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a - * key-reference but do not have access to the public key material. This operation requires the keys/encrypt - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - return encryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil + .withContext(context -> service.encrypt(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * + * * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for @@ -2350,69 +2618,56 @@ public Mono encryptAsync(String vaultBaseUrl, String keyName * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a * key-reference but do not have access to the public key material. This operation requires the keys/encrypt * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for the encryption operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response encryptWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { + public Response encryptWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.encryptSync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. - * - * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key - * Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on - * the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for - * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public - * portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a - * key-reference but do not have access to the public key material. This operation requires the keys/encrypt - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return encryptWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, Context.NONE) - .getValue(); + return service.encryptSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Decrypts a single block of encrypted data. - * + * * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies @@ -2420,30 +2675,57 @@ public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String ke * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption * without first ensuring the integrity of the ciphertext using an HMAC, for example. See * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for the decryption operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> decryptWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return FluxUtil.withContext(context -> decryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, - value, iv, aad, tag, context)); + public Mono> decryptWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.decrypt(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * Decrypts a single block of encrypted data. - * + * * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies @@ -2451,2189 +2733,1772 @@ public Mono> decryptWithResponseAsync(String vaultB * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption * without first ensuring the integrity of the ciphertext using an HMAC, for example. See * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. + * @param parameters The parameters for the decryption operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key operation result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> decryptWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, - Context context) { + public Response decryptWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.decrypt(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); + return service.decryptSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** - * Decrypts a single block of encrypted data. - * - * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified - * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, - * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies - * to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This - * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption - * without first ensuring the integrity of the ciphertext using an HMAC, for example. See - * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * Creates a signature from a digest using the specified key. + * + * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation + * uses the private portion of the key. This operation requires the keys/sign permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(PS256/PS384/PS512/RS256/RS384/RS512/RSNULL/ES256/ES384/ES512/ES256K) (Required)
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. + * @param parameters The parameters for the signing operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return decryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + public Mono> signWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.sign(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + keyVersion, contentType, accept, parameters, requestOptions, context)); } /** - * Decrypts a single block of encrypted data. - * - * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified - * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, - * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies - * to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This - * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption - * without first ensuring the integrity of the ciphertext using an HMAC, for example. See - * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * Creates a signature from a digest using the specified key. + * + * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation + * uses the private portion of the key. This operation requires the keys/sign permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(PS256/PS384/PS512/RS256/RS384/RS512/RSNULL/ES256/ES384/ES512/ES256K) (Required)
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. + * @param parameters The parameters for the signing operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key operation result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - return decryptWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Decrypts a single block of encrypted data. - * - * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified - * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, - * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies - * to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This - * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption - * without first ensuring the integrity of the ciphertext using an HMAC, for example. See - * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response decryptWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.decryptSync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Decrypts a single block of encrypted data. - * - * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified - * algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, - * the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies - * to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This - * operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption - * without first ensuring the integrity of the ciphertext using an HMAC, for example. See - * https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyOperationResult decrypt(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return decryptWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, Context.NONE) - .getValue(); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> signWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { - return FluxUtil.withContext( - context -> signWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, context)); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> signWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, Context context) { - final String accept = "application/json"; - KeySignParameters parameters = new KeySignParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - return service.sign(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono signAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] value) { - return signWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono signAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] value, Context context) { - return signWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response signWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] value, Context context) { - final String accept = "application/json"; - KeySignParameters parameters = new KeySignParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - return service.signSync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Creates a signature from a digest using the specified key. - * - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation - * uses the private portion of the key. This operation requires the keys/sign permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * @param value The value parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] value) { - return signWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, value, Context.NONE).getValue(); + public Response signWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.signSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Verifies a signature using a specified key. - * - * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary - * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public - * portion of the key but this operation is supported as a convenience for callers that only have a key-reference - * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key verify result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> verifyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { - return FluxUtil.withContext(context -> verifyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, - digest, signature, context)); - } - - /** - * Verifies a signature using a specified key. - * + * * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public * portion of the key but this operation is supported as a convenience for callers that only have a key-reference * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(PS256/PS384/PS512/RS256/RS384/RS512/RSNULL/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: Base64Url (Required)
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for verify operations. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key verify result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> verifyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, Context context) { + public Mono> verifyWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.setAlgorithm(algorithm); - parameters.setDigest(digest); - parameters.setSignature(signature); - return service.verify(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Verifies a signature using a specified key. - * - * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary - * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public - * portion of the key but this operation is supported as a convenience for callers that only have a key-reference - * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key verify result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { - return verifyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Verifies a signature using a specified key. - * - * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary - * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public - * portion of the key but this operation is supported as a convenience for callers that only have a key-reference - * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key verify result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, Context context) { - return verifyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil + .withContext(context -> service.verify(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * Verifies a signature using a specified key. - * + * * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public * portion of the key but this operation is supported as a convenience for callers that only have a key-reference * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(PS256/PS384/PS512/RS256/RS384/RS512/RSNULL/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: Base64Url (Required)
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for verify operations. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key verify result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response verifyWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, Context context) { + public Response verifyWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.setAlgorithm(algorithm); - parameters.setDigest(digest); - parameters.setSignature(signature); - return service.verifySync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Verifies a signature using a specified key. - * - * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary - * for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public - * portion of the key but this operation is supported as a convenience for callers that only have a key-reference - * and not the public portion of the key. This operation requires the keys/verify permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key verify result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { - return verifyWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature, Context.NONE) - .getValue(); - } - - /** - * Wraps a symmetric key using a specified key. - * - * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been - * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure - * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This - * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have - * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> wrapKeyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return FluxUtil.withContext(context -> wrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, - value, iv, aad, tag, context)); + return service.verifySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Wraps a symmetric key using a specified key. - * + * * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for wrap operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> wrapKeyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, - Context context) { + public Mono> wrapKeyWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.wrapKey(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Wraps a symmetric key using a specified key. - * - * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been - * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure - * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This - * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have - * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return wrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Wraps a symmetric key using a specified key. - * - * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been - * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure - * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This - * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have - * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - return wrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return FluxUtil + .withContext(context -> service.wrapKey(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * Wraps a symmetric key using a specified key. - * + * * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for wrap operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response wrapKeyWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { + public Response wrapKeyWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.wrapKeySync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Wraps a symmetric key using a specified key. - * - * The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been - * stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure - * Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This - * operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have - * access to the public key material. This operation requires the keys/wrapKey permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return wrapKeyWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, Context.NONE) - .getValue(); + return service.wrapKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * + * * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for the key operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> unwrapKeyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return FluxUtil.withContext(context -> unwrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, - value, iv, aad, tag, context)); + public Mono> unwrapKeyWithResponseAsync(String keyName, String keyVersion, + BinaryData parameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.unwrapKey(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * + * * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     alg: String(RSA-OAEP/RSA-OAEP-256/RSA1_5/A128GCM/A192GCM/A256GCM/A128KW/A192KW/A256KW/A128CBC/A192CBC/A256CBC/A128CBCPAD/A192CBCPAD/A256CBCPAD/CKM_AES_KEY_WRAP/CKM_AES_KEY_WRAP_PAD) (Required)
+     *     value: Base64Url (Required)
+     *     iv: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     value: Base64Url (Optional)
+     *     iv: Base64Url (Optional)
+     *     tag: Base64Url (Optional)
+     *     aad: Base64Url (Optional)
+     * }
+     * }
+     * 
+ * * @param keyName The name of the key. * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> unwrapKeyWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, - Context context) { - final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.unwrapKey(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * - * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation - * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in - * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return unwrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * - * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation - * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in - * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - return unwrapKeyWithResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * - * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation - * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in - * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param parameters The parameters for the key operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key operation result along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response unwrapKeyWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag, Context context) { - final String accept = "application/json"; - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - parameters.setIv(iv); - parameters.setAad(aad); - parameters.setTag(tag); - return service.unwrapKeySync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. - * - * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation - * is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in - * Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. - * @param value The value parameter. - * @param iv Cryptographically random, non-repeating initialization vector for symmetric algorithms. - * @param aad Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. - * @param tag The tag to authenticate when performing decryption with an authenticated algorithm. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key operation result. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, - JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, byte[] iv, byte[] aad, byte[] tag) { - return unwrapKeyWithResponse(vaultBaseUrl, keyName, keyVersion, algorithm, value, iv, aad, tag, Context.NONE) - .getValue(); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc) { - return FluxUtil.withContext(context -> releaseWithResponseAsync(vaultBaseUrl, keyName, keyVersion, - targetAttestationToken, nonce, enc, context)); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> releaseWithResponseAsync(String vaultBaseUrl, String keyName, - String keyVersion, String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc, - Context context) { - final String accept = "application/json"; - KeyReleaseParameters parameters = new KeyReleaseParameters(); - parameters.setTargetAttestationToken(targetAttestationToken); - parameters.setNonce(nonce); - parameters.setEnc(enc); - return service.release(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, context); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseAsync(String vaultBaseUrl, String keyName, String keyVersion, - String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc) { - return releaseWithResponseAsync(vaultBaseUrl, keyName, keyVersion, targetAttestationToken, nonce, enc) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono releaseAsync(String vaultBaseUrl, String keyName, String keyVersion, - String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc, Context context) { - return releaseWithResponseAsync(vaultBaseUrl, keyName, keyVersion, targetAttestationToken, nonce, enc, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseWithResponse(String vaultBaseUrl, String keyName, String keyVersion, - String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc, Context context) { - final String accept = "application/json"; - KeyReleaseParameters parameters = new KeyReleaseParameters(); - parameters.setTargetAttestationToken(targetAttestationToken); - parameters.setNonce(nonce); - parameters.setEnc(enc); - return service.releaseSync(vaultBaseUrl, keyName, keyVersion, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Releases a key. - * - * The release key operation is applicable to all key types. The target key must be marked exportable. This - * operation requires the keys/release permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. - * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param nonce A client provided nonce for freshness. - * @param enc The encryption algorithm to use to protected the exported key material. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the release result, containing the released key. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ReleaseKeyResult release(String vaultBaseUrl, String keyName, String keyVersion, - String targetAttestationToken, String nonce, KeyExportEncryptionAlgorithm enc) { - return releaseWithResponse(vaultBaseUrl, keyName, keyVersion, targetAttestationToken, nonce, enc, Context.NONE) - .getValue(); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeysSinglePageAsync(String vaultBaseUrl, Integer maxresults) { - final String accept = "application/json"; - return FluxUtil - .withContext( - context -> service.getDeletedKeys(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeysSinglePageAsync(String vaultBaseUrl, Integer maxresults, - Context context) { - final String accept = "application/json"; - return service.getDeletedKeys(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getDeletedKeysAsync(String vaultBaseUrl, Integer maxresults) { - return new PagedFlux<>(() -> getDeletedKeysSinglePageAsync(vaultBaseUrl, maxresults), - nextLink -> getDeletedKeysNextSinglePageAsync(nextLink, vaultBaseUrl)); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getDeletedKeysAsync(String vaultBaseUrl, Integer maxresults, Context context) { - return new PagedFlux<>(() -> getDeletedKeysSinglePageAsync(vaultBaseUrl, maxresults, context), - nextLink -> getDeletedKeysNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedKeysSinglePage(String vaultBaseUrl, Integer maxresults) { - final String accept = "application/json"; - Response res - = service.getDeletedKeysSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedKeysSinglePage(String vaultBaseUrl, Integer maxresults, - Context context) { - final String accept = "application/json"; - Response res - = service.getDeletedKeysSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getDeletedKeys(String vaultBaseUrl, Integer maxresults) { - return new PagedIterable<>(() -> getDeletedKeysSinglePage(vaultBaseUrl, maxresults, Context.NONE), - nextLink -> getDeletedKeysNextSinglePage(nextLink, vaultBaseUrl)); - } - - /** - * Lists the deleted keys in the specified vault. - * - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a - * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable - * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if - * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getDeletedKeys(String vaultBaseUrl, Integer maxresults, Context context) { - return new PagedIterable<>(() -> getDeletedKeysSinglePage(vaultBaseUrl, maxresults, context), - nextLink -> getDeletedKeysNextSinglePage(nextLink, vaultBaseUrl, context)); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with - * {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> getDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context)); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with - * {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName, - Context context) { - final String accept = "application/json"; - return service.getDeletedKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info on successful completion - * of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getDeletedKeyAsync(String vaultBaseUrl, String keyName) { - return getDeletedKeyWithResponseAsync(vaultBaseUrl, keyName).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info on successful completion - * of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getDeletedKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return getDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info along with - * {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getDeletedKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { - final String accept = "application/json"; - return service.getDeletedKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Gets the public part of a deleted key. - * - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on - * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DeletedKeyBundle getDeletedKey(String vaultBaseUrl, String keyName) { - return getDeletedKeyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> purgeDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> purgeDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context)); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> purgeDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName, Context context) { - final String accept = "application/json"; - return service.purgeDeletedKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono purgeDeletedKeyAsync(String vaultBaseUrl, String keyName) { - return purgeDeletedKeyWithResponseAsync(vaultBaseUrl, keyName).flatMap(ignored -> Mono.empty()); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono purgeDeletedKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return purgeDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context).flatMap(ignored -> Mono.empty()); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response purgeDeletedKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { - final String accept = "application/json"; - return service.purgeDeletedKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Permanently deletes the specified key. - * - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked - * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the - * keys/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void purgeDeletedKey(String vaultBaseUrl, String keyName) { - purgeDeletedKeyWithResponse(vaultBaseUrl, keyName, Context.NONE); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> recoverDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName) { - return FluxUtil.withContext(context -> recoverDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context)); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> recoverDeletedKeyWithResponseAsync(String vaultBaseUrl, String keyName, - Context context) { - final String accept = "application/json"; - return service.recoverDeletedKey(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono recoverDeletedKeyAsync(String vaultBaseUrl, String keyName) { - return recoverDeletedKeyWithResponseAsync(vaultBaseUrl, keyName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono recoverDeletedKeyAsync(String vaultBaseUrl, String keyName, Context context) { - return recoverDeletedKeyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response recoverDeletedKeyWithResponse(String vaultBaseUrl, String keyName, Context context) { - final String accept = "application/json"; - return service.recoverDeletedKeySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Recovers the deleted key to its latest version. - * - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the - * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an - * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires - * the keys/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a KeyBundle consisting of a WebKey plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyBundle recoverDeletedKey(String vaultBaseUrl, String keyName) { - return recoverDeletedKeyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyRotationPolicyWithResponseAsync(String vaultBaseUrl, - String keyName) { - return FluxUtil.withContext(context -> getKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName, context)); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyRotationPolicyWithResponseAsync(String vaultBaseUrl, String keyName, - Context context) { - final String accept = "application/json"; - return service.getKeyRotationPolicy(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getKeyRotationPolicyAsync(String vaultBaseUrl, String keyName) { - return getKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getKeyRotationPolicyAsync(String vaultBaseUrl, String keyName, Context context) { - return getKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getKeyRotationPolicyWithResponse(String vaultBaseUrl, String keyName, - Context context) { - final String accept = "application/json"; - return service.getKeyRotationPolicySync(vaultBaseUrl, keyName, this.getApiVersion(), accept, context); - } - - /** - * Lists the policy for a key. - * - * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This - * operation requires the keys/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyRotationPolicy getKeyRotationPolicy(String vaultBaseUrl, String keyName) { - return getKeyRotationPolicyWithResponse(vaultBaseUrl, keyName, Context.NONE).getValue(); + public Response unwrapKeyWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.unwrapKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. + * Releases a key. + * + * The release key operation is applicable to all key types. The target key must be marked exportable. This + * operation requires the keys/release permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     target: String (Required)
+     *     nonce: String (Optional)
+     *     enc: String(CKM_RSA_AES_KEY_WRAP/RSA_AES_KEY_WRAP_256/RSA_AES_KEY_WRAP_384) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. + * @param parameters The parameters for the key release operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the release result, containing the released key along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateKeyRotationPolicyWithResponseAsync(String vaultBaseUrl, - String keyName, KeyRotationPolicy keyRotationPolicy) { - return FluxUtil.withContext( - context -> updateKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName, keyRotationPolicy, context)); + public Mono> releaseWithResponseAsync(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.release(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, keyVersion, contentType, accept, parameters, requestOptions, context)); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. + * Releases a key. + * + * The release key operation is applicable to all key types. The target key must be marked exportable. This + * operation requires the keys/release permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     target: String (Required)
+     *     nonce: String (Optional)
+     *     enc: String(CKM_RSA_AES_KEY_WRAP/RSA_AES_KEY_WRAP_256/RSA_AES_KEY_WRAP_384) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. + * @param parameters The parameters for the key release operation. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the release result, containing the released key along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateKeyRotationPolicyWithResponseAsync(String vaultBaseUrl, - String keyName, KeyRotationPolicy keyRotationPolicy, Context context) { + public Response releaseWithResponse(String keyName, String keyVersion, BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.updateKeyRotationPolicy(vaultBaseUrl, keyName, this.getApiVersion(), keyRotationPolicy, accept, - context); + return service.releaseSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, keyVersion, + contentType, accept, parameters, requestOptions, Context.NONE); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key on successful completion of {@link Mono}. + * Lists the deleted keys in the specified vault. + * + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a + * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable + * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if + * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateKeyRotationPolicyAsync(String vaultBaseUrl, String keyName, - KeyRotationPolicy keyRotationPolicy) { - return updateKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName, keyRotationPolicy) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + private Mono> getDeletedKeysSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDeletedKeys(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key on successful completion of {@link Mono}. + * Lists the deleted keys in the specified vault. + * + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a + * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable + * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if + * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedFlux}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateKeyRotationPolicyAsync(String vaultBaseUrl, String keyName, - KeyRotationPolicy keyRotationPolicy, Context context) { - return updateKeyRotationPolicyWithResponseAsync(vaultBaseUrl, keyName, keyRotationPolicy, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux getDeletedKeysAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> getDeletedKeysSinglePageAsync(requestOptions), + nextLink -> getDeletedKeysNextSinglePageAsync(nextLink, requestOptionsForNextPage)); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key along with {@link Response}. + * Lists the deleted keys in the specified vault. + * + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a + * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable + * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if + * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of keys that have been deleted in this vault along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateKeyRotationPolicyWithResponse(String vaultBaseUrl, String keyName, - KeyRotationPolicy keyRotationPolicy, Context context) { + private PagedResponse getDeletedKeysSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - return service.updateKeyRotationPolicySync(vaultBaseUrl, keyName, this.getApiVersion(), keyRotationPolicy, - accept, context); + Response res = service.getDeletedKeysSync(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } /** - * Updates the rotation policy for a key. - * - * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key in the given vault. - * @param keyRotationPolicy The policy for the key. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a key. + * Lists the deleted keys in the specified vault. + * + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a + * deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable + * for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if + * invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsIntegerNoMaximum number of results to return in a page. If not + * specified the service will return up to 25 results.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of keys that have been deleted in this vault as paginated response with {@link PagedIterable}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyRotationPolicy updateKeyRotationPolicy(String vaultBaseUrl, String keyName, - KeyRotationPolicy keyRotationPolicy) { - return updateKeyRotationPolicyWithResponse(vaultBaseUrl, keyName, keyRotationPolicy, Context.NONE).getValue(); + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable getDeletedKeys(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> getDeletedKeysSinglePage(requestOptions), + nextLink -> getDeletedKeysNextSinglePage(nextLink, requestOptionsForNextPage)); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM along with {@link Response} on + * Gets the public part of a deleted key. + * + * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on + * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the + * keys/get permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the public part of a deleted key. + * + * The Get Deleted Key operation is applicable for soft-delete enabled vaults along with {@link Response} on * successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRandomBytesWithResponseAsync(String vaultBaseUrl, int count) { - return FluxUtil.withContext(context -> getRandomBytesWithResponseAsync(vaultBaseUrl, count, context)); + public Mono> getDeletedKeyWithResponseAsync(String keyName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getDeletedKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM along with {@link Response} on - * successful completion of {@link Mono}. + * Gets the public part of a deleted key. + * + * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on + * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the + * keys/get permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the public part of a deleted key. + * + * The Get Deleted Key operation is applicable for soft-delete enabled vaults along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRandomBytesWithResponseAsync(String vaultBaseUrl, int count, - Context context) { + public Response getDeletedKeyWithResponse(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - GetRandomBytesRequest parameters = new GetRandomBytesRequest(); - parameters.setCount(count); - return service.getRandomBytes(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); + return service.getDeletedKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, accept, + requestOptions, Context.NONE); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM on successful completion of - * {@link Mono}. + * Permanently deletes the specified key. + * + * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked + * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the + * keys/purge permission. + * + * @param keyName The name of the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRandomBytesAsync(String vaultBaseUrl, int count) { - return getRandomBytesWithResponseAsync(vaultBaseUrl, count).flatMap(res -> Mono.justOrEmpty(res.getValue())); + public Mono> purgeDeletedKeyWithResponseAsync(String keyName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.purgeDeletedKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM on successful completion of - * {@link Mono}. + * Permanently deletes the specified key. + * + * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked + * on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the + * keys/purge permission. + * + * @param keyName The name of the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRandomBytesAsync(String vaultBaseUrl, int count, Context context) { - return getRandomBytesWithResponseAsync(vaultBaseUrl, count, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + public Response purgeDeletedKeyWithResponse(String keyName, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.purgeDeletedKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + accept, requestOptions, Context.NONE); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM along with {@link Response}. + * Recovers the deleted key to its latest version. + * + * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the + * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an + * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires + * the keys/recover permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the deleted key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response} on successful + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRandomBytesWithResponse(String vaultBaseUrl, int count, Context context) { + public Mono> recoverDeletedKeyWithResponseAsync(String keyName, + RequestOptions requestOptions) { final String accept = "application/json"; - GetRandomBytesRequest parameters = new GetRandomBytesRequest(); - parameters.setCount(count); - return service.getRandomBytesSync(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); + return FluxUtil.withContext(context -> service.recoverDeletedKey(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** - * Get the requested number of bytes containing random values. - * - * Get the requested number of bytes containing random values from a managed HSM. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param count The requested number of random bytes. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the requested number of bytes containing random values from a managed HSM. + * Recovers the deleted key to its latest version. + * + * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the + * deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an + * error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires + * the keys/recover permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     key (Optional): {
+     *         kid: String (Optional)
+     *         kty: String(EC/EC-HSM/RSA/RSA-HSM/oct/oct-HSM) (Optional)
+     *         key_ops (Optional): [
+     *             String (Optional)
+     *         ]
+     *         n: Base64Url (Optional)
+     *         e: Base64Url (Optional)
+     *         d: Base64Url (Optional)
+     *         dp: Base64Url (Optional)
+     *         dq: Base64Url (Optional)
+     *         qi: Base64Url (Optional)
+     *         p: Base64Url (Optional)
+     *         q: Base64Url (Optional)
+     *         k: Base64Url (Optional)
+     *         key_hsm: Base64Url (Optional)
+     *         crv: String(P-256/P-384/P-521/P-256K) (Optional)
+     *         x: Base64Url (Optional)
+     *         y: Base64Url (Optional)
+     *     }
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     release_policy (Optional): {
+     *         contentType: String (Optional)
+     *         immutable: Boolean (Optional)
+     *         data: Base64Url (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the deleted key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a KeyBundle consisting of a WebKey plus its attributes along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RandomBytes getRandomBytes(String vaultBaseUrl, int count) { - return getRandomBytesWithResponse(vaultBaseUrl, count, Context.NONE).getValue(); + public Response recoverDeletedKeyWithResponse(String keyName, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.recoverDeletedKeySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + accept, requestOptions, Context.NONE); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. + * Lists the policy for a key. + * + * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This + * operation requires the keys/get permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key in a given key vault. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyVersionsNextSinglePageAsync(String nextLink, String vaultBaseUrl) { + public Mono> getKeyRotationPolicyWithResponseAsync(String keyName, + RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getKeyVersionsNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + return FluxUtil.withContext(context -> service.getKeyRotationPolicy(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), keyName, accept, requestOptions, context)); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. + * Lists the policy for a key. + * + * The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This + * operation requires the keys/get permission. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key in a given key vault. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return management policy for a key along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyVersionsNextSinglePageAsync(String nextLink, String vaultBaseUrl, - Context context) { + public Response getKeyRotationPolicyWithResponse(String keyName, RequestOptions requestOptions) { final String accept = "application/json"; - return service.getKeyVersionsNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + return service.getKeyRotationPolicySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), keyName, + accept, requestOptions, Context.NONE); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse}. + * Updates the rotation policy for a key. + * + * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update + * permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key in the given vault. + * @param keyRotationPolicy The policy for the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return management policy for a key along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeyVersionsNextSinglePage(String nextLink, String vaultBaseUrl) { + public Mono> updateKeyRotationPolicyWithResponseAsync(String keyName, + BinaryData keyRotationPolicy, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - Response res = service.getKeyVersionsNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + return FluxUtil.withContext( + context -> service.updateKeyRotationPolicy(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, contentType, accept, keyRotationPolicy, requestOptions, context)); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse}. + * Updates the rotation policy for a key. + * + * Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update + * permission. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Optional)
+     *     lifetimeActions (Optional): [
+     *          (Optional){
+     *             trigger (Optional): {
+     *                 timeAfterCreate: String (Optional)
+     *                 timeBeforeExpiry: String (Optional)
+     *             }
+     *             action (Optional): {
+     *                 type: String(Rotate/Notify) (Optional)
+     *             }
+     *         }
+     *     ]
+     *     attributes (Optional): {
+     *         expiryTime: String (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param keyName The name of the key in the given vault. + * @param keyRotationPolicy The policy for the key. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return management policy for a key along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeyVersionsNextSinglePage(String nextLink, String vaultBaseUrl, Context context) { + public Response updateKeyRotationPolicyWithResponse(String keyName, BinaryData keyRotationPolicy, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - Response res = service.getKeyVersionsNextSync(nextLink, vaultBaseUrl, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + return service.updateKeyRotationPolicySync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), + keyName, contentType, accept, keyRotationPolicy, requestOptions, Context.NONE); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. + * Get the requested number of bytes containing random values. + * + * Get the requested number of bytes containing random values from a managed HSM. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     count: int (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + * @param parameters The request object to get random bytes. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the requested number of bytes containing random values. + * + * Get the requested number of bytes containing random values from a managed HSM along with {@link Response} on + * successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeysNextSinglePageAsync(String nextLink, String vaultBaseUrl) { + public Mono> getRandomBytesWithResponseAsync(BinaryData parameters, + RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getKeysNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + return FluxUtil.withContext(context -> service.getRandomBytes(this.getVaultBaseUrl(), + this.getServiceVersion().getVersion(), contentType, accept, parameters, requestOptions, context)); } /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeysNextSinglePageAsync(String nextLink, String vaultBaseUrl, - Context context) { + * Get the requested number of bytes containing random values. + * + * Get the requested number of bytes containing random values from a managed HSM. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     count: int (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+     * 
+ * + * @param parameters The request object to get random bytes. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the requested number of bytes containing random values. + * + * Get the requested number of bytes containing random values from a managed HSM along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRandomBytesWithResponse(BinaryData parameters, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.getKeysNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + return service.getRandomBytesSync(this.getVaultBaseUrl(), this.getServiceVersion().getVersion(), contentType, + accept, parameters, requestOptions, Context.NONE); } /** + * Retrieves a list of individual key versions with the same key name. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the key list result along with {@link PagedResponse}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeysNextSinglePage(String nextLink, String vaultBaseUrl) { + private Mono> getKeyVersionsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.getKeysNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + return FluxUtil.withContext( + context -> service.getKeyVersionsNext(nextLink, this.getVaultBaseUrl(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** + * Retrieves a list of individual key versions with the same key name. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return the key list result along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getKeysNextSinglePage(String nextLink, String vaultBaseUrl, Context context) { + private PagedResponse getKeyVersionsNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.getKeysNextSync(nextLink, vaultBaseUrl, accept, context); + Response res + = service.getKeyVersionsNextSync(nextLink, this.getVaultBaseUrl(), accept, requestOptions, Context.NONE); return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } /** + * List keys in the specified vault. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful - * completion of {@link Mono}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key list result along with {@link PagedResponse} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeysNextSinglePageAsync(String nextLink, String vaultBaseUrl) { + private Mono> getKeysNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDeletedKeysNext(nextLink, vaultBaseUrl, accept, context)) + return FluxUtil + .withContext( + context -> service.getKeysNext(nextLink, this.getVaultBaseUrl(), accept, requestOptions, context)) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** + * List keys in the specified vault. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful - * completion of {@link Mono}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the key list result along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedKeysNextSinglePageAsync(String nextLink, String vaultBaseUrl, - Context context) { + private PagedResponse getKeysNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDeletedKeysNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); + Response res + = service.getKeysNextSync(nextLink, this.getVaultBaseUrl(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } /** + * Lists the deleted keys in the specified vault. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of keys that have been deleted in this vault along with {@link PagedResponse}. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of keys that have been deleted in this vault along with {@link PagedResponse} on successful + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedKeysNextSinglePage(String nextLink, String vaultBaseUrl) { + private Mono> getDeletedKeysNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.getDeletedKeysNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + return FluxUtil.withContext( + context -> service.getDeletedKeysNext(nextLink, this.getVaultBaseUrl(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); } /** + * Lists the deleted keys in the specified vault. + * * Get the next page of items. - * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kid: String (Optional)
+     *     attributes (Optional): {
+     *         enabled: Boolean (Optional)
+     *         nbf: Long (Optional)
+     *         exp: Long (Optional)
+     *         created: Long (Optional)
+     *         updated: Long (Optional)
+     *         recoverableDays: Integer (Optional)
+     *         recoveryLevel: String(Purgeable/Recoverable+Purgeable/Recoverable/Recoverable+ProtectedSubscription/CustomizedRecoverable+Purgeable/CustomizedRecoverable/CustomizedRecoverable+ProtectedSubscription) (Optional)
+     *         exportable: Boolean (Optional)
+     *         hsmPlatform: String (Optional)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Required)
+     *     }
+     *     managed: Boolean (Optional)
+     *     recoveryId: String (Optional)
+     *     scheduledPurgeDate: Long (Optional)
+     *     deletedDate: Long (Optional)
+     * }
+     * }
+     * 
+ * * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return a list of keys that have been deleted in this vault along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedKeysNextSinglePage(String nextLink, String vaultBaseUrl, - Context context) { + private PagedResponse getDeletedKeysNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.getDeletedKeysNextSync(nextLink, vaultBaseUrl, accept, context); + Response res + = service.getDeletedKeysNextSync(nextLink, this.getVaultBaseUrl(), accept, requestOptions, Context.NONE); return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyVaultKeysUtils.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyVaultKeysUtils.java index aef4314a5c59c..86fc5b89ff711 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyVaultKeysUtils.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/KeyVaultKeysUtils.java @@ -3,16 +3,14 @@ package com.azure.security.keyvault.keys.implementation; import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.RequestOptions; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import com.azure.json.JsonReader; import com.azure.security.keyvault.keys.KeyServiceVersion; import com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder; import com.azure.security.keyvault.keys.cryptography.CryptographyServiceVersion; -import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException; import java.io.IOException; import java.net.MalformedURLException; @@ -31,6 +29,8 @@ public final class KeyVaultKeysUtils { private static final ClientLogger LOGGER = new ClientLogger(KeyVaultKeysUtils.class); + public static final RequestOptions EMPTY_OPTIONS = new RequestOptions(); + /** * Creates a {@link CryptographyClientBuilder} based on the values passed from a Keys service client. * @@ -78,35 +78,19 @@ private static String generateKeyId(String keyName, String keyVersion, String va } /** - * Calls a supplier and maps any {@link KeyVaultErrorException} to an {@link HttpResponseException}. + * Calls a supplier and maps any {@link HttpResponseException} to an {@link HttpResponseException}. * * @param The type of the result of the supplier. * @param call The supplier to call. - * @param exceptionMapper The function to map a {@link KeyVaultErrorException} to an {@link HttpResponseException}. + * @param exceptionMapper The function to map a {@link HttpResponseException} to an {@link HttpResponseException}. * @return The result of the supplier. */ public static T callWithMappedException(Supplier call, - Function exceptionMapper) { + Function exceptionMapper) { try { return call.get(); - } catch (KeyVaultErrorException ex) { - throw exceptionMapper.apply(ex); - } - } - - /** - * Maps a {@link KeyVaultErrorException} to an {@link HttpResponseException} for get key operations. - * - * @param ex The {@link KeyVaultErrorException} to map. - * @return The {@link HttpResponseException} that maps from the {@link KeyVaultErrorException}. - */ - public static HttpResponseException mapGetKeyException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 403) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; + } catch (HttpResponseException e) { + throw exceptionMapper.apply(e); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Attributes.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Attributes.java deleted file mode 100644 index af80db7418167..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Attributes.java +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; - -/** - * The object attributes managed by the KeyVault service. - */ -@Fluent -public class Attributes implements JsonSerializable { - /* - * Determines whether the object is enabled. - */ - private Boolean enabled; - - /* - * Not before date in UTC. - */ - private Long notBefore; - - /* - * Expiry date in UTC. - */ - private Long expires; - - /* - * Creation time in UTC. - */ - private Long created; - - /* - * Last updated time in UTC. - */ - private Long updated; - - /** - * Creates an instance of Attributes class. - */ - public Attributes() { - } - - /** - * Get the enabled property: Determines whether the object is enabled. - * - * @return the enabled value. - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled property: Determines whether the object is enabled. - * - * @param enabled the enabled value to set. - * @return the Attributes object itself. - */ - public Attributes setEnabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the notBefore property: Not before date in UTC. - * - * @return the notBefore value. - */ - public OffsetDateTime getNotBefore() { - if (this.notBefore == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.notBefore), ZoneOffset.UTC); - } - - /** - * Set the notBefore property: Not before date in UTC. - * - * @param notBefore the notBefore value to set. - * @return the Attributes object itself. - */ - public Attributes setNotBefore(OffsetDateTime notBefore) { - if (notBefore == null) { - this.notBefore = null; - } else { - this.notBefore = notBefore.toEpochSecond(); - } - return this; - } - - /** - * Get the expires property: Expiry date in UTC. - * - * @return the expires value. - */ - public OffsetDateTime getExpires() { - if (this.expires == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expires), ZoneOffset.UTC); - } - - /** - * Set the expires property: Expiry date in UTC. - * - * @param expires the expires value to set. - * @return the Attributes object itself. - */ - public Attributes setExpires(OffsetDateTime expires) { - if (expires == null) { - this.expires = null; - } else { - this.expires = expires.toEpochSecond(); - } - return this; - } - - /** - * Get the created property: Creation time in UTC. - * - * @return the created value. - */ - public OffsetDateTime getCreated() { - if (this.created == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); - } - - /** - * Set the created property: Creation time in UTC. - * - * @param created the created value to set. - * @return the Attributes object itself. - */ - Attributes setCreated(OffsetDateTime created) { - if (created == null) { - this.created = null; - } else { - this.created = created.toEpochSecond(); - } - return this; - } - - /** - * Get the updated property: Last updated time in UTC. - * - * @return the updated value. - */ - public OffsetDateTime getUpdated() { - if (this.updated == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.updated), ZoneOffset.UTC); - } - - /** - * Set the updated property: Last updated time in UTC. - * - * @param updated the updated value to set. - * @return the Attributes object itself. - */ - Attributes setUpdated(OffsetDateTime updated) { - if (updated == null) { - this.updated = null; - } else { - this.updated = updated.toEpochSecond(); - } - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("enabled", this.enabled); - jsonWriter.writeNumberField("nbf", this.notBefore); - jsonWriter.writeNumberField("exp", this.expires); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Attributes from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Attributes if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IOException If an error occurs while reading the Attributes. - */ - public static Attributes fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Attributes deserializedAttributes = new Attributes(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("enabled".equals(fieldName)) { - deserializedAttributes.enabled = reader.getNullable(JsonReader::getBoolean); - } else if ("nbf".equals(fieldName)) { - deserializedAttributes.notBefore = reader.getNullable(JsonReader::getLong); - } else if ("exp".equals(fieldName)) { - deserializedAttributes.expires = reader.getNullable(JsonReader::getLong); - } else if ("created".equals(fieldName)) { - deserializedAttributes.created = reader.getNullable(JsonReader::getLong); - } else if ("updated".equals(fieldName)) { - deserializedAttributes.updated = reader.getNullable(JsonReader::getLong); - } else { - reader.skipChildren(); - } - } - - return deserializedAttributes; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/BackupKeyResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/BackupKeyResult.java index c6cfc35a17c0c..77b2c5aa613c8 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/BackupKeyResult.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/BackupKeyResult.java @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; import com.azure.json.JsonReader; @@ -20,12 +21,14 @@ public final class BackupKeyResult implements JsonSerializable /* * The backup blob containing the backed up key. */ + @Generated private Base64Url value; /** * Creates an instance of BackupKeyResult class. */ - public BackupKeyResult() { + @Generated + private BackupKeyResult() { } /** @@ -33,6 +36,7 @@ public BackupKeyResult() { * * @return the value value. */ + @Generated public byte[] getValue() { if (this.value == null) { return null; @@ -43,6 +47,7 @@ public byte[] getValue() { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -57,6 +62,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the BackupKeyResult. */ + @Generated public static BackupKeyResult fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { BackupKeyResult deserializedBackupKeyResult = new BackupKeyResult(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyBundle.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyBundle.java index 9b4365d2c9b2a..d4135a2043a84 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyBundle.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyBundle.java @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; @@ -17,77 +19,92 @@ /** * A DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info. */ -@Fluent -public final class DeletedKeyBundle extends KeyBundle { +@Immutable +public final class DeletedKeyBundle implements JsonSerializable { /* - * The url of the recovery object, used to identify and recover the deleted key. + * The Json web key. */ - private String recoveryId; + @Generated + private JsonWebKey key; /* - * The time when the key is scheduled to be purged, in UTC + * The key management attributes. */ - private Long scheduledPurgeDate; + @Generated + private KeyAttributes attributes; /* - * The time when the key was deleted, in UTC + * Application specific metadata in the form of key-value pairs. */ - private Long deletedDate; + @Generated + private Map tags; /* * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be * true. */ + @Generated private Boolean managed; - /** - * Creates an instance of DeletedKeyBundle class. + /* + * The policy rules under which the key can be exported. */ - public DeletedKeyBundle() { - } + @Generated + private KeyReleasePolicy releasePolicy; + + /* + * The url of the recovery object, used to identify and recover the deleted key. + */ + @Generated + private String recoveryId; + + /* + * The time when the key is scheduled to be purged, in UTC + */ + @Generated + private Long scheduledPurgeDate; + + /* + * The time when the key was deleted, in UTC + */ + @Generated + private Long deletedDate; /** - * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. - * - * @return the recoveryId value. + * Creates an instance of DeletedKeyBundle class. */ - public String getRecoveryId() { - return this.recoveryId; + @Generated + private DeletedKeyBundle() { } /** - * Set the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. + * Get the key property: The Json web key. * - * @param recoveryId the recoveryId value to set. - * @return the DeletedKeyBundle object itself. + * @return the key value. */ - public DeletedKeyBundle setRecoveryId(String recoveryId) { - this.recoveryId = recoveryId; - return this; + @Generated + public JsonWebKey getKey() { + return this.key; } /** - * Get the scheduledPurgeDate property: The time when the key is scheduled to be purged, in UTC. + * Get the attributes property: The key management attributes. * - * @return the scheduledPurgeDate value. + * @return the attributes value. */ - public OffsetDateTime getScheduledPurgeDate() { - if (this.scheduledPurgeDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); + @Generated + public KeyAttributes getAttributes() { + return this.attributes; } /** - * Get the deletedDate property: The time when the key was deleted, in UTC. + * Get the tags property: Application specific metadata in the form of key-value pairs. * - * @return the deletedDate value. + * @return the tags value. */ - public OffsetDateTime getDeletedDate() { - if (this.deletedDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); + @Generated + public Map getTags() { + return this.tags; } /** @@ -96,57 +113,68 @@ public OffsetDateTime getDeletedDate() { * * @return the managed value. */ - @Override + @Generated public Boolean isManaged() { return this.managed; } /** - * {@inheritDoc} + * Get the releasePolicy property: The policy rules under which the key can be exported. + * + * @return the releasePolicy value. */ - @Override - public DeletedKeyBundle setKey(JsonWebKey key) { - super.setKey(key); - return this; + @Generated + public KeyReleasePolicy getReleasePolicy() { + return this.releasePolicy; } /** - * {@inheritDoc} + * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. + * + * @return the recoveryId value. */ - @Override - public DeletedKeyBundle setAttributes(KeyAttributes attributes) { - super.setAttributes(attributes); - return this; + @Generated + public String getRecoveryId() { + return this.recoveryId; } /** - * {@inheritDoc} + * Get the scheduledPurgeDate property: The time when the key is scheduled to be purged, in UTC. + * + * @return the scheduledPurgeDate value. */ - @Override - public DeletedKeyBundle setTags(Map tags) { - super.setTags(tags); - return this; + @Generated + public OffsetDateTime getScheduledPurgeDate() { + if (this.scheduledPurgeDate == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); } /** - * {@inheritDoc} + * Get the deletedDate property: The time when the key was deleted, in UTC. + * + * @return the deletedDate value. */ - @Override - public DeletedKeyBundle setReleasePolicy(KeyReleasePolicy releasePolicy) { - super.setReleasePolicy(releasePolicy); - return this; + @Generated + public OffsetDateTime getDeletedDate() { + if (this.deletedDate == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); } /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("key", getKey()); - jsonWriter.writeJsonField("attributes", getAttributes()); - jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); - jsonWriter.writeJsonField("release_policy", getReleasePolicy()); + jsonWriter.writeJsonField("key", this.key); + jsonWriter.writeJsonField("attributes", this.attributes); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("release_policy", this.releasePolicy); jsonWriter.writeStringField("recoveryId", this.recoveryId); return jsonWriter.writeEndObject(); } @@ -159,6 +187,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the DeletedKeyBundle. */ + @Generated public static DeletedKeyBundle fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { DeletedKeyBundle deserializedDeletedKeyBundle = new DeletedKeyBundle(); @@ -167,16 +196,16 @@ public static DeletedKeyBundle fromJson(JsonReader jsonReader) throws IOExceptio reader.nextToken(); if ("key".equals(fieldName)) { - deserializedDeletedKeyBundle.setKey(JsonWebKey.fromJson(reader)); + deserializedDeletedKeyBundle.key = JsonWebKey.fromJson(reader); } else if ("attributes".equals(fieldName)) { - deserializedDeletedKeyBundle.setAttributes(KeyAttributes.fromJson(reader)); + deserializedDeletedKeyBundle.attributes = KeyAttributes.fromJson(reader); } else if ("tags".equals(fieldName)) { Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedDeletedKeyBundle.setTags(tags); + deserializedDeletedKeyBundle.tags = tags; } else if ("managed".equals(fieldName)) { deserializedDeletedKeyBundle.managed = reader.getNullable(JsonReader::getBoolean); } else if ("release_policy".equals(fieldName)) { - deserializedDeletedKeyBundle.setReleasePolicy(KeyReleasePolicy.fromJson(reader)); + deserializedDeletedKeyBundle.releasePolicy = KeyReleasePolicy.fromJson(reader); } else if ("recoveryId".equals(fieldName)) { deserializedDeletedKeyBundle.recoveryId = reader.getString(); } else if ("scheduledPurgeDate".equals(fieldName)) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyItem.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyItem.java index 6a11612360d65..bee2d03e60fe4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyItem.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyItem.java @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; @@ -17,77 +19,86 @@ /** * The deleted key item containing the deleted key metadata and information about deletion. */ -@Fluent -public final class DeletedKeyItem extends KeyItem { +@Immutable +public final class DeletedKeyItem implements JsonSerializable { /* - * The url of the recovery object, used to identify and recover the deleted key. + * Key identifier. */ - private String recoveryId; + @Generated + private String kid; /* - * The time when the key is scheduled to be purged, in UTC + * The key management attributes. */ - private Long scheduledPurgeDate; + @Generated + private KeyAttributes attributes; /* - * The time when the key was deleted, in UTC + * Application specific metadata in the form of key-value pairs. */ - private Long deletedDate; + @Generated + private Map tags; /* * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be * true. */ + @Generated private Boolean managed; - /** - * Creates an instance of DeletedKeyItem class. + /* + * The url of the recovery object, used to identify and recover the deleted key. */ - public DeletedKeyItem() { - } + @Generated + private String recoveryId; + + /* + * The time when the key is scheduled to be purged, in UTC + */ + @Generated + private Long scheduledPurgeDate; + + /* + * The time when the key was deleted, in UTC + */ + @Generated + private Long deletedDate; /** - * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. - * - * @return the recoveryId value. + * Creates an instance of DeletedKeyItem class. */ - public String getRecoveryId() { - return this.recoveryId; + @Generated + private DeletedKeyItem() { } /** - * Set the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. + * Get the kid property: Key identifier. * - * @param recoveryId the recoveryId value to set. - * @return the DeletedKeyItem object itself. + * @return the kid value. */ - public DeletedKeyItem setRecoveryId(String recoveryId) { - this.recoveryId = recoveryId; - return this; + @Generated + public String getKid() { + return this.kid; } /** - * Get the scheduledPurgeDate property: The time when the key is scheduled to be purged, in UTC. + * Get the attributes property: The key management attributes. * - * @return the scheduledPurgeDate value. + * @return the attributes value. */ - public OffsetDateTime getScheduledPurgeDate() { - if (this.scheduledPurgeDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); + @Generated + public KeyAttributes getAttributes() { + return this.attributes; } /** - * Get the deletedDate property: The time when the key was deleted, in UTC. + * Get the tags property: Application specific metadata in the form of key-value pairs. * - * @return the deletedDate value. + * @return the tags value. */ - public OffsetDateTime getDeletedDate() { - if (this.deletedDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); + @Generated + public Map getTags() { + return this.tags; } /** @@ -96,47 +107,57 @@ public OffsetDateTime getDeletedDate() { * * @return the managed value. */ - @Override + @Generated public Boolean isManaged() { return this.managed; } /** - * {@inheritDoc} + * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted key. + * + * @return the recoveryId value. */ - @Override - public DeletedKeyItem setKid(String kid) { - super.setKid(kid); - return this; + @Generated + public String getRecoveryId() { + return this.recoveryId; } /** - * {@inheritDoc} + * Get the scheduledPurgeDate property: The time when the key is scheduled to be purged, in UTC. + * + * @return the scheduledPurgeDate value. */ - @Override - public DeletedKeyItem setAttributes(KeyAttributes attributes) { - super.setAttributes(attributes); - return this; + @Generated + public OffsetDateTime getScheduledPurgeDate() { + if (this.scheduledPurgeDate == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); } /** - * {@inheritDoc} + * Get the deletedDate property: The time when the key was deleted, in UTC. + * + * @return the deletedDate value. */ - @Override - public DeletedKeyItem setTags(Map tags) { - super.setTags(tags); - return this; + @Generated + public OffsetDateTime getDeletedDate() { + if (this.deletedDate == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); } /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("kid", getKid()); - jsonWriter.writeJsonField("attributes", getAttributes()); - jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("kid", this.kid); + jsonWriter.writeJsonField("attributes", this.attributes); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("recoveryId", this.recoveryId); return jsonWriter.writeEndObject(); } @@ -149,6 +170,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the DeletedKeyItem. */ + @Generated public static DeletedKeyItem fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { DeletedKeyItem deserializedDeletedKeyItem = new DeletedKeyItem(); @@ -157,12 +179,12 @@ public static DeletedKeyItem fromJson(JsonReader jsonReader) throws IOException reader.nextToken(); if ("kid".equals(fieldName)) { - deserializedDeletedKeyItem.setKid(reader.getString()); + deserializedDeletedKeyItem.kid = reader.getString(); } else if ("attributes".equals(fieldName)) { - deserializedDeletedKeyItem.setAttributes(KeyAttributes.fromJson(reader)); + deserializedDeletedKeyItem.attributes = KeyAttributes.fromJson(reader); } else if ("tags".equals(fieldName)) { Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedDeletedKeyItem.setTags(tags); + deserializedDeletedKeyItem.tags = tags; } else if ("managed".equals(fieldName)) { deserializedDeletedKeyItem.managed = reader.getNullable(JsonReader::getBoolean); } else if ("recoveryId".equals(fieldName)) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyListResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyListResult.java deleted file mode 100644 index ea1014033faf8..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletedKeyListResult.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * A list of keys that have been deleted in this vault. - */ -@Immutable -public final class DeletedKeyListResult implements JsonSerializable { - /* - * A response message containing a list of deleted keys in the vault along with a link to the next page of deleted - * keys - */ - private List value; - - /* - * The URL to get the next set of deleted keys. - */ - private String nextLink; - - /** - * Creates an instance of DeletedKeyListResult class. - */ - public DeletedKeyListResult() { - } - - /** - * Get the value property: A response message containing a list of deleted keys in the vault along with a link to - * the next page of deleted keys. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Get the nextLink property: The URL to get the next set of deleted keys. - * - * @return the nextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DeletedKeyListResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DeletedKeyListResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the DeletedKeyListResult. - */ - public static DeletedKeyListResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - DeletedKeyListResult deserializedDeletedKeyListResult = new DeletedKeyListResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - List value = reader.readArray(reader1 -> DeletedKeyItem.fromJson(reader1)); - deserializedDeletedKeyListResult.value = value; - } else if ("nextLink".equals(fieldName)) { - deserializedDeletedKeyListResult.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedDeletedKeyListResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletionRecoveryLevel.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletionRecoveryLevel.java index 73ccff158f27d..166df2baadf1f 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletionRecoveryLevel.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/DeletionRecoveryLevel.java @@ -1,16 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' - * the key can be permanently deleted by a privileged user; otherwise, only the system can purge the key, at the end of - * the retention interval. + * Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains + * 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can purge + * the certificate, at the end of the retention interval. */ public final class DeletionRecoveryLevel extends ExpandableStringEnum { /** @@ -18,6 +19,7 @@ public final class DeletionRecoveryLevel extends ExpandableStringEnum values() { return values(DeletionRecoveryLevel.class); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Error.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Error.java deleted file mode 100644 index 95a6daf023c6d..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/Error.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The key vault server error. - */ -@Immutable -public final class Error implements JsonSerializable { - /* - * The error code. - */ - private String code; - - /* - * The error message. - */ - private String message; - - /* - * The key vault server error. - */ - private Error innerError; - - /** - * Creates an instance of Error class. - */ - public Error() { - } - - /** - * Get the code property: The error code. - * - * @return the code value. - */ - public String getCode() { - return this.code; - } - - /** - * Get the message property: The error message. - * - * @return the message value. - */ - public String getMessage() { - return this.message; - } - - /** - * Get the innerError property: The key vault server error. - * - * @return the innerError value. - */ - public Error getInnerError() { - return this.innerError; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Error from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Error if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. - * @throws IOException If an error occurs while reading the Error. - */ - public static Error fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Error deserializedError = new Error(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedError.code = reader.getString(); - } else if ("message".equals(fieldName)) { - deserializedError.message = reader.getString(); - } else if ("innererror".equals(fieldName)) { - deserializedError.innerError = Error.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedError; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/GetRandomBytesRequest.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/GetRandomBytesRequest.java index 34079cb1b7b7c..68621b738b355 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/GetRandomBytesRequest.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/GetRandomBytesRequest.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -14,17 +15,22 @@ /** * The get random bytes request object. */ -@Fluent +@Immutable public final class GetRandomBytesRequest implements JsonSerializable { /* * The requested number of random bytes. */ - private int count; + @Generated + private final int count; /** * Creates an instance of GetRandomBytesRequest class. + * + * @param count the count value to set. */ - public GetRandomBytesRequest() { + @Generated + public GetRandomBytesRequest(int count) { + this.count = count; } /** @@ -32,24 +38,15 @@ public GetRandomBytesRequest() { * * @return the count value. */ + @Generated public int getCount() { return this.count; } - /** - * Set the count property: The requested number of random bytes. - * - * @param count the count value to set. - * @return the GetRandomBytesRequest object itself. - */ - public GetRandomBytesRequest setCount(int count) { - this.count = count; - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -66,21 +63,21 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the GetRandomBytesRequest. */ + @Generated public static GetRandomBytesRequest fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - GetRandomBytesRequest deserializedGetRandomBytesRequest = new GetRandomBytesRequest(); + int count = 0; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("count".equals(fieldName)) { - deserializedGetRandomBytesRequest.count = reader.getInt(); + count = reader.getInt(); } else { reader.skipChildren(); } } - - return deserializedGetRandomBytesRequest; + return new GetRandomBytesRequest(count); }); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKey.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKey.java index 3e8ab290f2d76..a260d82c628a7 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKey.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKey.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.core.util.Base64Url; import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; @@ -12,7 +13,6 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import com.azure.security.keyvault.keys.models.KeyCurveName; -import com.azure.security.keyvault.keys.models.KeyOperation; import com.azure.security.keyvault.keys.models.KeyType; import java.io.IOException; import java.util.List; @@ -26,86 +26,103 @@ public final class JsonWebKey implements JsonSerializable { /* * Key identifier. */ + @Generated private String kid; /* * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. */ + @Generated private KeyType kty; /* - * The key_ops property. + * Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. */ - private List keyOps; + @Generated + private List keyOps; /* * RSA modulus. */ + @Generated private Base64Url n; /* * RSA public exponent. */ + @Generated private Base64Url e; /* * RSA private exponent, or the D component of an EC private key. */ + @Generated private Base64Url d; /* * RSA private key parameter. */ + @Generated private Base64Url dp; /* * RSA private key parameter. */ + @Generated private Base64Url dq; /* * RSA private key parameter. */ + @Generated private Base64Url qi; /* * RSA secret prime. */ + @Generated private Base64Url p; /* * RSA secret prime, with p < q. */ + @Generated private Base64Url q; /* * Symmetric key. */ + @Generated private Base64Url k; /* * Protected Key, used with 'Bring Your Own Key'. */ + @Generated private Base64Url t; /* - * Elliptic curve name. + * Elliptic curve name. For valid values, see JsonWebKeyCurveName. */ + @Generated private KeyCurveName crv; /* * X component of an EC public key. */ + @Generated private Base64Url x; /* * Y component of an EC public key. */ + @Generated private Base64Url y; /** * Creates an instance of JsonWebKey class. */ + @Generated public JsonWebKey() { } @@ -114,6 +131,7 @@ public JsonWebKey() { * * @return the kid value. */ + @Generated public String getKid() { return this.kid; } @@ -124,6 +142,7 @@ public String getKid() { * @param kid the kid value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setKid(String kid) { this.kid = kid; return this; @@ -135,6 +154,7 @@ public JsonWebKey setKid(String kid) { * * @return the kty value. */ + @Generated public KeyType getKty() { return this.kty; } @@ -146,27 +166,32 @@ public KeyType getKty() { * @param kty the kty value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setKty(KeyType kty) { this.kty = kty; return this; } /** - * Get the keyOps property: The key_ops property. + * Get the keyOps property: Json web key operations. For more information on possible key operations, see + * JsonWebKeyOperation. * * @return the keyOps value. */ - public List getKeyOps() { + @Generated + public List getKeyOps() { return this.keyOps; } /** - * Set the keyOps property: The key_ops property. + * Set the keyOps property: Json web key operations. For more information on possible key operations, see + * JsonWebKeyOperation. * * @param keyOps the keyOps value to set. * @return the JsonWebKey object itself. */ - public JsonWebKey setKeyOps(List keyOps) { + @Generated + public JsonWebKey setKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -176,6 +201,7 @@ public JsonWebKey setKeyOps(List keyOps) { * * @return the n value. */ + @Generated public byte[] getN() { if (this.n == null) { return null; @@ -189,6 +215,7 @@ public byte[] getN() { * @param n the n value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setN(byte[] n) { if (n == null) { this.n = null; @@ -203,6 +230,7 @@ public JsonWebKey setN(byte[] n) { * * @return the e value. */ + @Generated public byte[] getE() { if (this.e == null) { return null; @@ -216,6 +244,7 @@ public byte[] getE() { * @param e the e value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setE(byte[] e) { if (e == null) { this.e = null; @@ -230,6 +259,7 @@ public JsonWebKey setE(byte[] e) { * * @return the d value. */ + @Generated public byte[] getD() { if (this.d == null) { return null; @@ -243,6 +273,7 @@ public byte[] getD() { * @param d the d value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setD(byte[] d) { if (d == null) { this.d = null; @@ -257,6 +288,7 @@ public JsonWebKey setD(byte[] d) { * * @return the dp value. */ + @Generated public byte[] getDp() { if (this.dp == null) { return null; @@ -270,6 +302,7 @@ public byte[] getDp() { * @param dp the dp value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setDp(byte[] dp) { if (dp == null) { this.dp = null; @@ -284,6 +317,7 @@ public JsonWebKey setDp(byte[] dp) { * * @return the dq value. */ + @Generated public byte[] getDq() { if (this.dq == null) { return null; @@ -297,6 +331,7 @@ public byte[] getDq() { * @param dq the dq value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setDq(byte[] dq) { if (dq == null) { this.dq = null; @@ -311,6 +346,7 @@ public JsonWebKey setDq(byte[] dq) { * * @return the qi value. */ + @Generated public byte[] getQi() { if (this.qi == null) { return null; @@ -324,6 +360,7 @@ public byte[] getQi() { * @param qi the qi value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setQi(byte[] qi) { if (qi == null) { this.qi = null; @@ -338,6 +375,7 @@ public JsonWebKey setQi(byte[] qi) { * * @return the p value. */ + @Generated public byte[] getP() { if (this.p == null) { return null; @@ -351,6 +389,7 @@ public byte[] getP() { * @param p the p value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setP(byte[] p) { if (p == null) { this.p = null; @@ -365,6 +404,7 @@ public JsonWebKey setP(byte[] p) { * * @return the q value. */ + @Generated public byte[] getQ() { if (this.q == null) { return null; @@ -378,6 +418,7 @@ public byte[] getQ() { * @param q the q value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setQ(byte[] q) { if (q == null) { this.q = null; @@ -392,6 +433,7 @@ public JsonWebKey setQ(byte[] q) { * * @return the k value. */ + @Generated public byte[] getK() { if (this.k == null) { return null; @@ -405,6 +447,7 @@ public byte[] getK() { * @param k the k value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setK(byte[] k) { if (k == null) { this.k = null; @@ -419,6 +462,7 @@ public JsonWebKey setK(byte[] k) { * * @return the t value. */ + @Generated public byte[] getT() { if (this.t == null) { return null; @@ -432,6 +476,7 @@ public byte[] getT() { * @param t the t value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setT(byte[] t) { if (t == null) { this.t = null; @@ -442,20 +487,22 @@ public JsonWebKey setT(byte[] t) { } /** - * Get the crv property: Elliptic curve name. + * Get the crv property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. * * @return the crv value. */ + @Generated public KeyCurveName getCrv() { return this.crv; } /** - * Set the crv property: Elliptic curve name. + * Set the crv property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. * * @param crv the crv value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setCrv(KeyCurveName crv) { this.crv = crv; return this; @@ -466,6 +513,7 @@ public JsonWebKey setCrv(KeyCurveName crv) { * * @return the x value. */ + @Generated public byte[] getX() { if (this.x == null) { return null; @@ -479,6 +527,7 @@ public byte[] getX() { * @param x the x value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setX(byte[] x) { if (x == null) { this.x = null; @@ -493,6 +542,7 @@ public JsonWebKey setX(byte[] x) { * * @return the y value. */ + @Generated public byte[] getY() { if (this.y == null) { return null; @@ -506,6 +556,7 @@ public byte[] getY() { * @param y the y value to set. * @return the JsonWebKey object itself. */ + @Generated public JsonWebKey setY(byte[] y) { if (y == null) { this.y = null; @@ -518,13 +569,13 @@ public JsonWebKey setY(byte[] y) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("kid", this.kid); jsonWriter.writeStringField("kty", this.kty == null ? null : this.kty.toString()); - jsonWriter.writeArrayField("key_ops", this.keyOps, - (writer, element) -> writer.writeString(element == null ? null : element.toString())); + jsonWriter.writeArrayField("key_ops", this.keyOps, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("n", Objects.toString(this.n, null)); jsonWriter.writeStringField("e", Objects.toString(this.e, null)); jsonWriter.writeStringField("d", Objects.toString(this.d, null)); @@ -549,6 +600,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * to JSON null. * @throws IOException If an error occurs while reading the JsonWebKey. */ + @Generated public static JsonWebKey fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { JsonWebKey deserializedJsonWebKey = new JsonWebKey(); @@ -561,8 +613,7 @@ public static JsonWebKey fromJson(JsonReader jsonReader) throws IOException { } else if ("kty".equals(fieldName)) { deserializedJsonWebKey.kty = KeyType.fromString(reader.getString()); } else if ("key_ops".equals(fieldName)) { - List keyOps - = reader.readArray(reader1 -> KeyOperation.fromString(reader1.getString())); + List keyOps = reader.readArray(reader1 -> reader1.getString()); deserializedJsonWebKey.keyOps = keyOps; } else if ("n".equals(fieldName)) { deserializedJsonWebKey.n diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeyEncryptionAlgorithm.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeyEncryptionAlgorithm.java index 3def90a799f4c..cdd2a4eebfbf4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeyEncryptionAlgorithm.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeyEncryptionAlgorithm.java @@ -1,96 +1,128 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; /** - * algorithm identifier. + * An algorithm used for encryption and decryption. */ public final class JsonWebKeyEncryptionAlgorithm extends ExpandableStringEnum { /** - * Static value RSA-OAEP for JsonWebKeyEncryptionAlgorithm. + * RSAES using Optimal Asymmetric Encryption Padding (OAEP), as described in https://tools.ietf.org/html/rfc3447, + * with the default parameters specified by RFC 3447 in Section A.2.1. Those default parameters are using a hash + * function of SHA-1 and a mask generation function of MGF1 with SHA-1. */ - public static final JsonWebKeyEncryptionAlgorithm RSAOAEP = fromString("RSA-OAEP"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP = fromString("RSA-OAEP"); /** - * Static value RSA-OAEP-256 for JsonWebKeyEncryptionAlgorithm. + * RSAES using Optimal Asymmetric Encryption Padding with a hash function of SHA-256 and a mask generation function + * of MGF1 with SHA-256. */ - public static final JsonWebKeyEncryptionAlgorithm RSAOAEP256 = fromString("RSA-OAEP-256"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP256 = fromString("RSA-OAEP-256"); /** - * Static value RSA1_5 for JsonWebKeyEncryptionAlgorithm. + * RSAES-PKCS1-V1_5 key encryption, as described in https://tools.ietf.org/html/rfc3447. */ - public static final JsonWebKeyEncryptionAlgorithm RSA15 = fromString("RSA1_5"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm RSA1_5 = fromString("RSA1_5"); /** - * Static value A128GCM for JsonWebKeyEncryptionAlgorithm. + * 128-bit AES-GCM. */ - public static final JsonWebKeyEncryptionAlgorithm A128GCM = fromString("A128GCM"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A128_GCM = fromString("A128GCM"); /** - * Static value A192GCM for JsonWebKeyEncryptionAlgorithm. + * 192-bit AES-GCM. */ - public static final JsonWebKeyEncryptionAlgorithm A192GCM = fromString("A192GCM"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A192_GCM = fromString("A192GCM"); /** - * Static value A256GCM for JsonWebKeyEncryptionAlgorithm. + * 256-bit AES-GCM. */ - public static final JsonWebKeyEncryptionAlgorithm A256GCM = fromString("A256GCM"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A256_GCM = fromString("A256GCM"); /** - * Static value A128KW for JsonWebKeyEncryptionAlgorithm. + * 128-bit AES key wrap. */ - public static final JsonWebKeyEncryptionAlgorithm A128KW = fromString("A128KW"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A128_KW = fromString("A128KW"); /** - * Static value A192KW for JsonWebKeyEncryptionAlgorithm. + * 192-bit AES key wrap. */ - public static final JsonWebKeyEncryptionAlgorithm A192KW = fromString("A192KW"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A192_KW = fromString("A192KW"); /** - * Static value A256KW for JsonWebKeyEncryptionAlgorithm. + * 256-bit AES key wrap. */ - public static final JsonWebKeyEncryptionAlgorithm A256KW = fromString("A256KW"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A256_KW = fromString("A256KW"); /** - * Static value A128CBC for JsonWebKeyEncryptionAlgorithm. + * 128-bit AES-CBC. */ - public static final JsonWebKeyEncryptionAlgorithm A128CBC = fromString("A128CBC"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A128_CBC = fromString("A128CBC"); /** - * Static value A192CBC for JsonWebKeyEncryptionAlgorithm. + * 192-bit AES-CBC. */ - public static final JsonWebKeyEncryptionAlgorithm A192CBC = fromString("A192CBC"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A192_CBC = fromString("A192CBC"); /** - * Static value A256CBC for JsonWebKeyEncryptionAlgorithm. + * 256-bit AES-CBC. */ - public static final JsonWebKeyEncryptionAlgorithm A256CBC = fromString("A256CBC"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A256_CBC = fromString("A256CBC"); /** - * Static value A128CBCPAD for JsonWebKeyEncryptionAlgorithm. + * 128-bit AES-CBC with PKCS padding. */ - public static final JsonWebKeyEncryptionAlgorithm A128CBCPAD = fromString("A128CBCPAD"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A128_CBCPAD = fromString("A128CBCPAD"); /** - * Static value A192CBCPAD for JsonWebKeyEncryptionAlgorithm. + * 192-bit AES-CBC with PKCS padding. */ - public static final JsonWebKeyEncryptionAlgorithm A192CBCPAD = fromString("A192CBCPAD"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A192_CBCPAD = fromString("A192CBCPAD"); /** - * Static value A256CBCPAD for JsonWebKeyEncryptionAlgorithm. + * 256-bit AES-CBC with PKCS padding. */ - public static final JsonWebKeyEncryptionAlgorithm A256CBCPAD = fromString("A256CBCPAD"); + @Generated + public static final JsonWebKeyEncryptionAlgorithm A256_CBCPAD = fromString("A256CBCPAD"); + + /** + * CKM AES key wrap. + */ + @Generated + public static final JsonWebKeyEncryptionAlgorithm CKM_AES_KEY_WRAP = fromString("CKM_AES_KEY_WRAP"); + + /** + * CKM AES key wrap with padding. + */ + @Generated + public static final JsonWebKeyEncryptionAlgorithm CKM_AES_KEY_WRAP_PAD = fromString("CKM_AES_KEY_WRAP_PAD"); /** * Creates a new instance of JsonWebKeyEncryptionAlgorithm value. * * @deprecated Use the {@link #fromString(String)} factory method. */ + @Generated @Deprecated public JsonWebKeyEncryptionAlgorithm() { } @@ -101,6 +133,7 @@ public JsonWebKeyEncryptionAlgorithm() { * @param name a name to look for. * @return the corresponding JsonWebKeyEncryptionAlgorithm. */ + @Generated public static JsonWebKeyEncryptionAlgorithm fromString(String name) { return fromString(name, JsonWebKeyEncryptionAlgorithm.class); } @@ -110,6 +143,7 @@ public static JsonWebKeyEncryptionAlgorithm fromString(String name) { * * @return known JsonWebKeyEncryptionAlgorithm values. */ + @Generated public static Collection values() { return values(JsonWebKeyEncryptionAlgorithm.class); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeySignatureAlgorithm.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeySignatureAlgorithm.java index 791ca48500c09..0a35b9537b22e 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeySignatureAlgorithm.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/JsonWebKeySignatureAlgorithm.java @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; @@ -15,63 +16,75 @@ public final class JsonWebKeySignatureAlgorithm extends ExpandableStringEnum values() { return values(JsonWebKeySignatureAlgorithm.class); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyAttributes.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyAttributes.java index 8e207d0f06ee8..16fe9f338a266 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyAttributes.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyAttributes.java @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; @@ -17,10 +19,41 @@ * The attributes of a key managed by the key vault service. */ @Fluent -public final class KeyAttributes extends Attributes { +public final class KeyAttributes implements JsonSerializable { + /* + * Determines whether the object is enabled. + */ + @Generated + private Boolean enabled; + + /* + * Not before date in UTC. + */ + @Generated + private Long notBefore; + + /* + * Expiry date in UTC. + */ + @Generated + private Long expires; + + /* + * Creation time in UTC. + */ + @Generated + private Long created; + + /* + * Last updated time in UTC. + */ + @Generated + private Long updated; + /* * softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, otherwise 0. */ + @Generated private Integer recoverableDays; /* @@ -28,85 +61,120 @@ public final class KeyAttributes extends Attributes { * 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the system can purge the * key, at the end of the retention interval. */ + @Generated private DeletionRecoveryLevel recoveryLevel; /* * Indicates if the private key can be exported. Release policy must be provided when creating the first version of * an exportable key. */ + @Generated private Boolean exportable; /* * The underlying HSM Platform. */ + @Generated private String hsmPlatform; - /* - * Last updated time in UTC. + /** + * Creates an instance of KeyAttributes class. */ - private Long updated; + @Generated + public KeyAttributes() { + } - /* - * Creation time in UTC. + /** + * Get the enabled property: Determines whether the object is enabled. + * + * @return the enabled value. */ - private Long created; + @Generated + public Boolean isEnabled() { + return this.enabled; + } /** - * Creates an instance of KeyAttributes class. + * Set the enabled property: Determines whether the object is enabled. + * + * @param enabled the enabled value to set. + * @return the KeyAttributes object itself. */ - public KeyAttributes() { + @Generated + public KeyAttributes setEnabled(Boolean enabled) { + this.enabled = enabled; + return this; } /** - * Get the recoverableDays property: softDelete data retention days. Value should be >=7 and <=90 when - * softDelete enabled, otherwise 0. + * Get the notBefore property: Not before date in UTC. * - * @return the recoverableDays value. + * @return the notBefore value. */ - public Integer getRecoverableDays() { - return this.recoverableDays; + @Generated + public OffsetDateTime getNotBefore() { + if (this.notBefore == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.notBefore), ZoneOffset.UTC); } /** - * Get the recoveryLevel property: Reflects the deletion recovery level currently in effect for keys in the current - * vault. If it contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the - * system can purge the key, at the end of the retention interval. + * Set the notBefore property: Not before date in UTC. * - * @return the recoveryLevel value. + * @param notBefore the notBefore value to set. + * @return the KeyAttributes object itself. */ - public DeletionRecoveryLevel getRecoveryLevel() { - return this.recoveryLevel; + @Generated + public KeyAttributes setNotBefore(OffsetDateTime notBefore) { + if (notBefore == null) { + this.notBefore = null; + } else { + this.notBefore = notBefore.toEpochSecond(); + } + return this; } /** - * Get the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. + * Get the expires property: Expiry date in UTC. * - * @return the exportable value. + * @return the expires value. */ - public Boolean isExportable() { - return this.exportable; + @Generated + public OffsetDateTime getExpires() { + if (this.expires == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expires), ZoneOffset.UTC); } /** - * Set the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. + * Set the expires property: Expiry date in UTC. * - * @param exportable the exportable value to set. + * @param expires the expires value to set. * @return the KeyAttributes object itself. */ - public KeyAttributes setExportable(Boolean exportable) { - this.exportable = exportable; + @Generated + public KeyAttributes setExpires(OffsetDateTime expires) { + if (expires == null) { + this.expires = null; + } else { + this.expires = expires.toEpochSecond(); + } return this; } /** - * Get the hsmPlatform property: The underlying HSM Platform. + * Get the created property: Creation time in UTC. * - * @return the hsmPlatform value. + * @return the created value. */ - public String getHsmPlatform() { - return this.hsmPlatform; + @Generated + public OffsetDateTime getCreated() { + if (this.created == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); } /** @@ -114,7 +182,7 @@ public String getHsmPlatform() { * * @return the updated value. */ - @Override + @Generated public OffsetDateTime getUpdated() { if (this.updated == null) { return null; @@ -123,58 +191,72 @@ public OffsetDateTime getUpdated() { } /** - * Get the created property: Creation time in UTC. + * Get the recoverableDays property: softDelete data retention days. Value should be >=7 and <=90 when + * softDelete enabled, otherwise 0. * - * @return the created value. + * @return the recoverableDays value. */ - @Override - public OffsetDateTime getCreated() { - if (this.created == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); + @Generated + public Integer getRecoverableDays() { + return this.recoverableDays; } /** - * {@inheritDoc} + * Get the recoveryLevel property: Reflects the deletion recovery level currently in effect for keys in the current + * vault. If it contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the + * system can purge the key, at the end of the retention interval. + * + * @return the recoveryLevel value. */ - @Override - public KeyAttributes setEnabled(Boolean enabled) { - super.setEnabled(enabled); - return this; + @Generated + public DeletionRecoveryLevel getRecoveryLevel() { + return this.recoveryLevel; } /** - * {@inheritDoc} + * Get the exportable property: Indicates if the private key can be exported. Release policy must be provided when + * creating the first version of an exportable key. + * + * @return the exportable value. */ - @Override - public KeyAttributes setNotBefore(OffsetDateTime notBefore) { - super.setNotBefore(notBefore); - return this; + @Generated + public Boolean isExportable() { + return this.exportable; } /** - * {@inheritDoc} + * Set the exportable property: Indicates if the private key can be exported. Release policy must be provided when + * creating the first version of an exportable key. + * + * @param exportable the exportable value to set. + * @return the KeyAttributes object itself. */ - @Override - public KeyAttributes setExpires(OffsetDateTime expires) { - super.setExpires(expires); + @Generated + public KeyAttributes setExportable(Boolean exportable) { + this.exportable = exportable; return this; } + /** + * Get the hsmPlatform property: The underlying HSM Platform. + * + * @return the hsmPlatform value. + */ + @Generated + public String getHsmPlatform() { + return this.hsmPlatform; + } + /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("enabled", isEnabled()); - if (getNotBefore() != null) { - jsonWriter.writeNumberField("nbf", getNotBefore().toEpochSecond()); - } - if (getExpires() != null) { - jsonWriter.writeNumberField("exp", getExpires().toEpochSecond()); - } + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeNumberField("nbf", this.notBefore); + jsonWriter.writeNumberField("exp", this.expires); jsonWriter.writeBooleanField("exportable", this.exportable); return jsonWriter.writeEndObject(); } @@ -187,6 +269,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the KeyAttributes. */ + @Generated public static KeyAttributes fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyAttributes deserializedKeyAttributes = new KeyAttributes(); @@ -195,19 +278,11 @@ public static KeyAttributes fromJson(JsonReader jsonReader) throws IOException { reader.nextToken(); if ("enabled".equals(fieldName)) { - deserializedKeyAttributes.setEnabled(reader.getNullable(JsonReader::getBoolean)); + deserializedKeyAttributes.enabled = reader.getNullable(JsonReader::getBoolean); } else if ("nbf".equals(fieldName)) { - Long notBeforeHolder = reader.getNullable(JsonReader::getLong); - if (notBeforeHolder != null) { - deserializedKeyAttributes.setNotBefore( - OffsetDateTime.ofInstant(Instant.ofEpochSecond(notBeforeHolder), ZoneOffset.UTC)); - } + deserializedKeyAttributes.notBefore = reader.getNullable(JsonReader::getLong); } else if ("exp".equals(fieldName)) { - Long expiresHolder = reader.getNullable(JsonReader::getLong); - if (expiresHolder != null) { - deserializedKeyAttributes - .setExpires(OffsetDateTime.ofInstant(Instant.ofEpochSecond(expiresHolder), ZoneOffset.UTC)); - } + deserializedKeyAttributes.expires = reader.getNullable(JsonReader::getLong); } else if ("created".equals(fieldName)) { deserializedKeyAttributes.created = reader.getNullable(JsonReader::getLong); } else if ("updated".equals(fieldName)) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyBundle.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyBundle.java index ca2eb19b893a7..09ef2fa6747ca 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyBundle.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyBundle.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -15,38 +16,44 @@ /** * A KeyBundle consisting of a WebKey plus its attributes. */ -@Fluent -public class KeyBundle implements JsonSerializable { +@Immutable +public final class KeyBundle implements JsonSerializable { /* * The Json web key. */ + @Generated private JsonWebKey key; /* * The key management attributes. */ + @Generated private KeyAttributes attributes; /* * Application specific metadata in the form of key-value pairs. */ + @Generated private Map tags; /* * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be * true. */ + @Generated private Boolean managed; /* * The policy rules under which the key can be exported. */ + @Generated private KeyReleasePolicy releasePolicy; /** * Creates an instance of KeyBundle class. */ - public KeyBundle() { + @Generated + private KeyBundle() { } /** @@ -54,106 +61,56 @@ public KeyBundle() { * * @return the key value. */ + @Generated public JsonWebKey getKey() { return this.key; } - /** - * Set the key property: The Json web key. - * - * @param key the key value to set. - * @return the KeyBundle object itself. - */ - public KeyBundle setKey(JsonWebKey key) { - this.key = key; - return this; - } - /** * Get the attributes property: The key management attributes. * * @return the attributes value. */ + @Generated public KeyAttributes getAttributes() { return this.attributes; } - /** - * Set the attributes property: The key management attributes. - * - * @param attributes the attributes value to set. - * @return the KeyBundle object itself. - */ - public KeyBundle setAttributes(KeyAttributes attributes) { - this.attributes = attributes; - return this; - } - /** * Get the tags property: Application specific metadata in the form of key-value pairs. * * @return the tags value. */ + @Generated public Map getTags() { return this.tags; } - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the KeyBundle object itself. - */ - public KeyBundle setTags(Map tags) { - this.tags = tags; - return this; - } - /** * Get the managed property: True if the key's lifetime is managed by key vault. If this is a key backing a * certificate, then managed will be true. * * @return the managed value. */ + @Generated public Boolean isManaged() { return this.managed; } - /** - * Set the managed property: True if the key's lifetime is managed by key vault. If this is a key backing a - * certificate, then managed will be true. - * - * @param managed the managed value to set. - * @return the KeyBundle object itself. - */ - KeyBundle setManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * Get the releasePolicy property: The policy rules under which the key can be exported. * * @return the releasePolicy value. */ + @Generated public KeyReleasePolicy getReleasePolicy() { return this.releasePolicy; } - /** - * Set the releasePolicy property: The policy rules under which the key can be exported. - * - * @param releasePolicy the releasePolicy value to set. - * @return the KeyBundle object itself. - */ - public KeyBundle setReleasePolicy(KeyReleasePolicy releasePolicy) { - this.releasePolicy = releasePolicy; - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -172,6 +129,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * to JSON null. * @throws IOException If an error occurs while reading the KeyBundle. */ + @Generated public static KeyBundle fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyBundle deserializedKeyBundle = new KeyBundle(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyCreateParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyCreateParameters.java index a01382b38fd97..79e63176977d8 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyCreateParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyCreateParameters.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -22,78 +23,79 @@ @Fluent public final class KeyCreateParameters implements JsonSerializable { /* - * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. + * The type of key to create. For valid values, see JsonWebKeyType. */ - private KeyType kty; + @Generated + private final KeyType kty; /* * The key size in bits. For example: 2048, 3072, or 4096 for RSA. */ + @Generated private Integer keySize; /* * The public exponent for a RSA key. */ + @Generated private Integer publicExponent; /* - * The key_ops property. + * Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. */ + @Generated private List keyOps; /* * The attributes of a key managed by the key vault service. */ + @Generated private KeyAttributes keyAttributes; /* * Application specific metadata in the form of key-value pairs. */ + @Generated private Map tags; /* - * Elliptic curve name. + * Elliptic curve name. For valid values, see JsonWebKeyCurveName. */ - private KeyCurveName crv; + @Generated + private KeyCurveName curve; /* * The policy rules under which the key can be exported. */ + @Generated private KeyReleasePolicy releasePolicy; /** * Creates an instance of KeyCreateParameters class. + * + * @param kty the kty value to set. */ - public KeyCreateParameters() { + @Generated + public KeyCreateParameters(KeyType kty) { + this.kty = kty; } /** - * Get the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. + * Get the kty property: The type of key to create. For valid values, see JsonWebKeyType. * * @return the kty value. */ + @Generated public KeyType getKty() { return this.kty; } - /** - * Set the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * - * @param kty the kty value to set. - * @return the KeyCreateParameters object itself. - */ - public KeyCreateParameters setKty(KeyType kty) { - this.kty = kty; - return this; - } - /** * Get the keySize property: The key size in bits. For example: 2048, 3072, or 4096 for RSA. * * @return the keySize value. */ + @Generated public Integer getKeySize() { return this.keySize; } @@ -104,6 +106,7 @@ public Integer getKeySize() { * @param keySize the keySize value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setKeySize(Integer keySize) { this.keySize = keySize; return this; @@ -114,6 +117,7 @@ public KeyCreateParameters setKeySize(Integer keySize) { * * @return the publicExponent value. */ + @Generated public Integer getPublicExponent() { return this.publicExponent; } @@ -124,26 +128,31 @@ public Integer getPublicExponent() { * @param publicExponent the publicExponent value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setPublicExponent(Integer publicExponent) { this.publicExponent = publicExponent; return this; } /** - * Get the keyOps property: The key_ops property. + * Get the keyOps property: Json web key operations. For more information on possible key operations, see + * JsonWebKeyOperation. * * @return the keyOps value. */ + @Generated public List getKeyOps() { return this.keyOps; } /** - * Set the keyOps property: The key_ops property. + * Set the keyOps property: Json web key operations. For more information on possible key operations, see + * JsonWebKeyOperation. * * @param keyOps the keyOps value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setKeyOps(List keyOps) { this.keyOps = keyOps; return this; @@ -154,6 +163,7 @@ public KeyCreateParameters setKeyOps(List keyOps) { * * @return the keyAttributes value. */ + @Generated public KeyAttributes getKeyAttributes() { return this.keyAttributes; } @@ -164,6 +174,7 @@ public KeyAttributes getKeyAttributes() { * @param keyAttributes the keyAttributes value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; @@ -174,6 +185,7 @@ public KeyCreateParameters setKeyAttributes(KeyAttributes keyAttributes) { * * @return the tags value. */ + @Generated public Map getTags() { return this.tags; } @@ -184,28 +196,31 @@ public Map getTags() { * @param tags the tags value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setTags(Map tags) { this.tags = tags; return this; } /** - * Get the crv property: Elliptic curve name. + * Get the curve property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. * - * @return the crv value. + * @return the curve value. */ - public KeyCurveName getCrv() { - return this.crv; + @Generated + public KeyCurveName getCurve() { + return this.curve; } /** - * Set the crv property: Elliptic curve name. + * Set the curve property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. * - * @param crv the crv value to set. + * @param curve the curve value to set. * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setCrv(KeyCurveName crv) { - this.crv = crv; + @Generated + public KeyCreateParameters setCurve(KeyCurveName curve) { + this.curve = curve; return this; } @@ -214,6 +229,7 @@ public KeyCreateParameters setCrv(KeyCurveName crv) { * * @return the releasePolicy value. */ + @Generated public KeyReleasePolicy getReleasePolicy() { return this.releasePolicy; } @@ -224,6 +240,7 @@ public KeyReleasePolicy getReleasePolicy() { * @param releasePolicy the releasePolicy value to set. * @return the KeyCreateParameters object itself. */ + @Generated public KeyCreateParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { this.releasePolicy = releasePolicy; return this; @@ -232,6 +249,7 @@ public KeyCreateParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -242,7 +260,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { (writer, element) -> writer.writeString(element == null ? null : element.toString())); jsonWriter.writeJsonField("attributes", this.keyAttributes); jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - jsonWriter.writeStringField("crv", this.crv == null ? null : this.crv.toString()); + jsonWriter.writeStringField("crv", this.curve == null ? null : this.curve.toString()); jsonWriter.writeJsonField("release_policy", this.releasePolicy); return jsonWriter.writeEndObject(); } @@ -256,36 +274,49 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the KeyCreateParameters. */ + @Generated public static KeyCreateParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - KeyCreateParameters deserializedKeyCreateParameters = new KeyCreateParameters(); + KeyType kty = null; + Integer keySize = null; + Integer publicExponent = null; + List keyOps = null; + KeyAttributes keyAttributes = null; + Map tags = null; + KeyCurveName curve = null; + KeyReleasePolicy releasePolicy = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("kty".equals(fieldName)) { - deserializedKeyCreateParameters.kty = KeyType.fromString(reader.getString()); + kty = KeyType.fromString(reader.getString()); } else if ("key_size".equals(fieldName)) { - deserializedKeyCreateParameters.keySize = reader.getNullable(JsonReader::getInt); + keySize = reader.getNullable(JsonReader::getInt); } else if ("public_exponent".equals(fieldName)) { - deserializedKeyCreateParameters.publicExponent = reader.getNullable(JsonReader::getInt); + publicExponent = reader.getNullable(JsonReader::getInt); } else if ("key_ops".equals(fieldName)) { - List keyOps - = reader.readArray(reader1 -> KeyOperation.fromString(reader1.getString())); - deserializedKeyCreateParameters.keyOps = keyOps; + keyOps = reader.readArray(reader1 -> KeyOperation.fromString(reader1.getString())); } else if ("attributes".equals(fieldName)) { - deserializedKeyCreateParameters.keyAttributes = KeyAttributes.fromJson(reader); + keyAttributes = KeyAttributes.fromJson(reader); } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedKeyCreateParameters.tags = tags; + tags = reader.readMap(reader1 -> reader1.getString()); } else if ("crv".equals(fieldName)) { - deserializedKeyCreateParameters.crv = KeyCurveName.fromString(reader.getString()); + curve = KeyCurveName.fromString(reader.getString()); } else if ("release_policy".equals(fieldName)) { - deserializedKeyCreateParameters.releasePolicy = KeyReleasePolicy.fromJson(reader); + releasePolicy = KeyReleasePolicy.fromJson(reader); } else { reader.skipChildren(); } } + KeyCreateParameters deserializedKeyCreateParameters = new KeyCreateParameters(kty); + deserializedKeyCreateParameters.keySize = keySize; + deserializedKeyCreateParameters.publicExponent = publicExponent; + deserializedKeyCreateParameters.keyOps = keyOps; + deserializedKeyCreateParameters.keyAttributes = keyAttributes; + deserializedKeyCreateParameters.tags = tags; + deserializedKeyCreateParameters.curve = curve; + deserializedKeyCreateParameters.releasePolicy = releasePolicy; return deserializedKeyCreateParameters; }); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyExportParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyExportParameters.java deleted file mode 100644 index 97533a27ac5b6..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyExportParameters.java +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.keys.models.KeyExportEncryptionAlgorithm; -import java.io.IOException; - -/** - * The export key parameters. - */ -@Fluent -public final class KeyExportParameters implements JsonSerializable { - /* - * The export key encryption Json web key. This key MUST be a RSA key that supports encryption. - */ - private JsonWebKey wrappingKey; - - /* - * The export key encryption key identifier. This key MUST be a RSA key that supports encryption. - */ - private String wrappingKid; - - /* - * The encryption algorithm to use to protected the exported key material - */ - private KeyExportEncryptionAlgorithm enc; - - /** - * Creates an instance of KeyExportParameters class. - */ - public KeyExportParameters() { - } - - /** - * Get the wrappingKey property: The export key encryption Json web key. This key MUST be a RSA key that supports - * encryption. - * - * @return the wrappingKey value. - */ - public JsonWebKey getWrappingKey() { - return this.wrappingKey; - } - - /** - * Set the wrappingKey property: The export key encryption Json web key. This key MUST be a RSA key that supports - * encryption. - * - * @param wrappingKey the wrappingKey value to set. - * @return the KeyExportParameters object itself. - */ - public KeyExportParameters setWrappingKey(JsonWebKey wrappingKey) { - this.wrappingKey = wrappingKey; - return this; - } - - /** - * Get the wrappingKid property: The export key encryption key identifier. This key MUST be a RSA key that supports - * encryption. - * - * @return the wrappingKid value. - */ - public String getWrappingKid() { - return this.wrappingKid; - } - - /** - * Set the wrappingKid property: The export key encryption key identifier. This key MUST be a RSA key that supports - * encryption. - * - * @param wrappingKid the wrappingKid value to set. - * @return the KeyExportParameters object itself. - */ - public KeyExportParameters setWrappingKid(String wrappingKid) { - this.wrappingKid = wrappingKid; - return this; - } - - /** - * Get the enc property: The encryption algorithm to use to protected the exported key material. - * - * @return the enc value. - */ - public KeyExportEncryptionAlgorithm getEnc() { - return this.enc; - } - - /** - * Set the enc property: The encryption algorithm to use to protected the exported key material. - * - * @param enc the enc value to set. - * @return the KeyExportParameters object itself. - */ - public KeyExportParameters setEnc(KeyExportEncryptionAlgorithm enc) { - this.enc = enc; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("wrappingKey", this.wrappingKey); - jsonWriter.writeStringField("wrappingKid", this.wrappingKid); - jsonWriter.writeStringField("enc", this.enc == null ? null : this.enc.toString()); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyExportParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyExportParameters if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyExportParameters. - */ - public static KeyExportParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyExportParameters deserializedKeyExportParameters = new KeyExportParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("wrappingKey".equals(fieldName)) { - deserializedKeyExportParameters.wrappingKey = JsonWebKey.fromJson(reader); - } else if ("wrappingKid".equals(fieldName)) { - deserializedKeyExportParameters.wrappingKid = reader.getString(); - } else if ("enc".equals(fieldName)) { - deserializedKeyExportParameters.enc = KeyExportEncryptionAlgorithm.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyExportParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyImportParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyImportParameters.java index 35bd87eb23efd..4a8bf0a37bfd7 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyImportParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyImportParameters.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -20,32 +21,41 @@ public final class KeyImportParameters implements JsonSerializable tags; /* * The policy rules under which the key can be exported. */ + @Generated private KeyReleasePolicy releasePolicy; /** * Creates an instance of KeyImportParameters class. + * + * @param key the key value to set. */ - public KeyImportParameters() { + @Generated + public KeyImportParameters(JsonWebKey key) { + this.key = key; } /** @@ -53,6 +63,7 @@ public KeyImportParameters() { * * @return the hsm value. */ + @Generated public Boolean isHsm() { return this.hsm; } @@ -63,6 +74,7 @@ public Boolean isHsm() { * @param hsm the hsm value to set. * @return the KeyImportParameters object itself. */ + @Generated public KeyImportParameters setHsm(Boolean hsm) { this.hsm = hsm; return this; @@ -73,26 +85,17 @@ public KeyImportParameters setHsm(Boolean hsm) { * * @return the key value. */ + @Generated public JsonWebKey getKey() { return this.key; } - /** - * Set the key property: The Json web key. - * - * @param key the key value to set. - * @return the KeyImportParameters object itself. - */ - public KeyImportParameters setKey(JsonWebKey key) { - this.key = key; - return this; - } - /** * Get the keyAttributes property: The key management attributes. * * @return the keyAttributes value. */ + @Generated public KeyAttributes getKeyAttributes() { return this.keyAttributes; } @@ -103,6 +106,7 @@ public KeyAttributes getKeyAttributes() { * @param keyAttributes the keyAttributes value to set. * @return the KeyImportParameters object itself. */ + @Generated public KeyImportParameters setKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; @@ -113,6 +117,7 @@ public KeyImportParameters setKeyAttributes(KeyAttributes keyAttributes) { * * @return the tags value. */ + @Generated public Map getTags() { return this.tags; } @@ -123,6 +128,7 @@ public Map getTags() { * @param tags the tags value to set. * @return the KeyImportParameters object itself. */ + @Generated public KeyImportParameters setTags(Map tags) { this.tags = tags; return this; @@ -133,6 +139,7 @@ public KeyImportParameters setTags(Map tags) { * * @return the releasePolicy value. */ + @Generated public KeyReleasePolicy getReleasePolicy() { return this.releasePolicy; } @@ -143,6 +150,7 @@ public KeyReleasePolicy getReleasePolicy() { * @param releasePolicy the releasePolicy value to set. * @return the KeyImportParameters object itself. */ + @Generated public KeyImportParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { this.releasePolicy = releasePolicy; return this; @@ -151,6 +159,7 @@ public KeyImportParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -171,28 +180,37 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the KeyImportParameters. */ + @Generated public static KeyImportParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - KeyImportParameters deserializedKeyImportParameters = new KeyImportParameters(); + JsonWebKey key = null; + Boolean hsm = null; + KeyAttributes keyAttributes = null; + Map tags = null; + KeyReleasePolicy releasePolicy = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("key".equals(fieldName)) { - deserializedKeyImportParameters.key = JsonWebKey.fromJson(reader); + key = JsonWebKey.fromJson(reader); } else if ("Hsm".equals(fieldName)) { - deserializedKeyImportParameters.hsm = reader.getNullable(JsonReader::getBoolean); + hsm = reader.getNullable(JsonReader::getBoolean); } else if ("attributes".equals(fieldName)) { - deserializedKeyImportParameters.keyAttributes = KeyAttributes.fromJson(reader); + keyAttributes = KeyAttributes.fromJson(reader); } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedKeyImportParameters.tags = tags; + tags = reader.readMap(reader1 -> reader1.getString()); } else if ("release_policy".equals(fieldName)) { - deserializedKeyImportParameters.releasePolicy = KeyReleasePolicy.fromJson(reader); + releasePolicy = KeyReleasePolicy.fromJson(reader); } else { reader.skipChildren(); } } + KeyImportParameters deserializedKeyImportParameters = new KeyImportParameters(key); + deserializedKeyImportParameters.hsm = hsm; + deserializedKeyImportParameters.keyAttributes = keyAttributes; + deserializedKeyImportParameters.tags = tags; + deserializedKeyImportParameters.releasePolicy = releasePolicy; return deserializedKeyImportParameters; }); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyItem.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyItem.java index b21d84785ae1b..359677646e1be 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyItem.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyItem.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -15,33 +16,38 @@ /** * The key item containing key metadata. */ -@Fluent -public class KeyItem implements JsonSerializable { +@Immutable +public final class KeyItem implements JsonSerializable { /* * Key identifier. */ + @Generated private String kid; /* * The key management attributes. */ + @Generated private KeyAttributes attributes; /* * Application specific metadata in the form of key-value pairs. */ + @Generated private Map tags; /* * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be * true. */ + @Generated private Boolean managed; /** * Creates an instance of KeyItem class. */ - public KeyItem() { + @Generated + private KeyItem() { } /** @@ -49,86 +55,46 @@ public KeyItem() { * * @return the kid value. */ + @Generated public String getKid() { return this.kid; } - /** - * Set the kid property: Key identifier. - * - * @param kid the kid value to set. - * @return the KeyItem object itself. - */ - public KeyItem setKid(String kid) { - this.kid = kid; - return this; - } - /** * Get the attributes property: The key management attributes. * * @return the attributes value. */ + @Generated public KeyAttributes getAttributes() { return this.attributes; } - /** - * Set the attributes property: The key management attributes. - * - * @param attributes the attributes value to set. - * @return the KeyItem object itself. - */ - public KeyItem setAttributes(KeyAttributes attributes) { - this.attributes = attributes; - return this; - } - /** * Get the tags property: Application specific metadata in the form of key-value pairs. * * @return the tags value. */ + @Generated public Map getTags() { return this.tags; } - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the KeyItem object itself. - */ - public KeyItem setTags(Map tags) { - this.tags = tags; - return this; - } - /** * Get the managed property: True if the key's lifetime is managed by key vault. If this is a key backing a * certificate, then managed will be true. * * @return the managed value. */ + @Generated public Boolean isManaged() { return this.managed; } - /** - * Set the managed property: True if the key's lifetime is managed by key vault. If this is a key backing a - * certificate, then managed will be true. - * - * @param managed the managed value to set. - * @return the KeyItem object itself. - */ - KeyItem setManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -146,6 +112,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * JSON null. * @throws IOException If an error occurs while reading the KeyItem. */ + @Generated public static KeyItem fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyItem deserializedKeyItem = new KeyItem(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyListResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyListResult.java deleted file mode 100644 index 10787e79d6fd9..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyListResult.java +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * The key list result. - */ -@Immutable -public final class KeyListResult implements JsonSerializable { - /* - * A response message containing a list of keys in the key vault along with a link to the next page of keys. - */ - private List value; - - /* - * The URL to get the next set of keys. - */ - private String nextLink; - - /** - * Creates an instance of KeyListResult class. - */ - public KeyListResult() { - } - - /** - * Get the value property: A response message containing a list of keys in the key vault along with a link to the - * next page of keys. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Get the nextLink property: The URL to get the next set of keys. - * - * @return the nextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyListResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyListResult if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyListResult. - */ - public static KeyListResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyListResult deserializedKeyListResult = new KeyListResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - List value = reader.readArray(reader1 -> KeyItem.fromJson(reader1)); - deserializedKeyListResult.value = value; - } else if ("nextLink".equals(fieldName)) { - deserializedKeyListResult.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyListResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationResult.java index 4a32c1bc1a9de..043b923d9c86d 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationResult.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationResult.java @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; import com.azure.json.JsonReader; @@ -20,32 +21,38 @@ public final class KeyOperationResult implements JsonSerializable { KeyOperationResult deserializedKeyOperationResult = new KeyOperationResult(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationsParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationsParameters.java index ecb81c28fde7e..12373339331ac 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationsParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyOperationsParameters.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.core.util.Base64Url; import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; @@ -22,32 +23,47 @@ public final class KeyOperationsParameters implements JsonSerializable { - KeyOperationsParameters deserializedKeyOperationsParameters = new KeyOperationsParameters(); + JsonWebKeyEncryptionAlgorithm algorithm = null; + byte[] value = null; + Base64Url iv = null; + Base64Url aad = null; + Base64Url tag = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("alg".equals(fieldName)) { - deserializedKeyOperationsParameters.algorithm - = JsonWebKeyEncryptionAlgorithm.fromString(reader.getString()); + algorithm = JsonWebKeyEncryptionAlgorithm.fromString(reader.getString()); } else if ("value".equals(fieldName)) { - deserializedKeyOperationsParameters.value + Base64Url valueHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (valueHolder != null) { + value = valueHolder.decodedBytes(); + } } else if ("iv".equals(fieldName)) { - deserializedKeyOperationsParameters.iv - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + iv = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); } else if ("aad".equals(fieldName)) { - deserializedKeyOperationsParameters.aad - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + aad = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); } else if ("tag".equals(fieldName)) { - deserializedKeyOperationsParameters.tag - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + tag = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); } else { reader.skipChildren(); } } + KeyOperationsParameters deserializedKeyOperationsParameters = new KeyOperationsParameters(algorithm, value); + deserializedKeyOperationsParameters.iv = iv; + deserializedKeyOperationsParameters.aad = aad; + deserializedKeyOperationsParameters.tag = tag; return deserializedKeyOperationsParameters; }); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyProperties.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyProperties.java deleted file mode 100644 index dba8bf6293728..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyProperties.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.keys.models.KeyCurveName; -import com.azure.security.keyvault.keys.models.KeyType; -import java.io.IOException; - -/** - * Properties of the key pair backing a certificate. - */ -@Fluent -public final class KeyProperties implements JsonSerializable { - /* - * Indicates if the private key can be exported. Release policy must be provided when creating the first version of - * an exportable key. - */ - private Boolean exportable; - - /* - * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - */ - private KeyType kty; - - /* - * The key size in bits. For example: 2048, 3072, or 4096 for RSA. - */ - private Integer keySize; - - /* - * Indicates if the same key pair will be used on certificate renewal. - */ - private Boolean reuseKey; - - /* - * Elliptic curve name. - */ - private KeyCurveName crv; - - /** - * Creates an instance of KeyProperties class. - */ - public KeyProperties() { - } - - /** - * Get the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. - * - * @return the exportable value. - */ - public Boolean isExportable() { - return this.exportable; - } - - /** - * Set the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. - * - * @param exportable the exportable value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setExportable(Boolean exportable) { - this.exportable = exportable; - return this; - } - - /** - * Get the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * - * @return the kty value. - */ - public KeyType getKty() { - return this.kty; - } - - /** - * Set the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * - * @param kty the kty value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setKty(KeyType kty) { - this.kty = kty; - return this; - } - - /** - * Get the keySize property: The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * - * @return the keySize value. - */ - public Integer getKeySize() { - return this.keySize; - } - - /** - * Set the keySize property: The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * - * @param keySize the keySize value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setKeySize(Integer keySize) { - this.keySize = keySize; - return this; - } - - /** - * Get the reuseKey property: Indicates if the same key pair will be used on certificate renewal. - * - * @return the reuseKey value. - */ - public Boolean isReuseKey() { - return this.reuseKey; - } - - /** - * Set the reuseKey property: Indicates if the same key pair will be used on certificate renewal. - * - * @param reuseKey the reuseKey value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setReuseKey(Boolean reuseKey) { - this.reuseKey = reuseKey; - return this; - } - - /** - * Get the crv property: Elliptic curve name. - * - * @return the crv value. - */ - public KeyCurveName getCrv() { - return this.crv; - } - - /** - * Set the crv property: Elliptic curve name. - * - * @param crv the crv value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setCrv(KeyCurveName crv) { - this.crv = crv; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("exportable", this.exportable); - jsonWriter.writeStringField("kty", this.kty == null ? null : this.kty.toString()); - jsonWriter.writeNumberField("key_size", this.keySize); - jsonWriter.writeBooleanField("reuse_key", this.reuseKey); - jsonWriter.writeStringField("crv", this.crv == null ? null : this.crv.toString()); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyProperties from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyProperties if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyProperties. - */ - public static KeyProperties fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyProperties deserializedKeyProperties = new KeyProperties(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("exportable".equals(fieldName)) { - deserializedKeyProperties.exportable = reader.getNullable(JsonReader::getBoolean); - } else if ("kty".equals(fieldName)) { - deserializedKeyProperties.kty = KeyType.fromString(reader.getString()); - } else if ("key_size".equals(fieldName)) { - deserializedKeyProperties.keySize = reader.getNullable(JsonReader::getInt); - } else if ("reuse_key".equals(fieldName)) { - deserializedKeyProperties.reuseKey = reader.getNullable(JsonReader::getBoolean); - } else if ("crv".equals(fieldName)) { - deserializedKeyProperties.crv = KeyCurveName.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyProperties; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleaseParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleaseParameters.java index c11dd6fecbb48..2e18a5811469d 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleaseParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleaseParameters.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -20,22 +21,29 @@ public final class KeyReleaseParameters implements JsonSerializable { - KeyReleaseParameters deserializedKeyReleaseParameters = new KeyReleaseParameters(); + String targetAttestationToken = null; + String nonce = null; + KeyExportEncryptionAlgorithm enc = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("target".equals(fieldName)) { - deserializedKeyReleaseParameters.targetAttestationToken = reader.getString(); + targetAttestationToken = reader.getString(); } else if ("nonce".equals(fieldName)) { - deserializedKeyReleaseParameters.nonce = reader.getString(); + nonce = reader.getString(); } else if ("enc".equals(fieldName)) { - deserializedKeyReleaseParameters.enc = KeyExportEncryptionAlgorithm.fromString(reader.getString()); + enc = KeyExportEncryptionAlgorithm.fromString(reader.getString()); } else { reader.skipChildren(); } } + KeyReleaseParameters deserializedKeyReleaseParameters = new KeyReleaseParameters(targetAttestationToken); + deserializedKeyReleaseParameters.nonce = nonce; + deserializedKeyReleaseParameters.enc = enc; return deserializedKeyReleaseParameters; }); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleasePolicy.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleasePolicy.java index c5de807bce69c..d3d2d07f7d102 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleasePolicy.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyReleasePolicy.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.core.util.Base64Url; import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; @@ -22,22 +23,26 @@ public final class KeyReleasePolicy implements JsonSerializable { KeyReleasePolicy deserializedKeyReleasePolicy = new KeyReleasePolicy(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRestoreParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRestoreParameters.java index 720b708c67690..dbe82c18a8631 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRestoreParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRestoreParameters.java @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -17,17 +17,26 @@ /** * The key restore parameters. */ -@Fluent +@Immutable public final class KeyRestoreParameters implements JsonSerializable { /* * The backup blob associated with a key bundle. */ - private Base64Url keyBundleBackup; + @Generated + private final Base64Url keyBundleBackup; /** * Creates an instance of KeyRestoreParameters class. + * + * @param keyBundleBackup the keyBundleBackup value to set. */ - public KeyRestoreParameters() { + @Generated + public KeyRestoreParameters(byte[] keyBundleBackup) { + if (keyBundleBackup == null) { + this.keyBundleBackup = null; + } else { + this.keyBundleBackup = Base64Url.encode(keyBundleBackup); + } } /** @@ -35,6 +44,7 @@ public KeyRestoreParameters() { * * @return the keyBundleBackup value. */ + @Generated public byte[] getKeyBundleBackup() { if (this.keyBundleBackup == null) { return null; @@ -42,24 +52,10 @@ public byte[] getKeyBundleBackup() { return this.keyBundleBackup.decodedBytes(); } - /** - * Set the keyBundleBackup property: The backup blob associated with a key bundle. - * - * @param keyBundleBackup the keyBundleBackup value to set. - * @return the KeyRestoreParameters object itself. - */ - public KeyRestoreParameters setKeyBundleBackup(byte[] keyBundleBackup) { - if (keyBundleBackup == null) { - this.keyBundleBackup = null; - } else { - this.keyBundleBackup = Base64Url.encode(CoreUtils.clone(keyBundleBackup)); - } - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -76,22 +72,25 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the KeyRestoreParameters. */ + @Generated public static KeyRestoreParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - KeyRestoreParameters deserializedKeyRestoreParameters = new KeyRestoreParameters(); + byte[] keyBundleBackup = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("value".equals(fieldName)) { - deserializedKeyRestoreParameters.keyBundleBackup + Base64Url keyBundleBackupHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (keyBundleBackupHolder != null) { + keyBundleBackup = keyBundleBackupHolder.decodedBytes(); + } } else { reader.skipChildren(); } } - - return deserializedKeyRestoreParameters; + return new KeyRestoreParameters(keyBundleBackup); }); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicy.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicy.java index d6e6b7517cc2a..d10f285cdb00b 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicy.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicy.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -20,6 +21,7 @@ public final class KeyRotationPolicy implements JsonSerializable lifetimeActions; /* * The key rotation policy attributes. */ + @Generated private KeyRotationPolicyAttributes attributes; /** * Creates an instance of KeyRotationPolicy class. */ + @Generated public KeyRotationPolicy() { } @@ -45,6 +50,7 @@ public KeyRotationPolicy() { * * @return the id value. */ + @Generated public String getId() { return this.id; } @@ -56,6 +62,7 @@ public String getId() { * * @return the lifetimeActions value. */ + @Generated public List getLifetimeActions() { return this.lifetimeActions; } @@ -68,6 +75,7 @@ public List getLifetimeActions() { * @param lifetimeActions the lifetimeActions value to set. * @return the KeyRotationPolicy object itself. */ + @Generated public KeyRotationPolicy setLifetimeActions(List lifetimeActions) { this.lifetimeActions = lifetimeActions; return this; @@ -78,6 +86,7 @@ public KeyRotationPolicy setLifetimeActions(List lifetimeAction * * @return the attributes value. */ + @Generated public KeyRotationPolicyAttributes getAttributes() { return this.attributes; } @@ -88,6 +97,7 @@ public KeyRotationPolicyAttributes getAttributes() { * @param attributes the attributes value to set. * @return the KeyRotationPolicy object itself. */ + @Generated public KeyRotationPolicy setAttributes(KeyRotationPolicyAttributes attributes) { this.attributes = attributes; return this; @@ -96,6 +106,7 @@ public KeyRotationPolicy setAttributes(KeyRotationPolicyAttributes attributes) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -113,6 +124,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the KeyRotationPolicy. */ + @Generated public static KeyRotationPolicy fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyRotationPolicy deserializedKeyRotationPolicy = new KeyRotationPolicy(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicyAttributes.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicyAttributes.java index b9cfc05d62534..43c431aa80f3f 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicyAttributes.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyRotationPolicyAttributes.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -23,21 +24,25 @@ public final class KeyRotationPolicyAttributes implements JsonSerializable { KeyRotationPolicyAttributes deserializedKeyRotationPolicyAttributes = new KeyRotationPolicyAttributes(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeySignParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeySignParameters.java index fb149d41690aa..55452bf88c21d 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeySignParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeySignParameters.java @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -17,23 +17,35 @@ /** * The key operations parameters. */ -@Fluent +@Immutable public final class KeySignParameters implements JsonSerializable { /* * The signing/verification algorithm identifier. For more information on possible algorithm types, see * JsonWebKeySignatureAlgorithm. */ - private JsonWebKeySignatureAlgorithm algorithm; + @Generated + private final JsonWebKeySignatureAlgorithm algorithm; /* - * The value property. + * The value to operate on. */ - private Base64Url value; + @Generated + private final Base64Url value; /** * Creates an instance of KeySignParameters class. + * + * @param algorithm the algorithm value to set. + * @param value the value value to set. */ - public KeySignParameters() { + @Generated + public KeySignParameters(JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + this.algorithm = algorithm; + if (value == null) { + this.value = null; + } else { + this.value = Base64Url.encode(value); + } } /** @@ -42,27 +54,17 @@ public KeySignParameters() { * * @return the algorithm value. */ + @Generated public JsonWebKeySignatureAlgorithm getAlgorithm() { return this.algorithm; } /** - * Set the algorithm property: The signing/verification algorithm identifier. For more information on possible - * algorithm types, see JsonWebKeySignatureAlgorithm. - * - * @param algorithm the algorithm value to set. - * @return the KeySignParameters object itself. - */ - public KeySignParameters setAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { - this.algorithm = algorithm; - return this; - } - - /** - * Get the value property: The value property. + * Get the value property: The value to operate on. * * @return the value value. */ + @Generated public byte[] getValue() { if (this.value == null) { return null; @@ -70,24 +72,10 @@ public byte[] getValue() { return this.value.decodedBytes(); } - /** - * Set the value property: The value property. - * - * @param value the value value to set. - * @return the KeySignParameters object itself. - */ - public KeySignParameters setValue(byte[] value) { - if (value == null) { - this.value = null; - } else { - this.value = Base64Url.encode(CoreUtils.clone(value)); - } - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -105,25 +93,28 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the KeySignParameters. */ + @Generated public static KeySignParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - KeySignParameters deserializedKeySignParameters = new KeySignParameters(); + JsonWebKeySignatureAlgorithm algorithm = null; + byte[] value = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("alg".equals(fieldName)) { - deserializedKeySignParameters.algorithm - = JsonWebKeySignatureAlgorithm.fromString(reader.getString()); + algorithm = JsonWebKeySignatureAlgorithm.fromString(reader.getString()); } else if ("value".equals(fieldName)) { - deserializedKeySignParameters.value + Base64Url valueHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (valueHolder != null) { + value = valueHolder.decodedBytes(); + } } else { reader.skipChildren(); } } - - return deserializedKeySignParameters; + return new KeySignParameters(algorithm, value); }); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyUpdateParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyUpdateParameters.java index 16aa11c86eaf5..22b099b7e6c5d 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyUpdateParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyUpdateParameters.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -22,26 +23,31 @@ public final class KeyUpdateParameters implements JsonSerializable keyOps; /* * The attributes of a key managed by the key vault service. */ + @Generated private KeyAttributes keyAttributes; /* * Application specific metadata in the form of key-value pairs. */ + @Generated private Map tags; /* * The policy rules under which the key can be exported. */ + @Generated private KeyReleasePolicy releasePolicy; /** * Creates an instance of KeyUpdateParameters class. */ + @Generated public KeyUpdateParameters() { } @@ -51,6 +57,7 @@ public KeyUpdateParameters() { * * @return the keyOps value. */ + @Generated public List getKeyOps() { return this.keyOps; } @@ -62,6 +69,7 @@ public List getKeyOps() { * @param keyOps the keyOps value to set. * @return the KeyUpdateParameters object itself. */ + @Generated public KeyUpdateParameters setKeyOps(List keyOps) { this.keyOps = keyOps; return this; @@ -72,6 +80,7 @@ public KeyUpdateParameters setKeyOps(List keyOps) { * * @return the keyAttributes value. */ + @Generated public KeyAttributes getKeyAttributes() { return this.keyAttributes; } @@ -82,6 +91,7 @@ public KeyAttributes getKeyAttributes() { * @param keyAttributes the keyAttributes value to set. * @return the KeyUpdateParameters object itself. */ + @Generated public KeyUpdateParameters setKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; @@ -92,6 +102,7 @@ public KeyUpdateParameters setKeyAttributes(KeyAttributes keyAttributes) { * * @return the tags value. */ + @Generated public Map getTags() { return this.tags; } @@ -102,6 +113,7 @@ public Map getTags() { * @param tags the tags value to set. * @return the KeyUpdateParameters object itself. */ + @Generated public KeyUpdateParameters setTags(Map tags) { this.tags = tags; return this; @@ -112,6 +124,7 @@ public KeyUpdateParameters setTags(Map tags) { * * @return the releasePolicy value. */ + @Generated public KeyReleasePolicy getReleasePolicy() { return this.releasePolicy; } @@ -122,6 +135,7 @@ public KeyReleasePolicy getReleasePolicy() { * @param releasePolicy the releasePolicy value to set. * @return the KeyUpdateParameters object itself. */ + @Generated public KeyUpdateParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { this.releasePolicy = releasePolicy; return this; @@ -130,6 +144,7 @@ public KeyUpdateParameters setReleasePolicy(KeyReleasePolicy releasePolicy) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -149,6 +164,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the KeyUpdateParameters. */ + @Generated public static KeyUpdateParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyUpdateParameters deserializedKeyUpdateParameters = new KeyUpdateParameters(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultError.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultError.java deleted file mode 100644 index 878f44cec3d8f..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultError.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The key vault error exception. - */ -@Immutable -public final class KeyVaultError implements JsonSerializable { - /* - * The key vault server error. - */ - private Error error; - - /** - * Creates an instance of KeyVaultError class. - */ - public KeyVaultError() { - } - - /** - * Get the error property: The key vault server error. - * - * @return the error value. - */ - public Error getError() { - return this.error; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyVaultError from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyVaultError if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyVaultError. - */ - public static KeyVaultError fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyVaultError deserializedKeyVaultError = new KeyVaultError(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("error".equals(fieldName)) { - deserializedKeyVaultError.error = Error.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyVaultError; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultErrorException.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultErrorException.java deleted file mode 100644 index 43c502fea6801..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultErrorException.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.keys.implementation.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; - -/** - * Exception thrown for an invalid response with KeyVaultError information. - */ -public final class KeyVaultErrorException extends HttpResponseException { - /** - * Initializes a new instance of the KeyVaultErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - */ - public KeyVaultErrorException(String message, HttpResponse response) { - super(message, response); - } - - /** - * Initializes a new instance of the KeyVaultErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - * @param value the deserialized response value. - */ - public KeyVaultErrorException(String message, HttpResponse response, KeyVaultError value) { - super(message, response, value); - } - - /** - * {@inheritDoc} - */ - @Override - public KeyVaultError getValue() { - return (KeyVaultError) super.getValue(); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultKeysModelsUtils.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultKeysModelsUtils.java index 45420fe409328..b7e0d43a434da 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultKeysModelsUtils.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVaultKeysModelsUtils.java @@ -11,6 +11,7 @@ import com.azure.security.keyvault.keys.models.CreateKeyOptions; import com.azure.security.keyvault.keys.models.DeletedKey; import com.azure.security.keyvault.keys.models.JsonWebKey; +import com.azure.security.keyvault.keys.models.KeyOperation; import com.azure.security.keyvault.keys.models.KeyProperties; import com.azure.security.keyvault.keys.models.KeyReleasePolicy; import com.azure.security.keyvault.keys.models.KeyRotationPolicy; @@ -18,8 +19,10 @@ import java.net.MalformedURLException; import java.net.URL; +import java.util.Map; import java.util.Objects; import java.util.function.Consumer; +import java.util.stream.Collectors; /** * Utility class for KeyVault Keys models. @@ -48,29 +51,16 @@ public static KeyProperties createKeyProperties(KeyItem keyItem) { } private static void populateKeyProperties(KeyItem keyItem, KeyProperties properties) { - if (keyItem == null) { - return; + if (keyItem != null) { + populateKeyProperties(null, keyItem.getTags(), keyItem.isManaged(), keyItem.getKid(), properties, + keyItem.getAttributes()); } + } - properties.setTags(keyItem.getTags()); - KeyPropertiesHelper.setManaged(properties, keyItem.isManaged()); - KeyPropertiesHelper.setId(properties, keyItem.getKid()); - - unpackId(keyItem.getKid(), name -> KeyPropertiesHelper.setName(properties, name), - version -> KeyPropertiesHelper.setVersion(properties, version)); - - KeyAttributes attributes = keyItem.getAttributes(); - if (attributes != null) { - properties.setEnabled(attributes.isEnabled()) - .setExpiresOn(attributes.getExpires()) - .setExportable(attributes.isExportable()) - .setNotBefore(attributes.getNotBefore()); - - KeyPropertiesHelper.setCreatedOn(properties, attributes.getCreated()); - KeyPropertiesHelper.setUpdatedOn(properties, attributes.getUpdated()); - KeyPropertiesHelper.setRecoveryLevel(properties, Objects.toString(attributes.getRecoveryLevel(), null)); - KeyPropertiesHelper.setRecoverableDays(properties, attributes.getRecoverableDays()); - KeyPropertiesHelper.setHsmPlatform(properties, attributes.getHsmPlatform()); + private static void populateKeyProperties(DeletedKeyItem item, KeyProperties properties) { + if (item != null) { + populateKeyProperties(null, item.getTags(), item.isManaged(), item.getKid(), properties, + item.getAttributes()); } } @@ -112,7 +102,7 @@ public static DeletedKey createDeletedKey(DeletedKeyItem item) { return new JsonWebKey().setId(impl.getKid()) .setKeyType(impl.getKty()) - .setKeyOps(impl.getKeyOps()) + .setKeyOps(impl.getKeyOps().stream().map(KeyOperation::fromString).collect(Collectors.toList())) .setN(impl.getN()) .setE(impl.getE()) .setD(impl.getD()) @@ -135,7 +125,7 @@ public static com.azure.security.keyvault.keys.implementation.models.JsonWebKey return new com.azure.security.keyvault.keys.implementation.models.JsonWebKey().setKid(key.getId()) .setKty(key.getKeyType()) - .setKeyOps(key.getKeyOps()) + .setKeyOps(key.getKeyOps().stream().map(KeyOperation::toString).collect(Collectors.toList())) .setN(key.getN()) .setE(key.getE()) .setD(key.getD()) @@ -174,29 +164,39 @@ public static KeyAttributes createKeyAttributes(KeyProperties properties) { } private static void populateKeyProperties(KeyBundle bundle, KeyProperties properties) { - if (bundle == null) { - return; + if (bundle != null) { + populateKeyProperties(mapKeyReleasePolicyImpl(bundle.getReleasePolicy()), bundle.getTags(), + bundle.isManaged(), bundle.getKey().getKid(), properties, bundle.getAttributes()); + } + } + + private static void populateKeyProperties(DeletedKeyBundle bundle, KeyProperties properties) { + if (bundle != null) { + populateKeyProperties(mapKeyReleasePolicyImpl(bundle.getReleasePolicy()), bundle.getTags(), + bundle.isManaged(), bundle.getKey().getKid(), properties, bundle.getAttributes()); } + } - properties.setReleasePolicy(mapKeyReleasePolicyImpl(bundle.getReleasePolicy())).setTags(bundle.getTags()); + private static void populateKeyProperties(KeyReleasePolicy keyReleasePolicy, Map tags, + Boolean isManaged, String kid, KeyProperties properties, KeyAttributes attributes) { - KeyPropertiesHelper.setManaged(properties, bundle.isManaged()); - KeyPropertiesHelper.setId(properties, bundle.getKey().getKid()); - unpackId(bundle.getKey().getKid(), name -> KeyPropertiesHelper.setName(properties, name), + properties.setReleasePolicy(keyReleasePolicy).setTags(tags); + + KeyPropertiesHelper.setManaged(properties, isManaged); + KeyPropertiesHelper.setId(properties, kid); + + unpackId(kid, name -> KeyPropertiesHelper.setName(properties, name), version -> KeyPropertiesHelper.setVersion(properties, version)); - KeyAttributes attributes = bundle.getAttributes(); if (attributes != null) { properties.setEnabled(attributes.isEnabled()) - .setEnabled(attributes.isEnabled()) .setExportable(attributes.isExportable()) .setNotBefore(attributes.getNotBefore()) .setExpiresOn(attributes.getExpires()); KeyPropertiesHelper.setCreatedOn(properties, attributes.getCreated()); KeyPropertiesHelper.setUpdatedOn(properties, attributes.getUpdated()); - KeyPropertiesHelper.setRecoveryLevel(properties, - Objects.toString(attributes.getRecoveryLevel().toString(), null)); + KeyPropertiesHelper.setRecoveryLevel(properties, Objects.toString(attributes.getRecoveryLevel(), null)); KeyPropertiesHelper.setRecoverableDays(properties, attributes.getRecoverableDays()); KeyPropertiesHelper.setHsmPlatform(properties, attributes.getHsmPlatform()); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyParameters.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyParameters.java index 6edf08bbffa4c..0fed937ef96f1 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyParameters.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyParameters.java @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -17,28 +17,47 @@ /** * The key verify parameters. */ -@Fluent +@Immutable public final class KeyVerifyParameters implements JsonSerializable { /* * The signing/verification algorithm. For more information on possible algorithm types, see * JsonWebKeySignatureAlgorithm. */ - private JsonWebKeySignatureAlgorithm algorithm; + @Generated + private final JsonWebKeySignatureAlgorithm algorithm; /* * The digest used for signing. */ - private Base64Url digest; + @Generated + private final Base64Url digest; /* * The signature to be verified. */ - private Base64Url signature; + @Generated + private final Base64Url signature; /** * Creates an instance of KeyVerifyParameters class. + * + * @param algorithm the algorithm value to set. + * @param digest the digest value to set. + * @param signature the signature value to set. */ - public KeyVerifyParameters() { + @Generated + public KeyVerifyParameters(JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + this.algorithm = algorithm; + if (digest == null) { + this.digest = null; + } else { + this.digest = Base64Url.encode(digest); + } + if (signature == null) { + this.signature = null; + } else { + this.signature = Base64Url.encode(signature); + } } /** @@ -47,27 +66,17 @@ public KeyVerifyParameters() { * * @return the algorithm value. */ + @Generated public JsonWebKeySignatureAlgorithm getAlgorithm() { return this.algorithm; } - /** - * Set the algorithm property: The signing/verification algorithm. For more information on possible algorithm types, - * see JsonWebKeySignatureAlgorithm. - * - * @param algorithm the algorithm value to set. - * @return the KeyVerifyParameters object itself. - */ - public KeyVerifyParameters setAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { - this.algorithm = algorithm; - return this; - } - /** * Get the digest property: The digest used for signing. * * @return the digest value. */ + @Generated public byte[] getDigest() { if (this.digest == null) { return null; @@ -75,26 +84,12 @@ public byte[] getDigest() { return this.digest.decodedBytes(); } - /** - * Set the digest property: The digest used for signing. - * - * @param digest the digest value to set. - * @return the KeyVerifyParameters object itself. - */ - public KeyVerifyParameters setDigest(byte[] digest) { - if (digest == null) { - this.digest = null; - } else { - this.digest = Base64Url.encode(CoreUtils.clone(digest)); - } - return this; - } - /** * Get the signature property: The signature to be verified. * * @return the signature value. */ + @Generated public byte[] getSignature() { if (this.signature == null) { return null; @@ -102,24 +97,10 @@ public byte[] getSignature() { return this.signature.decodedBytes(); } - /** - * Set the signature property: The signature to be verified. - * - * @param signature the signature value to set. - * @return the KeyVerifyParameters object itself. - */ - public KeyVerifyParameters setSignature(byte[] signature) { - if (signature == null) { - this.signature = null; - } else { - this.signature = Base64Url.encode(CoreUtils.clone(signature)); - } - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -138,28 +119,35 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the KeyVerifyParameters. */ + @Generated public static KeyVerifyParameters fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - KeyVerifyParameters deserializedKeyVerifyParameters = new KeyVerifyParameters(); + JsonWebKeySignatureAlgorithm algorithm = null; + byte[] digest = null; + byte[] signature = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("alg".equals(fieldName)) { - deserializedKeyVerifyParameters.algorithm - = JsonWebKeySignatureAlgorithm.fromString(reader.getString()); + algorithm = JsonWebKeySignatureAlgorithm.fromString(reader.getString()); } else if ("digest".equals(fieldName)) { - deserializedKeyVerifyParameters.digest + Base64Url digestHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (digestHolder != null) { + digest = digestHolder.decodedBytes(); + } } else if ("value".equals(fieldName)) { - deserializedKeyVerifyParameters.signature + Base64Url signatureHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (signatureHolder != null) { + signature = signatureHolder.decodedBytes(); + } } else { reader.skipChildren(); } } - - return deserializedKeyVerifyParameters; + return new KeyVerifyParameters(algorithm, digest, signature); }); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyResult.java index 578a9a1a25095..7edbf07653db9 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyResult.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/KeyVerifyResult.java @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; +import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; @@ -19,12 +20,14 @@ public final class KeyVerifyResult implements JsonSerializable /* * True if the signature is verified, otherwise false. */ + @Generated private Boolean value; /** * Creates an instance of KeyVerifyResult class. */ - public KeyVerifyResult() { + @Generated + private KeyVerifyResult() { } /** @@ -32,6 +35,7 @@ public KeyVerifyResult() { * * @return the value value. */ + @Generated public Boolean isValue() { return this.value; } @@ -39,6 +43,7 @@ public Boolean isValue() { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -53,6 +58,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the KeyVerifyResult. */ + @Generated public static KeyVerifyResult fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { KeyVerifyResult deserializedKeyVerifyResult = new KeyVerifyResult(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActions.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActions.java index 6476fe65a397f..45690a771842e 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActions.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActions.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -19,16 +20,19 @@ public final class LifetimeActions implements JsonSerializable /* * The condition that will execute the action. */ + @Generated private LifetimeActionsTrigger trigger; /* * The action that will be executed. */ + @Generated private LifetimeActionsType action; /** * Creates an instance of LifetimeActions class. */ + @Generated public LifetimeActions() { } @@ -37,6 +41,7 @@ public LifetimeActions() { * * @return the trigger value. */ + @Generated public LifetimeActionsTrigger getTrigger() { return this.trigger; } @@ -47,6 +52,7 @@ public LifetimeActionsTrigger getTrigger() { * @param trigger the trigger value to set. * @return the LifetimeActions object itself. */ + @Generated public LifetimeActions setTrigger(LifetimeActionsTrigger trigger) { this.trigger = trigger; return this; @@ -57,6 +63,7 @@ public LifetimeActions setTrigger(LifetimeActionsTrigger trigger) { * * @return the action value. */ + @Generated public LifetimeActionsType getAction() { return this.action; } @@ -67,6 +74,7 @@ public LifetimeActionsType getAction() { * @param action the action value to set. * @return the LifetimeActions object itself. */ + @Generated public LifetimeActions setAction(LifetimeActionsType action) { this.action = action; return this; @@ -75,6 +83,7 @@ public LifetimeActions setAction(LifetimeActionsType action) { /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -91,6 +100,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * pointing to JSON null. * @throws IOException If an error occurs while reading the LifetimeActions. */ + @Generated public static LifetimeActions fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { LifetimeActions deserializedLifetimeActions = new LifetimeActions(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsTrigger.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsTrigger.java index e5c62cf2053ac..72e73d4b0ea48 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsTrigger.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsTrigger.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -20,17 +21,20 @@ public final class LifetimeActionsTrigger implements JsonSerializable { LifetimeActionsTrigger deserializedLifetimeActionsTrigger = new LifetimeActionsTrigger(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsType.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsType.java index 931bf6d380c0e..29f689f9c80c3 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsType.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/LifetimeActionsType.java @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -20,11 +21,13 @@ public final class LifetimeActionsType implements JsonSerializable { LifetimeActionsType deserializedLifetimeActionsType = new LifetimeActionsType(); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/RandomBytes.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/RandomBytes.java index 78672c3d9dd8f..7006eaeaef091 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/RandomBytes.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/RandomBytes.java @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -17,17 +17,26 @@ /** * The get random bytes response object containing the bytes. */ -@Fluent +@Immutable public final class RandomBytes implements JsonSerializable { /* * The bytes encoded as a base64url string. */ - private Base64Url value; + @Generated + private final Base64Url value; /** * Creates an instance of RandomBytes class. + * + * @param value the value value to set. */ - public RandomBytes() { + @Generated + private RandomBytes(byte[] value) { + if (value == null) { + this.value = null; + } else { + this.value = Base64Url.encode(value); + } } /** @@ -35,6 +44,7 @@ public RandomBytes() { * * @return the value value. */ + @Generated public byte[] getValue() { if (this.value == null) { return null; @@ -42,24 +52,10 @@ public byte[] getValue() { return this.value.decodedBytes(); } - /** - * Set the value property: The bytes encoded as a base64url string. - * - * @param value the value value to set. - * @return the RandomBytes object itself. - */ - public RandomBytes setValue(byte[] value) { - if (value == null) { - this.value = null; - } else { - this.value = Base64Url.encode(CoreUtils.clone(value)); - } - return this; - } - /** * {@inheritDoc} */ + @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -76,22 +72,25 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException If the deserialized JSON object was missing any required properties. * @throws IOException If an error occurs while reading the RandomBytes. */ + @Generated public static RandomBytes fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - RandomBytes deserializedRandomBytes = new RandomBytes(); + byte[] value = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("value".equals(fieldName)) { - deserializedRandomBytes.value + Base64Url valueHolder = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (valueHolder != null) { + value = valueHolder.decodedBytes(); + } } else { reader.skipChildren(); } } - - return deserializedRandomBytes; + return new RandomBytes(value); }); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/package-info.java index ea5b08c3e06c4..03acc328a2eec 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/models/package-info.java @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the data models for KeyClient. + * + * Package containing the data models for KeyVault. * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. + * */ package com.azure.security.keyvault.keys.implementation.models; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/package-info.java index d1c0e17672db6..ce02c774a060f 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/package-info.java @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - +// Code generated by Microsoft (R) TypeSpec Code Generator. /** - * Package containing the implementations for KeyClient. - * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. + * + * Package containing the implementations for KeyClient. The key vault client performs cryptographic key operations and + * vault operations against the Key Vault service. */ package com.azure.security.keyvault.keys.implementation; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyCurveName.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyCurveName.java index 6805836416edd..d26689bade4b8 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyCurveName.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyCurveName.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; import com.azure.core.util.ExpandableStringEnum; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyExportEncryptionAlgorithm.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyExportEncryptionAlgorithm.java index d62ffec53bdb3..31acf2fd6cfcc 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyExportEncryptionAlgorithm.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyExportEncryptionAlgorithm.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; import com.azure.core.util.ExpandableStringEnum; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyOperation.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyOperation.java index 4028bd25bb96a..a2122df5976e9 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyOperation.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyOperation.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; import com.azure.core.util.ExpandableStringEnum; @@ -11,6 +10,7 @@ * JSON web key operations. For more information, see JsonWebKeyOperation. */ public final class KeyOperation extends ExpandableStringEnum { + /** * Static value encrypt for KeyOperation. */ @@ -48,7 +48,7 @@ public final class KeyOperation extends ExpandableStringEnum { /** * Creates a new instance of KeyOperation value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Deprecated @@ -57,7 +57,7 @@ public KeyOperation() { /** * Creates or finds a KeyOperation from its string representation. - * + * * @param name a name to look for. * @return the corresponding KeyOperation. */ @@ -67,10 +67,15 @@ public static KeyOperation fromString(String name) { /** * Gets known KeyOperation values. - * + * * @return known KeyOperation values. */ public static Collection values() { return values(KeyOperation.class); } + + /** + * Indicates that the private component of the key can be exported. + */ + static final KeyOperation EXPORT = fromString("export"); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyRotationPolicyAction.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyRotationPolicyAction.java index 63246059c5993..a237654b31773 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyRotationPolicyAction.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyRotationPolicyAction.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyType.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyType.java index 8994aedea1c07..e7f84c2e47f34 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyType.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyType.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; import com.azure.core.util.ExpandableStringEnum; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyResult.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyResult.java index 738a6c76067ef..cebd7082b7b85 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyResult.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyResult.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - +// Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.security.keyvault.keys.models; import com.azure.core.annotation.Immutable; @@ -16,6 +15,7 @@ */ @Immutable public final class ReleaseKeyResult implements JsonSerializable { + /* * A signed object containing the released key. */ @@ -29,7 +29,7 @@ public ReleaseKeyResult() { /** * Get the value property: A signed object containing the released key. - * + * * @return the value value. */ public String getValue() { @@ -47,7 +47,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ReleaseKeyResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ReleaseKeyResult if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -59,14 +59,12 @@ public static ReleaseKeyResult fromJson(JsonReader jsonReader) throws IOExceptio while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("value".equals(fieldName)) { deserializedReleaseKeyResult.value = reader.getString(); } else { reader.skipChildren(); } } - return deserializedReleaseKeyResult; }); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/package-info.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/package-info.java index 63e0a5265402b..0bd801bfb170c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/package-info.java @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - /** - * Package containing the data models for KeyClient. - * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. + * + * Package containing the data models for KeyClient. The key vault client performs cryptographic key operations and + * vault operations against the Key Vault service. */ package com.azure.security.keyvault.keys.models; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/package-info.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/package-info.java index 61944b9d9d3c5..5210e4a493c73 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/package-info.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. - /** + * *

Azure Key Vault is a cloud-based service * provided by Microsoft Azure that allows users to securely store and manage cryptographic keys used for encrypting * and decrypting data. It is a part of Azure Key Vault, which is a cloud-based service for managing cryptographic keys, diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/module-info.java index 88148cf46e4a9..31eef1ec91e31 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/module-info.java @@ -1,22 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. module com.azure.security.keyvault.keys { requires transitive com.azure.core; requires com.azure.json; - requires java.xml.crypto; exports com.azure.security.keyvault.keys; + exports com.azure.security.keyvault.keys.models; exports com.azure.security.keyvault.keys.cryptography; exports com.azure.security.keyvault.keys.cryptography.models; - exports com.azure.security.keyvault.keys.models; + opens com.azure.security.keyvault.keys.implementation.models to com.azure.core; + opens com.azure.security.keyvault.keys.models to com.azure.core; opens com.azure.security.keyvault.keys to com.azure.core; opens com.azure.security.keyvault.keys.cryptography to com.azure.core; opens com.azure.security.keyvault.keys.cryptography.implementation to com.azure.core; opens com.azure.security.keyvault.keys.cryptography.models to com.azure.core; opens com.azure.security.keyvault.keys.implementation to com.azure.core; - opens com.azure.security.keyvault.keys.implementation.models to com.azure.core; - opens com.azure.security.keyvault.keys.models to com.azure.core; } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-keys/resource-config.json b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-keys/resource-config.json index 0e369c7032955..e370b99bbe2e4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-keys/resource-config.json +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-keys/resource-config.json @@ -2,7 +2,7 @@ "resources": { "includes": [ { - "pattern": "azure-key-vault-keys.properties" + "pattern": "azure-security-keyvault-keys.properties" }, { "pattern": "kvErrorStrings.properties" diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-security-keyvault-keys.properties similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties rename to sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-security-keyvault-keys.properties diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java index aa09df2fc2210..746249cffc489 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java @@ -14,7 +14,7 @@ public class KeyVaultKeysUserAgentPropertiesTest { @Test public void testAzureConfiguration() { - Map properties = CoreUtils.getProperties("azure-key-vault-keys.properties"); + Map properties = CoreUtils.getProperties("azure-security-keyvault-keys.properties"); assertTrue(properties.get("name").matches("azure-security-keyvault-keys")); assertTrue(properties.get("version").matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); diff --git a/sdk/keyvault/azure-security-keyvault-keys/swagger/src/main/java/KeysCustomizations.java b/sdk/keyvault/azure-security-keyvault-keys/swagger/src/main/java/KeysCustomizations.java index 88500b428b17a..9355228a67204 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/swagger/src/main/java/KeysCustomizations.java +++ b/sdk/keyvault/azure-security-keyvault-keys/swagger/src/main/java/KeysCustomizations.java @@ -3,9 +3,12 @@ import com.azure.autorest.customization.ClassCustomization; import com.azure.autorest.customization.Customization; +import com.azure.autorest.customization.Editor; import com.azure.autorest.customization.LibraryCustomization; import com.azure.autorest.customization.PackageCustomization; -import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.NodeList; import org.slf4j.Logger; /** @@ -14,26 +17,115 @@ public class KeysCustomizations extends Customization { @Override public void customize(LibraryCustomization libraryCustomization, Logger logger) { - modelsCustomizations(libraryCustomization.getPackage("com.azure.security.keyvault.keys.models")); + Editor rawEditor = libraryCustomization.getRawEditor(); + + // Remove unnecessary files. + removeFiles(rawEditor); + + // Customize the KeyClientImpl class. + PackageCustomization implPackageCustomization = + libraryCustomization.getPackage("com.azure.security.keyvault.keys.implementation"); + ClassCustomization implClientClassCustomization = implPackageCustomization.getClass("KeyClientImpl"); + customizeClientImpl(implClientClassCustomization); + + // Change the names of generated + ClassCustomization keyCurveNameCustomization = + libraryCustomization.getPackage("com.azure.security.keyvault.keys.models") + .getClass("KeyCurveName"); + + customizeKeyCurveName(keyCurveNameCustomization); + } + + private static void removeFiles(Editor editor) { + // Remove the next line in favor of renaming to KeyServiceVersion once the TSP spec includes all service + // versions. + editor.removeFile("src/main/java/com/azure/security/keyvault/keys/KeyVaultServiceVersion.java"); + editor.removeFile("src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java"); + editor.removeFile("src/main/java/com/azure/security/keyvault/keys/KeyClient.java"); + editor.removeFile("src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java"); + } + + private static void customizeClientImpl(ClassCustomization classCustomization) { + // Remove the KeyVaultServiceVersion import since we will use KeyServiceVersion for now. We'll remove + // this once the TSP spec includes all service versions. + classCustomization.customizeAst(ast -> + replaceImport(ast, "com.azure.security.keyvault.keys.KeyVaultServiceVersion", + "com.azure.security.keyvault.keys.KeyServiceVersion")); + + String classPath = + "src/main/java/com/azure/security/keyvault/keys/implementation/KeyClientImpl.java"; + + replaceInFile(classCustomization, classPath, "KeyVault", "Key"); + } + + private static void customizeKeyCurveName(ClassCustomization classCustomization) { + classCustomization.customizeAst(ast -> + ast.getClassByName("KeyCurveName") + .ifPresent(clazz -> { + clazz.getFieldByName("P256").ifPresent(field -> field.getVariable(0).setName("P_256")); + clazz.getFieldByName("P384").ifPresent(field -> field.getVariable(0).setName("P_384")); + clazz.getFieldByName("P521").ifPresent(field -> field.getVariable(0).setName("P_521")); + clazz.getFieldByName("P256_K").ifPresent(field -> field.getVariable(0).setName("P_256K")); + }) + ); + + String classPath = + "src/main/java/com/azure/security/keyvault/keys/models/KeyCurveName.java"; + + replaceInFile(classCustomization, classPath, " For valid values, see JsonWebKeyCurveName.", ""); + } + + /** + * This method replaces all the provided strings in the specified file with new strings provided in the latter half + * of the 'strings' parameter. + * + * @param classCustomization The class customization to use to edit the file. + * @param classPath The path to the file to edit. + * @param strings The strings to replace. The first half of the strings will be replaced with the second half in the + * order they are provided. + */ + private static void replaceInFile(ClassCustomization classCustomization, String classPath, + String... strings) { + + // Replace all instances of KeyVaultServiceVersion with KeyServiceVersion. We'll remove this once the + // TSP spec includes all service versions. + Editor editor = classCustomization.getEditor(); + String fileContent = editor.getFileContent(classPath); + + // Ensure names has an even length. + if (strings.length % 2 != 0) { + throw new IllegalArgumentException("The 'names' parameter must have an even number of elements."); + } + + for (int i = 0; i < (strings.length / 2); i++) { + fileContent = fileContent.replace(strings[i], strings[i + strings.length / 2]); + } + + editor.replaceFile(classPath, fileContent); + + // Uncomment once there's a new version of the AutoRest library out. + /*List ranges = editor.searchText(classPath, "KeyVaultServiceVersion"); + + for (Range range : ranges) { + editor.replace(classPath, range.getStart(), range.getEnd(), "KeyServiceVersion"); + }*/ + } + + private static void replaceImport(CompilationUnit ast, String originalImport, String newImport) { + NodeList nodeList = ast.getImports(); + + for (ImportDeclaration importDeclaration : nodeList) { + if (importDeclaration.getNameAsString().equals(originalImport)) { + importDeclaration.setName(newImport); + + break; + } + } + + ast.setImports(nodeList); } - private static void modelsCustomizations(PackageCustomization models) { - models.getClass("KeyCurveName").customizeAst(ast -> ast.getClassByName("KeyCurveName").ifPresent(clazz -> { - clazz.getFieldByName("P256K").ifPresent(field -> field.getVariable(0).setName("P_256K")); - clazz.getFieldByName("P256").ifPresent(field -> field.getVariable(0).setName("P_256")); - clazz.getFieldByName("P384").ifPresent(field -> field.getVariable(0).setName("P_384")); - clazz.getFieldByName("P521").ifPresent(field -> field.getVariable(0).setName("P_521")); - })); - - models.getClass("KeyType").customizeAst(ast -> ast.getClassByName("KeyType").ifPresent(clazz -> { - clazz.getFieldByName("ECHSM").ifPresent(field -> field.getVariable(0).setName("EC_HSM")); - clazz.getFieldByName("RSAHSM").ifPresent(field -> field.getVariable(0).setName("RSA_HSM")); - })); - - models.getClass("KeyExportEncryptionAlgorithm").customizeAst(ast -> ast.getClassByName("KeyExportEncryptionAlgorithm").ifPresent(clazz -> { - clazz.getFieldByName("CKMRSAAESKEYWRAP").ifPresent(field -> field.getVariable(0).setName("CKM_RSA_AES_KEY_WRAP")); - clazz.getFieldByName("RSAAESKEYWRAP256").ifPresent(field -> field.getVariable(0).setName("RSA_AES_KEY_WRAP_256")); - clazz.getFieldByName("RSAAESKEYWRAP384").ifPresent(field -> field.getVariable(0).setName("RSA_AES_KEY_WRAP_384")); - })); + private static String joinWithNewline(String... lines) { + return String.join("\n", lines); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/tsp-location.yaml b/sdk/keyvault/azure-security-keyvault-keys/tsp-location.yaml new file mode 100644 index 0000000000000..b7708fba0cd15 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/keyvault/Security.KeyVault.Keys +commit: 435f669c2bb635913b0ecec4a0794e19ad186e62 +repo: Azure/azure-rest-api-specs +cleanup: true