From 3fac428e8a954ee56c3158f02b6de8e8d2c94c9f Mon Sep 17 00:00:00 2001 From: vcolin7 Date: Mon, 3 Aug 2020 21:43:21 -0700 Subject: [PATCH] Made minor corrections to all KeyVault READMEs. (#13319) * Made minor corrections to all KeyVault READMEs. * Applied PR feedback. * Fixed minor grammar issues and added quotation marks where needed. * Add azure-data-appconfiguration as an AdditionalModule to Keyvault (#13647) (cherry picked from commit b75d7322d3f44f311a08425c817c7804e7600432) * Made minor fix for the sake of consistency. Co-authored-by: James Suplizio --- .../README.md | 22 +++++----- .../azure-security-keyvault-keys/README.md | 43 +++++++++---------- .../azure-security-keyvault-secrets/README.md | 36 ++++++++-------- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/README.md b/sdk/keyvault/azure-security-keyvault-certificates/README.md index 7d022c00304c8..ff7154e491fad 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/README.md +++ b/sdk/keyvault/azure-security-keyvault-certificates/README.md @@ -138,7 +138,7 @@ SyncPoller certificatePolle certificateClient.beginCreateCertificate("certificateName", CertificatePolicy.getDefault()); certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); KeyVaultCertificate certificate = certificatePoller.getFinalResult(); -System.out.printf("Certificate created with name \"%s\"\n", certificate.getName()); +System.out.printf("Certificate created with name \"%s\"%n", certificate.getName()); ``` ### Retrieve a certificate @@ -146,7 +146,7 @@ Retrieve a previously stored certificate by calling `getCertificate` or `getCert ```Java KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate(""); -System.out.printf("Recevied certificate with name \"%s\", version %s and secret id %s\n", +System.out.printf("Recevied certificate with name \"%s\", version %s and secret id %s%n", certificate.getProperties().getName(), certificate.getProperties().getVersion(), certificate.getSecretId()); ``` @@ -159,7 +159,7 @@ KeyVaultCertificate certificate = certificateClient.getCertificate("") .subscribe(certificateResponse -> - System.out.printf("Certificate was returned with name \"%s\" and secretId %s\n", + System.out.printf("Certificate was returned with name \"%s\" and secretId %s%n", certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); ``` @@ -250,8 +250,8 @@ certificateAsyncClient.getCertificate("") certificate.getProperties().setEnabled(false); certificateAsyncClient.updateCertificateProperties(certificate.getProperties()) .subscribe(certificateResponse -> - System.out.printf("Certificate's enabled status %s\n", - certificateResponse.getProperties().isEnabled().toString())); + System.out.printf("Certificate's enabled status: %s%n", + certificateResponse.getProperties().isEnabled())); }); ``` @@ -261,9 +261,9 @@ Delete an existing certificate by calling `beginDeleteCertificate`. ```java certificateAsyncClient.beginDeleteCertificate("") .subscribe(pollResponse -> { - System.out.printf("Deletion status: %s\n", pollResponse.getStatus().toString()); - System.out.printf("Deleted certificate name: %s\n", pollResponse.getValue().getName()); - System.out.printf("Certificate deletion date: %s\n", pollResponse.getValue().getDeletedOn().toString()); + System.out.printf("Deletion status: %s%n", pollResponse.getStatus()); + System.out.printf("Deleted certificate name: %s%n", pollResponse.getValue().getName()); + System.out.printf("Certificate deletion date: %s%n", pollResponse.getValue().getDeletedOn()); }); ``` @@ -278,8 +278,8 @@ certificateAsyncClient.listPropertiesOfCertificates() certificateAsyncClient.getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()) .subscribe(certificateResponse -> - System.out.printf("Received certificate with name \"%s\" and key id %s", - certificateResponse.getName(), certificateResponse.getKeyId()))); + System.out.printf("Received certificate with name \"%s\" and key id %s", certificateResponse.getName(), + certificateResponse.getKeyId()))); ``` ## Troubleshooting diff --git a/sdk/keyvault/azure-security-keyvault-keys/README.md b/sdk/keyvault/azure-security-keyvault-keys/README.md index 43189ca7f2329..2bb2847de18b1 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/README.md +++ b/sdk/keyvault/azure-security-keyvault-keys/README.md @@ -159,12 +159,12 @@ KeyClient keyClient = new KeyClientBuilder() KeyVaultKey rsaKey = keyClient.createRsaKey(new CreateRsaKeyOptions("CloudRsaKey") .setExpiresOn(OffsetDateTime.now().plusYears(1)) .setKeySize(2048)); -System.out.printf("Key created with name \"%s\" and id %s\n", rsaKey.getName(), rsaKey.getId()); +System.out.printf("Key created with name \"%s\" and id %s%n", rsaKey.getName(), rsaKey.getId()); KeyVaultKey ecKey = keyClient.createEcKey(new CreateEcKeyOptions("CloudEcKey") .setCurveName(KeyCurveName.P_256) .setExpiresOn(OffsetDateTime.now().plusYears(1))); -System.out.printf("Key created with name \"%s\" and id %s\n", ecKey.getName(), ecKey.getId()); +System.out.printf("Key created with name \"%s\" and id %s%n", ecKey.getName(), ecKey.getId()); ``` ### Retrieve a key @@ -172,7 +172,7 @@ Retrieve a previously stored key by calling `getKey`. ```Java KeyVaultKey key = keyClient.getKey(""); -System.out.printf("A key was returned with name \"%s\" and id %s\n", key.getName(), key.getId()); +System.out.printf("A key was returned with name \"%s\" and id %s%n", key.getName(), key.getId()); ``` ### Update an existing key @@ -184,7 +184,7 @@ KeyVaultKey key = keyClient.getKey(""); // Update the expiry time of the key. key.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(30)); KeyVaultKey updatedKey = keyClient.updateKeyProperties(key.getProperties()); -System.out.printf("Key's updated expiry time: %s\n", updatedKey.getProperties().getExpiresOn().toString()); +System.out.printf("Key's updated expiry time: %s%n", updatedKey.getProperties().getExpiresOn()); ``` ### Delete a key @@ -198,7 +198,7 @@ PollResponse deletedKeyPollResponse = deletedKeyPoller.poll(); // Deleted key is accessible as soon as polling begins. DeletedKey deletedKey = deletedKeyPollResponse.getValue(); // Deletion date only works for a SoftDelete-enabled Key Vault. -System.out.printf("Deletion date: %s\n", deletedKey.getDeletedOn().toString()); +System.out.printf("Deletion date: %s%n", deletedKey.getDeletedOn()); // Key is being deleted on server. deletedKeyPoller.waitForCompletion(); @@ -212,7 +212,7 @@ List the keys in the key vault by calling `listPropertiesOfKeys`. // get the key with its key material information. for (KeyProperties keyProperties : keyClient.listPropertiesOfKeys()) { KeyVaultKey keyWithMaterial = keyClient.getKey(keyProperties.getName(), keyProperties.getVersion()); - System.out.printf("Received key with name \"%s\" and type \"%s\"\n", keyWithMaterial.getName(), + System.out.printf("Received key with name \"%s\" and type \"%s\"%n", keyWithMaterial.getName(), keyWithMaterial.getKey().getKeyType()); } ``` @@ -231,8 +231,8 @@ new Random(0x1234567L).nextBytes(plainText); // Let's encrypt a simple plain text of size 100 bytes. EncryptResult encryptionResult = cryptoClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText); -System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"\n", - encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString()); +System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n", + encryptionResult.getCipherText().length, encryptionResult.getAlgorithm()); ``` ### Decrypt @@ -245,7 +245,7 @@ EncryptResult encryptionResult = cryptoClient.encrypt(EncryptionAlgorithm.RSA_OA //Let's decrypt the encrypted result. DecryptResult decryptionResult = cryptoClient.decrypt(EncryptionAlgorithm.RSA_OAEP, encryptionResult.getCipherText()); -System.out.printf("Returned plainText size is %d bytes\n", decryptionResult.getPlainText().length); +System.out.printf("Returned plainText size is %d bytes%n", decryptionResult.getPlainText().length); ``` ### Async API @@ -280,12 +280,12 @@ keyAsyncClient.createRsaKey(new CreateRsaKeyOptions("CloudRsaKey") .setExpiresOn(OffsetDateTime.now().plusYears(1)) .setKeySize(2048)) .subscribe(key -> - System.out.printf("Key created with name \"%s\" and id %s\n", key.getName(), key.getId())); + System.out.printf("Key created with name \"%s\" and id %s%n", key.getName(), key.getId())); keyAsyncClient.createEcKey(new CreateEcKeyOptions("CloudEcKey") .setExpiresOn(OffsetDateTime.now().plusYears(1))) .subscribe(key -> - System.out.printf("Key created with name \"%s\" and id %s\n", key.getName(), key.getId())); + System.out.printf("Key created with name \"%s\" and id %s%n", key.getName(), key.getId())); ``` ### Retrieve a key asynchronously @@ -294,7 +294,7 @@ Retrieve a previously stored key by calling `getKey`. ```Java keyAsyncClient.getKey("") .subscribe(key -> - System.out.printf("Key was returned with name \"%s\" and id %s\n", key.getName(), key.getId())); + System.out.printf("Key was returned with name \"%s\" and id %s%n", key.getName(), key.getId())); ``` ### Update an existing key asynchronously @@ -308,8 +308,7 @@ keyAsyncClient.getKey("") key.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(50)); keyAsyncClient.updateKeyProperties(key.getProperties()) .subscribe(updatedKey -> - System.out.printf("Key's updated expiry time: %s\n", - updatedKey.getProperties().getExpiresOn().toString())); + System.out.printf("Key's updated expiry time: %s%n", updatedKey.getProperties().getExpiresOn())); }); ``` @@ -319,9 +318,9 @@ Delete an existing key by calling `beginDeleteKey`. ```java keyAsyncClient.beginDeleteKey("") .subscribe(pollResponse -> { - System.out.printf("Deletetion status: %s\n", pollResponse.getStatus().toString()); - System.out.printf("Deleted key name: %s\n", pollResponse.getValue().getName()); - System.out.printf("Key deletion date: %s\n", pollResponse.getValue().getDeletedOn().toString()); + System.out.printf("Deletetion status: %s%n", pollResponse.getStatus()); + System.out.printf("Deleted key name: %s%n", pollResponse.getValue().getName()); + System.out.printf("Key deletion date: %s%n", pollResponse.getValue().getDeletedOn()); }); ``` @@ -353,8 +352,8 @@ new Random(0x1234567L).nextBytes(plainText); // Let's encrypt a simple plain text of size 100 bytes. cryptoAsyncClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText) .subscribe(encryptionResult -> { - System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"\n", - encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString()); + System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n", + encryptionResult.getCipherText().length, encryptionResult.getAlgorithm()); }); ``` @@ -368,12 +367,12 @@ new Random(0x1234567L).nextBytes(plainText); // Let's encrypt a simple plain text of size 100 bytes. cryptoAsyncClient.encrypt(EncryptionAlgorithm.RSA_OAEP, plainText) .subscribe(encryptionResult -> { - System.out.printf("Returned cipherText size is %d bytes with algorithm %s\n", - encryptionResult.getCipherText().length, encryptionResult.getAlgorithm().toString()); + System.out.printf("Returned cipherText size is %d bytes with algorithm \"%s\"%n", + encryptionResult.getCipherText().length, encryptionResult.getAlgorithm()); //Let's decrypt the encrypted response. cryptoAsyncClient.decrypt(EncryptionAlgorithm.RSA_OAEP, encryptionResult.getCipherText()) .subscribe(decryptionResult -> - System.out.printf("Returned plainText size is %d bytes\n", decryptionResult.getPlainText().length)); + System.out.printf("Returned plainText size is %d bytes%n", decryptionResult.getPlainText().length)); }); ``` diff --git a/sdk/keyvault/azure-security-keyvault-secrets/README.md b/sdk/keyvault/azure-security-keyvault-secrets/README.md index b67f216d0cb10..3c16c6e47722b 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/README.md +++ b/sdk/keyvault/azure-security-keyvault-secrets/README.md @@ -121,7 +121,7 @@ The following sections provide several code snippets covering some of the most c ### Create a secret Create a secret to be stored in the Azure Key Vault. -- `setSecret` creates a new secret in the Azure Key Vault. If the secret with name already exists then a new version of the secret is created. +- `setSecret` creates a new secret in the Azure Key Vault. If a secret with the given name already exists then a new version of the secret is created. ```Java import com.azure.identity.DefaultAzureCredentialBuilder; @@ -135,7 +135,7 @@ SecretClient secretClient = new SecretClientBuilder() .buildClient(); KeyVaultSecret secret = secretClient.setSecret("", ""); -System.out.printf("Secret created with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue()); +System.out.printf("Secret created with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue()); ``` ### Retrieve a secret @@ -143,7 +143,7 @@ Retrieve a previously stored secret by calling `getSecret`. ```Java KeyVaultSecret secret = secretClient.getSecret(""); -System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue()); +System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue()); ``` ### Update an existing secret @@ -155,7 +155,7 @@ KeyVaultSecret secret = secretClient.getSecret(""); // Update the expiry time of the secret. secret.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(30)); SecretProperties updatedSecretProperties = secretClient.updateSecretProperties(secret.getProperties()); -System.out.printf("Secret's updated expiry time: %s\n", updatedSecretProperties.getExpiresOn().toString()); +System.out.printf("Secret's updated expiry time: %s%n", updatedSecretProperties.getExpiresOn()); ``` ### Delete a secret @@ -168,7 +168,7 @@ SyncPoller deletedSecretPoller = secretClient.beginDeleteSe PollResponse deletedSecretPollResponse = deletedSecretPoller.poll(); // Deletion date only works for a SoftDelete-enabled Key Vault. -System.out.println("Deletion date: \"%s\"" + deletedSecretPollResponse.getValue().getDeletedOn().toString()); +System.out.printf("Deletion date: %s%n", deletedSecretPollResponse.getValue().getDeletedOn()); // Secret is being deleted on server. deletedSecretPoller.waitForCompletion(); @@ -178,10 +178,11 @@ deletedSecretPoller.waitForCompletion(); List the secrets in the Azure Key Vault by calling `listPropertiesOfSecrets`. ```Java -// List operations don't return the secrets with value information. So, for each returned secret we call getSecret to get the secret with its value information. +// List operations don't return the secrets with value information. So, for each returned secret we call getSecret to +// get the secret with its value information. for (SecretProperties secretProperties : secretClient.listPropertiesOfSecrets()) { - KeyVaultSecret secretWithValue = secretClient.getSecret(secretProperties.getName(), secretProperties.getVersion()); - System.out.printf("Retreieved secret with name \"%s\" and value \"%s\"\n", secretWithValue.getName(), + KeyVaultSecret secretWithValue = secretClient.getSecret(secretProperties.getName(), secretProperties.getVersion()); + System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secretWithValue.getName(), secretWithValue.getValue()); } ``` @@ -198,7 +199,7 @@ The following sections provide several code snippets covering some of the most c ### Create a secret asynchronously Create a secret to be stored in the Azure Key Vault. -- `setSecret` creates a new secret in the Azure Key Vault. if the secret with name already exists then a new version of the secret is created. +- `setSecret` creates a new secret in the Azure Key Vault. If a secret with the given name already exists then a new version of the secret is created. ```Java import com.azure.identity.DefaultAzureCredentialBuilder; @@ -212,7 +213,7 @@ SecretAsyncClient secretAsyncClient = new SecretClientBuilder() secretAsyncClient.setSecret("", "") .subscribe(secret -> - System.out.printf("Created secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue())); + System.out.printf("Created secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue())); ``` ### Retrieve a secret asynchronously @@ -221,7 +222,7 @@ Retrieve a previously stored secret by calling `getSecret`. ```Java secretAsyncClient.getSecret("") .subscribe(secret -> - System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"\n", secret.getName(), secret.getValue())); + System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secret.getName(), secret.getValue())); ``` ### Update an existing secret asynchronously @@ -234,8 +235,7 @@ secretAsyncClient.getSecret("") secret.getProperties().setExpiresOn(OffsetDateTime.now().plusDays(50)); secretAsyncClient.updateSecretProperties(secret.getProperties()) .subscribe(updatedSecretProperties -> - System.out.printf("Secret's updated expiry time: %s\n", - updatedSecretProperties.getExpiresOn().toString())); + System.out.printf("Secret's updated expiry time: %s%n", updatedSecretProperties.getExpiresOn())); }); ``` @@ -245,9 +245,9 @@ Delete an existing secret by calling `beginDeleteSecret`. ```Java secretAsyncClient.beginDeleteSecret("") .subscribe(pollResponse -> { - System.out.println("Deletion status: " + pollResponse.getStatus().toString()); - System.out.println("Deleted secret name: " + pollResponse.getValue().getName()); - System.out.println("Deleted secret value: " + pollResponse.getValue().getValue()); + System.out.printf("Deletion status: %s%n", pollResponse.getStatus()); + System.out.printf("Deleted secret name: %s%n", pollResponse.getValue().getName()); + System.out.printf("Deleted secret value: %s%n", pollResponse.getValue().getValue()); }); ``` @@ -255,13 +255,13 @@ secretAsyncClient.beginDeleteSecret("") List the secrets in the Azure Key Vault by calling `listPropertiesOfSecrets`. ```Java -// The List Secrets operation returns secrets without their value, so for each secret returned we call `getSecret` +// The List secrets operation returns secrets without their value, so for each secret returned we call `getSecret` // to get its value as well. secretAsyncClient.listPropertiesOfSecrets() .subscribe(secretProperties -> secretAsyncClient.getSecret(secretProperties.getName(), secretProperties.getVersion()) .subscribe(secretResponse -> - System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"", secretResponse.getName(), + System.out.printf("Retrieved secret with name \"%s\" and value \"%s\"%n", secretResponse.getName(), secretResponse.getValue()))); ```