diff --git a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml index f7e3bcb5eb317..a560cfc875492 100755 --- a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml +++ b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml @@ -443,6 +443,16 @@ + + + + + + + + + diff --git a/sdk/keyvault/azure-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java b/sdk/keyvault/azure-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java index a08d51cb1a66c..25a7775cec376 100644 --- a/sdk/keyvault/azure-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java +++ b/sdk/keyvault/azure-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java @@ -86,7 +86,7 @@ public final class SecretAsyncClient { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono setSecret(Secret secret) { - return withContext(context -> setSecret(secret, context)) + return withContext(context -> setSecretWithResponse(secret)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -140,14 +140,14 @@ Mono> setSecret(Secret secret, Context context) { * * @param name The name of the secret. It is required and cannot be null. * @param value The value of the secret. It is required and cannot be null. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#value() value} - * contains the {@link Secret created secret}. + * @return A {@link Mono} containing the {@link Secret created secret}. * @throws ResourceModifiedException if invalid {@code name} or {@code value} are specified. * @throws HttpRequestException if {@code name} or {@code value} is empty string. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setSecret(String name, String value) { - return withContext(context -> setSecret(name, value, context)); + public Mono setSecret(String name, String value) { + return withContext(context -> setSecret(name, value, context)) + .flatMap(response -> Mono.justOrEmpty(response.value())); } Mono> setSecret(String name, String value, Context context) { @@ -181,7 +181,7 @@ Mono> setSecret(String name, String value, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getSecret(String name, String version) { - return withContext(context -> getSecret(name, version, context)) + return withContext(context -> getSecretWithResponse(name, version)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -236,8 +236,7 @@ Mono> getSecret(String name, String version, Context context) { * * @param secretBase The {@link SecretBase base secret} secret base holding attributes of the * secret being requested. - * @return A {@link Response} whose {@link Response#value() value} contains the requested {@link - * Secret secret}. + * @return A {@link Mono} containing the requested {@link Secret secret}. * @throws ResourceNotFoundException when a secret with {@link SecretBase#name() name} and {@link * SecretBase#version() version} doesn't exist in the key vault. * @throws HttpRequestException if {@link SecretBase#name()} name} or {@link SecretBase#version() @@ -249,7 +248,8 @@ public Mono getSecret(SecretBase secretBase) { if (secretBase.version() == null) { return getSecret(secretBase.name()); } - return getSecret(secretBase.name(), secretBase.version()); + return getSecretWithResponse(secretBase.name(), secretBase.version()) + .flatMap(response -> Mono.justOrEmpty(response.value())); } /** @@ -302,11 +302,12 @@ Mono> getSecret(SecretBase secretBase, Context context) { * @param name The name of the secret. * @throws ResourceNotFoundException when a secret with {@code name} doesn't exist in the key vault. * @throws HttpRequestException if {@code name} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#value() value} contains the requested {@link Secret secret}. + * @return A {@link Mono} containing the requested {@link Secret secret}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getSecret(String name) { - return getSecret(name, ""); + return getSecretWithResponse(name, "") + .flatMap(response -> Mono.justOrEmpty(response.value())); } Mono> getSecret(String name, Context context) { @@ -333,7 +334,7 @@ Mono> getSecret(String name, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono updateSecret(SecretBase secret) { - return withContext(context -> updateSecret(secret, context)) + return withContext(context -> updateSecretWithResponse(secret)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -390,7 +391,7 @@ Mono> updateSecret(SecretBase secret, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono deleteSecret(String name) { - return withContext(context -> deleteSecret(name, context)) + return withContext(context -> deleteSecretWithResponse(name)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -441,7 +442,7 @@ Mono> deleteSecret(String name, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getDeletedSecret(String name) { - return withContext(context -> getDeletedSecret(name, context)) + return withContext(context -> getDeletedSecretWithResponse(name)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -525,7 +526,7 @@ Mono purgeDeletedSecret(String name, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono recoverDeletedSecret(String name) { - return withContext(context -> recoverDeletedSecret(name, context)) + return withContext(context -> recoverDeletedSecretWithResponse(name)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -576,7 +577,7 @@ Mono> recoverDeletedSecret(String name, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono backupSecret(String name) { - return withContext(context -> backupSecret(name, context)) + return withContext(context -> backupSecretWithResponse(name)) .flatMap(response -> Mono.justOrEmpty(response.value())); } @@ -629,7 +630,7 @@ Mono> backupSecret(String name, Context context) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono restoreSecret(byte[] backup) { - return withContext(context -> restoreSecret(backup, context)) + return withContext(context -> restoreSecretWithResponse(backup)) .flatMap(response -> Mono.justOrEmpty(response.value())); } diff --git a/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/HelloWorldAsync.java b/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/HelloWorldAsync.java index 7f1738b791538..17015ed1915c3 100644 --- a/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/HelloWorldAsync.java +++ b/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/HelloWorldAsync.java @@ -59,7 +59,7 @@ public static void main(String[] args) throws InterruptedException { // To achieve this, we need to create a new version of the secret in the key vault. The update operation cannot // change the value of the secret. secretAsyncClient.setSecret("BankAccountPassword", "bhjd4DDgsa").subscribe(secretResponse -> - System.out.printf("Secret is created with name %s and value %s \n", secretResponse.value().name(), secretResponse.value().value())); + System.out.printf("Secret is created with name %s and value %s \n", secretResponse.name(), secretResponse.value())); Thread.sleep(2000); diff --git a/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/SecretAsyncClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/SecretAsyncClientJavaDocCodeSnippets.java index 05bdcf40a3879..e57a47e82cedc 100644 --- a/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/SecretAsyncClientJavaDocCodeSnippets.java +++ b/sdk/keyvault/azure-keyvault-secrets/src/samples/java/com/azure/security/keyvault/secrets/SecretAsyncClientJavaDocCodeSnippets.java @@ -153,7 +153,7 @@ public void setSecretCodeSnippets() { .subscriberContext(Context.of(key1, value1, key2, value2)) .subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s \n", - secretResponse.value().name(), secretResponse.value().value())); + secretResponse.name(), secretResponse.value())); // END: com.azure.keyvault.secrets.secretclient.setSecret#string-string }