diff --git a/sdk/attestation/azure-resourcemanager-attestation/pom.xml b/sdk/attestation/azure-resourcemanager-attestation/pom.xml
index b69a3c03f8789..381f82c1c3b2d 100644
--- a/sdk/attestation/azure-resourcemanager-attestation/pom.xml
+++ b/sdk/attestation/azure-resourcemanager-attestation/pom.xml
@@ -39,6 +39,9 @@
Retrieve the OpenID metadata for this async client. Retrieve the OpenID metadata for this async client.
+ * BinaryData expectedHash = client.calculatePolicyTokenHash(policyToSet, null);
+ * BinaryData actualHash = result.getPolicyTokenHash();
+ * if (!expectedHash.equals(actualHash)) {
+ * throw new RuntimeException("Policy was set but not received!!!");
+ * }
+ *
+ *
*
* @param policy AttestationPolicy document use in the underlying JWT.
* @param signer Optional signing key used to sign the underlying JWT.
diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClient.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClient.java
index 5963835d282e3..a1dc54603e6b6 100644
--- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClient.java
+++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClient.java
@@ -180,7 +180,15 @@ public Response
+ * BinaryData expectedHash = client.calculatePolicyTokenHash(policyToSet, null);
+ * BinaryData actualHash = result.getPolicyTokenHash();
+ * if (!expectedHash.equals(actualHash)) {
+ * throw new RuntimeException("Policy was set but not received!!!");
+ * }
+ *
+ *
*
* @param policy AttestationPolicy document use in the underlying JWT.
* @param signer Optional signing key used to sign the underlying JWT.
diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClientBuilder.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClientBuilder.java
index c949c829583aa..3c39d90dcddae 100644
--- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClientBuilder.java
+++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClientBuilder.java
@@ -190,7 +190,13 @@ public AttestationAdministrationClientBuilder tokenValidationOptions(Attestation
*
* Instantiating a synchronous Attestation client:
*
- * {@codesnippet com.azure.security.attestation.AttestationAdministrationClientBuilder.buildClient}
+ *
+ *
+ * AttestationAdministrationClient client = new AttestationAdministrationClientBuilder()
+ * .endpoint(endpoint)
+ * .buildClient();
+ *
+ *
* @return an instance of {@link AttestationClient}.
*/
public AttestationAdministrationClient buildClient() {
@@ -202,7 +208,13 @@ public AttestationAdministrationClient buildClient() {
*
* Instantiating a synchronous Attestation client:
*
- * {@codesnippet com.azure.security.attestation.AttestationAdministrationClientBuilder.buildAsyncClient}
+ *
+ *
+ * AttestationAdministrationAsyncClient asyncClient = new AttestationAdministrationClientBuilder()
+ * .endpoint(endpoint)
+ * .buildAsyncClient();
+ *
+ *
* @return an instance of {@link AttestationClient}.
*/
public AttestationAdministrationAsyncClient buildAsyncClient() {
diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAsyncClient.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAsyncClient.java
index d82f7f318f921..1ea1c518d0244 100644
--- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAsyncClient.java
+++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAsyncClient.java
@@ -171,7 +171,11 @@ public final class AttestationAsyncClient {
* Retrieves metadata about the attestation signing keys in use by the attestation service.
*
*
+ * Mono<Response<AttestationOpenIdMetadata>> response = client.getOpenIdMetadataWithResponse();
+ *
+ *
*
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
@@ -191,7 +195,11 @@ Mono
+ * Mono<AttestationOpenIdMetadata> openIdMetadata = client.getOpenIdMetadata();
+ *
+ *
*
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
@@ -211,7 +219,23 @@ public Mono
Retrieve Attestation Signers for this async client.
- * {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getAttestationSigners} + * + *+ * Mono<List<AttestationSigner>> signers = client.listAttestationSigners(); + * signers.block().forEach(cert -> { + * System.out.println("Found certificate."); + * if (cert.getKeyId() != null) { + * System.out.println(" Certificate Key ID: " + cert.getKeyId()); + * } else { + * System.out.println(" Signer does not have a Key ID"); + * } + * cert.getCertificates().forEach(chainElement -> { + * System.out.println(" Cert Subject: " + chainElement.getSubjectDN().getName()); + * System.out.println(" Cert Issuer: " + chainElement.getIssuerDN().getName()); + * }); + * }); + *+ * * * @return Returns an array of {@link AttestationSigner} objects. */ @@ -228,7 +252,11 @@ public Mono
Retrieve Attestation Signers for this async client.
- * {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getAttestationSignersWithResponse} + * + *+ * Mono<Response<List<AttestationSigner>>> responseOfSigners = client.listAttestationSignersWithResponse(); + *+ * * * @return Returns an array of {@link AttestationSigner} objects. */ diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationClientBuilder.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationClientBuilder.java index 0addb31a70dbb..ee18d4f39d20b 100644 --- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationClientBuilder.java +++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationClientBuilder.java @@ -188,7 +188,13 @@ public AttestationClientBuilder tokenValidationOptions(AttestationTokenValidatio * * Instantiating a synchronous Attestation client: *
+ * AttestationClient client = new AttestationClientBuilder() + * .endpoint(endpoint) + * .buildClient(); + *+ * * @return an instance of {@link AttestationClient}. */ public AttestationClient buildClient() { @@ -200,7 +206,13 @@ public AttestationClient buildClient() { * * Instantiating a synchronous Attestation client: *
+ * AttestationAsyncClient asyncClient = new AttestationClientBuilder() + * .endpoint(endpoint) + * .buildAsyncClient(); + *+ * * @return an instance of {@link AttestationClient}. */ public AttestationAsyncClient buildAsyncClient() { diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationServiceVersion.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationServiceVersion.java index 18fb50e731b21..b188b78eabd30 100644 --- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationServiceVersion.java +++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationServiceVersion.java @@ -9,6 +9,9 @@ * The versions of Azure Metrics Advisor supported by this client library. */ public enum AttestationServiceVersion implements ServiceVersion { + /** + * Service version {@code 2020-10-01}. + */ V2020_10_01("2020-10-01"); private final String version; diff --git a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/models/AttestationOptions.java b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/models/AttestationOptions.java index 9a2a75aaf070e..4b950139c6811 100644 --- a/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/models/AttestationOptions.java +++ b/sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/models/AttestationOptions.java @@ -81,7 +81,11 @@ public final class AttestationOptions { * The evidence will typically take the form of either an OpenEnclave report or an Intel SGX quote. * *
Create an AttestationOptions from an SGX quote:
- * {@codesnippet com.azure.security.attestation.models..fromEvidence#byte} + * + *+ * AttestationOptions options = new AttestationOptions(sgxQuote); + *+ * * @param evidence to be used in the attest request. */ public AttestationOptions(BinaryData evidence) { @@ -110,7 +114,12 @@ public BinaryData getEvidence() { * the {@link AttestationDataInterpretation} specified for the RunTime Data was set to "BINARY", or * *
Setting RunTime Data Property
- * {@codesnippet com.azure.security.attestation.models..setInitTimeData#byte} + * + *+ * AttestationOptions optionsWithInitTimeData = new AttestationOptions(openEnclaveReport) + * .setInitTimeData(new AttestationData(inittimeData, AttestationDataInterpretation.BINARY)); + *+ * * @param attestationData the runtimeData value to set. * @return this {@link AttestationOptions} object itself. */ @@ -122,7 +131,14 @@ public AttestationOptions setRunTimeData(AttestationData attestationData) { /** * Retrieves the RunTimeData property to be sent to the service. *
Retrieve the RunTimeData value.
- * {@codesnippet com.azure.security.attestation.models.AttestationOptions.getRunTimeData} + * + *+ * AttestationOptions attestationOptions = new AttestationOptions(openEnclaveReport) + * .setRunTimeData(new AttestationData(runtimeData, AttestationDataInterpretation.JSON)); + * + * AttestationData existingRuntimeData = attestationOptions.getRunTimeData(); + *+ * * @return The RunTimeData value set by {@link AttestationOptions#setRunTimeData} */ public AttestationData getRunTimeData() { @@ -140,7 +156,12 @@ public AttestationData getRunTimeData() { * for the {@link AttestationData} is set to "JSON". * *
Setting InitTime Data Property
- * {@codesnippet com.azure.security.attestation.models..setInitTimeData#byte} + * + *+ * AttestationOptions optionsWithInitTimeData = new AttestationOptions(openEnclaveReport) + * .setInitTimeData(new AttestationData(inittimeData, AttestationDataInterpretation.BINARY)); + *+ * * @param attestationData the InitTimeData value to set. * @return this {@link AttestationOptions} object itself. */ @@ -152,7 +173,14 @@ public AttestationOptions setInitTimeData(AttestationData attestationData) { /** * Retrieves the InitTimeData property to be sent to the service. *
Retrieve the InitTimeData value.
- * {@codesnippet com.azure.security.attestation.models.AttestationOptions.getInitTimeData} + * + *+ * AttestationOptions attestationOptions = new AttestationOptions(openEnclaveReport) + * .setInitTimeData(new AttestationData(inittimeData, AttestationDataInterpretation.JSON)); + * + * AttestationData existingRuntimeData = attestationOptions.getInitTimeData(); + *+ * * @return The InitTimeData value set by {@link AttestationOptions#setInitTimeData} */ public AttestationData getInitTimeData() { @@ -165,7 +193,12 @@ public AttestationData getInitTimeData() { * determine how a proposed attestation policy would affect an attestation token. * Note that the resulting token cannot be validated. *
Example of setting AttestationOptions with a draft policy.
- * {@codesnippet com.azure.security.attestation.models.AttestationOptions.setDraftPolicyForAttestation#String} + * + *+ * AttestationOptions request = new AttestationOptions(openEnclaveReport) + * .setDraftPolicyForAttestation("version=1.0; authorizationrules{=> permit();}; issuancerules{};"); + *+ * * @param draftPolicyForAttestation the draftPolicyForAttestation value to set. * @return this {@link AttestationOptions} object itself. */ @@ -178,7 +211,14 @@ public AttestationOptions setDraftPolicyForAttestation(String draftPolicyForAtte * Gets the draftPolicyForAttestation property which is used to attest against the draft policy. * *
Gets the previously set draft policy for attestation.
- * {@codesnippet com.azure.security.attestation.models.AttestationOptions.getDraftPolicyForAttestation} + * + *+ * AttestationOptions getOptions = new AttestationOptions(openEnclaveReport) + * .setDraftPolicyForAttestation("version=1.0; authorizationrules{=> permit();}; issuancerules{};"); + * + * String draftPolicy = getOptions.getDraftPolicyForAttestation(); + *+ * * @return The draft policy if set. */ public String getDraftPolicyForAttestation() { diff --git a/sdk/attestation/azure-security-attestation/src/samples/java/com/azure/security/attestation/ReadMeSamples.java b/sdk/attestation/azure-security-attestation/src/samples/java/com/azure/security/attestation/ReadmeSamples.java similarity index 100% rename from sdk/attestation/azure-security-attestation/src/samples/java/com/azure/security/attestation/ReadMeSamples.java rename to sdk/attestation/azure-security-attestation/src/samples/java/com/azure/security/attestation/ReadmeSamples.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index 20c6213b13525..5e608b3fadd74 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -24,9 +24,9 @@ Maven dependency for the Azure Key Vault Administration library. Add it to your - [Azure Subscription][azure_subscription] - An existing [Azure Key Vault Managed HSM][azure_keyvault_mhsm]. If you need to create a Managed HSM, you can use the [Azure Cloud Shell][azure_cloud_shell] to create one with this Azure CLI command. Replace `
Samples to construct an async client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.instantiation} + * + *+ * KeyVaultAccessControlAsyncClient keyVaultAccessControlAsyncClient = new KeyVaultAccessControlClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildAsyncClient(); + *+ * * * @see KeyVaultAccessControlClientBuilder */ @@ -144,7 +151,13 @@ HttpPipeline getHttpPipeline() { *
Code Samples
*Lists all {@link KeyVaultRoleDefinition role definitions}. Prints out the details of the retrieved * {@link KeyVaultRoleDefinition role definitions}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.listRoleDefinitions#KeyVaultRoleScope} + * + *+ * keyVaultAccessControlAsyncClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL) + * .subscribe(roleDefinition -> + * System.out.printf("Retrieved role definition with name '%s'.%n", roleDefinition.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definitions}. * @@ -254,7 +267,14 @@ Mono
Code Samples
*Creates a {@link KeyVaultRoleDefinition role definition} with a randomly generated name. Prints out the * details of the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.setRoleDefinition#KeyVaultRoleScope} + * + *+ * keyVaultAccessControlAsyncClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL) + * .subscribe(roleDefinition -> + * System.out.printf("Created role definition with randomly generated name '%s' and role name '%s'.%n", + * roleDefinition.getName(), roleDefinition.getRoleName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -276,7 +296,16 @@ public Mono
Code Samples
*Creates or updates a {@link KeyVaultRoleDefinition role definition} with a given generated name. Prints out * the details of the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.setRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String myRoleDefinitionName = "504a3d11-5a63-41a9-b603-41bdf88df03e"; + * + * keyVaultAccessControlAsyncClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL, myRoleDefinitionName) + * .subscribe(roleDefinition -> + * System.out.printf("Set role definition with name '%s' and role name '%s'.%n", roleDefinition.getName(), + * roleDefinition.getRoleName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -301,7 +330,39 @@ public Mono
Code Samples
*Creates or updates a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response} and the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.setRoleDefinitionWithResponse#SetRoleDefinitionOptions} + * + *+ * String roleDefinitionName = "9de303d3-6ea8-4b8f-a20b-18e67f77e42a"; + * + * List<KeyVaultRoleScope> assignableScopes = new ArrayList<>(); + * assignableScopes.add(KeyVaultRoleScope.GLOBAL); + * assignableScopes.add(KeyVaultRoleScope.KEYS); + * + * List<KeyVaultDataAction> dataActions = new ArrayList<>(); + * dataActions.add(KeyVaultDataAction.START_HSM_RESTORE); + * dataActions.add(KeyVaultDataAction.START_HSM_BACKUP); + * dataActions.add(KeyVaultDataAction.READ_HSM_BACKUP_STATUS); + * dataActions.add(KeyVaultDataAction.READ_HSM_RESTORE_STATUS); + * dataActions.add(KeyVaultDataAction.BACKUP_HSM_KEYS); + * dataActions.add(KeyVaultDataAction.RESTORE_HSM_KEYS); + * + * List<KeyVaultPermission> permissions = new ArrayList<>(); + * permissions.add(new KeyVaultPermission(null, null, dataActions, null)); + * + * SetRoleDefinitionOptions setRoleDefinitionOptions = + * new SetRoleDefinitionOptions(KeyVaultRoleScope.GLOBAL, roleDefinitionName) + * .setRoleName("Backup and Restore Role Definition") + * .setDescription("Can backup and restore a whole Managed HSM, as well as individual keys.%n") + * .setAssignableScopes(assignableScopes) + * .setPermissions(permissions); + * + * keyVaultAccessControlAsyncClient.setRoleDefinitionWithResponse(setRoleDefinitionOptions) + * .subscribe(response -> + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' and role" + * + " name '%s' was set.%n", response.getStatusCode(), response.getValue().getName(), + * response.getValue().getRoleName())); + *+ * * * @param options Object representing the configurable options to create or update a * {@link KeyVaultRoleDefinition role definition}. @@ -401,7 +462,16 @@ Mono
Code Samples
*Gets a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the retrieved * {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.getRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String roleDefinitionName = "8f90b099-7361-4db6-8321-719adaf6e4ca"; + * + * keyVaultAccessControlAsyncClient.getRoleDefinition(KeyVaultRoleScope.GLOBAL, roleDefinitionName) + * .subscribe(roleDefinition -> + * System.out.printf("Retrieved role definition with name '%s' and role name '%s'.%n", + * roleDefinition.getName(), roleDefinition.getRoleName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name used of the {@link KeyVaultRoleDefinition role definition}. @@ -424,7 +494,17 @@ public Mono
Code Samples
*Gets a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response} and the retrieved {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.getRoleDefinitionWithResponse#KeyVaultRoleScope-String} + * + *+ * String myRoleDefinitionName = "0877b4ee-6275-4559-89f1-c289060ef398"; + * + * keyVaultAccessControlAsyncClient.getRoleDefinitionWithResponse(KeyVaultRoleScope.GLOBAL, myRoleDefinitionName) + * .subscribe(response -> + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' and role" + * + " name '%s' was retrieved.%n", response.getStatusCode(), response.getValue().getName(), + * response.getValue().getRoleName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name of the {@link KeyVaultRoleDefinition role definition}. @@ -488,7 +568,14 @@ Mono
Code Samples
*Deletes a {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.deleteRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String roleDefinitionName = "e3c7c51a-8abd-4b1b-9201-48ded34d0358"; + * + * keyVaultAccessControlAsyncClient.deleteRoleDefinition(KeyVaultRoleScope.GLOBAL, roleDefinitionName) + * .subscribe(unused -> System.out.printf("Deleted role definition with name '%s'.%n", roleDefinitionName)); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -511,7 +598,16 @@ public Mono
Code Samples
*Deletes a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.deleteRoleDefinitionWithResponse#KeyVaultRoleScope-String} + * + *+ * String myRoleDefinitionName = "ccaafb00-31fb-40fe-9ccc-39a2ad2af082"; + * + * keyVaultAccessControlAsyncClient.deleteRoleDefinitionWithResponse(KeyVaultRoleScope.GLOBAL, + * myRoleDefinitionName).subscribe(response -> + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' was" + * + " deleted.%n", response.getStatusCode(), myRoleDefinitionName)); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name of the {@link KeyVaultRoleDefinition role definition}. @@ -678,7 +774,17 @@ Mono
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment} with a randomly generated name. Prints out the * details of the created {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.createRoleAssignment#KeyVaultRoleScope-String-String} + * + *+ * String roleDefinitionId = "142e42c1-ab29-4dc7-9dfa-8fd7c0815128"; + * String servicePrincipalId = "07dca82e-b625-4a60-977b-859d2a162ca7"; + * + * keyVaultAccessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleDefinitionId, + * servicePrincipalId).subscribe(roleAssignment -> + * System.out.printf("Created role assignment with randomly generated name '%s' for principal with id" + * + "'%s'.%n", roleAssignment.getName(), roleAssignment.getProperties().getPrincipalId())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -704,7 +810,18 @@ public Mono
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment}. Prints out the details of the created * {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.createRoleAssignment#KeyVaultRoleScope-String-String-String} + * + *+ * String myRoleDefinitionId = "e1ca67d0-4332-465c-b9cd-894b2834401b"; + * String myServicePrincipalId = "31af81fe-6123-4838-92c0-7c2531ec13d7"; + * String myRoleAssignmentName = "94d7827f-f8c9-4a5d-94fd-9fd2cd02d12f"; + * + * keyVaultAccessControlAsyncClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, myRoleDefinitionId, + * myServicePrincipalId, myRoleAssignmentName).subscribe(roleAssignment -> + * System.out.printf("Created role assignment with name '%s' for principal with id '%s'.%n", + * roleAssignment.getName(), roleAssignment.getProperties().getPrincipalId())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -733,7 +850,22 @@ public Mono
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response} and the created {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.createRoleAssignmentWithResponse#KeyVaultRoleScope-String-String-String} + * + *+ * String someRoleDefinitionId = "686b0f78-5012-4def-8a70-eba36aa54d3d"; + * String someServicePrincipalId = "345ec980-904b-4238-aafc-1eaeed3e23cf"; + * String someRoleAssignmentName = "1c79927c-6e08-4e5c-8a6c-f58c13c9bbb5"; + * + * keyVaultAccessControlAsyncClient.createRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, + * someRoleDefinitionId, someServicePrincipalId, someRoleAssignmentName).subscribe(response -> { + * KeyVaultRoleAssignment createdRoleAssignment = response.getValue(); + * + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' for" + * + " principal with id '%s' was created.%n", response.getStatusCode(), + * createdRoleAssignment.getName(), createdRoleAssignment.getProperties().getPrincipalId()); + * }); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -823,7 +955,15 @@ Mono
Code Samples
*Gets a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the retrieved * {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.getRoleAssignment#KeyVaultRoleScope-String} + * + *+ * String roleAssignmentName = "c5a305c0-e17a-40f5-af79-73801bdd8867"; + * + * keyVaultAccessControlAsyncClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName) + * .subscribe(roleAssignment -> + * System.out.printf("Retrieved role assignment with name '%s'.%n", roleAssignment.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name used of the {@link KeyVaultRoleAssignment role assignment}. @@ -846,7 +986,16 @@ public Mono
Code Samples
*Gets a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response} and the retrieved {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.getRoleAssignmentWithResponse#KeyVaultRoleScope-String} + * + *+ * String myRoleAssignmentName = "76ccbf52-4d49-4fcc-ad3f-044c254be114"; + * + * keyVaultAccessControlAsyncClient.getRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, myRoleAssignmentName) + * .subscribe(response -> + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' was" + * + " retrieved.%n", response.getStatusCode(), response.getValue().getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. @@ -910,7 +1059,15 @@ Mono
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.deleteRoleAssignment#KeyVaultRoleScope-String} + * + *+ * String roleAssignmentName = "f05d11ce-578a-4524-950c-fb4c53e5fb96"; + * + * keyVaultAccessControlAsyncClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName) + * .subscribe(unused -> + * System.out.printf("Deleted role assignment with name '%s'.%n", roleAssignmentName)); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. @@ -932,7 +1089,16 @@ public Mono
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.deleteRoleAssignmentWithResponse#KeyVaultRoleScope-String} + * + *+ * String myRoleAssignmentName = "06aaea13-e4f3-4d3f-8a93-088dff6e90ed"; + * + * keyVaultAccessControlAsyncClient.deleteRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, + * myRoleAssignmentName).subscribe(response -> + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' was" + * + " deleted.%n", response.getStatusCode(), myRoleAssignmentName)); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java index 4d63af822a605..cb8e9e4cfeb66 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java @@ -28,7 +28,14 @@ * method on a {@link KeyVaultAccessControlClientBuilder} object. * *
Samples to construct a sync client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.instantiation} + * + *+ * KeyVaultAccessControlClient keyVaultAccessControlClient = new KeyVaultAccessControlClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildClient(); + *+ * * * @see KeyVaultAccessControlClientBuilder */ @@ -61,7 +68,15 @@ public String getVaultUrl() { *
Code Samples
*Lists all {@link KeyVaultRoleDefinition role definitions}. Prints out the details of the retrieved * {@link KeyVaultRoleDefinition role definitions}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.listRoleDefinitions#KeyVaultRoleScope} + * + *+ * PagedIterable<KeyVaultRoleDefinition> roleDefinitions = + * keyVaultAccessControlClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL); + * + * roleDefinitions.forEach(roleDefinition -> + * System.out.printf("Retrieved role definition with name '%s'.%n", roleDefinition.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope roleScope} of the {@link KeyVaultRoleDefinition role definitions}. * @@ -83,7 +98,15 @@ public PagedIterable
Code Samples
*Lists all {@link KeyVaultRoleDefinition role definitions}. Prints out the details of the retrieved * {@link KeyVaultRoleDefinition role definitions}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.listRoleDefinitions#KeyVaultRoleScope-Context} + * + *+ * PagedIterable<KeyVaultRoleDefinition> keyVaultRoleDefinitions = + * keyVaultAccessControlClient.listRoleDefinitions(KeyVaultRoleScope.GLOBAL, new Context("key1", "value1")); + * + * keyVaultRoleDefinitions.forEach(roleDefinition -> + * System.out.printf("Retrieved role definition with name '%s'.%n", roleDefinition.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. @@ -105,7 +128,14 @@ public PagedIterable
Code Samples
*Creates a {@link KeyVaultRoleDefinition role definition} with a randomly generated name. Prints out the * details of the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.setRoleDefinition#KeyVaultRoleScope} + * + *+ * KeyVaultRoleDefinition roleDefinition = keyVaultAccessControlClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL); + * + * System.out.printf("Created role definition with randomly generated name '%s' and role name '%s'.%n", + * roleDefinition.getName(), roleDefinition.getRoleName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -127,7 +157,16 @@ public KeyVaultRoleDefinition setRoleDefinition(KeyVaultRoleScope roleScope) { *
Code Samples
*Creates or updates a {@link KeyVaultRoleDefinition role definition} with a given generated name. Prints out * the details of the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.setRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String myRoleDefinitionName = "b67c3cf4-cbfd-451e-89ab-97c01906a2e0"; + * KeyVaultRoleDefinition myRoleDefinition = + * keyVaultAccessControlClient.setRoleDefinition(KeyVaultRoleScope.GLOBAL, myRoleDefinitionName); + * + * System.out.printf("Set role definition with name '%s' and role name '%s'.%n", myRoleDefinition.getName(), + * myRoleDefinition.getRoleName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -151,7 +190,40 @@ public KeyVaultRoleDefinition setRoleDefinition(KeyVaultRoleScope roleScope, Str *
Code Samples
*Creates or updates a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response} and the created {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.setRoleDefinitionWithResponse#SetRoleDefinitionOptions-Context} + * + *+ * String roleDefinitionName = "a86990e4-2080-4666-bd36-6e1664d3706f"; + * + * List<KeyVaultRoleScope> assignableScopes = new ArrayList<>(); + * assignableScopes.add(KeyVaultRoleScope.GLOBAL); + * assignableScopes.add(KeyVaultRoleScope.KEYS); + * + * List<KeyVaultDataAction> dataActions = new ArrayList<>(); + * dataActions.add(KeyVaultDataAction.START_HSM_RESTORE); + * dataActions.add(KeyVaultDataAction.START_HSM_BACKUP); + * dataActions.add(KeyVaultDataAction.READ_HSM_BACKUP_STATUS); + * dataActions.add(KeyVaultDataAction.READ_HSM_RESTORE_STATUS); + * dataActions.add(KeyVaultDataAction.BACKUP_HSM_KEYS); + * dataActions.add(KeyVaultDataAction.RESTORE_HSM_KEYS); + * + * List<KeyVaultPermission> permissions = new ArrayList<>(); + * permissions.add(new KeyVaultPermission(null, null, dataActions, null)); + * + * SetRoleDefinitionOptions setRoleDefinitionOptions = + * new SetRoleDefinitionOptions(KeyVaultRoleScope.GLOBAL, roleDefinitionName) + * .setRoleName("Backup and Restore Role Definition") + * .setDescription("Can backup and restore a whole Managed HSM, as well as individual keys.") + * .setAssignableScopes(assignableScopes) + * .setPermissions(permissions); + * + * Response<KeyVaultRoleDefinition> response = + * keyVaultAccessControlClient.setRoleDefinitionWithResponse(setRoleDefinitionOptions, + * new Context("key1", "value1")); + * + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' and role name '%s' " + * + "was set.%n", response.getStatusCode(), response.getValue().getName(), response.getValue().getRoleName()); + *+ * * * @param options Object representing the configurable options to create or update a * {@link KeyVaultRoleDefinition role definition}. @@ -176,7 +248,16 @@ public Response
Code Samples
*Gets a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the retrieved * {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.getRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String roleDefinitionName = "de8df120-987e-4477-b9cc-570fd219a62c"; + * KeyVaultRoleDefinition roleDefinition = + * keyVaultAccessControlClient.getRoleDefinition(KeyVaultRoleScope.GLOBAL, roleDefinitionName); + * + * System.out.printf("Retrieved role definition with name '%s' and role name '%s'.%n", roleDefinition.getName(), + * roleDefinition.getRoleName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name used of the {@link KeyVaultRoleDefinition role definition}. @@ -199,7 +280,18 @@ public KeyVaultRoleDefinition getRoleDefinition(KeyVaultRoleScope roleScope, Str *
Code Samples
*Gets a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response} and the retrieved {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.getRoleDefinitionWithResponse#KeyVaultRoleScope-String-Context} + * + *+ * String myRoleDefinitionName = "cb15ef18-b32c-4224-b048-3a91cd68acc3"; + * Response<KeyVaultRoleDefinition> response = + * keyVaultAccessControlClient.getRoleDefinitionWithResponse(KeyVaultRoleScope.GLOBAL, myRoleDefinitionName, + * new Context("key1", "value1")); + * + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' and role name '%s'" + * + " was retrieved.%n", response.getStatusCode(), response.getValue().getName(), + * response.getValue().getRoleName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name of the {@link KeyVaultRoleDefinition role definition}. @@ -224,7 +316,15 @@ public Response
Code Samples
*Deletes a {@link KeyVaultRoleDefinition role definition}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.deleteRoleDefinition#KeyVaultRoleScope-String} + * + *+ * String roleDefinitionName = "6a709e6e-8964-4012-a99b-6b0131e8ce40"; + * + * keyVaultAccessControlClient.deleteRoleDefinition(KeyVaultRoleScope.GLOBAL, roleDefinitionName); + * + * System.out.printf("Deleted role definition with name '%s'.%n", roleDefinitionName); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * Managed HSM only supports '/'. @@ -245,7 +345,17 @@ public void deleteRoleDefinition(KeyVaultRoleScope roleScope, String roleDefinit *
Code Samples
*Deletes a {@link KeyVaultRoleDefinition role definition}. Prints out the details of the * {@link Response HTTP response}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.deleteRoleDefinitionWithResponse#KeyVaultRoleScope-String-Context} + * + *+ * String myRoleDefinitionName = "6b2d0b58-4108-44d6-b7e0-4fd02f77fe7e"; + * Response<Void> response = + * keyVaultAccessControlClient.deleteRoleDefinitionWithResponse(KeyVaultRoleScope.GLOBAL, myRoleDefinitionName, + * new Context("key1", "value1")); + * + * System.out.printf("Response successful with status code: %d. Role definition with name '%s' was deleted.%n", + * response.getStatusCode(), myRoleDefinitionName); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition role definition}. * @param roleDefinitionName The name of the {@link KeyVaultRoleDefinition role definition}. @@ -271,7 +381,15 @@ public Response
Code Samples
*Lists all {@link KeyVaultRoleAssignment role assignments}. Prints out the details of the retrieved * {@link KeyVaultRoleAssignment role assignments}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.listRoleAssignments#KeyVaultRoleScope} + * + *+ * PagedIterable<KeyVaultRoleAssignment> roleAssignments = + * keyVaultAccessControlClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL); + * + * roleAssignments.forEach(roleAssignment -> + * System.out.printf("Retrieved role assignment with name '%s'.%n", roleAssignment.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment role assignment}. * @@ -293,7 +411,15 @@ public PagedIterable
Code Samples
*Lists all {@link KeyVaultRoleAssignment role assignments}. Prints out the details of the retrieved * {@link KeyVaultRoleAssignment role assignments}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.listRoleAssignments#KeyVaultRoleScope-Context} + * + *+ * PagedIterable<KeyVaultRoleAssignment> keyVaultRoleAssignments = + * keyVaultAccessControlClient.listRoleAssignments(KeyVaultRoleScope.GLOBAL, new Context("key1", "value1")); + * + * keyVaultRoleAssignments.forEach(roleAssignment -> + * System.out.printf("Retrieved role assignment with name '%s'.%n", roleAssignment.getName())); + *+ * * * @param roleScope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. @@ -315,7 +441,18 @@ public PagedIterable
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment} with a randomly generated name. Prints out the * details of the created {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.createRoleAssignment#KeyVaultRoleScope-String-String} + * + *+ * String roleDefinitionId = "b0b43a39-920c-475b-b34c-32ecc2bbb0ea"; + * String servicePrincipalId = "169d6a86-61b3-4615-ac7e-2da09edfeed4"; + * KeyVaultRoleAssignment roleAssignment = + * keyVaultAccessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, roleDefinitionId, + * servicePrincipalId); + * + * System.out.printf("Created role assignment with randomly generated name '%s' for principal with id '%s'.%n", + * roleAssignment.getName(), roleAssignment.getProperties().getPrincipalId()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -342,7 +479,19 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, *
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment}. Prints out the details of the created * {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.createRoleAssignment#KeyVaultRoleScope-String-String-String} + * + *+ * String myRoleDefinitionId = "c7d4f70f-944d-494a-a73e-ff62fe7f04da"; + * String myServicePrincipalId = "4196fc8f-7312-46b9-9a08-05bf44fdff37"; + * String myRoleAssignmentName = "d80e9366-47a6-4f42-ba84-f2eefb084972"; + * KeyVaultRoleAssignment myRoleAssignment = + * keyVaultAccessControlClient.createRoleAssignment(KeyVaultRoleScope.GLOBAL, myRoleDefinitionId, + * myServicePrincipalId, myRoleAssignmentName); + * + * System.out.printf("Created role assignment with name '%s' for principal with id '%s'.%n", + * myRoleAssignment.getName(), myRoleAssignment.getProperties().getPrincipalId()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -371,7 +520,22 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope roleScope, *
Code Samples
*Creates a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response} and the created {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.createRoleAssignmentWithResponse#KeyVaultRoleScope-String-String-String-Context} + * + *+ * String someRoleDefinitionId = "11385c39-5efa-4e5f-8748-055aa51d4d23"; + * String someServicePrincipalId = "eab943f7-a204-4434-9681-ef2cc0c85b51"; + * String someRoleAssignmentName = "4d95e0ea-4808-43a4-b7f9-d9e61dba7ea9"; + * + * Response<KeyVaultRoleAssignment> response = + * keyVaultAccessControlClient.createRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, someRoleDefinitionId, + * someServicePrincipalId, someRoleAssignmentName, new Context("key1", "value1")); + * KeyVaultRoleAssignment createdRoleAssignment = response.getValue(); + * + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' for principal with" + * + "id '%s' was created.%n", response.getStatusCode(), createdRoleAssignment.getName(), + * createdRoleAssignment.getProperties().getPrincipalId()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment} * to create. @@ -406,7 +570,15 @@ public Response
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the retrieved * {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.getRoleAssignment#KeyVaultRoleScope-String} + * + *+ * String roleAssignmentName = "06d1ae8b-0791-4f02-b976-f631251f5a95"; + * KeyVaultRoleAssignment roleAssignment = + * keyVaultAccessControlClient.getRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); + * + * System.out.printf("Retrieved role assignment with name '%s'.%n", roleAssignment.getName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. @@ -429,7 +601,17 @@ public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope roleScope, Str *
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response} and the retrieved {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.getRoleAssignmentWithResponse#KeyVaultRoleScope-String-Context} + * + *+ * String myRoleAssignmentName = "b4a970d5-c581-4760-bba5-61d3d5aa24f9"; + * Response<KeyVaultRoleAssignment> response = + * keyVaultAccessControlClient.getRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, myRoleAssignmentName, + * new Context("key1", "value1")); + * + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' was retrieved.%n", + * response.getStatusCode(), response.getValue().getName()); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. @@ -453,7 +635,15 @@ public Response
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.deleteRoleAssignment#KeyVaultRoleScope-String} + * + *+ * String roleAssignmentName = "c3ed874a-64a9-4a87-8581-2a1ad84b9ddb"; + * + * keyVaultAccessControlClient.deleteRoleAssignment(KeyVaultRoleScope.GLOBAL, roleAssignmentName); + * + * System.out.printf("Deleted role assignment with name '%s'.%n", roleAssignmentName); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. @@ -473,7 +663,17 @@ public void deleteRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignm *
Code Samples
*Deletes a {@link KeyVaultRoleAssignment role assignment}. Prints out details of the * {@link Response HTTP response}.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.deleteRoleAssignmentWithResponse#KeyVaultRoleScope-String-Context} + * + *+ * String myRoleAssignmentName = "8ac293e1-1ac8-4a71-b254-7caf9f7c2646"; + * Response<Void> response = + * keyVaultAccessControlClient.deleteRoleAssignmentWithResponse(KeyVaultRoleScope.GLOBAL, myRoleAssignmentName, + * new Context("key1", "value1")); + * + * System.out.printf("Response successful with status code: %d. Role assignment with name '%s' was deleted.%n", + * response.getStatusCode(), myRoleAssignmentName); + *+ * * * @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment role assignment}. * @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment role assignment}. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java index cdd911a94263c..a62746bc8a289 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java @@ -43,9 +43,23 @@ * an {@link KeyVaultAccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}. * *
Samples to construct a sync client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlClient.instantiation} + * + *+ * KeyVaultAccessControlClient keyVaultAccessControlClient = new KeyVaultAccessControlClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildClient(); + *+ * *
Samples to construct an async client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultAccessControlAsyncClient.instantiation} + * + *+ * KeyVaultAccessControlAsyncClient keyVaultAccessControlAsyncClient = new KeyVaultAccessControlClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildAsyncClient(); + *+ * * * @see KeyVaultAccessControlClient * @see KeyVaultAccessControlAsyncClient diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java index 7a92b7357de9d..9a571cde4ecb2 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAdministrationServiceVersion.java @@ -9,7 +9,14 @@ * The versions of Azure Key Vault Administration service supported by this client library. */ public enum KeyVaultAdministrationServiceVersion implements ServiceVersion { + /** + * Service version {@code 7.2}. + */ V7_2("7.2"), + + /** + * Service version {@code 7.3-preview}. + */ V7_3_PREVIEW("7.3-preview"); private final String version; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java index 8e590f8e20610..6733da603051e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupAsyncClient.java @@ -57,7 +57,14 @@ * method on a {@link KeyVaultBackupClientBuilder} object. * *
Samples to construct an async client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupAsyncClient.instantiation} + * + *+ * KeyVaultBackupAsyncClient keyVaultBackupAsyncClient = new KeyVaultBackupClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildAsyncClient(); + *+ * * * @see KeyVaultBackupClientBuilder */ @@ -141,7 +148,23 @@ HttpPipeline getHttpPipeline() { *
Starts a {@link KeyVaultBackupOperation backup operation}, polls for its status and waits for it to complete. * Prints out the details of the operation's final result in case of success or prints out details of an error in * case the operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupAsyncClient.beginBackup#String-String} + * + *+ * 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"; + * + * client.beginBackup(blobStorageUrl, sasToken) + * .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. + * .doOnError(e -> System.out.printf("Backup failed with error: %s.%n", e.getMessage())) + * .doOnNext(pollResponse -> + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) + * .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) + * .flatMap(AsyncPollResponse::getFinalResult) + * .subscribe(folderUrl -> + * System.out.printf("Backup completed. The storage location of this backup is: %s.%n", folderUrl)); + *+ * * * @param blobStorageUrl The URL for the Blob Storage resource where the backup will be located. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. @@ -303,7 +326,22 @@ private static LongRunningOperationStatus toLongRunningOperationStatus(String op *
Code Samples
*Starts a {@link KeyVaultRestoreOperation restore operation}, polls for its status and waits for it to * complete. Prints out error details in case the operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupAsyncClient.beginRestore#String-String} + * + *+ * 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"; + * + * client.beginRestore(folderUrl, sasToken) + * .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. + * .doOnError(e -> System.out.printf("Restore failed with error: %s.%n", e.getMessage())) + * .doOnNext(pollResponse -> + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) + * .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) + * .flatMap(AsyncPollResponse::getFinalResult) + * .subscribe(unused -> System.out.printf("Backup restored successfully.%n")); + *+ * * * @param folderUrl The URL for the Blob Storage resource where the backup is located, including the path to * the blob container where the backup resides. This would be the exact value that is returned as the result of a @@ -449,7 +487,23 @@ private static Mono
Code Samples
*Starts a {@link KeyVaultSelectiveKeyRestoreOperation selective key restore operation}, polls for its status * and waits for it to complete. Prints out error details in case the operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupAsyncClient.beginSelectiveKeyRestore#String-String-String} + * + *+ * 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"; + * String keyName = "myKey"; + * + * client.beginSelectiveKeyRestore(folderUrl, sasToken, keyName) + * .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. + * .doOnError(e -> System.out.printf("Key restoration failed with error: %s.%n", e.getMessage())) + * .doOnNext(pollResponse -> + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) + * .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) + * .flatMap(AsyncPollResponse::getFinalResult) + * .subscribe(unused -> System.out.printf("Key restored successfully.%n")); + *+ * * * @param keyName The name of the key to be restored. * @param folderUrl The URL for the Blob Storage resource where the backup is located, including the path to diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java index 2c7fae0e6a2d0..c3020b71b2410 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClient.java @@ -22,7 +22,14 @@ * method on a {@link KeyVaultBackupClientBuilder} object. * *
Samples to construct a sync client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupClient.instantiation} + * + *+ * KeyVaultBackupClient keyVaultBackupClient = new KeyVaultBackupClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildClient(); + *+ * * * @see KeyVaultBackupClientBuilder */ @@ -55,7 +62,31 @@ public String getVaultUrl() { *
Starts a {@link KeyVaultBackupOperation backup operation}, polls for its status and waits for it to complete. * Prints out the details of the operation's final result in case of success or prints out error details in case the * operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupClient.beginBackup#String-String} + * + *+ * 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"; + * + * SyncPoller<KeyVaultBackupOperation, String> backupPoller = client.beginBackup(blobStorageUrl, sasToken); + * + * PollResponse<KeyVaultBackupOperation> pollResponse = backupPoller.poll(); + * + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus()); + * + * PollResponse<KeyVaultBackupOperation> finalPollResponse = backupPoller.waitForCompletion(); + * + * if (finalPollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + * String folderUrl = backupPoller.getFinalResult(); + * + * System.out.printf("Backup completed. The storage location of this backup is: %s.%n", folderUrl); + * } else { + * KeyVaultBackupOperation operation = backupPoller.poll().getValue(); + * + * System.out.printf("Backup failed with error: %s.%n", operation.getError().getMessage()); + * } + *+ * * * @param blobStorageUrl The URL for the Blob Storage resource where the backup will be located. * @param sasToken A Shared Access Signature (SAS) token to authorize access to the blob. @@ -76,7 +107,31 @@ public SyncPoller
Code Samples
*Starts a {@link KeyVaultRestoreOperation restore operation}, polls for its status and waits for it to * complete. Prints out error details in case the operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupClient.beginBackup#String-String} + * + *+ * 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"; + * + * SyncPoller<KeyVaultBackupOperation, String> backupPoller = client.beginBackup(blobStorageUrl, sasToken); + * + * PollResponse<KeyVaultBackupOperation> pollResponse = backupPoller.poll(); + * + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus()); + * + * PollResponse<KeyVaultBackupOperation> finalPollResponse = backupPoller.waitForCompletion(); + * + * if (finalPollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + * String folderUrl = backupPoller.getFinalResult(); + * + * System.out.printf("Backup completed. The storage location of this backup is: %s.%n", folderUrl); + * } else { + * KeyVaultBackupOperation operation = backupPoller.poll().getValue(); + * + * System.out.printf("Backup failed with error: %s.%n", operation.getError().getMessage()); + * } + *+ * * * @param folderUrl The URL for the Blob Storage resource where the backup is located, including the path to * the blob container where the backup resides. This would be the exact value that is returned as the result of a @@ -101,7 +156,31 @@ public SyncPoller
Code Samples
*Starts a {@link KeyVaultSelectiveKeyRestoreOperation selective key restore operation}, polls for its status * and waits for it to complete. Prints out error details in case the operation fails.
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupClient.beginSelectiveKeyRestore#String-String-String} + * + *+ * 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"; + * String keyName = "myKey"; + * + * SyncPoller<KeyVaultSelectiveKeyRestoreOperation, KeyVaultSelectiveKeyRestoreResult> backupPoller = + * client.beginSelectiveKeyRestore(folderUrl, sasToken, keyName); + * + * PollResponse<KeyVaultSelectiveKeyRestoreOperation> pollResponse = backupPoller.poll(); + * + * System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus()); + * + * PollResponse<KeyVaultSelectiveKeyRestoreOperation> finalPollResponse = backupPoller.waitForCompletion(); + * + * if (finalPollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + * System.out.printf("Key restored successfully.%n"); + * } else { + * KeyVaultSelectiveKeyRestoreOperation operation = backupPoller.poll().getValue(); + * + * System.out.printf("Key restore failed with error: %s.%n", operation.getError().getMessage()); + * } + *+ * * * @param keyName The name of the key to be restored. * @param folderUrl The URL for the Blob Storage resource where the backup is located, including the path to diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java index 5ff890f1111e0..428fbe8374fde 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultBackupClientBuilder.java @@ -42,9 +42,23 @@ * an {@link KeyVaultBackupAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}. * *
Samples to construct a sync client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupClient.instantiation} + * + *+ * KeyVaultBackupClient keyVaultBackupClient = new KeyVaultBackupClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildClient(); + *+ * *
Samples to construct an async client
- * {@codesnippet com.azure.security.keyvault.administration.keyVaultBackupAsyncClient.instantiation} + * + *+ * KeyVaultBackupAsyncClient keyVaultBackupAsyncClient = new KeyVaultBackupClientBuilder() + * .vaultUrl("https://myaccount.managedhsm.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .buildAsyncClient(); + *+ * * * @see KeyVaultBackupClient * @see KeyVaultBackupAsyncClient diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java index 6bd6295819ee2..2d9a9b61364f8 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java @@ -12,7 +12,14 @@ * A class that defines the scope of a role. */ public final class KeyVaultRoleScope extends ExpandableStringEnum
Samples to construct the async client
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation} + * + *+ * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() + * .credential(new DefaultAzureCredentialBuilder().build()) + * .vaultUrl("https://myvault.vault.azure.net/") + * .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + * .buildAsyncClient(); + *+ * * * @see CertificateClientBuilder * @see PagedFlux @@ -132,7 +140,20 @@ Duration getDefaultPollingInterval() { *
Create certificate is a long running operation. The {@link PollerFlux poller} allows users to automatically poll on the create certificate * operation status. It is possible to monitor each intermediate poll response during the poll operation.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map} + * + *+ * CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); + * Map<String, String> tags = new HashMap<>(); + * tags.put("foo", "bar"); + * certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) + * .subscribe(pollResponse -> { + * System.out.println("---------------------------------------------------------------------------------"); + * System.out.println(pollResponse.getStatus()); + * System.out.println(pollResponse.getValue().getStatus()); + * System.out.println(pollResponse.getValue().getStatusDetails()); + * }); + *+ * * * @param certificateName The name of the certificate to be created. * @param policy The policy of the certificate to be created. @@ -185,7 +206,18 @@ Mono
Create certificate is a long running operation. The {@link PollerFlux poller} allows users to automatically poll on the create certificate * operation status. It is possible to monitor each intermediate poll response during the poll operation.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy} + * + *+ * CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); + * certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy) + * .subscribe(pollResponse -> { + * System.out.println("---------------------------------------------------------------------------------"); + * System.out.println(pollResponse.getStatus()); + * System.out.println(pollResponse.getValue().getStatus()); + * System.out.println(pollResponse.getValue().getStatusDetails()); + * }); + *+ * * * @param certificateName The name of the certificate to be created. * @param policy The policy of the certificate to be created. @@ -252,7 +284,17 @@ Mono
Get a pending certificate operation. The {@link PollerFlux poller} allows users to automatically poll on the certificate * operation status. It is possible to monitor each intermediate poll response during the poll operation.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateOperation#String} + * + *+ * certificateAsyncClient.getCertificateOperation("certificateName") + * .subscribe(pollResponse -> { + * System.out.println("---------------------------------------------------------------------------------"); + * System.out.println(pollResponse.getStatus()); + * System.out.println(pollResponse.getValue().getStatus()); + * System.out.println(pollResponse.getValue().getStatusDetails()); + * }); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} doesn't exist. @@ -274,7 +316,15 @@ public PollerFlux
Gets a specific version of the certificate in the key vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificate#String} + * + *+ * certificateAsyncClient.getCertificate("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponse -> + * System.out.printf("Certificate is returned with name %s and secretId %s %n", + * certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -298,7 +348,16 @@ public Mono
Gets a specific version of the certificate in the key vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateWithResponse#String} + * + *+ * certificateAsyncClient.getCertificateWithResponse("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponse -> + * System.out.printf("Certificate is returned with name %s and secretId %s %n", + * certificateResponse.getValue().getProperties().getName(), + * certificateResponse.getValue().getSecretId())); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -340,7 +399,17 @@ Mono
Gets a specific version of the certificate in the key vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersionWithResponse#string-string} + * + *+ * String certificateVersion = "6A385B124DEF4096AF1361A85B16C204"; + * certificateAsyncClient.getCertificateVersionWithResponse("certificateName", certificateVersion) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateWithVersion -> + * System.out.printf("Certificate is returned with name %s and secretId %s %n", + * certificateWithVersion.getValue().getProperties().getName(), + * certificateWithVersion.getValue().getSecretId())); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved. @@ -365,7 +434,15 @@ public Mono
Gets a specific version of the certificate in the key vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersion#String-String} + * + *+ * certificateAsyncClient.getCertificateVersion("certificateName", certificateVersion) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateWithVersion -> + * System.out.printf("Certificate is returned with name %s and secretId %s %n", + * certificateWithVersion.getProperties().getName(), certificateWithVersion.getSecretId())); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved. @@ -391,7 +468,21 @@ public Mono
Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificateProperties#CertificateProperties} + * + *+ * certificateAsyncClient.getCertificate("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponseValue -> { + * KeyVaultCertificate certificate = certificateResponseValue; + * //Update enabled status of the certificate + * certificate.getProperties().setEnabled(false); + * certificateAsyncClient.updateCertificateProperties(certificate.getProperties()) + * .subscribe(certificateResponse -> + * System.out.printf("Certificate's enabled status %s %n", + * certificateResponse.getProperties().isEnabled().toString())); + * }); + *+ * * * @param properties The {@link CertificateProperties} object with updated properties. * @throws NullPointerException if {@code certificate} is {@code null}. @@ -416,7 +507,21 @@ public Mono
Gets latest version of the certificate, changes its enabled status and then updates it in the Azure Key Vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePropertiesWithResponse#CertificateProperties} + * + *+ * certificateAsyncClient.getCertificate("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponseValue -> { + * KeyVaultCertificate certificate = certificateResponseValue; + * //Update the enabled status of the certificate. + * certificate.getProperties().setEnabled(false); + * certificateAsyncClient.updateCertificatePropertiesWithResponse(certificate.getProperties()) + * .subscribe(certificateResponse -> + * System.out.printf("Certificate's enabled status %s %n", + * certificateResponse.getValue().getProperties().isEnabled().toString())); + * }); + *+ * * * @param properties The {@link CertificateProperties} object with updated properties. * @throws NullPointerException if {@code properties} is {@code null}. @@ -457,7 +562,16 @@ Mono
Code Samples
*Deletes the certificate in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.beginDeleteCertificate#String} + * + *+ * certificateAsyncClient.beginDeleteCertificate("certificateName") + * .subscribe(pollResponse -> { + * System.out.println("Delete Status: " + pollResponse.getStatus().toString()); + * System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); + * System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); + * }); + *+ * * * @param certificateName The name of the certificate to be deleted. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -519,7 +633,14 @@ Mono
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificate#string} + * + *+ * certificateAsyncClient.getDeletedCertificate("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedSecretResponse -> + * System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.getRecoveryId())); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -545,7 +666,15 @@ public Mono
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificateWithResponse#string} + * + *+ * certificateAsyncClient.getDeletedCertificateWithResponse("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedSecretResponse -> + * System.out.printf("Deleted Certificate's Recovery Id %s %n", + * deletedSecretResponse.getValue().getRecoveryId())); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -579,7 +708,14 @@ Mono
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the * status code from the server response when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificateWithResponse#string} + * + *+ * certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(purgeResponse -> + * System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -603,7 +739,14 @@ public Mono
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the * status code from the server response when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificateWithResponse#string} + * + *+ * certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(purgeResponse -> + * System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -638,7 +781,16 @@ Mono
Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the * recovered certificate details when a response has been received.
* - * {@codesnippet com.azure.security.certificatevault.certificates.CertificateAsyncClient.beginRecoverDeletedCertificate#String} + * + *+ * certificateAsyncClient.beginRecoverDeletedCertificate("deletedCertificateName") + * .subscribe(pollResponse -> { + * System.out.println("Recovery Status: " + pollResponse.getStatus().toString()); + * System.out.println("Recover Certificate Name: " + pollResponse.getValue().getName()); + * System.out.println("Recover Certificate Id: " + pollResponse.getValue().getId()); + * }); + *+ * * * @param certificateName The name of the deleted certificate to be recovered. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the certificate vault. @@ -701,7 +853,14 @@ Mono
Backs up the certificate from the key vault. Prints out the * length of the certificate's backup byte array returned in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificate#string} + * + *+ * certificateAsyncClient.backupCertificate("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateBackupResponse -> + * System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length)); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -725,7 +884,15 @@ public Mono
Backs up the certificate from the key vault. Prints out the * length of the certificate's backup byte array returned in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificateWithResponse#string} + * + *+ * certificateAsyncClient.backupCertificateWithResponse("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateBackupResponse -> + * System.out.printf("Certificate's Backup Byte array's length %s %n", + * certificateBackupResponse.getValue().length)); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -761,7 +928,15 @@ Mono
Restores the certificate in the key vault from its backup. Prints out the restored certificate * details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificate#byte} + * + *+ * byte[] certificateBackupByteArray = {}; + * certificateAsyncClient.restoreCertificateBackup(certificateBackupByteArray) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", + * certificateResponse.getProperties().getName(), certificateResponse.getKeyId())); + *+ * * * @param backup The backup blob associated with the certificate. * @throws ResourceModifiedException when {@code backup} blob is malformed. @@ -784,7 +959,15 @@ public Mono
Restores the certificate in the key vault from its backup. Prints out the restored certificate * details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificateWithResponse#byte} + * + *+ * byte[] certificateBackup = {}; + * certificateAsyncClient.restoreCertificateBackup(certificateBackup) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", + * certificateResponse.getProperties().getName(), certificateResponse.getKeyId())); + *+ * * * @param backup The backup blob associated with the certificate. * @throws ResourceModifiedException when {@code backup} blob is malformed. @@ -819,7 +1002,16 @@ Mono
It is possible to get certificates with all the properties excluding the policy from this information. Convert the {@link Flux} containing {@link CertificateProperties} to * {@link Flux} containing {@link KeyVaultCertificate certificate} using {@link CertificateAsyncClient#getCertificateVersion(String, String)} within {@link Flux#flatMap(Function)}.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificates} + * + *+ * certificateAsyncClient.listPropertiesOfCertificates() + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), + * certificate.getVersion()) + * .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", + * certificateResponse.getName(), certificateResponse.getKeyId()))); + *+ * * * @param includePending indicate if pending certificates should be included in the results. * @return A {@link PagedFlux} containing {@link CertificateProperties certificate} for all the certificates in the vault. @@ -845,7 +1037,16 @@ public PagedFlux
It is possible to get certificates with all the properties excluding the policy from this information. Convert the {@link Flux} containing {@link CertificateProperties} to * {@link Flux} containing {@link KeyVaultCertificate certificate} using {@link CertificateAsyncClient#getCertificateVersion(String, String)} within {@link Flux#flatMap(Function)}.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificates} + * + *+ * certificateAsyncClient.listPropertiesOfCertificates() + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), + * certificate.getVersion()) + * .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", + * certificateResponse.getName(), certificateResponse.getKeyId()))); + *+ * * * @return A {@link PagedFlux} containing {@link CertificateProperties certificate} for all the certificates in the vault. */ @@ -912,7 +1113,14 @@ private Mono
Lists the deleted certificates in the key vault. Prints out the * recovery id of each deleted certificate when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listDeletedCertificates} + * + *+ * certificateAsyncClient.listDeletedCertificates() + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", + * deletedCertificateResponse.getRecoveryId())); + *+ * * * @return A {@link PagedFlux} containing all of the {@link DeletedCertificate deleted certificates} in the vault. */ @@ -939,7 +1147,14 @@ public PagedFlux
Lists the deleted certificates in the key vault. Prints out the * recovery id of each deleted certificate when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listDeletedCertificates} + * + *+ * certificateAsyncClient.listDeletedCertificates() + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", + * deletedCertificateResponse.getRecoveryId())); + *+ * * * @param includePending indicate if pending deleted certificates should be included in the results. * @return A {@link PagedFlux} containing all of the {@link DeletedCertificate deleted certificates} in the vault. @@ -1008,7 +1223,16 @@ private Mono
+ * certificateAsyncClient.listPropertiesOfCertificateVersions("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), + * certificate.getVersion()) + * .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", + * certificateResponse.getProperties().getName(), certificateResponse.getKeyId()))); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -1067,7 +1291,16 @@ private Mono
Code Samples
*Merges a certificate with a kay pair available in the service.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificate#config} + * + *+ * List<byte[]> x509CertificatesToMerge = new ArrayList<>(); + * MergeCertificateOptions config = + * new MergeCertificateOptions("certificateName", x509CertificatesToMerge).setEnabled(false); + * certificateAsyncClient.mergeCertificate(config) + * .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", + * certificate.getProperties().getName(), certificate.getKeyId())); + *+ * * * @param mergeCertificateOptions the merge certificate options holding the x509 certificates. * @@ -1091,7 +1324,16 @@ public Mono
Code Samples
*Merges a certificate with a kay pair available in the service.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificateWithResponse#config} + * + *+ * List<byte[]> x509CertsToMerge = new ArrayList<>(); + * MergeCertificateOptions mergeConfig = + * new MergeCertificateOptions("certificateName", x509CertsToMerge).setEnabled(false); + * certificateAsyncClient.mergeCertificateWithResponse(mergeConfig) + * .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", + * certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId())); + *+ * * * @param mergeCertificateOptions the merge certificate options holding the x509 certificates. * @@ -1128,7 +1370,15 @@ Mono
Gets the policy of a certirifcate in the key vault. Prints out the * returned certificate policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicy#string} + * + *+ * certificateAsyncClient.getCertificatePolicy("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(policy -> + * System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", + * policy.getIssuerName(), policy.getSubject())); + *+ * * * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -1151,7 +1401,15 @@ public Mono
Gets the policy of a certirifcate in the key vault. Prints out the * returned certificate policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicyWithResponse#string} + * + *+ * certificateAsyncClient.getCertificatePolicyWithResponse("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(policyResponse -> + * System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", + * policyResponse.getValue().getIssuerName(), policyResponse.getValue().getSubject())); + *+ * * * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -1184,7 +1442,21 @@ Mono
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the * returned policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicy#string} + * + *+ * certificateAsyncClient.getCertificatePolicy("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificatePolicyResponseValue -> { + * CertificatePolicy certificatePolicy = certificatePolicyResponseValue; + * // Update transparency + * certificatePolicy.setCertificateTransparent(true); + * certificateAsyncClient.updateCertificatePolicy("certificateName", certificatePolicy) + * .subscribe(updatedPolicy -> + * System.out.printf("Certificate policy's updated transparency status %s %n", + * updatedPolicy.isCertificateTransparent())); + * }); + *+ * * * @param certificateName The name of the certificate whose policy is to be updated. * @param policy The certificate policy to be updated. @@ -1210,7 +1482,22 @@ public Mono
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the * returned policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicyWithResponse#string} + * + *+ * certificateAsyncClient.getCertificatePolicy("certificateName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(certificatePolicyResponseValue -> { + * CertificatePolicy certificatePolicy = certificatePolicyResponseValue; + * // Update transparency + * certificatePolicy.setCertificateTransparent(true); + * certificateAsyncClient.updateCertificatePolicyWithResponse("certificateName", + * certificatePolicy) + * .subscribe(updatedPolicyResponse -> + * System.out.printf("Certificate policy's updated transparency status %s %n", + * updatedPolicyResponse.getValue().isCertificateTransparent())); + * }); + *+ * * * @param certificateName The name of the certificate whose policy is to be updated. * @param policy The certificate policy is to be updated. @@ -1246,7 +1533,19 @@ Mono
Creates a new certificate issuer in the key vault. Prints out the created certificate * issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuer#CertificateIssuer} + * + *+ * CertificateIssuer issuer = new CertificateIssuer("issuerName", "providerName") + * .setAccountId("keyvaultuser") + * .setPassword("temp2"); + * certificateAsyncClient.createIssuer(issuer) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerResponse -> { + * System.out.printf("Issuer created with %s and %s", issuerResponse.getName(), + * issuerResponse.getProvider()); + * }); + *+ * * * @param issuer The configuration of the certificate issuer to be created. * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. @@ -1271,7 +1570,19 @@ public Mono
Creates a new certificate issuer in the key vault. Prints out the created certificate * issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuerWithResponse#CertificateIssuer} + * + *+ * CertificateIssuer newIssuer = new CertificateIssuer("issuerName", "providerName") + * .setAccountId("keyvaultuser") + * .setPassword("temp2"); + * certificateAsyncClient.createIssuerWithResponse(newIssuer) + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerResponse -> { + * System.out.printf("Issuer created with %s and %s", issuerResponse.getValue().getName(), + * issuerResponse.getValue().getProvider()); + * }); + *+ * * * @param issuer The configuration of the certificate issuer to be created. Use * {@link CertificateIssuer#CertificateIssuer(String, String)} to initialize the issuer object @@ -1309,7 +1620,16 @@ Mono
Gets the specificed certifcate issuer in the key vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuerWithResponse#string} + * + *+ * certificateAsyncClient.getIssuerWithResponse("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerResponse -> { + * System.out.printf("Issuer returned with %s and %s", issuerResponse.getValue().getName(), + * issuerResponse.getValue().getProvider()); + * }); + *+ * * * @param issuerName The name of the certificate issuer to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -1332,7 +1652,16 @@ public Mono
Gets the specified certificate issuer in the key vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuer#string} + * + *+ * certificateAsyncClient.getIssuer("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuer -> { + * System.out.printf("Issuer returned with %s and %s", issuer.getName(), + * issuer.getProvider()); + * }); + *+ * * * @param issuerName The name of the certificate to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -1366,7 +1695,14 @@ Mono
Deletes the certificate issuer in the Azure Key Vault. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuerWithResponse#string} + * + *+ * certificateAsyncClient.deleteIssuerWithResponse("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedIssuerResponse -> + * System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getValue().getName())); + *+ * * * @param issuerName The name of the certificate issuer to be deleted. * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -1390,7 +1726,14 @@ public Mono
Deletes the certificate issuer in the Azure Key Vault. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuer#string} + * + *+ * certificateAsyncClient.deleteIssuer("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(deletedIssuerResponse -> + * System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getName())); + *+ * * * @param issuerName The name of the certificate issuer to be deleted. * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -1425,7 +1768,15 @@ Mono
It is possible to get the certificate issuer with all of its properties from this information. Convert the {@link PagedFlux} * containing {@link IssuerProperties issuerProperties} to {@link PagedFlux} containing {@link CertificateIssuer issuer} using * {@link CertificateAsyncClient#getIssuer(String)} - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listPropertiesOfIssuers} + * + *
+ * certificateAsyncClient.listPropertiesOfIssuers() + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerProperties -> certificateAsyncClient.getIssuer(issuerProperties.getName()) + * .subscribe(issuerResponse -> System.out.printf("Received issuer with name %s and provider %s", + * issuerResponse.getName(), issuerResponse.getProvider()))); + *+ * * * @return A {@link PagedFlux} containing all of the {@link IssuerProperties certificate issuers} in the vault. */ @@ -1486,7 +1837,21 @@ private Mono
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuer#CertificateIssuer} + * + *+ * certificateAsyncClient.getIssuer("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerResponseValue -> { + * CertificateIssuer issuer = issuerResponseValue; + * //Update the enabled status of the issuer. + * issuer.setEnabled(false); + * certificateAsyncClient.updateIssuer(issuer) + * .subscribe(issuerResponse -> + * System.out.printf("Issuer's enabled status %s %n", + * issuerResponse.isEnabled().toString())); + * }); + *+ * * * @param issuer The {@link CertificateIssuer issuer} with updated properties. Use * {@link CertificateIssuer#CertificateIssuer(String)} to initialize the issuer object @@ -1513,7 +1878,21 @@ public Mono
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuer#CertificateIssuer} + * + *+ * certificateAsyncClient.getIssuer("issuerName") + * .subscriberContext(Context.of(key1, value1, key2, value2)) + * .subscribe(issuerResponseValue -> { + * CertificateIssuer issuer = issuerResponseValue; + * //Update the enabled status of the issuer. + * issuer.setEnabled(false); + * certificateAsyncClient.updateIssuer(issuer) + * .subscribe(issuerResponse -> + * System.out.printf("Issuer's enabled status %s %n", + * issuerResponse.isEnabled().toString())); + * }); + *+ * * * @param issuer The {@link CertificateIssuer issuer} with updated properties. * @throws NullPointerException if {@code issuer} is {@code null}. @@ -1552,7 +1931,14 @@ Mono
Sets the certificate contacts in the Azure Key Vault. Prints out the * returned contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.setContacts#contacts} + * + *+ * CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); + * certificateAsyncClient.setContacts(Collections.singletonList(contactToAdd)).subscribe(contact -> + * System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) + * ); + *+ * * * @param contacts The list of contacts to set on the vault. * @throws HttpResponseException when a contact information provided is invalid/incomplete. @@ -1589,7 +1975,13 @@ private Mono
Lists the certificate contacts in the Azure Key Vault. Prints out the * returned contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.listContacts} + * + *+ * certificateAsyncClient.listContacts().subscribe(contact -> + * System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) + * ); + *+ * * * @return A {@link PagedFlux} containing all of the {@link CertificateContact certificate contacts} in the vault. */ @@ -1627,7 +2019,13 @@ private Mono
Deletes the certificate contacts in the Azure Key Vault. Prints out the * deleted contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteContacts} + * + *+ * certificateAsyncClient.deleteContacts().subscribe(contact -> + * System.out.printf("Deleted Contact name %s and email %s", contact.getName(), contact.getEmail()) + * ); + *+ * * * @return A {@link PagedFlux} containing all of the {@link CertificateContact deleted certificate contacts} in the vault. */ @@ -1662,7 +2060,13 @@ private Mono
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Prints out the * deleted certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperation#string} + * + *+ * certificateAsyncClient.deleteCertificateOperation("certificateName") + * .subscribe(certificateOperation -> System.out.printf("Deleted Certificate operation last status %s", + * certificateOperation.getStatus())); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} doesn't exist in the key vault. @@ -1686,7 +2090,13 @@ public Mono
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Prints out the * deleted certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperationWithResponse#string} + * + *+ * certificateAsyncClient.deleteCertificateOperationWithResponse("certificateName") + * .subscribe(certificateOperationResponse -> System.out.printf("Deleted Certificate operation's last" + * + " status %s", certificateOperationResponse.getValue().getStatus())); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} doesn't exist in the key vault. @@ -1728,7 +2138,13 @@ Mono
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Prints out the * updated certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperation#string} + * + *+ * certificateAsyncClient.cancelCertificateOperation("certificateName") + * .subscribe(certificateOperation -> System.out.printf("Certificate operation status %s", + * certificateOperation.getStatus())); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist in the key vault. @@ -1751,7 +2167,13 @@ public Mono
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Prints out the * updated certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperationWithResponse#string} + * + *+ * certificateAsyncClient.cancelCertificateOperationWithResponse("certificateName") + * .subscribe(certificateOperationResponse -> System.out.printf("Certificate operation status %s", + * certificateOperationResponse.getValue().getStatus())); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist in the key vault. @@ -1776,7 +2198,16 @@ public Mono
Code Samples
*Imports a certificate into the key vault.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificate#options} + * + *+ * byte[] certificateToImport = new byte[100]; + * ImportCertificateOptions config = + * new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); + * certificateAsyncClient.importCertificate(config) + * .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", + * certificate.getProperties().getName(), certificate.getKeyId())); + *+ * * * @param importCertificateOptions The details of the certificate to import to the key vault * @throws HttpResponseException when the {@code importCertificateOptions} are invalid. @@ -1798,7 +2229,16 @@ public Mono
Code Samples
*Imports a certificate into the key vault.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificateWithResponse#options} + * + *+ * byte[] certToImport = new byte[100]; + * ImportCertificateOptions importCertificateOptions = + * new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); + * certificateAsyncClient.importCertificateWithResponse(importCertificateOptions) + * .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", + * certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId())); + *+ * * * @param importCertificateOptions The details of the certificate to import to the key vault * @throws HttpResponseException when the {@code importCertificateOptions} are invalid. diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java index 713f1896de322..ef516cd2985ea 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java @@ -43,7 +43,15 @@ * *
Samples to construct the sync client
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.instantiation} + * + *+ * CertificateClient certificateClient = new CertificateClientBuilder() + * .credential(new DefaultAzureCredentialBuilder().build()) + * .vaultUrl("https://myvault.vault.azure.net/") + * .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + * .buildClient(); + *+ * * * @see CertificateClientBuilder * @see PagedIterable @@ -79,7 +87,17 @@ public String getVaultUrl() { *
Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to complete and * returns its last status. The details of the last certificate operation status are printed when a response is received
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map} + * + *+ * CertificatePolicy certificatePolicyPkcsSelf = new CertificatePolicy("Self", + * "CN=SelfSignedJavaPkcs12"); + * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certificateSyncPoller = certificateClient + * .beginCreateCertificate("certificateName", certificatePolicyPkcsSelf, true, new HashMap<>()); + * certificateSyncPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); + * KeyVaultCertificate createdCertificate = certificateSyncPoller.getFinalResult(); + * System.out.printf("Certificate created with name %s%n", createdCertificate.getName()); + *+ * * * @param certificateName The name of the certificate to be created. * @param policy The policy of the certificate to be created. @@ -103,7 +121,17 @@ public SyncPoller
Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to complete and * returns its last status. The details of the last certificate operation status are printed when a response is received
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy} + * + *+ * CertificatePolicy certPolicy = new CertificatePolicy("Self", + * "CN=SelfSignedJavaPkcs12"); + * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = certificateClient + * .beginCreateCertificate("certificateName", certPolicy); + * certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); + * KeyVaultCertificate cert = certPoller.getFinalResult(); + * System.out.printf("Certificate created with name %s%n", cert.getName()); + *+ * * * @param certificateName The name of the certificate to be created. * @param policy The policy of the certificate to be created. @@ -122,7 +150,15 @@ public SyncPoller
Geta a pending certificate operation. The {@link SyncPoller poller} allows users to automatically poll on the certificate * operation status.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificateOperation#String} + * + *+ * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> getCertPoller = certificateClient + * .getCertificateOperation("certificateName"); + * getCertPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); + * KeyVaultCertificate cert = getCertPoller.getFinalResult(); + * System.out.printf("Certificate created with name %s%n", cert.getName()); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} doesn't exist. @@ -138,7 +174,14 @@ public SyncPoller
Code Samples
*Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificate#String} + * + *+ * KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("certificateName"); + * System.out.printf("Received certificate with name %s and version %s and secret id %s%n", + * certificate.getProperties().getName(), + * certificate.getProperties().getVersion(), certificate.getSecretId()); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -156,7 +199,15 @@ public KeyVaultCertificateWithPolicy getCertificate(String certificateName) { *
Code Samples
*Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificateWithResponse#String-Context} + * + *+ * Response<KeyVaultCertificateWithPolicy> certificateWithResponse = certificateClient + * .getCertificateWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Received certificate with name %s and version %s and secret id %s%n", + * certificateWithResponse.getValue().getProperties().getName(), + * certificateWithResponse.getValue().getProperties().getVersion(), certificate.getSecretId()); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @param context Additional context that is passed through the Http pipeline during the service call. @@ -175,7 +226,17 @@ public Response
Code Samples
*Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersionWithResponse#String-String-Context} + * + *+ * Response<KeyVaultCertificate> returnedCertificateWithResponse = certificateClient + * .getCertificateVersionWithResponse("certificateName", "certificateVersion", + * new Context(key1, value1)); + * System.out.printf("Received certificate with name %s and version %s and secret id %s%n", + * returnedCertificateWithResponse.getValue().getProperties().getName(), + * returnedCertificateWithResponse.getValue().getProperties().getVersion(), + * returnedCertificateWithResponse.getValue().getSecretId()); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved. @@ -195,7 +256,15 @@ public Response
Code Samples
*Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersion#String-String} + * + *+ * KeyVaultCertificate returnedCertificate = certificateClient.getCertificateVersion("certificateName", + * "certificateVersion"); + * System.out.printf("Received certificate with name %s and version %s and secret id %s%n", + * returnedCertificate.getProperties().getName(), returnedCertificate.getProperties().getVersion(), + * returnedCertificate.getSecretId()); + *+ * * * @param certificateName The name of the certificate to retrieve, cannot be null * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved. @@ -216,7 +285,16 @@ public KeyVaultCertificate getCertificateVersion(String certificateName, String *
Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateCertificateProperties#CertificateProperties} + * + *+ * KeyVaultCertificate certificate = certificateClient.getCertificate("certificateName"); + * // Update certificate enabled status + * certificate.getProperties().setEnabled(false); + * KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); + * System.out.printf("Updated Certificate with name %s and enabled status %s%n", + * updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled()); + *+ * * * @param properties The {@link CertificateProperties} object with updated properties. * @throws NullPointerException if {@code certificate} is {@code null}. @@ -237,7 +315,18 @@ public KeyVaultCertificate updateCertificateProperties(CertificateProperties pro *
Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the * returned certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePropertiesWithResponse#CertificateProperties-Context} + * + *+ * KeyVaultCertificate certificateToUpdate = certificateClient.getCertificate("certificateName"); + * // Update certificate enabled status + * certificateToUpdate.getProperties().setEnabled(false); + * Response<KeyVaultCertificate> updatedCertificateResponse = certificateClient. + * updateCertificatePropertiesWithResponse(certificateToUpdate.getProperties(), new Context(key1, value1)); + * System.out.printf("Updated Certificate with name %s and enabled status %s%n", + * updatedCertificateResponse.getValue().getProperties().getName(), + * updatedCertificateResponse.getValue().getProperties().isEnabled()); + *+ * * * @param properties The {@link CertificateProperties} object with updated properties. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -261,7 +350,17 @@ public Response
Deletes the certificate in the Azure Key Vault. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.beginDeleteCertificate#String} + * + *+ * SyncPoller<DeletedCertificate, Void> deleteCertPoller = + * certificateClient.beginDeleteCertificate("certificateName"); + * // Deleted Certificate is accessible as soon as polling beings. + * PollResponse<DeletedCertificate> deleteCertPollResponse = deleteCertPoller.poll(); + * System.out.printf("Deleted certificate with name %s and recovery id %s%n", + * deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId()); + * deleteCertPoller.waitForCompletion(); + *+ * * * @param certificateName The name of the certificate to be deleted. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -282,7 +381,13 @@ public SyncPoller
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificate#string} + * + *+ * DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate("certificateName"); + * System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificate.getName(), + * deletedCertificate.getRecoveryId()); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -303,7 +408,15 @@ public DeletedCertificate getDeletedCertificate(String certificateName) { *
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificateWithResponse#String-Context} + * + *+ * Response<DeletedCertificate> deletedCertificateWithResponse = certificateClient + * .getDeletedCertificateWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Deleted certificate with name %s and recovery id %s%n", + * deletedCertificateWithResponse.getValue().getName(), + * deletedCertificateWithResponse.getValue().getRecoveryId()); + *+ * * * @param certificateName The name of the deleted certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -324,7 +437,11 @@ public Response
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the * status code from the server response when a response has been received.
- * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificate#string} + * + *+ * certificateClient.purgeDeletedCertificate("certificateName"); + *+ * * * @param certificateName The name of the deleted certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -343,7 +460,13 @@ public void purgeDeletedCertificate(String certificateName) { *
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the * status code from the server response when a response has been received.
- * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificateWithResponse#string-Context} + * + *+ * Response<Void> purgeResponse = certificateClient.purgeDeletedCertificateWithResponse("certificateName", + * new Context(key1, value1)); + * System.out.printf("Purged Deleted certificate with status %d%n", purgeResponse.getStatusCode()); + *+ * * * @param certificateName The name of the deleted certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -365,7 +488,18 @@ public Response
Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the * recovered certificate details when a response has been received.
- * {@codesnippet com.azure.security.certificatevault.certificates.CertificateClient.beginRecoverDeletedCertificate#String} + * + *+ * SyncPoller<KeyVaultCertificateWithPolicy, Void> recoverDeletedCertPoller = certificateClient + * .beginRecoverDeletedCertificate("deletedCertificateName"); + * // Recovered certificate is accessible as soon as polling beings + * PollResponse<KeyVaultCertificateWithPolicy> recoverDeletedCertPollResponse = recoverDeletedCertPoller.poll(); + * System.out.printf(" Recovered Deleted certificate with name %s and id %s%n", + * recoverDeletedCertPollResponse.getValue().getProperties().getName(), + * recoverDeletedCertPollResponse.getValue().getProperties().getId()); + * recoverDeletedCertPoller.waitForCompletion(); + *+ * * * @param certificateName The name of the deleted certificate to be recovered. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the certificate vault. @@ -385,7 +519,12 @@ public SyncPoller
Backs up the certificate from the key vault. Prints out the * length of the certificate's backup byte array returned in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.backupCertificate#string} + * + *+ * byte[] certificateBackup = certificateClient.backupCertificate("certificateName"); + * System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackup.length); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -405,7 +544,14 @@ public byte[] backupCertificate(String certificateName) { *
Backs up the certificate from the key vault. Prints out the * length of the certificate's backup byte array returned in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.backupCertificateWithResponse#String-Context} + * + *+ * Response<byte[]> certificateBackupWithResponse = certificateClient + * .backupCertificateWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Backed up certificate with back up blob length %d%n", + * certificateBackupWithResponse.getValue().length); + *+ * * * @param certificateName The certificateName of the certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -426,7 +572,14 @@ public Response
Restores the certificate in the key vault from its backup. Prints out the restored certificate * details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.restoreCertificate#byte} + * + *+ * byte[] certificateBackupBlob = {}; + * KeyVaultCertificate certificate = certificateClient.restoreCertificateBackup(certificateBackupBlob); + * System.out.printf(" Restored certificate with name %s and id %s%n", + * certificate.getProperties().getName(), certificate.getProperties().getId()); + *+ * * * @param backup The backup blob associated with the certificate. * @throws ResourceModifiedException when {@code backup} blob is malformed. @@ -445,7 +598,16 @@ public KeyVaultCertificateWithPolicy restoreCertificateBackup(byte[] backup) { *
Restores the certificate in the key vault from its backup. Prints out the restored certificate * details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.restoreCertificateWithResponse#byte-Context} + * + *+ * byte[] certificateBackupBlobArray = {}; + * Response<KeyVaultCertificateWithPolicy> certificateResponse = certificateClient + * .restoreCertificateBackupWithResponse(certificateBackupBlobArray, new Context(key1, value1)); + * System.out.printf(" Restored certificate with name %s and id %s%n", + * certificateResponse.getValue().getProperties().getName(), + * certificateResponse.getValue().getProperties().getId()); + *+ * * * @param backup The backup blob associated with the certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -467,7 +629,17 @@ public Response
+ * for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { + * KeyVaultCertificate certificateWithAllProperties = certificateClient + * .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); + * System.out.printf("Received certificate with name %s and secret id %s%n", + * certificateWithAllProperties.getProperties().getName(), + * certificateWithAllProperties.getSecretId()); + * } + *+ * * * @return A {@link PagedIterable} containing {@link CertificateProperties certificate} for all the certificates in the vault. */ @@ -486,7 +658,18 @@ public PagedIterable
+ * for (CertificateProperties certificateProperties : certificateClient + * .listPropertiesOfCertificates(true, new Context(key1, value1))) { + * KeyVaultCertificate certificateWithAllProperties = certificateClient + * .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); + * System.out.printf("Received certificate with name %s and secret id %s%n", + * certificateWithAllProperties.getProperties().getName(), + * certificateWithAllProperties.getSecretId()); + * } + *+ * * * @param includePending indicate if pending certificates should be included in the results. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -506,7 +689,13 @@ public PagedIterable
Lists the deleted certificates in the key vault. Prints out the * recovery id of each deleted certificate when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates} + * + *+ * for (DeletedCertificate deletedCertificate : certificateClient.listDeletedCertificates()) { + * System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); + * } + *+ * * * @return A {@link PagedIterable} containing all of the {@link DeletedCertificate deleted certificates} in the vault. */ @@ -524,7 +713,14 @@ public PagedIterable
Lists the deleted certificates in the key vault. Prints out the * recovery id of each deleted certificate when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates#context} + * + *+ * for (DeletedCertificate deletedCertificate : certificateClient + * .listDeletedCertificates(true, new Context(key1, value1))) { + * System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); + * } + *+ * * * @param includePending indicate if pending deleted certificates should be included in the results. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -544,7 +740,18 @@ public PagedIterable
+ * for (CertificateProperties certificateProperties : certificateClient + * .listPropertiesOfCertificateVersions("certificateName")) { + * KeyVaultCertificate certificateWithAllProperties = certificateClient + * .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); + * System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", + * certificateWithAllProperties.getProperties().getName(), + * certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); + * } + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -565,7 +772,18 @@ public PagedIterable
+ * for (CertificateProperties certificateProperties : certificateClient + * .listPropertiesOfCertificateVersions("certificateName")) { + * KeyVaultCertificate certificateWithAllProperties = certificateClient + * .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); + * System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", + * certificateWithAllProperties.getProperties().getName(), + * certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); + * } + *+ * * * @param certificateName The name of the certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -585,7 +803,12 @@ public PagedIterable
Gets the policy of a certirifcate in the key vault. Prints out the * returned certificate policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicy#string} + * + *+ * CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName"); + * System.out.printf("Received policy with subject name %s%n", policy.getSubject()); + *+ * * * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. @@ -604,7 +827,14 @@ public CertificatePolicy getCertificatePolicy(String certificateName) { *
Gets the policy of a certirifcate in the key vault. Prints out the * returned certificate policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicyWithResponse#string} + * + *+ * Response<CertificatePolicy> returnedPolicyWithResponse = certificateClient.getCertificatePolicyWithResponse( + * "certificateName", new Context(key1, value1)); + * System.out.printf("Received policy with subject name %s%n", + * returnedPolicyWithResponse.getValue().getSubject()); + *+ * * * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null * @param context Additional context that is passed through the Http pipeline during the service call. @@ -625,7 +855,17 @@ public Response
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the * returned policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicy#string} + * + *+ * CertificatePolicy certificatePolicy = certificateClient.getCertificatePolicy("certificateName"); + * //Update the certificate policy cert transparency property. + * certificatePolicy.setCertificateTransparent(true); + * CertificatePolicy updatedCertPolicy = certificateClient.updateCertificatePolicy("certificateName", + * certificatePolicy); + * System.out.printf("Updated Certificate Policy transparency status %s%n", + * updatedCertPolicy.isCertificateTransparent()); + *+ * * * @param certificateName The name of the certificate whose policy is to be updated. * @param policy The certificate policy to be updated. @@ -647,7 +887,18 @@ public CertificatePolicy updateCertificatePolicy(String certificateName, Certifi *
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the * returned policy details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicyWithResponse#string} + * + *+ * CertificatePolicy certificatePolicyToUpdate = certificateClient.getCertificatePolicy("certificateName"); + * //Update the certificate policy cert transparency property. + * certificatePolicyToUpdate.setCertificateTransparent(true); + * Response<CertificatePolicy> updatedCertPolicyWithResponse = certificateClient + * .updateCertificatePolicyWithResponse("certificateName", certificatePolicyToUpdate, + * new Context(key1, value1)); + * System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicyWithResponse + * .getValue().isCertificateTransparent()); + *+ * * * @param certificateName The certificateName of the certificate whose policy is to be updated. * @param policy The certificate policy to be updated. @@ -670,7 +921,17 @@ public Response
Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a * response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.createIssuer#CertificateIssuer} + * + *+ * CertificateIssuer issuerToCreate = new CertificateIssuer("myissuer", "myProvider") + * .setAccountId("testAccount") + * .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") + * .setLastName("name").setEmail("test@example.com"))); + * CertificateIssuer returnedIssuer = certificateClient.createIssuer(issuerToCreate); + * System.out.printf("Created Issuer with name %s provider %s%n", returnedIssuer.getName(), + * returnedIssuer.getProvider()); + *+ * * * @param issuer The configuration of the certificate issuer to be created. * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. @@ -690,7 +951,18 @@ public CertificateIssuer createIssuer(CertificateIssuer issuer) { *
Creates a new certificate issuer in the key vault. Prints out the created certificate * issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.createIssuerWithResponse#CertificateIssuer-Context} + * + *+ * CertificateIssuer issuer = new CertificateIssuer("issuerName", "myProvider") + * .setAccountId("testAccount") + * .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") + * .setLastName("name").setEmail("test@example.com"))); + * Response<CertificateIssuer> issuerResponse = certificateClient.createIssuerWithResponse(issuer, + * new Context(key1, value1)); + * System.out.printf("Created Issuer with name %s provider %s%n", issuerResponse.getValue().getName(), + * issuerResponse.getValue().getProvider()); + *+ * * * @param issuer The configuration of the certificate issuer to be created. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -710,7 +982,14 @@ public Response
Gets the specificed certifcate issuer in the key vault. Prints out the returned certificate issuer details when * a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getIssuerWithResponse#string-context} + * + *+ * Response<CertificateIssuer> issuerResponse = certificateClient.getIssuerWithResponse("issuerName", + * new Context(key1, value1)); + * System.out.printf("Retrieved issuer with name %s and provider %s%n", issuerResponse.getValue().getName(), + * issuerResponse.getValue().getProvider()); + *+ * * * @param issuerName The name of the certificate issuer to retrieve, cannot be null * @param context Additional context that is passed through the Http pipeline during the service call. @@ -730,7 +1009,13 @@ public Response
Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details * when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.getIssuer#string} + * + *+ * CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); + * System.out.printf("Retrieved issuer with name %s and provider %s%n", returnedIssuer.getName(), + * returnedIssuer.getProvider()); + *+ * * * @param issuerName The name of the certificate issuer to retrieve, cannot be null * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -750,7 +1035,13 @@ public CertificateIssuer getIssuer(String issuerName) { *
Deletes the certificate issuer in the Azure Key Vault. Prints out the * deleted certificate details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteIssuerWithResponse#string-context} + * + *+ * CertificateIssuer deletedIssuer = certificateClient.deleteIssuer("certificateName"); + * System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuer.getName(), + * deletedIssuer.getProvider()); + *+ * * * @param issuerName The name of the certificate issuer to be deleted. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -771,7 +1062,15 @@ public Response
Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a * response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteIssuer#string} + * + *+ * Response<CertificateIssuer> deletedIssuerWithResponse = certificateClient. + * deleteIssuerWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", + * deletedIssuerWithResponse.getValue().getName(), + * deletedIssuerWithResponse.getValue().getProvider()); + *+ * * * @param issuerName The name of the certificate issuer to be deleted. * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key vault. @@ -792,7 +1091,15 @@ public CertificateIssuer deleteIssuer(String issuerName) { * call {@link CertificateClient#getIssuer(String)} . This will return the {@link CertificateIssuer issuer} * with all its properties.. * - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers} + * + *
+ * for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers()) { + * CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); + * System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), + * retrievedIssuer.getProvider()); + * } + *+ * * * @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault. */ @@ -810,7 +1117,15 @@ public PagedIterable
+ * for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers(new Context(key1, value1))) { + * CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); + * System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), + * retrievedIssuer.getProvider()); + * } + *+ * * * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault. @@ -828,7 +1143,15 @@ public PagedIterable
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateIssuer#CertificateIssuer} + * + *+ * CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); + * returnedIssuer.setAccountId("newAccountId"); + * CertificateIssuer updatedIssuer = certificateClient.updateIssuer(returnedIssuer); + * System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuer.getName(), + * updatedIssuer.getProvider(), updatedIssuer.getAccountId()); + *+ * * * @param issuer The {@link CertificateIssuer issuer} with updated properties. * @throws NullPointerException if {@code issuer} is {@code null}. @@ -849,7 +1172,18 @@ public CertificateIssuer updateIssuer(CertificateIssuer issuer) { *
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the * returned certificate issuer details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.updateIssuerWithResponse#CertificateIssuer-Context} + * + *+ * CertificateIssuer issuer = certificateClient.getIssuer("issuerName"); + * returnedIssuer.setAccountId("newAccountId"); + * Response<CertificateIssuer> updatedIssuerWithResponse = certificateClient.updateIssuerWithResponse(issuer, + * new Context(key1, value1)); + * System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", + * updatedIssuerWithResponse.getValue().getName(), + * updatedIssuerWithResponse.getValue().getProvider(), + * updatedIssuerWithResponse.getValue().getAccountId()); + *+ * * * @param issuer The {@link CertificateIssuer issuer} with updated properties. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -871,7 +1205,15 @@ public Response
Code Samples
*Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts} + * + *+ * CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); + * for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) { + * System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @param contacts The list of contacts to set on the vault. * @throws HttpRequestException when a contact information provided is invalid/incomplete. @@ -890,7 +1232,16 @@ public PagedIterable
Code Samples
*Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts-context} + * + *+ * CertificateContact sampleContact = new CertificateContact().setName("user").setEmail("useremail@example.com"); + * for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(sampleContact), + * new Context(key1, value1))) { + * System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @param contacts The list of contacts to set on the vault. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -908,7 +1259,14 @@ public PagedIterable
Code Samples
*Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.listContacts} + * + *+ * for (CertificateContact contact : certificateClient.listContacts()) { + * System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the vault. */ @@ -923,7 +1281,14 @@ public PagedIterable
Code Samples
*Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.listContacts#context} + * + *+ * for (CertificateContact contact : certificateClient.listContacts(new Context(key1, value1))) { + * System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the vault. @@ -940,7 +1305,14 @@ public PagedIterable
Deletes the certificate contacts in the Azure Key Vault. Subscribes to the call and prints out the * deleted contacts details.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteContacts} + * + *+ * for (CertificateContact contact : certificateClient.deleteContacts()) { + * System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @return A {@link PagedIterable} containing all of the deleted {@link CertificateContact certificate contacts} in the vault. */ @@ -955,7 +1327,14 @@ public PagedIterable
Code Samples
*Deletes the certificate contacts in the Azure Key Vault. Prints out the deleted contacts details in the response.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteContacts#context} + * + *+ * for (CertificateContact contact : certificateClient.deleteContacts(new Context(key1, value1))) { + * System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), + * contact.getEmail()); + * } + *+ * * * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link PagedIterable} containing all of the deleted {@link CertificateContact certificate contacts} in the vault. @@ -973,7 +1352,14 @@ public PagedIterable
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the * deleted certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperation#string} + * + *+ * Response<CertificateOperation> deletedCertificateOperationWithResponse = certificateClient + * .deleteCertificateOperationWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Deleted Certificate Operation's last status %s%n", + * deletedCertificateOperationWithResponse.getValue().getStatus()); + *+ * * * @param certificateName The name of the certificate. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} doesn't exist in the key vault. @@ -993,7 +1379,13 @@ public CertificateOperation deleteCertificateOperation(String certificateName) { *
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the * deleted certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperationWithResponse#string} + * + *+ * CertificateOperation deletedCertificateOperation = certificateClient + * .deleteCertificateOperation("certificateName"); + * System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperation.getStatus()); + *+ * * * @param certificateName The name of the certificate. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -1013,7 +1405,13 @@ public Response
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the * updated certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperation#string} + * + *+ * CertificateOperation certificateOperation = certificateClient + * .cancelCertificateOperation("certificateName"); + * System.out.printf("Certificate Operation status %s%n", certificateOperation.getStatus()); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist in the key vault. @@ -1032,7 +1430,13 @@ public CertificateOperation cancelCertificateOperation(String certificateName) { *
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the * updated certificate operation details when a response has been received.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperationWithResponse#string} + * + *+ * Response<CertificateOperation> certificateOperationWithResponse = certificateClient + * .cancelCertificateOperationWithResponse("certificateName", new Context(key1, value1)); + * System.out.printf("Certificate Operation status %s%n", certificateOperationWithResponse.getValue().getStatus()); + *+ * * * @param certificateName The name of the certificate which is in the process of being created. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -1052,7 +1456,17 @@ public Response
Code Samples
*Merges a certificate with a kay pair available in the service.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.mergeCertificate#config} + * + *+ * List<byte[]> x509CertificatesToMerge = new ArrayList<>(); + * MergeCertificateOptions config = + * new MergeCertificateOptions("certificateName", x509CertificatesToMerge) + * .setEnabled(false); + * KeyVaultCertificate mergedCertificate = certificateClient.mergeCertificate(config); + * System.out.printf("Received Certificate with name %s and key id %s%n", + * mergedCertificate.getProperties().getName(), mergedCertificate.getKeyId()); + *+ * * * @param mergeCertificateOptions the merge certificate configuration holding the x509 certificates. * @throws NullPointerException when {@code mergeCertificateOptions} is null. @@ -1071,7 +1485,19 @@ public KeyVaultCertificateWithPolicy mergeCertificate(MergeCertificateOptions me *
Code Samples
*Merges a certificate with a kay pair available in the service.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.mergeCertificateWithResponse#config} + * + *+ * List<byte[]> x509CertsToMerge = new ArrayList<>(); + * MergeCertificateOptions mergeConfig = + * new MergeCertificateOptions("certificateName", x509CertsToMerge) + * .setEnabled(false); + * Response<KeyVaultCertificateWithPolicy> mergedCertificateWithResponse = + * certificateClient.mergeCertificateWithResponse(mergeConfig, new Context(key2, value2)); + * System.out.printf("Received Certificate with name %s and key id %s%n", + * mergedCertificateWithResponse.getValue().getProperties().getName(), + * mergedCertificateWithResponse.getValue().getKeyId()); + *+ * * * @param mergeCertificateOptions the merge certificate configuration holding the x509 certificates. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -1092,7 +1518,16 @@ public Response
Code Samples
*Imports a certificate into the key vault.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.importCertificate#options} + * + *+ * byte[] certificateToImport = new byte[100]; + * ImportCertificateOptions config = + * new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); + * KeyVaultCertificate importedCertificate = certificateClient.importCertificate(config); + * System.out.printf("Received Certificate with name %s and key id %s%n", + * importedCertificate.getProperties().getName(), importedCertificate.getKeyId()); + *+ * * * @param importCertificateOptions The details of the certificate to import to the key vault * @throws HttpRequestException when the {@code importCertificateOptions} are invalid. @@ -1110,7 +1545,18 @@ public KeyVaultCertificateWithPolicy importCertificate(ImportCertificateOptions *
Code Samples
*Imports a certificate into the key vault.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.importCertificateWithResponse#options} + * + *+ * byte[] certToImport = new byte[100]; + * ImportCertificateOptions importCertificateOptions = + * new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); + * Response<KeyVaultCertificateWithPolicy> importedCertificateWithResponse = + * certificateClient.importCertificateWithResponse(importCertificateOptions, new Context(key2, value2)); + * System.out.printf("Received Certificate with name %s and key id %s%n", + * importedCertificateWithResponse.getValue().getProperties().getName(), + * importedCertificateWithResponse.getValue().getKeyId()); + *+ * * * @param importCertificateOptions The details of the certificate to import to the key vault * @param context Additional context that is passed through the Http pipeline during the service call. diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index f755eea1d257e..63190aabe5507 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -43,25 +43,60 @@ * CertificateAsyncClient} * are {@link String vaultUrl} and {@link TokenCredential credential}. * - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation} + * + *
+ * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() + * .credential(new DefaultAzureCredentialBuilder().build()) + * .vaultUrl("https://myvault.vault.azure.net/") + * .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + * .buildAsyncClient(); + *+ * * *
The {@link HttpLogDetailLevel log detail level}, multiple custom {@link HttpLoggingPolicy policies} and custom * {@link HttpClient http client} can be optionally configured in the {@link CertificateClientBuilder}.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.withhttpclient.instantiation} + * + *+ * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() + * .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + * .vaultUrl("https://myvault.azure.net/") + * .credential(new DefaultAzureCredentialBuilder().build()) + * .httpClient(HttpClient.createDefault()) + * .buildAsyncClient(); + *+ * * *
Alternatively, custom {@link HttpPipeline http pipeline} with custom {@link HttpPipelinePolicy} policies and * {@link String vaultUrl} * can be specified. It provides finer control over the construction of {@link CertificateAsyncClient} and {@link * CertificateClient}
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateAsyncClient.pipeline.instantiation} + * + *+ * HttpPipeline pipeline = new HttpPipelineBuilder() + * .policies(new KeyVaultCredentialPolicy(new DefaultAzureCredentialBuilder().build()), new RetryPolicy()) + * .build(); + * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() + * .pipeline(pipeline) + * .vaultUrl("https://myvault.azure.net/") + * .buildAsyncClient(); + *+ * * *
The minimal configuration options required by {@link CertificateClientBuilder certificateClientBuilder} to build * {@link CertificateClient} * are {@link String vaultUrl} and {@link TokenCredential credential}.
* - * {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.instantiation} + * + *+ * CertificateClient certificateClient = new CertificateClientBuilder() + * .credential(new DefaultAzureCredentialBuilder().build()) + * .vaultUrl("https://myvault.vault.azure.net/") + * .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) + * .buildClient(); + *+ * * * @see CertificateAsyncClient * @see CertificateClient @@ -121,14 +156,14 @@ public CertificateClient buildClient() { /** * Creates a {@link CertificateAsyncClient} based on options set in the builder. Every time - * {@link #buildAsyncClient()} is called, a new instance of {@link CertificateAsyncClient} is created. + * {@code buildAsyncClient()} is called, a new instance of {@link CertificateAsyncClient} is created. * *
If {@link CertificateClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and * {@link CertificateClientBuilder#vaultUrl(String) serviceEndpoint} are used to create the {@link * CertificateClientBuilder client}. All other builder settings are ignored. If {@code pipeline} is not set, then - * {@link CertificateClientBuilder#credential(TokenCredential) key vault credential and {@link + * {@link CertificateClientBuilder#credential(TokenCredential) key vault credential} and {@link * CertificateClientBuilder#vaultUrl(String)} key vault url are required to build the {@link CertificateAsyncClient - * client}.}
+ * client}. * * @return A {@link CertificateAsyncClient} with the options set from the builder. * diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java index 2e88096369c0f..3cf5099a1d37e 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java @@ -9,9 +9,24 @@ * The versions of Azure Key Vault Certificate supported by this client library. */ public enum CertificateServiceVersion implements ServiceVersion { + /** + * Service version {@code 7.0}. + */ V7_0("7.0"), + + /** + * Service version {@code 7.1}. + */ V7_1("7.1"), + + /** + * Service version {@code 7.2}. + */ V7_2("7.2"), + + /** + * Service version {@code 7.3-preview}. + */ V7_3_PREVIEW("7.3-preview"); private final String version; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java new file mode 100644 index 0000000000000..bbf24b92e143b --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.certificates; + +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.SyncPoller; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.certificates.models.CertificateOperation; +import com.azure.security.keyvault.certificates.models.CertificatePolicy; +import com.azure.security.keyvault.certificates.models.CertificateProperties; +import com.azure.security.keyvault.certificates.models.DeletedCertificate; +import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; +import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; + +@SuppressWarnings("unused") +public class ReadmeSamples { + private final CertificateClient certificateClient = new CertificateClientBuilder() + .vaultUrl("