diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index 35a4635e24098..20c6213b13525 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -150,7 +150,7 @@ A restore operation represents a long running operation for both a full key and ## Create an Access Control client Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET**, and **AZURE_TENANT_ID** environment variables and replaced **your-key-vault-url** with the URI returned above, you can create the `KeyVaultAccessControlClient`: - + ```java KeyVaultAccessControlClient accessControlClient = new KeyVaultAccessControlClientBuilder() .vaultUrl("") @@ -174,7 +174,7 @@ The following sections provide several code snippets covering some of the most c ### List role definitions List the role definitions in the key vault by calling `listRoleDefinitions()`. - + ```java PagedIterable roleDefinitions = keyVaultAccessControlClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); @@ -186,7 +186,7 @@ roleDefinitions.forEach(roleDefinition -> ### Create or update a role definition Create or update a role definition in the key vault. The following example shows how to create a role definition with a randomly generated name. - + ```java KeyVaultRoleDefinition roleDefinition = keyVaultAccessControlClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL); @@ -197,7 +197,7 @@ System.out.printf("Created role definition with randomly generated name '%s' and ### Retrieve a role definition Get an existing role definition. To do this, the scope and 'name' property from an existing role definition are required. - + ```java String roleDefinitionName = ""; KeyVaultRoleDefinition roleDefinition = @@ -210,7 +210,7 @@ System.out.printf("Retrieved role definition with name '%s' and role name '%s'.% ### Delete a role definition Delete a role definition. To do this, the scope and 'name' property property from an existing role definition are required. - + ```java String roleDefinitionName = ""; @@ -222,7 +222,7 @@ System.out.printf("Deleted role definition with name '%s'.%n", roleDefinitionNam ### List role assignments List the role assignments in the key vault by calling `listRoleAssignments()`. - + ```java PagedIterable roleAssignments = keyVaultAccessControlClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL); @@ -242,7 +242,7 @@ See the [Create/Get Credentials section](#createget-credentials) for links and i az ad signed-in-user show --query objectId ``` - + ```java String roleDefinitionId = ""; String servicePrincipalId = ""; @@ -257,7 +257,7 @@ System.out.printf("Created role assignment with randomly generated name '%s' for ### Retrieve a role assignment Get an existing role assignment. To do this, the 'name' property from an existing role assignment is required. - + ```java String roleAssignmentName = ""; KeyVaultRoleAssignment roleAssignment = @@ -268,7 +268,7 @@ System.out.printf("Retrieved role assignment with name '%s'.%n", roleAssignment. ### Delete a role assignment To remove a role assignment from a service principal, the role assignment must be deleted. To do this, the 'name' property from an existing role assignment is required. - + ```java String roleAssignmentName = ""; @@ -293,7 +293,7 @@ The following sections provide several code snippets covering some of the most c ### List role definitions asynchronously List the role definitions in the key vault by calling `listRoleDefinitions()`. - + ```java keyVaultAccessControlAsyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL) .subscribe(roleDefinition -> @@ -303,7 +303,7 @@ keyVaultAccessControlAsyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL) ### Create or update a role definition asynchronously Create or update a role definition in the key vault. The following example shows how to create a role definition with a randomly generated name. - + ```java keyVaultAccessControlAsyncClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL) .subscribe(roleDefinition -> @@ -314,7 +314,7 @@ keyVaultAccessControlAsyncClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL) ### Retrieve a role definition asynchronously Get an existing role definition. To do this, the 'name' property from an existing role definition is required. - + ```java String roleDefinitionName = ""; @@ -327,7 +327,7 @@ keyVaultAccessControlAsyncClient.getRoleDefinition(KeyVaultRoleScope.GLOBAL, rol ### Delete a role definition asynchronously Delete a role definition. To do this, the 'name' property from an existing role definition is required. - + ```java String roleDefinitionName = ""; @@ -338,7 +338,7 @@ keyVaultAccessControlAsyncClient.deleteRoleDefinition(KeyVaultRoleScope.GLOBAL, ### List role assignments asynchronously List the role assignments in the key vault by calling `listRoleAssignments()`. - + ```java keyVaultAccessControlAsyncClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL) .subscribe(roleAssignment -> @@ -356,7 +356,7 @@ See the [Create/Get Credentials section](#createget-credentials) for links and i az ad signed-in-user show --query objectId ``` - + ```java String roleDefinitionId = ""; String servicePrincipalId = ""; @@ -370,7 +370,7 @@ keyVaultAccessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, ### Retrieve a role assignment asynchronously Get an existing role assignment. To do this, the 'name' property from an existing role assignment is required. - + ```java String roleAssignmentName = ""; @@ -382,7 +382,7 @@ keyVaultAccessControlAsyncClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, rol ### Delete a role assignment asynchronously To remove a role assignment from a service principal, the role assignment must be deleted. To do this, the 'name' property from an existing role assignment is required. - + ```java String roleAssignmentName = ""; @@ -394,7 +394,7 @@ keyVaultAccessControlAsyncClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, ### Create a Backup client Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET**, and **AZURE_TENANT_ID** environment variables and replaced **your-key-vault-url** with the URI returned above, you can create the `KeyVaultBackupClient`: - + ```java KeyVaultBackupClient keyVaultBackupClient = new KeyVaultBackupClientBuilder() .vaultUrl("") @@ -414,7 +414,7 @@ The following sections provide several code snippets covering some of the most c ### Backup a collection of keys Back up an entire collection of keys using `beginBackup()`. - + ```java String blobStorageUrl = "https://myaccount.blob.core.windows.net/myContainer"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; @@ -442,7 +442,7 @@ if (finalPollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COM ### Restore a collection of keys Restore an entire collection of keys from a backup using `beginRestore()`. - + ```java String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; @@ -468,7 +468,7 @@ if (finalPollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COM ### Selectively restore a key Restore a specific key from a backup using `beginSelectiveRestore()`. - + ```java String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; @@ -503,7 +503,7 @@ The following sections provide several code snippets covering some of the most c ### Backup a collection of keys asynchronously Back up an entire collection of keys using `beginBackup()`. - + ```java String blobStorageUrl = "https://myaccount.blob.core.windows.net/myContainer"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; @@ -522,7 +522,7 @@ keyVaultBackupAsyncClient.beginBackup(blobStorageUrl, sasToken) ### Restore a collection of keys asynchronously Restore an entire collection of keys from a backup using `beginRestore()`. - + ```java String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; @@ -540,7 +540,7 @@ keyVaultBackupAsyncClient.beginRestore(folderUrl, sasToken) ### Selectively restore a key asynchronously Restore an entire collection of keys from a backup using `beginSelectiveRestore()`. - + ```java String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com/azure/security/keyvault/administration/ReadmeSamples.java b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com/azure/security/keyvault/administration/ReadmeSamples.java index ebbfee4d346d7..85aa3e830ff16 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com/azure/security/keyvault/administration/ReadmeSamples.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/samples/java/com/azure/security/keyvault/administration/ReadmeSamples.java @@ -28,9 +28,17 @@ * Class containing code snippets that will be injected to README.md. */ public class ReadmeSamples { - private final KeyVaultAccessControlClient keyVaultAccessControlClient = new KeyVaultAccessControlClient(null); + private final KeyVaultAccessControlClient keyVaultAccessControlClient = + new KeyVaultAccessControlClientBuilder() + .vaultUrl("") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); private final KeyVaultAccessControlAsyncClient keyVaultAccessControlAsyncClient = null; - private final KeyVaultBackupClient keyVaultBackupClient = new KeyVaultBackupClient(null); + private final KeyVaultBackupClient keyVaultBackupClient = + new KeyVaultBackupClientBuilder() + .vaultUrl("") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); private final KeyVaultBackupAsyncClient keyVaultBackupAsyncClient = null; /**