From f99f825a5b9613c25afed1f56d48b20c1342ec0a Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 15 Jun 2020 12:07:29 -0700 Subject: [PATCH 01/40] Created azure-security-keyvault-administration module including its POM, README and CHANGELOG files. --- .../CHANGELOG.md | 3 + .../README.md | 129 ++++++++++++++++++ .../pom.xml | 109 +++++++++++++++ sdk/keyvault/pom.xml | 3 +- 4 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md create mode 100644 sdk/keyvault/azure-security-keyvault-administration/README.md create mode 100644 sdk/keyvault/azure-security-keyvault-administration/pom.xml diff --git a/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md b/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md new file mode 100644 index 000000000000..b9bbe3a8243f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History +## 4.1.0-beta.1 (Unreleased) +- Added `KeyVaultAccessControlClient`. diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md new file mode 100644 index 000000000000..f38c59e76fff --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -0,0 +1,129 @@ +# Azure Key Vault Administration client library for Java + +## Getting started +### Adding the package to your project +Maven dependency for the Azure Key Vault Administration client library. Add it to your project's POM file. + +[//]: # ({x-version-update-start;com.azure:azure-security-keyvault-keys;current}) +```xml + + com.azure + azure-security-keyvault-administration + 4.1.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Prerequisites +- Java Development Kit (JDK) with version 8 or above +- [Azure Subscription][azure_subscription] +- An existing [Azure Key Vault][azure_keyvault]. If you need to create a Key Vault, you can use the [Azure Cloud Shell](https://shell.azure.com/bash) to create one with this Azure CLI command. Replace `` and `` with your own, unique names: + + ```Bash + az keyvault create --resource-group --name + ``` + +### Authenticate the client +In order to interact with the Azure Key Vault service, you'll need to create an instance of the [KeyClient](#create-key-client) class. You would need a **vault url** and **client secret credentials (client id, client secret, tenant id)** to instantiate a client object using the default `DefaultAzureCredential` examples shown in this document. + +The `DefaultAzureCredential` way of authentication by providing client secret credentials is being used in this getting started section but you can find more ways to authenticate with [azure-identity][azure_identity]. + +#### Create/Get credentials +To create/get client secret credentials you can use the [Azure Portal][azure_create_application_in_portal], [Azure CLI][azure_keyvault_cli_full] or [Azure Cloud Shell](https://shell.azure.com/bash) + +Here is an [Azure Cloud Shell](https://shell.azure.com/bash) snippet below to + + * Create a service principal and configure its access to Azure resources: + + ```Bash + az ad sp create-for-rbac -n --skip-assignment + ``` + + Output: + + ```json + { + "appId": "generated-app-ID", + "displayName": "dummy-app-name", + "name": "http://dummy-app-name", + "password": "random-password", + "tenant": "tenant-ID" + } + ``` + +* Use the above returned credentials information to set the **AZURE_CLIENT_ID** (appId), **AZURE_CLIENT_SECRET** (password), and **AZURE_TENANT_ID** (tenantId) environment variables. The following example shows a way to do this in Bash: + + ```Bash + export AZURE_CLIENT_ID="generated-app-ID" + export AZURE_CLIENT_SECRET="random-password" + export AZURE_TENANT_ID="tenant-ID" + ``` + +* Use the aforementioned Key Vault name to retrieve details of your Key Vault, which also contain your Key Vault URL: + + ```Bash + az keyvault show --name + ``` + +#### Create Access Control client + +## Key concepts +### Role definition + +### Role assignment + +### Access Control client + +## Examples +### Sync API +The following sections provide several code snippets covering some of the most common Azure Key Vault Key service tasks, including: + +### Async API +The following sections provide several code snippets covering some of the most common asynchronous Azure Key Vault Key service tasks, including: + +## Key concepts + +## Troubleshooting +### General + +### Default HTTP client +All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the [HTTP clients wiki](https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients). + +### Default SSL library +All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSL operations. The Boring SSL library is an Uber JAR containing native libraries for Linux / macOS / Windows, and provides better performance compared to the default SSL implementation within the JDK. For more information, including how to reduce the dependency size, refer to the [performance tuning][performance_tuning] section of the wiki. + +## Next steps +Several Key Vault Java SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Azure Key Vault. + +## Next steps samples +Samples are explained in detail [here][samples_readme]. + +### Additional documentation +For more extensive documentation on Azure Key Vault, see the [API reference documentation][azkeyvault_rest]. + +## Contributing +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the Code of Conduct FAQ or contact with any additional questions or comments. + + +[source_code]: src +[api_documentation]: https://azure.github.io/azure-sdk-for-java +[azkeyvault_docs]: https://docs.microsoft.com/azure/key-vault/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/identity/azure-identity +[maven]: https://maven.apache.org/ +[azure_subscription]: https://azure.microsoft.com/ +[azure_keyvault]: https://docs.microsoft.com/azure/key-vault/quick-create-portal +[azure_cli]: https://docs.microsoft.com/cli/azure +[rest_api]: https://docs.microsoft.com/rest/api/keyvault/ +[azkeyvault_rest]: https://docs.microsoft.com/rest/api/keyvault/ +[azure_create_application_in_portal]: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +[azure_keyvault_cli]: https://docs.microsoft.com/azure/key-vault/quick-create-cli +[azure_keyvault_cli_full]: https://docs.microsoft.com/cli/azure/keyvault?view=azure-cli-latest +[keys_samples]: src/samples/java/com/azure/security/keyvault/keys +[samples_readme]: src/samples/README.md +[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fkeyvault%2Fazure-security-keyvault-administration%2FREADME.png) diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml new file mode 100644 index 000000000000..b7a0acfd6d8e --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -0,0 +1,109 @@ + + + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + 4.0.0 + + com.azure + azure-security-keyvault-administration + 4.1.0-beta.1 + + Microsoft Azure client library for KeyVault Administration + This module contains client library for Microsoft Azure KeyVault Administration. + https://github.com/Azure/azure-sdk-for-java + + + + azure-java-build-docs + ${site.url}/site/${project.artifactId} + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M3 + + 3 + + + + + + + + com.azure + azure-core + 1.5.1 + + + com.azure + azure-core-http-netty + 1.5.2 + + + + org.junit.jupiter + junit-jupiter-api + 5.6.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.6.2 + test + + + org.junit.jupiter + junit-jupiter-params + 5.6.2 + test + + + org.hamcrest + hamcrest-library + 2.2 + test + + + io.projectreactor + reactor-test + 3.3.5.RELEASE + test + + + com.azure + azure-core-test + 1.3.0 + test + + + com.azure + azure-core-http-okhttp + 1.2.3 + test + + + com.azure + azure-identity + 1.0.7 + test + + + diff --git a/sdk/keyvault/pom.xml b/sdk/keyvault/pom.xml index 5f620284c6a4..6042dcedc8af 100644 --- a/sdk/keyvault/pom.xml +++ b/sdk/keyvault/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 com.azure @@ -16,6 +16,7 @@ microsoft-azure-keyvault-cryptography microsoft-azure-keyvault-extensions microsoft-azure-keyvault-test + azure-security-keyvault-administration azure-security-keyvault-certificates azure-security-keyvault-keys azure-security-keyvault-secrets From 08f62648e8f9784f1b13b8f48286fa29474209e4 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 15 Jun 2020 14:16:24 -0700 Subject: [PATCH 02/40] Created AutoRest README and generated artifacts. --- .../AccessControlClientBuilder.java | 66 ++++++ .../AccessControlClientImpl.java | 100 +++++++++ .../implementation/RoleAssignmentsImpl.java | 158 ++++++++++++++ .../implementation/RoleDefinitionsImpl.java | 92 +++++++++ .../implementation/models/Error.java | 59 ++++++ .../implementation/models/KeyVaultError.java | 29 +++ .../models/KeyVaultErrorException.java | 39 ++++ .../implementation/models/Permission.java | 119 +++++++++++ .../implementation/models/RoleAssignment.java | 85 ++++++++ .../RoleAssignmentCreateParameters.java | 40 ++++ .../models/RoleAssignmentFilter.java | 42 ++++ .../models/RoleAssignmentListResult.java | 69 +++++++ .../models/RoleAssignmentProperties.java | 74 +++++++ .../RoleAssignmentPropertiesWithScope.java | 92 +++++++++ .../implementation/models/RoleDefinition.java | 192 ++++++++++++++++++ .../models/RoleDefinitionFilter.java | 42 ++++ .../models/RoleDefinitionListResult.java | 69 +++++++ .../implementation/models/package-info.java | 10 + .../implementation/package-info.java | 11 + .../swagger/README.md | 51 +++++ 20 files changed, 1439 insertions(+) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/swagger/README.md diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java new file mode 100644 index 000000000000..f06623dddf00 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; + +/** + * A builder for creating a new instance of the AccessControlClient type. + */ +@ServiceClientBuilder(serviceClients = AccessControlClientImpl.class) +public final class AccessControlClientBuilder { + /* + * Client API version. + */ + private String apiVersion; + + /** + * Sets Client API version. + * + * @param apiVersion the apiVersion value. + * @return the AccessControlClientBuilder. + */ + public AccessControlClientBuilder apiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AccessControlClientBuilder. + */ + public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /** + * Builds an instance of AccessControlClientImpl with the provided parameters. + * + * @return an instance of AccessControlClientImpl. + */ + public AccessControlClientImpl build() { + if (pipeline == null) { + this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build(); + } + AccessControlClientImpl client = new AccessControlClientImpl(pipeline); + if (this.apiVersion != null) { + client.setApiVersion(this.apiVersion); + } + return client; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java new file mode 100644 index 000000000000..433a0e665f07 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; + +/** + * Initializes a new instance of the AccessControlClient type. + */ +public final class AccessControlClientImpl { + /** + * Client API version. + */ + private String apiVersion; + + /** + * Gets Client API version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * Sets Client API version. + * + * @param apiVersion the apiVersion value. + */ + AccessControlClientImpl setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + /** + * The HTTP pipeline to send requests through. + */ + private HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The RoleDefinitionsImpl object to access its operations. + */ + private RoleDefinitionsImpl roleDefinitions; + + /** + * Gets the RoleDefinitionsImpl object to access its operations. + * + * @return the RoleDefinitionsImpl object. + */ + public RoleDefinitionsImpl roleDefinitions() { + return this.roleDefinitions; + } + + /** + * The RoleAssignmentsImpl object to access its operations. + */ + private RoleAssignmentsImpl roleAssignments; + + /** + * Gets the RoleAssignmentsImpl object to access its operations. + * + * @return the RoleAssignmentsImpl object. + */ + public RoleAssignmentsImpl roleAssignments() { + return this.roleAssignments; + } + + /** + * Initializes an instance of AccessControlClient client. + */ + public AccessControlClientImpl() { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build()); + } + + /** + * Initializes an instance of AccessControlClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + */ + public AccessControlClientImpl(HttpPipeline httpPipeline) { + this.httpPipeline = httpPipeline; + this.roleDefinitions = new RoleDefinitionsImpl(this); + this.roleAssignments = new RoleAssignmentsImpl(this); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java new file mode 100644 index 000000000000..1e699f22d82b --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentCreateParameters; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in + * RoleAssignments. + */ +public final class RoleAssignmentsImpl { + /** + * The proxy service used to perform REST calls. + */ + private RoleAssignmentsService service; + + /** + * The service client containing this operation class. + */ + private AccessControlClientImpl client; + + /** + * Initializes an instance of RoleAssignmentsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + public RoleAssignmentsImpl(AccessControlClientImpl client) { + this.service = RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for + * AccessControlClientRoleAssignments to be used by the proxy service to + * perform REST calls. + */ + @Host("{vaultBaseUrl}") + @ServiceInterface(name = "AccessControlClientRoleAssignments") + private interface RoleAssignmentsService { + @Delete("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> delete(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("api-version") String apiVersion, Context context); + + @Put("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @ExpectedResponses({201}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> create(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @BodyParam("application/json; charset=utf-8") RoleAssignmentCreateParameters parameters, @QueryParam("api-version") String apiVersion, Context context); + + @Get("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> get(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("api-version") String apiVersion, Context context); + + @Get("{scope}/providers/Microsoft.Authorization/roleAssignments") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> listForScope(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); + } + + /** + * Deletes a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to delete. + * @param roleAssignmentName The name of the role assignment to delete. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return service.delete(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); + } + + /** + * Creates a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to create. + * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. + * @param parameters Parameters for the role assignment. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { + return service.create(scope, roleAssignmentName, vaultBaseUrl, parameters, this.client.getApiVersion(), context); + } + + /** + * Get the specified role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment. + * @param roleAssignmentName The name of the role assignment to get. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return service.get(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); + } + + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, Context context) { + final String filter = null; + return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + } + + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { + return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java new file mode 100644 index 000000000000..cac25bf6bc89 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in + * RoleDefinitions. + */ +public final class RoleDefinitionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private RoleDefinitionsService service; + + /** + * The service client containing this operation class. + */ + private AccessControlClientImpl client; + + /** + * Initializes an instance of RoleDefinitionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + public RoleDefinitionsImpl(AccessControlClientImpl client) { + this.service = RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for + * AccessControlClientRoleDefinitions to be used by the proxy service to + * perform REST calls. + */ + @Host("{vaultBaseUrl}") + @ServiceInterface(name = "AccessControlClientRoleDefinitions") + private interface RoleDefinitionsService { + @Get("{scope}/providers/Microsoft.Authorization/roleDefinitions") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> list(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, Context context) { + final String filter = null; + return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { + return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java new file mode 100644 index 000000000000..9395268bd3ee --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The key vault server error. + */ +@Fluent +public final class Error { + /* + * The error code. + */ + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /* + * The error message. + */ + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /* + * The innerError property. + */ + @JsonProperty(value = "innererror", access = JsonProperty.Access.WRITE_ONLY) + private Error innerError; + + /** + * Get the code property: The error code. + * + * @return the code value. + */ + public String getCode() { + return this.code; + } + + /** + * Get the message property: The error message. + * + * @return the message value. + */ + public String getMessage() { + return this.message; + } + + /** + * Get the innerError property: The innerError property. + * + * @return the innerError value. + */ + public Error getInnerError() { + return this.innerError; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java new file mode 100644 index 000000000000..f0e4b04947f5 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The key vault error exception. + */ +@Fluent +public final class KeyVaultError { + /* + * The error property. + */ + @JsonProperty(value = "error", access = JsonProperty.Access.WRITE_ONLY) + private Error error; + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + public Error getError() { + return this.error; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java new file mode 100644 index 000000000000..028291324eda --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpResponse; + +/** + * Exception thrown for an invalid response with KeyVaultError information. + */ +public final class KeyVaultErrorException extends HttpResponseException { + /** + * Initializes a new instance of the KeyVaultErrorException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + */ + public KeyVaultErrorException(String message, HttpResponse response) { + super(message, response); + } + + /** + * Initializes a new instance of the KeyVaultErrorException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + * @param value the deserialized response value. + */ + public KeyVaultErrorException(String message, HttpResponse response, KeyVaultError value) { + super(message, response, value); + } + + @Override + public KeyVaultError getValue() { + return (KeyVaultError) super.getValue(); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java new file mode 100644 index 000000000000..b369769a5ce8 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Role definition permissions. + */ +@Fluent +public final class Permission { + /* + * Allowed actions. + */ + @JsonProperty(value = "actions") + private List actions; + + /* + * Denied actions. + */ + @JsonProperty(value = "notActions") + private List notActions; + + /* + * Allowed Data actions. + */ + @JsonProperty(value = "dataActions") + private List dataActions; + + /* + * Denied Data actions. + */ + @JsonProperty(value = "notDataActions") + private List notDataActions; + + /** + * Get the actions property: Allowed actions. + * + * @return the actions value. + */ + public List getActions() { + return this.actions; + } + + /** + * Set the actions property: Allowed actions. + * + * @param actions the actions value to set. + * @return the Permission object itself. + */ + public Permission setActions(List actions) { + this.actions = actions; + return this; + } + + /** + * Get the notActions property: Denied actions. + * + * @return the notActions value. + */ + public List getNotActions() { + return this.notActions; + } + + /** + * Set the notActions property: Denied actions. + * + * @param notActions the notActions value to set. + * @return the Permission object itself. + */ + public Permission setNotActions(List notActions) { + this.notActions = notActions; + return this; + } + + /** + * Get the dataActions property: Allowed Data actions. + * + * @return the dataActions value. + */ + public List getDataActions() { + return this.dataActions; + } + + /** + * Set the dataActions property: Allowed Data actions. + * + * @param dataActions the dataActions value to set. + * @return the Permission object itself. + */ + public Permission setDataActions(List dataActions) { + this.dataActions = dataActions; + return this; + } + + /** + * Get the notDataActions property: Denied Data actions. + * + * @return the notDataActions value. + */ + public List getNotDataActions() { + return this.notDataActions; + } + + /** + * Set the notDataActions property: Denied Data actions. + * + * @param notDataActions the notDataActions value to set. + * @return the Permission object itself. + */ + public Permission setNotDataActions(List notDataActions) { + this.notDataActions = notDataActions; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java new file mode 100644 index 000000000000..971d357fb9da --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role Assignments. + */ +@Fluent +public final class RoleAssignment { + /* + * The role assignment ID. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /* + * The role assignment name. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * The role assignment type. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /* + * Role assignment properties. + */ + @JsonProperty(value = "properties") + private RoleAssignmentPropertiesWithScope properties; + + /** + * Get the id property: The role assignment ID. + * + * @return the id value. + */ + public String getId() { + return this.id; + } + + /** + * Get the name property: The role assignment name. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * Get the type property: The role assignment type. + * + * @return the type value. + */ + public String getType() { + return this.type; + } + + /** + * Get the properties property: Role assignment properties. + * + * @return the properties value. + */ + public RoleAssignmentPropertiesWithScope getProperties() { + return this.properties; + } + + /** + * Set the properties property: Role assignment properties. + * + * @param properties the properties value to set. + * @return the RoleAssignment object itself. + */ + public RoleAssignment setProperties(RoleAssignmentPropertiesWithScope properties) { + this.properties = properties; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java new file mode 100644 index 000000000000..353044206a2f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role assignment create parameters. + */ +@Fluent +public final class RoleAssignmentCreateParameters { + /* + * Role assignment properties. + */ + @JsonProperty(value = "properties", required = true) + private RoleAssignmentProperties properties; + + /** + * Get the properties property: Role assignment properties. + * + * @return the properties value. + */ + public RoleAssignmentProperties getProperties() { + return this.properties; + } + + /** + * Set the properties property: Role assignment properties. + * + * @param properties the properties value to set. + * @return the RoleAssignmentCreateParameters object itself. + */ + public RoleAssignmentCreateParameters setProperties(RoleAssignmentProperties properties) { + this.properties = properties; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java new file mode 100644 index 000000000000..70d83a613bf9 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role Assignments filter. + */ +@Fluent +public final class RoleAssignmentFilter { + /* + * Returns role assignment of the specific principal. + */ + @JsonProperty(value = "principalId") + private String principalId; + + /** + * Get the principalId property: Returns role assignment of the specific + * principal. + * + * @return the principalId value. + */ + public String getPrincipalId() { + return this.principalId; + } + + /** + * Set the principalId property: Returns role assignment of the specific + * principal. + * + * @param principalId the principalId value to set. + * @return the RoleAssignmentFilter object itself. + */ + public RoleAssignmentFilter setPrincipalId(String principalId) { + this.principalId = principalId; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java new file mode 100644 index 000000000000..356740ae56b9 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Role assignment list operation result. + */ +@Fluent +public final class RoleAssignmentListResult { + /* + * Role assignment list. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The URL to use for getting the next set of results. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: Role assignment list. + * + * @return the value value. + */ + public List getValue() { + return this.value; + } + + /** + * Set the value property: Role assignment list. + * + * @param value the value value to set. + * @return the RoleAssignmentListResult object itself. + */ + public RoleAssignmentListResult setValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The URL to use for getting the next set of + * results. + * + * @return the nextLink value. + */ + public String getNextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The URL to use for getting the next set of + * results. + * + * @param nextLink the nextLink value to set. + * @return the RoleAssignmentListResult object itself. + */ + public RoleAssignmentListResult setNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java new file mode 100644 index 000000000000..913b357b370f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role assignment properties. + */ +@Fluent +public final class RoleAssignmentProperties { + /* + * The role definition ID used in the role assignment. + */ + @JsonProperty(value = "roleDefinitionId", required = true) + private String roleDefinitionId; + + /* + * The principal ID assigned to the role. This maps to the ID inside the + * Active Directory. It can point to a user, service principal, or security + * group. + */ + @JsonProperty(value = "principalId", required = true) + private String principalId; + + /** + * Get the roleDefinitionId property: The role definition ID used in the + * role assignment. + * + * @return the roleDefinitionId value. + */ + public String getRoleDefinitionId() { + return this.roleDefinitionId; + } + + /** + * Set the roleDefinitionId property: The role definition ID used in the + * role assignment. + * + * @param roleDefinitionId the roleDefinitionId value to set. + * @return the RoleAssignmentProperties object itself. + */ + public RoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { + this.roleDefinitionId = roleDefinitionId; + return this; + } + + /** + * Get the principalId property: The principal ID assigned to the role. + * This maps to the ID inside the Active Directory. It can point to a user, + * service principal, or security group. + * + * @return the principalId value. + */ + public String getPrincipalId() { + return this.principalId; + } + + /** + * Set the principalId property: The principal ID assigned to the role. + * This maps to the ID inside the Active Directory. It can point to a user, + * service principal, or security group. + * + * @param principalId the principalId value to set. + * @return the RoleAssignmentProperties object itself. + */ + public RoleAssignmentProperties setPrincipalId(String principalId) { + this.principalId = principalId; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java new file mode 100644 index 000000000000..94938432eebc --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role assignment properties with scope. + */ +@Fluent +public final class RoleAssignmentPropertiesWithScope { + /* + * The role assignment scope. + */ + @JsonProperty(value = "scope") + private String scope; + + /* + * The role definition ID. + */ + @JsonProperty(value = "roleDefinitionId") + private String roleDefinitionId; + + /* + * The principal ID. + */ + @JsonProperty(value = "principalId") + private String principalId; + + /** + * Get the scope property: The role assignment scope. + * + * @return the scope value. + */ + public String getScope() { + return this.scope; + } + + /** + * Set the scope property: The role assignment scope. + * + * @param scope the scope value to set. + * @return the RoleAssignmentPropertiesWithScope object itself. + */ + public RoleAssignmentPropertiesWithScope setScope(String scope) { + this.scope = scope; + return this; + } + + /** + * Get the roleDefinitionId property: The role definition ID. + * + * @return the roleDefinitionId value. + */ + public String getRoleDefinitionId() { + return this.roleDefinitionId; + } + + /** + * Set the roleDefinitionId property: The role definition ID. + * + * @param roleDefinitionId the roleDefinitionId value to set. + * @return the RoleAssignmentPropertiesWithScope object itself. + */ + public RoleAssignmentPropertiesWithScope setRoleDefinitionId(String roleDefinitionId) { + this.roleDefinitionId = roleDefinitionId; + return this; + } + + /** + * Get the principalId property: The principal ID. + * + * @return the principalId value. + */ + public String getPrincipalId() { + return this.principalId; + } + + /** + * Set the principalId property: The principal ID. + * + * @param principalId the principalId value to set. + * @return the RoleAssignmentPropertiesWithScope object itself. + */ + public RoleAssignmentPropertiesWithScope setPrincipalId(String principalId) { + this.principalId = principalId; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java new file mode 100644 index 000000000000..4e13e8a84bd5 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.JsonFlatten; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Role definition. + */ +@JsonFlatten +@Fluent +public class RoleDefinition { + /* + * The role definition ID. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /* + * The role definition name. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * The role definition type. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /* + * The role name. + */ + @JsonProperty(value = "properties.roleName") + private String roleName; + + /* + * The role definition description. + */ + @JsonProperty(value = "properties.description") + private String description; + + /* + * The role type. + */ + @JsonProperty(value = "properties.type") + private String roleType; + + /* + * Role definition permissions. + */ + @JsonProperty(value = "properties.permissions") + private List permissions; + + /* + * Role definition assignable scopes. + */ + @JsonProperty(value = "properties.assignableScopes") + private List assignableScopes; + + /** + * Get the id property: The role definition ID. + * + * @return the id value. + */ + public String getId() { + return this.id; + } + + /** + * Get the name property: The role definition name. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * Get the type property: The role definition type. + * + * @return the type value. + */ + public String getType() { + return this.type; + } + + /** + * Get the roleName property: The role name. + * + * @return the roleName value. + */ + public String getRoleName() { + return this.roleName; + } + + /** + * Set the roleName property: The role name. + * + * @param roleName the roleName value to set. + * @return the RoleDefinition object itself. + */ + public RoleDefinition setRoleName(String roleName) { + this.roleName = roleName; + return this; + } + + /** + * Get the description property: The role definition description. + * + * @return the description value. + */ + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The role definition description. + * + * @param description the description value to set. + * @return the RoleDefinition object itself. + */ + public RoleDefinition setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the roleType property: The role type. + * + * @return the roleType value. + */ + public String getRoleType() { + return this.roleType; + } + + /** + * Set the roleType property: The role type. + * + * @param roleType the roleType value to set. + * @return the RoleDefinition object itself. + */ + public RoleDefinition setRoleType(String roleType) { + this.roleType = roleType; + return this; + } + + /** + * Get the permissions property: Role definition permissions. + * + * @return the permissions value. + */ + public List getPermissions() { + return this.permissions; + } + + /** + * Set the permissions property: Role definition permissions. + * + * @param permissions the permissions value to set. + * @return the RoleDefinition object itself. + */ + public RoleDefinition setPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + /** + * Get the assignableScopes property: Role definition assignable scopes. + * + * @return the assignableScopes value. + */ + public List getAssignableScopes() { + return this.assignableScopes; + } + + /** + * Set the assignableScopes property: Role definition assignable scopes. + * + * @param assignableScopes the assignableScopes value to set. + * @return the RoleDefinition object itself. + */ + public RoleDefinition setAssignableScopes(List assignableScopes) { + this.assignableScopes = assignableScopes; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java new file mode 100644 index 000000000000..1e1bcf94b7aa --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Role Definitions filter. + */ +@Fluent +public final class RoleDefinitionFilter { + /* + * Returns role definition with the specific name. + */ + @JsonProperty(value = "roleName") + private String roleName; + + /** + * Get the roleName property: Returns role definition with the specific + * name. + * + * @return the roleName value. + */ + public String getRoleName() { + return this.roleName; + } + + /** + * Set the roleName property: Returns role definition with the specific + * name. + * + * @param roleName the roleName value to set. + * @return the RoleDefinitionFilter object itself. + */ + public RoleDefinitionFilter setRoleName(String roleName) { + this.roleName = roleName; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java new file mode 100644 index 000000000000..3c222206c22f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.security.keyvault.administration.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Role definition list operation result. + */ +@Fluent +public final class RoleDefinitionListResult { + /* + * Role definition list. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The URL to use for getting the next set of results. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: Role definition list. + * + * @return the value value. + */ + public List getValue() { + return this.value; + } + + /** + * Set the value property: Role definition list. + * + * @param value the value value to set. + * @return the RoleDefinitionListResult object itself. + */ + public RoleDefinitionListResult setValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The URL to use for getting the next set of + * results. + * + * @return the nextLink value. + */ + public String getNextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The URL to use for getting the next set of + * results. + * + * @param nextLink the nextLink value to set. + * @return the RoleDefinitionListResult object itself. + */ + public RoleDefinitionListResult setNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java new file mode 100644 index 000000000000..e01c674f7e77 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for AccessControlClient. + * The key vault client performs cryptographic key operations and vault + * operations against the Key Vault service. + */ +package com.azure.security.keyvault.administration.implementation.models; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java new file mode 100644 index 000000000000..61924df92481 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations and inner classes for + * AccessControlClient. + * The key vault client performs cryptographic key operations and vault + * operations against the Key Vault service. + */ +package com.azure.security.keyvault.administration.implementation; diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md new file mode 100644 index 000000000000..198ae167c139 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -0,0 +1,51 @@ +# Azure Key Vault Administration for Java +> see https://aka.ms/autorest + +### Setup +Increase max memory if you're using Autorest older than 3. Set the environment variable `NODE_OPTIONS` to `--max-old-space-size=8192`. + +This is the AutoRest configuration file for KeyVaultAccessControlClient. +--- +## Getting Started +To build the SDK for KeyVaultAccessControlClient, simply [Install AutoRest](https://aka.ms/autorest/install) and in this folder, run: + +> `autorest` + +To see additional help and options, run: + +> `autorest --help` + +### Generation +There is one swagger for KeyVault Administration: rbac. It uses the following tag: `--tag=rbac-preview`. + +```ps +cd +autorest --use=@microsoft.azure/autorest.java@3.0.4 --tag=${package} --version=2.0.4413 +``` + +e.g. +```ps +cd +autorest --use=@microsoft.azure/autorest.java@3.0.4 --tag=rbac-preview --version=2.0.4413 +``` +## Code generation settings +``` yaml +java: true +output-folder: ../ +namespace: com.azure.security.keyvault.administration +license-header: MICROSOFT_MIT_SMALL +models-subpackage: implementation.models +custom-types-subpackage: models +generate-client-as-impl: true +generate-client-interfaces: false +sync-methods: none +add-context-parameter: true +``` + +### Tag: rbac-preview +These settings apply only when `--tag=package-2019-05-searchservice-preview` is specified on the command line. + +``` yaml $(tag) == 'rbac-preview' +input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2/rbac.json +title: AccessControlClient +``` From c351f1754a61243dcbb52c1f8d744648d2a5f28c Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 15 Jun 2020 14:35:57 -0700 Subject: [PATCH 03/40] Added sync methods --- .../implementation/RoleAssignmentsImpl.java | 195 ++++++++++++++++++ .../implementation/RoleDefinitionsImpl.java | 76 +++++++ .../swagger/README.md | 2 +- 3 files changed, 272 insertions(+), 1 deletion(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index 1e699f22d82b..d1c990ef80e8 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -80,6 +80,23 @@ private interface RoleAssignmentsService { Mono> listForScope(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); } + /** + * Deletes a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to delete. + * @param roleAssignmentName The name of the role assignment to delete. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleAssignment object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment delete(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return deleteAsync(vaultBaseUrl, scope, roleAssignmentName, context).block(); + } + /** * Deletes a role assignment. * @@ -95,6 +112,46 @@ public Mono> deleteWithRestResponseAsync(String v return service.delete(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); } + /** + * Deletes a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to delete. + * @param roleAssignmentName The name of the role assignment to delete. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return deleteWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Creates a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to create. + * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. + * @param parameters Parameters for the role assignment. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleAssignment object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment create(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { + return createAsync(vaultBaseUrl, scope, roleAssignmentName, parameters, context).block(); + } + /** * Creates a role assignment. * @@ -111,6 +168,46 @@ public Mono> createWithRestResponseAsync(String v return service.create(scope, roleAssignmentName, vaultBaseUrl, parameters, this.client.getApiVersion(), context); } + /** + * Creates a role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment to create. + * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. + * @param parameters Parameters for the role assignment. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createAsync(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { + return createWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, parameters, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the specified role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment. + * @param roleAssignmentName The name of the role assignment to get. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleAssignment object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment get(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return getAsync(vaultBaseUrl, scope, roleAssignmentName, context).block(); + } + /** * Get the specified role assignment. * @@ -126,6 +223,44 @@ public Mono> getWithRestResponseAsync(String vaul return service.get(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); } + /** + * Get the specified role assignment. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignment. + * @param roleAssignmentName The name of the role assignment to get. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return getWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleAssignmentListResult object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignmentListResult listForScope(String vaultBaseUrl, String scope, Context context) { + return listForScopeAsync(vaultBaseUrl, scope, context).block(); + } + /** * Gets role assignments for a scope. * @@ -141,6 +276,44 @@ public Mono> listForScopeWithRestRespon return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listForScopeAsync(String vaultBaseUrl, String scope, Context context) { + return listForScopeWithRestResponseAsync(vaultBaseUrl, scope, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleAssignmentListResult object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignmentListResult listForScope(String vaultBaseUrl, String scope, String filter, Context context) { + return listForScopeAsync(vaultBaseUrl, scope, filter, context).block(); + } + /** * Gets role assignments for a scope. * @@ -155,4 +328,26 @@ public Mono> listForScopeWithRestRespon public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } + + /** + * Gets role assignments for a scope. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role assignments. + * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listForScopeAsync(String vaultBaseUrl, String scope, String filter, Context context) { + return listForScopeWithRestResponseAsync(vaultBaseUrl, scope, filter, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index cac25bf6bc89..556752f6ccfd 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -60,6 +60,22 @@ private interface RoleDefinitionsService { Mono> list(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); } + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleDefinitionListResult object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleDefinitionListResult list(String vaultBaseUrl, String scope, Context context) { + return listAsync(vaultBaseUrl, scope, context).block(); + } + /** * Get all role definitions that are applicable at scope and above. * @@ -75,6 +91,44 @@ public Mono> listWithRestResponseAsync( return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAsync(String vaultBaseUrl, String scope, Context context) { + return listWithRestResponseAsync(vaultBaseUrl, scope, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the RoleDefinitionListResult object if successful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleDefinitionListResult list(String vaultBaseUrl, String scope, String filter, Context context) { + return listAsync(vaultBaseUrl, scope, filter, context).block(); + } + /** * Get all role definitions that are applicable at scope and above. * @@ -89,4 +143,26 @@ public Mono> listWithRestResponseAsync( public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @return a Mono which performs the network request upon subscription. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAsync(String vaultBaseUrl, String scope, String filter, Context context) { + return listWithRestResponseAsync(vaultBaseUrl, scope, filter, context) + .flatMap((SimpleResponse res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md index 198ae167c139..0210faa3f63e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -38,7 +38,7 @@ models-subpackage: implementation.models custom-types-subpackage: models generate-client-as-impl: true generate-client-interfaces: false -sync-methods: none +sync-methods: all add-context-parameter: true ``` From 3b627b580140017d8d6d8482e8135b60b0357812 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 13:50:47 -0700 Subject: [PATCH 04/40] Modified the AutoRest specification to generate async methods only. Renamed the generated AccessControl client and builder. --- ...va => AccessControlRestClientBuilder.java} | 22 +- ....java => AccessControlRestClientImpl.java} | 14 +- .../implementation/RoleAssignmentsImpl.java | 205 +----------------- .../implementation/RoleDefinitionsImpl.java | 86 +------- .../implementation/models/package-info.java | 2 +- .../implementation/package-info.java | 2 +- .../swagger/README.md | 6 +- 7 files changed, 33 insertions(+), 304 deletions(-) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/{AccessControlClientBuilder.java => AccessControlRestClientBuilder.java} (65%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/{AccessControlClientImpl.java => AccessControlRestClientImpl.java} (84%) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java similarity index 65% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java index f06623dddf00..b9a61f633ae7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java @@ -12,10 +12,10 @@ import com.azure.core.http.policy.UserAgentPolicy; /** - * A builder for creating a new instance of the AccessControlClient type. + * A builder for creating a new instance of the AccessControlRestClient type. */ -@ServiceClientBuilder(serviceClients = AccessControlClientImpl.class) -public final class AccessControlClientBuilder { +@ServiceClientBuilder(serviceClients = AccessControlRestClientImpl.class) +public final class AccessControlRestClientBuilder { /* * Client API version. */ @@ -25,9 +25,9 @@ public final class AccessControlClientBuilder { * Sets Client API version. * * @param apiVersion the apiVersion value. - * @return the AccessControlClientBuilder. + * @return the AccessControlRestClientBuilder. */ - public AccessControlClientBuilder apiVersion(String apiVersion) { + public AccessControlRestClientBuilder apiVersion(String apiVersion) { this.apiVersion = apiVersion; return this; } @@ -41,23 +41,23 @@ public AccessControlClientBuilder apiVersion(String apiVersion) { * Sets The HTTP pipeline to send requests through. * * @param pipeline the pipeline value. - * @return the AccessControlClientBuilder. + * @return the AccessControlRestClientBuilder. */ - public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { + public AccessControlRestClientBuilder pipeline(HttpPipeline pipeline) { this.pipeline = pipeline; return this; } /** - * Builds an instance of AccessControlClientImpl with the provided parameters. + * Builds an instance of AccessControlRestClientImpl with the provided parameters. * - * @return an instance of AccessControlClientImpl. + * @return an instance of AccessControlRestClientImpl. */ - public AccessControlClientImpl build() { + public AccessControlRestClientImpl build() { if (pipeline == null) { this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build(); } - AccessControlClientImpl client = new AccessControlClientImpl(pipeline); + AccessControlRestClientImpl client = new AccessControlRestClientImpl(pipeline); if (this.apiVersion != null) { client.setApiVersion(this.apiVersion); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java similarity index 84% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java index 433a0e665f07..f01f19197d1e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java @@ -11,9 +11,9 @@ import com.azure.core.http.policy.UserAgentPolicy; /** - * Initializes a new instance of the AccessControlClient type. + * Initializes a new instance of the AccessControlRestClient type. */ -public final class AccessControlClientImpl { +public final class AccessControlRestClientImpl { /** * Client API version. */ @@ -33,7 +33,7 @@ public String getApiVersion() { * * @param apiVersion the apiVersion value. */ - AccessControlClientImpl setApiVersion(String apiVersion) { + AccessControlRestClientImpl setApiVersion(String apiVersion) { this.apiVersion = apiVersion; return this; } @@ -81,18 +81,18 @@ public RoleAssignmentsImpl roleAssignments() { } /** - * Initializes an instance of AccessControlClient client. + * Initializes an instance of AccessControlRestClient client. */ - public AccessControlClientImpl() { + public AccessControlRestClientImpl() { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build()); } /** - * Initializes an instance of AccessControlClient client. + * Initializes an instance of AccessControlRestClient client. * * @param httpPipeline The HTTP pipeline to send requests through. */ - public AccessControlClientImpl(HttpPipeline httpPipeline) { + public AccessControlRestClientImpl(HttpPipeline httpPipeline) { this.httpPipeline = httpPipeline; this.roleDefinitions = new RoleDefinitionsImpl(this); this.roleAssignments = new RoleAssignmentsImpl(this); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index d1c990ef80e8..8ec7ad080708 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -39,25 +39,25 @@ public final class RoleAssignmentsImpl { /** * The service client containing this operation class. */ - private AccessControlClientImpl client; + private AccessControlRestClientImpl client; /** * Initializes an instance of RoleAssignmentsImpl. * * @param client the instance of the service client containing this operation class. */ - public RoleAssignmentsImpl(AccessControlClientImpl client) { + public RoleAssignmentsImpl(AccessControlRestClientImpl client) { this.service = RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline()); this.client = client; } /** * The interface defining all the services for - * AccessControlClientRoleAssignments to be used by the proxy service to - * perform REST calls. + * AccessControlRestClientRoleAssignments to be used by the proxy service + * to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlClientRoleAssignments") + @ServiceInterface(name = "AccessControlRestClientRoleAssignments") private interface RoleAssignmentsService { @Delete("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @@ -80,23 +80,6 @@ private interface RoleAssignmentsService { Mono> listForScope(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); } - /** - * Deletes a role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment to delete. - * @param roleAssignmentName The name of the role assignment to delete. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleAssignment object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment delete(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return deleteAsync(vaultBaseUrl, scope, roleAssignmentName, context).block(); - } - /** * Deletes a role assignment. * @@ -112,46 +95,6 @@ public Mono> deleteWithRestResponseAsync(String v return service.delete(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); } - /** - * Deletes a role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment to delete. - * @param roleAssignmentName The name of the role assignment to delete. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return deleteWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } - - /** - * Creates a role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment to create. - * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. - * @param parameters Parameters for the role assignment. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleAssignment object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment create(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { - return createAsync(vaultBaseUrl, scope, roleAssignmentName, parameters, context).block(); - } - /** * Creates a role assignment. * @@ -168,46 +111,6 @@ public Mono> createWithRestResponseAsync(String v return service.create(scope, roleAssignmentName, vaultBaseUrl, parameters, this.client.getApiVersion(), context); } - /** - * Creates a role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment to create. - * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. - * @param parameters Parameters for the role assignment. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createAsync(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { - return createWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, parameters, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } - - /** - * Get the specified role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment. - * @param roleAssignmentName The name of the role assignment to get. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleAssignment object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment get(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return getAsync(vaultBaseUrl, scope, roleAssignmentName, context).block(); - } - /** * Get the specified role assignment. * @@ -223,44 +126,6 @@ public Mono> getWithRestResponseAsync(String vaul return service.get(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); } - /** - * Get the specified role assignment. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignment. - * @param roleAssignmentName The name of the role assignment to get. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return getWithRestResponseAsync(vaultBaseUrl, scope, roleAssignmentName, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } - - /** - * Gets role assignments for a scope. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignments. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleAssignmentListResult object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignmentListResult listForScope(String vaultBaseUrl, String scope, Context context) { - return listForScopeAsync(vaultBaseUrl, scope, context).block(); - } - /** * Gets role assignments for a scope. * @@ -276,44 +141,6 @@ public Mono> listForScopeWithRestRespon return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } - /** - * Gets role assignments for a scope. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignments. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listForScopeAsync(String vaultBaseUrl, String scope, Context context) { - return listForScopeWithRestResponseAsync(vaultBaseUrl, scope, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } - - /** - * Gets role assignments for a scope. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignments. - * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleAssignmentListResult object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignmentListResult listForScope(String vaultBaseUrl, String scope, String filter, Context context) { - return listForScopeAsync(vaultBaseUrl, scope, filter, context).block(); - } - /** * Gets role assignments for a scope. * @@ -328,26 +155,4 @@ public RoleAssignmentListResult listForScope(String vaultBaseUrl, String scope, public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } - - /** - * Gets role assignments for a scope. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignments. - * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listForScopeAsync(String vaultBaseUrl, String scope, String filter, Context context) { - return listForScopeWithRestResponseAsync(vaultBaseUrl, scope, filter, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 556752f6ccfd..4f48cc5f3e48 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -34,25 +34,25 @@ public final class RoleDefinitionsImpl { /** * The service client containing this operation class. */ - private AccessControlClientImpl client; + private AccessControlRestClientImpl client; /** * Initializes an instance of RoleDefinitionsImpl. * * @param client the instance of the service client containing this operation class. */ - public RoleDefinitionsImpl(AccessControlClientImpl client) { + public RoleDefinitionsImpl(AccessControlRestClientImpl client) { this.service = RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline()); this.client = client; } /** * The interface defining all the services for - * AccessControlClientRoleDefinitions to be used by the proxy service to - * perform REST calls. + * AccessControlRestClientRoleDefinitions to be used by the proxy service + * to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlClientRoleDefinitions") + @ServiceInterface(name = "AccessControlRestClientRoleDefinitions") private interface RoleDefinitionsService { @Get("{scope}/providers/Microsoft.Authorization/roleDefinitions") @ExpectedResponses({200}) @@ -60,22 +60,6 @@ private interface RoleDefinitionsService { Mono> list(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); } - /** - * Get all role definitions that are applicable at scope and above. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role definition. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleDefinitionListResult object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleDefinitionListResult list(String vaultBaseUrl, String scope, Context context) { - return listAsync(vaultBaseUrl, scope, context).block(); - } - /** * Get all role definitions that are applicable at scope and above. * @@ -91,44 +75,6 @@ public Mono> listWithRestResponseAsync( return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } - /** - * Get all role definitions that are applicable at scope and above. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role definition. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listAsync(String vaultBaseUrl, String scope, Context context) { - return listWithRestResponseAsync(vaultBaseUrl, scope, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } - - /** - * Get all role definitions that are applicable at scope and above. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the RoleDefinitionListResult object if successful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public RoleDefinitionListResult list(String vaultBaseUrl, String scope, String filter, Context context) { - return listAsync(vaultBaseUrl, scope, filter, context).block(); - } - /** * Get all role definitions that are applicable at scope and above. * @@ -143,26 +89,4 @@ public RoleDefinitionListResult list(String vaultBaseUrl, String scope, String f public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); } - - /** - * Get all role definitions that are applicable at scope and above. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listAsync(String vaultBaseUrl, String scope, String filter, Context context) { - return listWithRestResponseAsync(vaultBaseUrl, scope, filter, context) - .flatMap((SimpleResponse res) -> { - if (res.getValue() != null) { - return Mono.just(res.getValue()); - } else { - return Mono.empty(); - } - }); - } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java index e01c674f7e77..2374210d9914 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for AccessControlClient. + * Package containing the data models for AccessControlRestClient. * The key vault client performs cryptographic key operations and vault * operations against the Key Vault service. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java index 61924df92481..1159d219ebe7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java @@ -4,7 +4,7 @@ /** * Package containing the implementations and inner classes for - * AccessControlClient. + * AccessControlRestClient. * The key vault client performs cryptographic key operations and vault * operations against the Key Vault service. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md index 0210faa3f63e..57bf16ca271c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -38,7 +38,7 @@ models-subpackage: implementation.models custom-types-subpackage: models generate-client-as-impl: true generate-client-interfaces: false -sync-methods: all +sync-methods: none add-context-parameter: true ``` @@ -46,6 +46,6 @@ add-context-parameter: true These settings apply only when `--tag=package-2019-05-searchservice-preview` is specified on the command line. ``` yaml $(tag) == 'rbac-preview' -input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2/rbac.json -title: AccessControlClient +input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/rbac.json +title: AccessControlRestClient ``` From e4917eb7a8f2457a4da3674844fdb02fd1e88a82 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 13:52:36 -0700 Subject: [PATCH 05/40] Created the AccessControl builder and clients (sync + async), public API for getting Role Definitions and some helper classes and resources. --- .../AccessControlAsyncClient.java | 155 +++++++++ .../administration/AccessControlClient.java | 91 +++++ .../AccessControlClientBuilder.java | 310 ++++++++++++++++++ .../AccessControlServiceVersion.java | 34 ++ .../KeyVaultCredentialPolicy.java | 118 +++++++ .../KeyVaultErrorCodeStrings.java | 48 +++ .../implementation/ScopeTokenCache.java | 60 ++++ .../azure-key-vault-administration.properties | 2 + .../main/resources/kvErrorStrings.properties | 2 + 9 files changed, 820 insertions(+) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/resources/azure-key-vault-administration.properties create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java new file mode 100644 index 000000000000..b66d4413534c --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java @@ -0,0 +1,155 @@ +package com.azure.security.keyvault.administration; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.security.keyvault.administration.implementation.AccessControlRestClientBuilder; +import com.azure.security.keyvault.administration.implementation.AccessControlRestClientImpl; +import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; +import reactor.core.publisher.Mono; + +import java.net.URL; +import java.util.Objects; + +import static com.azure.core.util.FluxUtil.monoError; +import static com.azure.core.util.FluxUtil.withContext; +import static com.azure.core.util.tracing.Tracer.AZ_TRACING_NAMESPACE_KEY; + +/** + * The {@link AccessControlClient} provides synchronous and asynchronous methods to view and manage Role Based Access + * for the Azure Key Vault. The client supports creating, listing, updating, and deleting + * {@link com.azure.security.keyvault.administration.implementation.models.RoleAssignment}. Additionally, the + * client supports listing {@link com.azure.security.keyvault.administration.implementation.models.RoleDefinition}. + */ +@ServiceClient(builder = AccessControlClientBuilder.class, isAsync = true) +public class AccessControlAsyncClient { + // Please see here + // for more information on Azure resource provider namespaces. + private static final String KEYVAULT_TRACING_NAMESPACE_VALUE = "Microsoft.KeyVault"; + + /** + * The logger to be used. + */ + private final ClientLogger logger = new ClientLogger(AccessControlAsyncClient.class); + + /** + * The underlying AutoRest client used to interact with the Key Vault service. + */ + private final AccessControlRestClientImpl restClient; + + /** + * The Kay Vault URI this client is associated to. + */ + private final String vaultUrl; + + /** + * Role-based Access Control REST API version. + */ + private final String serviceVersion; + + /** + * Package private constructor to be used by {@link AccessControlClientBuilder}. + */ + AccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline, AccessControlServiceVersion serviceVersion) { + Objects.requireNonNull(vaultUrl, + KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); + + this.vaultUrl = vaultUrl.toString(); + this.serviceVersion = serviceVersion.getVersion(); + + restClient = new AccessControlRestClientBuilder() + .apiVersion(serviceVersion.getVersion()) + .pipeline(httpPipeline) + .build(); + } + + /** + * Gets the URI for the Key Vault this client is associated to. + * + * @return The Key Vault URI. + */ + public String getVaultUrl() { + return this.vaultUrl; + } + + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @return A Mono containing the {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listRoleDefinitions(String scope) { + return listRoleDefinitions(scope, null); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @return A Mono containing the {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listRoleDefinitions(String scope, String filter) { + try { + return listRoleDefinitionsWithResponse(scope, filter).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listRoleDefinitionsWithResponse(String scope) { + return listRoleDefinitionsWithResponse(scope, null); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listRoleDefinitionsWithResponse(String scope, String filter) { + try { + return withContext(context -> listRoleDefinitionsWithResponse(vaultUrl, scope, filter, context)); + } catch (RuntimeException e) { + return monoError(logger, e); + } + } + + Mono> listRoleDefinitionsWithResponse(String vaultUrl, String scope, + String filter, Context context) { + return restClient.roleDefinitions().listWithRestResponseAsync(vaultUrl, scope, filter, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) + .doOnSuccess(response -> logger.info("Retrieved role definitions for scope - {}", scope)) + .doOnError(error -> logger.warning("Failed to list role definitions for scope - {}", scope)); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java new file mode 100644 index 000000000000..6ecb083ee8a1 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java @@ -0,0 +1,91 @@ +package com.azure.security.keyvault.administration; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; + +public class AccessControlClient { + private final AccessControlAsyncClient asyncClient; + + /** + * Creates an {@link AccessControlClient} that uses a {@code pipeline} to service requests + * + * @param asyncClient The {@link AccessControlAsyncClient} that the client routes its request through. + */ + AccessControlClient(AccessControlAsyncClient asyncClient) { + this.asyncClient = asyncClient; + } + + /** + * Get the vault endpoint URL. + * + * @return The vault endpoint URL. + */ + public String getVaultUrl() { + return asyncClient.getVaultUrl(); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @return The {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleDefinitionListResult listRoleDefinitions(String scope) { + return listRoleDefinitions(scope, null); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @return The {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleDefinitionListResult listRoleDefinitions(String scope, String filter) { + return listRoleDefinitionsWithResponse(scope, filter, Context.NONE).getValue(); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SimpleResponse listRoleDefinitionsWithResponse(String scope, Context context) { + return listRoleDefinitionsWithResponse(scope, null, context); + } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * {@link RoleDefinitionListResult list of role definitions}. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SimpleResponse listRoleDefinitionsWithResponse(String scope, String filter, + Context context) { + return asyncClient.listRoleDefinitionsWithResponse(asyncClient.getVaultUrl(), scope, filter, context).block(); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java new file mode 100644 index 000000000000..88386bfc8f9d --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java @@ -0,0 +1,310 @@ +package com.azure.security.keyvault.administration; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.*; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.security.keyvault.administration.implementation.KeyVaultCredentialPolicy; +import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * This class provides a fluent builder API to help aid the configuration and instantiation of the + * {@link AccessControlAsyncClient} and {@link AccessControlClient}, by calling + * {@link AccessControlClientBuilder#buildAsyncClient()} and {@link AccessControlClientBuilder#buildClient()} + * respectively. It constructs an instance of the desired client. + * + *

The minimal configuration options required by {@link AccessControlClientBuilder} to build an + * an {@link AccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

+ *

+ * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.instantiation} + * + *

The {@link HttpLogDetailLevel}, multiple custom {@link HttpLoggingPolicy policies} and custom + * {@link HttpClient} can be optionally configured in the {@link AccessControlClientBuilder}.

+ *

+ * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.withhttpclient.instantiation} + * + *

Alternatively, a custom {@link HttpPipeline} with custom {@link HttpPipelinePolicy} policies and {@link String + * vaultUrl} can be specified. It provides finer control over the construction of {@link AccessControlAsyncClient} + * and {@link AccessControlClient} instances.

+ *

+ * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.pipeline.instantiation} + * + *

The minimal configuration options required by {@link AccessControlClientBuilder} to build an + * {@link AccessControlClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

+ *

+ * {@codesnippet com.azure.security.keyvault.keys.accesscontrolclient.instantiation} + * + * @see AccessControlAsyncClient + * @see AccessControlClient + */ +public class AccessControlClientBuilder { + // This is the properties file name. + private static final String AZURE_KEY_VAULT_RBAC = "azure-key-vault-administration.properties"; + private static final String SDK_NAME = "name"; + private static final String SDK_VERSION = "version"; + + private final ClientLogger logger = new ClientLogger(AccessControlClientBuilder.class); + private final List policies; + private final Map properties; + + private TokenCredential credential; + private HttpPipeline pipeline; + private URL vaultUrl; + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private RetryPolicy retryPolicy; + private Configuration configuration; + private AccessControlServiceVersion version; + + /** + * Creates a {@link AccessControlClientBuilder} instance that is able to configure and construct + * instances of {@link AccessControlClient} and {@link AccessControlAsyncClient}. + */ + public AccessControlClientBuilder() { + retryPolicy = new RetryPolicy(); + httpLogOptions = new HttpLogOptions(); + policies = new ArrayList<>(); + properties = CoreUtils.getProperties(AZURE_KEY_VAULT_RBAC); + } + + /** + * Creates an {@link AccessControlClient} based on options set in the Builder. Every time {@code buildClient()} + * is called a new instance of {@link AccessControlClient} is created. + *

+ * If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and + * {@link #vaultUrl(String) vaultUrl} are used to create the {@link AccessControlClient client}. All other + * builder settings are ignored. + * + * @return An {@link AccessControlClient} with the options set from the builder. + * @throws NullPointerException If {@code vaultUrl} is {@code null}. + */ + public AccessControlClient buildClient() { + return new AccessControlClient(buildAsyncClient()); + } + + /** + * Creates a {@link AccessControlAsyncClient} based on options set in the Builder. Every time {@code + * buildAsyncClient()} is called a new instance of {@link AccessControlAsyncClient} is created. + *

+ * If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and + * {@link #vaultUrl(String) endpoint} are used to create the {@link AccessControlAsyncClient client}. All other + * builder settings are ignored. + * + * @return An {@link AccessControlAsyncClient} with the options set from the builder. + * @throws NullPointerException If {@code vaultUrl} is {@code null}. + */ + public AccessControlAsyncClient buildAsyncClient() { + Configuration buildConfiguration = (configuration == null) + ? Configuration.getGlobalConfiguration().clone() + : configuration; + + URL buildEndpoint = getBuildEndpoint(buildConfiguration); + + if (buildEndpoint == null) { + throw logger.logExceptionAsError( + new IllegalStateException( + KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); + } + + AccessControlServiceVersion buildVersion = (version == null) + ? AccessControlServiceVersion.getLatest() + : version; + + if (pipeline != null) { + return new AccessControlAsyncClient(vaultUrl, pipeline, buildVersion); + } + + // Closest to API goes first, closest to wire goes last. + final List policies = new ArrayList<>(); + + String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); + + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, + buildConfiguration)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); + this.policies.add(new KeyVaultCredentialPolicy(credential)); + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + + HttpPipeline buildPipeline = new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .build(); + + return new AccessControlAsyncClient(vaultUrl, buildPipeline, buildVersion); + } + + /** + * Sets the URI to the Key Vault on which the client operates. Appears as "DNS Name" in the Azure portal. + * + * @param vaultUrl The vault URL is used as destination on Azure to send requests to. + * @return The updated {@link AccessControlClientBuilder} object. + * @throws IllegalArgumentException If {@code vaultUrl} is null or it cannot be parsed into a valid URL. + */ + public AccessControlClientBuilder vaultUrl(String vaultUrl) { + try { + this.vaultUrl = new URL(vaultUrl); + } catch (MalformedURLException e) { + throw logger.logExceptionAsWarning( + new IllegalArgumentException("The Azure Key Vault URL is malformed.", e)); + } + + return this; + } + + /** + * Sets the credential to use when authenticating HTTP requests. + * + * @param credential The credential to use for authenticating HTTP requests. + * @return The updated {@link AccessControlClientBuilder} object. + * @throws NullPointerException If {@code credential} is {@code null}. + */ + public AccessControlClientBuilder credential(TokenCredential credential) { + Objects.requireNonNull(credential); + + this.credential = credential; + + return this; + } + + /** + * Sets the logging configuration for HTTP requests and responses. + * + *

If logLevel is not provided, default value of {@link HttpLogDetailLevel#NONE} is set.

+ * + * @param logOptions The logging configuration to use when sending and receiving HTTP requests/responses. + * @return The updated {@link AccessControlClientBuilder} object. + */ + public AccessControlClientBuilder httpLogOptions(HttpLogOptions logOptions) { + httpLogOptions = logOptions; + + return this; + } + + /** + * Adds a policy to the set of existing policies that are executed after and {@link AccessControlClient} + * {@link AccessControlAsyncClient} required policies. + * + * @param policy The {@link HttpPipelinePolicy policy} to be added. + * @return The updated {@link AccessControlClientBuilder} object. + * @throws NullPointerException If {@code policy} is {@code null}. + */ + public AccessControlClientBuilder addPolicy(HttpPipelinePolicy policy) { + Objects.requireNonNull(policy); + + policies.add(policy); + + return this; + } + + /** + * Sets the HTTP client to use for sending and receiving requests to and from the service. + * + * @param client The HTTP client to use for requests. + * @return The updated {@link AccessControlClientBuilder} object. + * @throws NullPointerException If {@code client} is {@code null}. + */ + public AccessControlClientBuilder httpClient(HttpClient client) { + Objects.requireNonNull(client); + + this.httpClient = client; + + return this; + } + + /** + * Sets the HTTP pipeline to use for the service client. + *

+ * If {@code pipeline} is set, all other settings are ignored, aside from + * {@link AccessControlClientBuilder#vaultUrl(String) vaultUrl} to build {@link AccessControlClient} or + * {@link AccessControlAsyncClient}. + * + * @param pipeline The HTTP pipeline to use for sending service requests and receiving responses. + * @return The updated {@link AccessControlClientBuilder} object. + */ + public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { + Objects.requireNonNull(pipeline); + this.pipeline = pipeline; + return this; + } + + /** + * Sets the {@link AccessControlServiceVersion} that is used when making API requests. + *

+ * If a service version is not provided, the service version that will be used will be the latest known service + * version based on the version of the client library being used. If no service version is specified, updating to a + * newer version the client library will have the result of potentially moving to a newer service version. + * + * @param version {@link AccessControlServiceVersion} of the service to be used when making requests. + * @return The updated {@link AccessControlClientBuilder} object. + */ + public AccessControlClientBuilder serviceVersion(AccessControlServiceVersion version) { + this.version = version; + + return this; + } + + /** + * Sets the configuration store that is used during construction of the service client. + *

+ * The default configuration store is a clone of the {@link Configuration#getGlobalConfiguration() global + * configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction. + * + * @param configuration The configuration store used to get configuration details. + * @return The updated {@link AccessControlClientBuilder} object. + */ + public AccessControlClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + + return this; + } + + /** + * Sets the {@link RetryPolicy} that is used when each request is sent. + *

+ * The default retry policy will be used in the pipeline, if not provided. + * + * @param retryPolicy User's retry policy applied to each request. + * @return The updated {@link AccessControlClientBuilder} object. + * @throws NullPointerException If the specified {@code retryPolicy} is null. + */ + public AccessControlClientBuilder retryPolicy(RetryPolicy retryPolicy) { + Objects.requireNonNull(retryPolicy, "The retry policy cannot be bull"); + + this.retryPolicy = retryPolicy; + + return this; + } + + private URL getBuildEndpoint(Configuration configuration) { + if (vaultUrl != null) { + return vaultUrl; + } + + String configEndpoint = configuration.get("AZURE_KEYVAULT_ENDPOINT"); + + if (CoreUtils.isNullOrEmpty(configEndpoint)) { + return null; + } + + try { + return new URL(configEndpoint); + } catch (MalformedURLException ex) { + return null; + } + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java new file mode 100644 index 000000000000..7ff4b3d76758 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java @@ -0,0 +1,34 @@ +package com.azure.security.keyvault.administration; + +import com.azure.core.util.ServiceVersion; + +/** + * The versions of Azure Form Recognizer supported by this client library. + */ +public enum AccessControlServiceVersion implements ServiceVersion { + V7_2_preview("7.2-preview"); + + private final String version; + + AccessControlServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library + * + * @return the latest {@link AccessControlServiceVersion} + */ + public static AccessControlServiceVersion getLatest() { + return V7_2_preview; + } +} + diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java new file mode 100644 index 000000000000..cb97c84877f0 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.credential.TokenRequestContext; +import com.azure.core.http.HttpPipelineCallContext; +import com.azure.core.http.HttpPipelineNextPolicy; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import reactor.core.publisher.Mono; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; + +/** + * A policy that authenticates requests with Azure Key Vault service. The content added by this policy + * is leveraged in {@link TokenCredential} to get and set the correct "Authorization" header value. + * + * @see TokenCredential + */ +public final class KeyVaultCredentialPolicy implements HttpPipelinePolicy { + private final ClientLogger logger = new ClientLogger(KeyVaultCredentialPolicy.class); + private static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + private static final String BEARER_TOKEN_PREFIX = "Bearer "; + private static final String AUTHORIZATION = "Authorization"; + private final ScopeTokenCache cache; + + /** + * Creates KeyVaultCredentialPolicy. + * + * @param credential the token credential to authenticate the request + */ + public KeyVaultCredentialPolicy(TokenCredential credential) { + Objects.requireNonNull(credential); + this.cache = new ScopeTokenCache((request) -> credential.getToken(request)); + } + + /** + * Adds the required header to authenticate a request to Azure Key Vault service. + * + * @param context The request context + * @param next The next HTTP pipeline policy to process the {@code context's} request after this policy completes. + * @return A {@link Mono} representing the HTTP response that will arrive asynchronously. + */ + @Override + public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { + if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) { + return Mono.error(new RuntimeException("Token credentials require a URL using the HTTPS protocol scheme")); + } + return next.clone().process() + .doOnNext(httpResponse -> { + // KV follows challenge based auth. Currently every service + // call hit the endpoint for challenge and then resend the + // request with token. The challenge response body is not + // consumed, not draining/closing the body will result in leak. + // Ref: https://github.com/Azure/azure-sdk-for-java/issues/7934 + // https://github.com/Azure/azure-sdk-for-java/issues/10467 + try { + httpResponse.getBody().subscribe().dispose(); + } catch (RuntimeException ignored) { + logger.logExceptionAsWarning(ignored); + } + // The ReactorNettyHttpResponse::close() should be sufficient + // and should take care similar body disposal but looks like that + // is not happening, need to re-visit the close() method. + }) + .map(res -> res.getHeaderValue(WWW_AUTHENTICATE)) + .map(header -> extractChallenge(header, BEARER_TOKEN_PREFIX)) + .flatMap(map -> { + cache.setTokenRequest(new TokenRequestContext().addScopes(map.get("resource") + "/.default")); + return cache.getToken(); + }) + .flatMap(token -> { + context.getHttpRequest().setHeader(AUTHORIZATION, BEARER_TOKEN_PREFIX + token.getToken()); + return next.process(); + }); + } + + /** + * Extracts the challenge off the authentication header. + * + * @param authenticateHeader The authentication header containing all the challenges. + * @param authChallengePrefix The authentication challenge name. + * @return a challenge map. + */ + private static Map extractChallenge(String authenticateHeader, String authChallengePrefix) { + if (!isValidChallenge(authenticateHeader, authChallengePrefix)) { + return null; + } + authenticateHeader = + authenticateHeader.toLowerCase(Locale.ROOT).replace(authChallengePrefix.toLowerCase(Locale.ROOT), ""); + + String[] challenges = authenticateHeader.split(", "); + Map challengeMap = new HashMap<>(); + for (String pair : challenges) { + String[] keyValue = pair.split("="); + challengeMap.put(keyValue[0].replaceAll("\"", ""), keyValue[1].replaceAll("\"", "")); + } + return challengeMap; + } + + /** + * Verifies whether a challenge is bearer or not. + * + * @param authenticateHeader The authentication header containing all the challenges. + * @param authChallengePrefix The authentication challenge name. + * @return A boolean indicating tha challenge is valid or not. + */ + private static boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { + return (!CoreUtils.isNullOrEmpty(authenticateHeader) + && authenticateHeader.toLowerCase(Locale.ROOT).startsWith(authChallengePrefix.toLowerCase(Locale.ROOT))); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java new file mode 100644 index 000000000000..a1a61ce929e8 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.implementation; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class KeyVaultErrorCodeStrings { + static final String ERROR_STRINGS_FILE_NAME = "kvErrorStrings.properties"; + private static Properties errorStrings; + + /** + * The property name of Azure Key Vault Credentials required error string. + */ + public static final String CREDENTIAL_REQUIRED = "credential_required"; + + /** + * The property name of Azure Key Vault Endpoint required error string. + */ + public static final String VAULT_END_POINT_REQUIRED = "vault_endpoint_required"; + + /** + * Gets the error String for the specified property. + * + * @param propertyName the property name for which error string is required. + * @return The {@link String value} containing the error message. + */ + public static String getErrorString(String propertyName) { + loadProperties(); + return errorStrings.getProperty(propertyName); + } + + private static synchronized void loadProperties() { + if (errorStrings == null) { + try (InputStream fileInputStream = + KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { + errorStrings = new Properties(); + errorStrings.load(fileInputStream); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } +} + + diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java new file mode 100644 index 000000000000..c7f1aaba7b6d --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.implementation; + +import com.azure.core.credential.AccessToken; +import com.azure.core.credential.TokenRequestContext; +import reactor.core.publisher.FluxSink; +import reactor.core.publisher.Mono; +import reactor.core.publisher.ReplayProcessor; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; + +/** + * A token cache that supports caching a token and refreshing it. + */ +class ScopeTokenCache { + private final AtomicBoolean wip; + private AccessToken cache; + private final ReplayProcessor emitterProcessor = ReplayProcessor.create(1); + private final FluxSink sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); + private final Function> getNew; + private TokenRequestContext request; + + + /** + * Creates an instance of RefreshableTokenCredential with default scheme "Bearer". + * + * @param getNew a method to get a new token + */ + ScopeTokenCache(Function> getNew) { + this.wip = new AtomicBoolean(false); + this.getNew = getNew; + } + + public void setTokenRequest(TokenRequestContext request) { + this.request = request; + } + + /** + * Asynchronously get a token from either the cache or replenish the cache with a new token. + * @return a Publisher that emits an AccessToken + */ + public Mono getToken() { + if (cache != null && !cache.isExpired()) { + return Mono.just(cache); + } + return Mono.defer(() -> { + if (!wip.getAndSet(true)) { + return getNew.apply(request).doOnNext(ac -> cache = ac) + .doOnNext(sink::next) + .doOnError(sink::error) + .doOnTerminate(() -> wip.set(false)); + } else { + return emitterProcessor.next(); + } + }); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/azure-key-vault-administration.properties b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/azure-key-vault-administration.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/azure-key-vault-administration.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties new file mode 100644 index 000000000000..ff2560ce762e --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties @@ -0,0 +1,2 @@ +credential_required=Azure Key Vault credentials are required. +vault_endpoint_required=Azure Key Vault endpoint url is required. From f9eebad72ea6bb3b52ad012fbbb554640d2d33cf Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 15:40:40 -0700 Subject: [PATCH 06/40] Regenerated classes with AutoRest v4 instead of v3. --- .../AccessControlAsyncClient.java | 126 +++++++------- .../administration/AccessControlClient.java | 57 ++----- .../AccessControlClientBuilder.java | 27 +-- .../AccessControlServiceVersion.java | 34 ---- .../AccessControlRestClientImpl.java | 53 ++---- ...> AccessControlRestClientImplBuilder.java} | 38 ++--- .../implementation/RoleAssignmentsImpl.java | 160 ++++++++++++------ .../implementation/RoleDefinitionsImpl.java | 92 ++++++---- .../implementation/models/Error.java | 12 +- .../implementation/models/KeyVaultError.java | 12 +- .../models/KeyVaultErrorException.java | 4 +- .../implementation/models/Permission.java | 4 +- .../implementation/models/RoleAssignment.java | 4 +- .../RoleAssignmentCreateParameters.java | 4 +- .../models/RoleAssignmentFilter.java | 10 +- .../models/RoleAssignmentListResult.java | 10 +- .../models/RoleAssignmentProperties.java | 20 +-- .../RoleAssignmentPropertiesWithScope.java | 4 +- .../implementation/models/RoleDefinition.java | 4 +- .../models/RoleDefinitionFilter.java | 10 +- .../models/RoleDefinitionListResult.java | 10 +- .../implementation/models/package-info.java | 5 +- .../implementation/package-info.java | 6 +- .../swagger/README.md | 6 +- 24 files changed, 321 insertions(+), 391 deletions(-) delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/{AccessControlRestClientBuilder.java => AccessControlRestClientImplBuilder.java} (53%) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java index b66d4413534c..e2689a67fb68 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java @@ -4,14 +4,16 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; -import com.azure.security.keyvault.administration.implementation.AccessControlRestClientBuilder; import com.azure.security.keyvault.administration.implementation.AccessControlRestClientImpl; +import com.azure.security.keyvault.administration.implementation.AccessControlRestClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; import reactor.core.publisher.Mono; @@ -30,6 +32,7 @@ */ @ServiceClient(builder = AccessControlClientBuilder.class, isAsync = true) public class AccessControlAsyncClient { + static final int DEFAULT_MAX_PAGE_RESULTS = 25; // Please see here // for more information on Azure resource provider namespaces. private static final String KEYVAULT_TRACING_NAMESPACE_VALUE = "Microsoft.KeyVault"; @@ -45,111 +48,116 @@ public class AccessControlAsyncClient { private final AccessControlRestClientImpl restClient; /** - * The Kay Vault URI this client is associated to. + * The Kay Vault URL this client is associated to. */ private final String vaultUrl; - /** - * Role-based Access Control REST API version. - */ - private final String serviceVersion; - /** * Package private constructor to be used by {@link AccessControlClientBuilder}. */ - AccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline, AccessControlServiceVersion serviceVersion) { + AccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline) { Objects.requireNonNull(vaultUrl, KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); this.vaultUrl = vaultUrl.toString(); - this.serviceVersion = serviceVersion.getVersion(); - restClient = new AccessControlRestClientBuilder() - .apiVersion(serviceVersion.getVersion()) + restClient = new AccessControlRestClientImplBuilder() .pipeline(httpPipeline) - .build(); + .buildClient(); } /** - * Gets the URI for the Key Vault this client is associated to. + * Gets the URL for the Key Vault this client is associated with. * - * @return The Key Vault URI. + * @return The Key Vault URL. */ public String getVaultUrl() { return this.vaultUrl; } - /** * Get all role definitions that are applicable at scope and above. * - * @param scope The scope of the role definition. - * @return A Mono containing the {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listRoleDefinitions(String scope) { - return listRoleDefinitions(scope, null); - } - - /** - * Get all role definitions that are applicable at scope and above. - * - * @param scope The scope of the role definition. - * @return A Mono containing the {@link RoleDefinitionListResult list of role definitions}. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * {@link RoleDefinitionListResult list of role definitions}. * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the * operation is unsuccessful. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono listRoleDefinitions(String scope, String filter) { + public PagedFlux listRoleDefinitions(String scope, String filter) { try { - return listRoleDefinitionsWithResponse(scope, filter).flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(logger, ex); + return new PagedFlux<>( + () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, filter, context)), + continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); + } catch (RuntimeException e) { + return new PagedFlux<>(() -> monoError(logger, e)); } } /** * Get all role definitions that are applicable at scope and above. * - * @param scope The scope of the role definition. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the * {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listRoleDefinitionsWithResponse(String scope) { - return listRoleDefinitionsWithResponse(scope, null); + PagedFlux listRoleDefinitions(String scope, String filter, Context context) { + return new PagedFlux<>( + () -> listRoleDefinitionsFirstPage(vaultUrl, scope, filter, context), + continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); } /** - * Get all role definitions that are applicable at scope and above. + * Gets role definitions in the first page. * - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the - * {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. + * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} of {@link PagedResponse} from the first page of results. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listRoleDefinitionsWithResponse(String scope, String filter) { + Mono> listRoleDefinitionsFirstPage(String vaultUrl, String scope, String filter, + Context context) { try { - return withContext(context -> listRoleDefinitionsWithResponse(vaultUrl, scope, filter, context)); + return restClient.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope, filter, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> + logger.info("Listing role definitions for scope - {}", scope)) + .doOnSuccess(response -> + logger.info("Listed role definitions for scope - {}", scope)) + .doOnError(error -> + logger.warning(String.format("Failed to list role definitions for scope - %s", scope), error)); } catch (RuntimeException e) { return monoError(logger, e); } } - Mono> listRoleDefinitionsWithResponse(String vaultUrl, String scope, - String filter, Context context) { - return restClient.roleDefinitions().listWithRestResponseAsync(vaultUrl, scope, filter, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) - .doOnSuccess(response -> logger.info("Retrieved role definitions for scope - {}", scope)) - .doOnError(error -> logger.warning("Failed to list role definitions for scope - {}", scope)); + /** + * Gets all the role definitions given by the {@code nextPageLink} that was retrieved from a call to + * {@link AccessControlAsyncClient#listRoleDefinitions(String, String)} ()}. + * + * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, + * successful call to one of the listRoleDefinitions operations. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} of {@link PagedResponse} from the next page of results. + */ + Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { + try { + return restClient.getRoleDefinitions().listNextSinglePageAsync(continuationToken, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Listing next role definitions page - Page {}", continuationToken)) + .doOnSuccess(response -> logger.info("Listed next role definitions page - Page {}", continuationToken)) + .doOnError(error -> logger.warning("Failed to list next role definitions page - Page {}", + continuationToken, error)); + } catch (RuntimeException e) { + return monoError(logger, e); + } } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java index 6ecb083ee8a1..63f323517271 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java @@ -2,9 +2,11 @@ import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; public class AccessControlClient { @@ -31,61 +33,30 @@ public String getVaultUrl() { /** * Get all role definitions that are applicable at scope and above. * - * @param scope The scope of the role definition. - * @return The {@link RoleDefinitionListResult list of role definitions}. + * @param scope The scope of the role definition. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the * operation is unsuccessful. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleDefinitionListResult listRoleDefinitions(String scope) { - return listRoleDefinitions(scope, null); + public PagedIterable listRoleDefinitions(String scope, Context context) { + return listRoleDefinitions(scope, null, context); } /** * Get all role definitions that are applicable at scope and above. * - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @return The {@link RoleDefinitionListResult list of role definitions}. + * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the * operation is unsuccessful. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleDefinitionListResult listRoleDefinitions(String scope, String filter) { - return listRoleDefinitionsWithResponse(scope, filter, Context.NONE).getValue(); - } - - /** - * Get all role definitions that are applicable at scope and above. - * - * @param scope The scope of the role definition. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link SimpleResponse response} whose {@link Response#getValue() value} contains the - * {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SimpleResponse listRoleDefinitionsWithResponse(String scope, Context context) { - return listRoleDefinitionsWithResponse(scope, null, context); - } - - /** - * Get all role definitions that are applicable at scope and above. - * - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link SimpleResponse response} whose {@link Response#getValue() value} contains the - * {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public SimpleResponse listRoleDefinitionsWithResponse(String scope, String filter, - Context context) { - return asyncClient.listRoleDefinitionsWithResponse(asyncClient.getVaultUrl(), scope, filter, context).block(); + public PagedIterable listRoleDefinitions(String scope, String filter, Context context) { + return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, filter, context)); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java index 88386bfc8f9d..f74f67578692 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java @@ -65,7 +65,6 @@ public class AccessControlClientBuilder { private HttpLogOptions httpLogOptions; private RetryPolicy retryPolicy; private Configuration configuration; - private AccessControlServiceVersion version; /** * Creates a {@link AccessControlClientBuilder} instance that is able to configure and construct @@ -117,12 +116,8 @@ public AccessControlAsyncClient buildAsyncClient() { KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); } - AccessControlServiceVersion buildVersion = (version == null) - ? AccessControlServiceVersion.getLatest() - : version; - if (pipeline != null) { - return new AccessControlAsyncClient(vaultUrl, pipeline, buildVersion); + return new AccessControlAsyncClient(vaultUrl, pipeline); } // Closest to API goes first, closest to wire goes last. @@ -145,11 +140,11 @@ public AccessControlAsyncClient buildAsyncClient() { .httpClient(httpClient) .build(); - return new AccessControlAsyncClient(vaultUrl, buildPipeline, buildVersion); + return new AccessControlAsyncClient(vaultUrl, buildPipeline); } /** - * Sets the URI to the Key Vault on which the client operates. Appears as "DNS Name" in the Azure portal. + * Sets the URL to the Key Vault on which the client operates. Appears as "DNS Name" in the Azure portal. * * @param vaultUrl The vault URL is used as destination on Azure to send requests to. * @return The updated {@link AccessControlClientBuilder} object. @@ -242,22 +237,6 @@ public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { return this; } - /** - * Sets the {@link AccessControlServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version the client library will have the result of potentially moving to a newer service version. - * - * @param version {@link AccessControlServiceVersion} of the service to be used when making requests. - * @return The updated {@link AccessControlClientBuilder} object. - */ - public AccessControlClientBuilder serviceVersion(AccessControlServiceVersion version) { - this.version = version; - - return this; - } - /** * Sets the configuration store that is used during construction of the service client. *

diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java deleted file mode 100644 index 7ff4b3d76758..000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlServiceVersion.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.azure.security.keyvault.administration; - -import com.azure.core.util.ServiceVersion; - -/** - * The versions of Azure Form Recognizer supported by this client library. - */ -public enum AccessControlServiceVersion implements ServiceVersion { - V7_2_preview("7.2-preview"); - - private final String version; - - AccessControlServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library - * - * @return the latest {@link AccessControlServiceVersion} - */ - public static AccessControlServiceVersion getLatest() { - return V7_2_preview; - } -} - diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java index f01f19197d1e..5450b7bda636 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java @@ -10,17 +10,13 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; -/** - * Initializes a new instance of the AccessControlRestClient type. - */ +/** Initializes a new instance of the AccessControlRestClient type. */ public final class AccessControlRestClientImpl { - /** - * Client API version. - */ - private String apiVersion; + /** Api Version. */ + private final String apiVersion; /** - * Gets Client API version. + * Gets Api Version. * * @return the apiVersion value. */ @@ -28,20 +24,8 @@ public String getApiVersion() { return this.apiVersion; } - /** - * Sets Client API version. - * - * @param apiVersion the apiVersion value. - */ - AccessControlRestClientImpl setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - /** - * The HTTP pipeline to send requests through. - */ - private HttpPipeline httpPipeline; + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; /** * Gets The HTTP pipeline to send requests through. @@ -52,38 +36,32 @@ public HttpPipeline getHttpPipeline() { return this.httpPipeline; } - /** - * The RoleDefinitionsImpl object to access its operations. - */ - private RoleDefinitionsImpl roleDefinitions; + /** The RoleDefinitionsImpl object to access its operations. */ + private final RoleDefinitionsImpl roleDefinitions; /** * Gets the RoleDefinitionsImpl object to access its operations. * * @return the RoleDefinitionsImpl object. */ - public RoleDefinitionsImpl roleDefinitions() { + public RoleDefinitionsImpl getRoleDefinitions() { return this.roleDefinitions; } - /** - * The RoleAssignmentsImpl object to access its operations. - */ - private RoleAssignmentsImpl roleAssignments; + /** The RoleAssignmentsImpl object to access its operations. */ + private final RoleAssignmentsImpl roleAssignments; /** * Gets the RoleAssignmentsImpl object to access its operations. * * @return the RoleAssignmentsImpl object. */ - public RoleAssignmentsImpl roleAssignments() { + public RoleAssignmentsImpl getRoleAssignments() { return this.roleAssignments; } - /** - * Initializes an instance of AccessControlRestClient client. - */ - public AccessControlRestClientImpl() { + /** Initializes an instance of AccessControlRestClient client. */ + AccessControlRestClientImpl() { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build()); } @@ -92,8 +70,9 @@ public AccessControlRestClientImpl() { * * @param httpPipeline The HTTP pipeline to send requests through. */ - public AccessControlRestClientImpl(HttpPipeline httpPipeline) { + AccessControlRestClientImpl(HttpPipeline httpPipeline) { this.httpPipeline = httpPipeline; + this.apiVersion = "7.2-preview"; this.roleDefinitions = new RoleDefinitionsImpl(this); this.roleAssignments = new RoleAssignmentsImpl(this); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java similarity index 53% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java index b9a61f633ae7..30ec136ab6b0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java @@ -11,27 +11,9 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; -/** - * A builder for creating a new instance of the AccessControlRestClient type. - */ -@ServiceClientBuilder(serviceClients = AccessControlRestClientImpl.class) -public final class AccessControlRestClientBuilder { - /* - * Client API version. - */ - private String apiVersion; - - /** - * Sets Client API version. - * - * @param apiVersion the apiVersion value. - * @return the AccessControlRestClientBuilder. - */ - public AccessControlRestClientBuilder apiVersion(String apiVersion) { - this.apiVersion = apiVersion; - return this; - } - +/** A builder for creating a new instance of the AccessControlRestClient type. */ +@ServiceClientBuilder(serviceClients = {AccessControlRestClientImpl.class}) +public final class AccessControlRestClientImplBuilder { /* * The HTTP pipeline to send requests through */ @@ -41,9 +23,9 @@ public AccessControlRestClientBuilder apiVersion(String apiVersion) { * Sets The HTTP pipeline to send requests through. * * @param pipeline the pipeline value. - * @return the AccessControlRestClientBuilder. + * @return the AccessControlRestClientImplBuilder. */ - public AccessControlRestClientBuilder pipeline(HttpPipeline pipeline) { + public AccessControlRestClientImplBuilder pipeline(HttpPipeline pipeline) { this.pipeline = pipeline; return this; } @@ -53,14 +35,14 @@ public AccessControlRestClientBuilder pipeline(HttpPipeline pipeline) { * * @return an instance of AccessControlRestClientImpl. */ - public AccessControlRestClientImpl build() { + public AccessControlRestClientImpl buildClient() { if (pipeline == null) { - this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build(); + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); } AccessControlRestClientImpl client = new AccessControlRestClientImpl(pipeline); - if (this.apiVersion != null) { - client.setApiVersion(this.apiVersion); - } return client; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index 8ec7ad080708..39a2ed99b0e1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -17,8 +17,10 @@ import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; @@ -26,133 +28,189 @@ import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentListResult; import reactor.core.publisher.Mono; -/** - * An instance of this class provides access to all the operations defined in - * RoleAssignments. - */ +/** An instance of this class provides access to all the operations defined in RoleAssignments. */ public final class RoleAssignmentsImpl { - /** - * The proxy service used to perform REST calls. - */ - private RoleAssignmentsService service; + /** The proxy service used to perform REST calls. */ + private final RoleAssignmentsService service; - /** - * The service client containing this operation class. - */ - private AccessControlRestClientImpl client; + /** The service client containing this operation class. */ + private final AccessControlRestClientImpl client; /** * Initializes an instance of RoleAssignmentsImpl. * * @param client the instance of the service client containing this operation class. */ - public RoleAssignmentsImpl(AccessControlRestClientImpl client) { + RoleAssignmentsImpl(AccessControlRestClientImpl client) { this.service = RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline()); this.client = client; } /** - * The interface defining all the services for - * AccessControlRestClientRoleAssignments to be used by the proxy service - * to perform REST calls. + * The interface defining all the services for AccessControlRestClientRoleAssignments to be used by the proxy + * service to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlRestClientRoleAssignments") + @ServiceInterface(name = "AccessControlRestCli") private interface RoleAssignmentsService { - @Delete("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @Delete("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> delete(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("api-version") String apiVersion, Context context); + Mono> delete( + @HostParam("vaultBaseUrl") String vaultBaseUrl, + @PathParam(value = "scope", encoded = true) String scope, + @PathParam("roleAssignmentName") String roleAssignmentName, + @QueryParam("api-version") String apiVersion, + Context context); - @Put("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @Put("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({201}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> create(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @BodyParam("application/json; charset=utf-8") RoleAssignmentCreateParameters parameters, @QueryParam("api-version") String apiVersion, Context context); + Mono> create( + @HostParam("vaultBaseUrl") String vaultBaseUrl, + @PathParam(value = "scope", encoded = true) String scope, + @PathParam("roleAssignmentName") String roleAssignmentName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") RoleAssignmentCreateParameters parameters, + Context context); - @Get("{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> get(@PathParam("scope") String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("api-version") String apiVersion, Context context); + Mono> get( + @HostParam("vaultBaseUrl") String vaultBaseUrl, + @PathParam(value = "scope", encoded = true) String scope, + @PathParam("roleAssignmentName") String roleAssignmentName, + @QueryParam("api-version") String apiVersion, + Context context); - @Get("{scope}/providers/Microsoft.Authorization/roleAssignments") + @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listForScope(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); + Mono> listForScope( + @HostParam("vaultBaseUrl") String vaultBaseUrl, + @PathParam(value = "scope", encoded = true) String scope, + @QueryParam("$filter") String filter, + @QueryParam("api-version") String apiVersion, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> listForScopeNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } /** * Deletes a role assignment. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param vaultBaseUrl simple string. * @param scope The scope of the role assignment to delete. * @param roleAssignmentName The name of the role assignment to delete. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return service.delete(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); + public Mono> deleteWithResponseAsync( + String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return service.delete(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } /** * Creates a role assignment. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param vaultBaseUrl simple string. * @param scope The scope of the role assignment to create. * @param roleAssignmentName The name of the role assignment to create. It can be any valid GUID. - * @param parameters Parameters for the role assignment. + * @param parameters Role assignment create parameters. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Context context) { - return service.create(scope, roleAssignmentName, vaultBaseUrl, parameters, this.client.getApiVersion(), context); + public Mono> createWithResponseAsync( + String vaultBaseUrl, + String scope, + String roleAssignmentName, + RoleAssignmentCreateParameters parameters, + Context context) { + return service.create( + vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), parameters, context); } /** * Get the specified role assignment. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param vaultBaseUrl simple string. * @param scope The scope of the role assignment. * @param roleAssignmentName The name of the role assignment to get. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the specified role assignment. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithRestResponseAsync(String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { - return service.get(scope, roleAssignmentName, vaultBaseUrl, this.client.getApiVersion(), context); + public Mono> getWithResponseAsync( + String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { + return service.get(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } /** * Gets role assignments for a scope. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param vaultBaseUrl simple string. * @param scope The scope of the role assignments. + * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or + * above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope + * for the specified principal. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return role assignments for a scope. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, Context context) { - final String filter = null; - return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + public Mono> listForScopeSinglePageAsync( + String vaultBaseUrl, String scope, String filter, Context context) { + return service.listForScope(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().getValue(), + res.getValue().getNextLink(), + null)); } /** - * Gets role assignments for a scope. + * Get the next page of items. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role assignments. - * @param filter The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. + * @param nextLink The nextLink parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return role assignment list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { - return service.listForScope(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + public Mono> listForScopeNextSinglePageAsync(String nextLink, Context context) { + return service.listForScopeNext(nextLink, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().getValue(), + res.getValue().getNextLink(), + null)); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 4f48cc5f3e48..2859b31d4699 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -14,79 +14,107 @@ import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; -import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; import reactor.core.publisher.Mono; -/** - * An instance of this class provides access to all the operations defined in - * RoleDefinitions. - */ +/** An instance of this class provides access to all the operations defined in RoleDefinitions. */ public final class RoleDefinitionsImpl { - /** - * The proxy service used to perform REST calls. - */ - private RoleDefinitionsService service; + /** The proxy service used to perform REST calls. */ + private final RoleDefinitionsService service; - /** - * The service client containing this operation class. - */ - private AccessControlRestClientImpl client; + /** The service client containing this operation class. */ + private final AccessControlRestClientImpl client; /** * Initializes an instance of RoleDefinitionsImpl. * * @param client the instance of the service client containing this operation class. */ - public RoleDefinitionsImpl(AccessControlRestClientImpl client) { + RoleDefinitionsImpl(AccessControlRestClientImpl client) { this.service = RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline()); this.client = client; } /** - * The interface defining all the services for - * AccessControlRestClientRoleDefinitions to be used by the proxy service - * to perform REST calls. + * The interface defining all the services for AccessControlRestClientRoleDefinitions to be used by the proxy + * service to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlRestClientRoleDefinitions") + @ServiceInterface(name = "AccessControlRestCli") private interface RoleDefinitionsService { - @Get("{scope}/providers/Microsoft.Authorization/roleDefinitions") + @Get("/{scope}/providers/Microsoft.Authorization/roleDefinitions") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> list(@PathParam("scope") String scope, @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("$filter") String filter, @QueryParam("api-version") String apiVersion, Context context); + Mono> list( + @HostParam("vaultBaseUrl") String vaultBaseUrl, + @PathParam(value = "scope", encoded = true) String scope, + @QueryParam("$filter") String filter, + @QueryParam("api-version") String apiVersion, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(KeyVaultErrorException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } /** * Get all role definitions that are applicable at scope and above. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param vaultBaseUrl simple string. * @param scope The scope of the role definition. + * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as + * well. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all role definitions that are applicable at scope and above. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, Context context) { - final String filter = null; - return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + public Mono> listSinglePageAsync( + String vaultBaseUrl, String scope, String filter, Context context) { + return service.list(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().getValue(), + res.getValue().getNextLink(), + null)); } /** - * Get all role definitions that are applicable at scope and above. + * Get the next page of items. * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. + * @param nextLink The nextLink parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @return a Mono which performs the network request upon subscription. + * @throws KeyVaultErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return role definition list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listWithRestResponseAsync(String vaultBaseUrl, String scope, String filter, Context context) { - return service.list(scope, vaultBaseUrl, filter, this.client.getApiVersion(), context); + public Mono> listNextSinglePageAsync(String nextLink, Context context) { + return service.listNext(nextLink, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().getValue(), + res.getValue().getNextLink(), + null)); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java index 9395268bd3ee..7d7efb8e170e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Error.java @@ -4,13 +4,11 @@ package com.azure.security.keyvault.administration.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * The key vault server error. - */ -@Fluent +/** The Error model. */ +@Immutable public final class Error { /* * The error code. @@ -25,7 +23,7 @@ public final class Error { private String message; /* - * The innerError property. + * The key vault server error. */ @JsonProperty(value = "innererror", access = JsonProperty.Access.WRITE_ONLY) private Error innerError; @@ -49,7 +47,7 @@ public String getMessage() { } /** - * Get the innerError property: The innerError property. + * Get the innerError property: The key vault server error. * * @return the innerError value. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java index f0e4b04947f5..e7a84828d10c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultError.java @@ -4,22 +4,20 @@ package com.azure.security.keyvault.administration.implementation.models; -import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * The key vault error exception. - */ -@Fluent +/** The KeyVaultError model. */ +@Immutable public final class KeyVaultError { /* - * The error property. + * The key vault server error. */ @JsonProperty(value = "error", access = JsonProperty.Access.WRITE_ONLY) private Error error; /** - * Get the error property: The error property. + * Get the error property: The key vault server error. * * @return the error value. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java index 028291324eda..77b9441be30e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultErrorException.java @@ -7,9 +7,7 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpResponse; -/** - * Exception thrown for an invalid response with KeyVaultError information. - */ +/** Exception thrown for an invalid response with KeyVaultError information. */ public final class KeyVaultErrorException extends HttpResponseException { /** * Initializes a new instance of the KeyVaultErrorException class. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java index b369769a5ce8..d1feaf6d24e4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java @@ -8,9 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** - * Role definition permissions. - */ +/** The Permission model. */ @Fluent public final class Permission { /* diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java index 971d357fb9da..1d06ce14088f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role Assignments. - */ +/** The RoleAssignment model. */ @Fluent public final class RoleAssignment { /* diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java index 353044206a2f..56d16b847a06 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role assignment create parameters. - */ +/** The RoleAssignmentCreateParameters model. */ @Fluent public final class RoleAssignmentCreateParameters { /* diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java index 70d83a613bf9..c04d69f36bd9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role Assignments filter. - */ +/** The RoleAssignmentFilter model. */ @Fluent public final class RoleAssignmentFilter { /* @@ -19,8 +17,7 @@ public final class RoleAssignmentFilter { private String principalId; /** - * Get the principalId property: Returns role assignment of the specific - * principal. + * Get the principalId property: Returns role assignment of the specific principal. * * @return the principalId value. */ @@ -29,8 +26,7 @@ public String getPrincipalId() { } /** - * Set the principalId property: Returns role assignment of the specific - * principal. + * Set the principalId property: Returns role assignment of the specific principal. * * @param principalId the principalId value to set. * @return the RoleAssignmentFilter object itself. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java index 356740ae56b9..72a6eb8440a6 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java @@ -8,9 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** - * Role assignment list operation result. - */ +/** The RoleAssignmentListResult model. */ @Fluent public final class RoleAssignmentListResult { /* @@ -46,8 +44,7 @@ public RoleAssignmentListResult setValue(List value) { } /** - * Get the nextLink property: The URL to use for getting the next set of - * results. + * Get the nextLink property: The URL to use for getting the next set of results. * * @return the nextLink value. */ @@ -56,8 +53,7 @@ public String getNextLink() { } /** - * Set the nextLink property: The URL to use for getting the next set of - * results. + * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. * @return the RoleAssignmentListResult object itself. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java index 913b357b370f..0ab892817a1e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role assignment properties. - */ +/** The RoleAssignmentProperties model. */ @Fluent public final class RoleAssignmentProperties { /* @@ -27,8 +25,7 @@ public final class RoleAssignmentProperties { private String principalId; /** - * Get the roleDefinitionId property: The role definition ID used in the - * role assignment. + * Get the roleDefinitionId property: The role definition ID used in the role assignment. * * @return the roleDefinitionId value. */ @@ -37,8 +34,7 @@ public String getRoleDefinitionId() { } /** - * Set the roleDefinitionId property: The role definition ID used in the - * role assignment. + * Set the roleDefinitionId property: The role definition ID used in the role assignment. * * @param roleDefinitionId the roleDefinitionId value to set. * @return the RoleAssignmentProperties object itself. @@ -49,9 +45,8 @@ public RoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { } /** - * Get the principalId property: The principal ID assigned to the role. - * This maps to the ID inside the Active Directory. It can point to a user, - * service principal, or security group. + * Get the principalId property: The principal ID assigned to the role. This maps to the ID inside the Active + * Directory. It can point to a user, service principal, or security group. * * @return the principalId value. */ @@ -60,9 +55,8 @@ public String getPrincipalId() { } /** - * Set the principalId property: The principal ID assigned to the role. - * This maps to the ID inside the Active Directory. It can point to a user, - * service principal, or security group. + * Set the principalId property: The principal ID assigned to the role. This maps to the ID inside the Active + * Directory. It can point to a user, service principal, or security group. * * @param principalId the principalId value to set. * @return the RoleAssignmentProperties object itself. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java index 94938432eebc..ff50c91dc2ae 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role assignment properties with scope. - */ +/** The RoleAssignmentPropertiesWithScope model. */ @Fluent public final class RoleAssignmentPropertiesWithScope { /* diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java index 4e13e8a84bd5..5383e4acbb8a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** - * Role definition. - */ +/** The RoleDefinition model. */ @JsonFlatten @Fluent public class RoleDefinition { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java index 1e1bcf94b7aa..ce01792ed37f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java @@ -7,9 +7,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** - * Role Definitions filter. - */ +/** The RoleDefinitionFilter model. */ @Fluent public final class RoleDefinitionFilter { /* @@ -19,8 +17,7 @@ public final class RoleDefinitionFilter { private String roleName; /** - * Get the roleName property: Returns role definition with the specific - * name. + * Get the roleName property: Returns role definition with the specific name. * * @return the roleName value. */ @@ -29,8 +26,7 @@ public String getRoleName() { } /** - * Set the roleName property: Returns role definition with the specific - * name. + * Set the roleName property: Returns role definition with the specific name. * * @param roleName the roleName value to set. * @return the RoleDefinitionFilter object itself. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java index 3c222206c22f..fa52f012f154 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java @@ -8,9 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** - * Role definition list operation result. - */ +/** The RoleDefinitionListResult model. */ @Fluent public final class RoleDefinitionListResult { /* @@ -46,8 +44,7 @@ public RoleDefinitionListResult setValue(List value) { } /** - * Get the nextLink property: The URL to use for getting the next set of - * results. + * Get the nextLink property: The URL to use for getting the next set of results. * * @return the nextLink value. */ @@ -56,8 +53,7 @@ public String getNextLink() { } /** - * Set the nextLink property: The URL to use for getting the next set of - * results. + * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. * @return the RoleDefinitionListResult object itself. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java index 2374210d9914..e7a10a365184 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java @@ -3,8 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for AccessControlRestClient. - * The key vault client performs cryptographic key operations and vault - * operations against the Key Vault service. + * Package containing the data models for AccessControlRestClient. The key vault client performs cryptographic key + * operations and vault operations against the Key Vault service. */ package com.azure.security.keyvault.administration.implementation.models; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java index 1159d219ebe7..e0af89b93510 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java @@ -3,9 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the implementations and inner classes for - * AccessControlRestClient. - * The key vault client performs cryptographic key operations and vault - * operations against the Key Vault service. + * Package containing the implementations and inner classes for AccessControlRestClient. The key vault client performs + * cryptographic key operations and vault operations against the Key Vault service. */ package com.azure.security.keyvault.administration.implementation; diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md index 57bf16ca271c..59a48b62c2c0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -20,13 +20,13 @@ There is one swagger for KeyVault Administration: rbac. It uses the following ta ```ps cd -autorest --use=@microsoft.azure/autorest.java@3.0.4 --tag=${package} --version=2.0.4413 +autorest --use=@microsoft.azure/autorest.java@4.0.0 --tag=${package} ``` e.g. ```ps cd -autorest --use=@microsoft.azure/autorest.java@3.0.4 --tag=rbac-preview --version=2.0.4413 +autorest --use=@microsoft.azure/autorest.java@4.0.0 --tag=rbac-preview ``` ## Code generation settings ``` yaml @@ -37,9 +37,9 @@ license-header: MICROSOFT_MIT_SMALL models-subpackage: implementation.models custom-types-subpackage: models generate-client-as-impl: true -generate-client-interfaces: false sync-methods: none add-context-parameter: true +context-client-method-parameter: true ``` ### Tag: rbac-preview From b69e738858cd091fd1d9f350714fb0bbf1c26435 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 15:46:41 -0700 Subject: [PATCH 07/40] Added the 'KeyVault' prefix to all access control clients, implementation classes and their builders. --- ... => KeyVaultAccessControlAsyncClient.java} | 27 +++-- ....java => KeyVaultAccessControlClient.java} | 13 +-- ...> KeyVaultAccessControlClientBuilder.java} | 98 +++++++++---------- ...a => KeyVaultAccessControlClientImpl.java} | 12 +-- ...yVaultAccessControlClientImplBuilder.java} | 18 ++-- .../implementation/RoleAssignmentsImpl.java | 8 +- .../implementation/RoleDefinitionsImpl.java | 8 +- .../implementation/models/package-info.java | 2 +- .../implementation/package-info.java | 4 +- .../swagger/README.md | 2 +- 10 files changed, 94 insertions(+), 98 deletions(-) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/{AccessControlAsyncClient.java => KeyVaultAccessControlAsyncClient.java} (88%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/{AccessControlClient.java => KeyVaultAccessControlClient.java} (79%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/{AccessControlClientBuilder.java => KeyVaultAccessControlClientBuilder.java} (68%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/{AccessControlRestClientImpl.java => KeyVaultAccessControlClientImpl.java} (85%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/{AccessControlRestClientImplBuilder.java => KeyVaultAccessControlClientImplBuilder.java} (62%) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java similarity index 88% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index e2689a67fb68..10cf0f15d244 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -10,8 +10,8 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.security.keyvault.administration.implementation.AccessControlRestClientImpl; -import com.azure.security.keyvault.administration.implementation.AccessControlRestClientImplBuilder; +import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImpl; +import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; @@ -25,14 +25,13 @@ import static com.azure.core.util.tracing.Tracer.AZ_TRACING_NAMESPACE_KEY; /** - * The {@link AccessControlClient} provides synchronous and asynchronous methods to view and manage Role Based Access + * The {@link KeyVaultAccessControlClient} provides synchronous and asynchronous methods to view and manage Role Based Access * for the Azure Key Vault. The client supports creating, listing, updating, and deleting * {@link com.azure.security.keyvault.administration.implementation.models.RoleAssignment}. Additionally, the * client supports listing {@link com.azure.security.keyvault.administration.implementation.models.RoleDefinition}. */ -@ServiceClient(builder = AccessControlClientBuilder.class, isAsync = true) -public class AccessControlAsyncClient { - static final int DEFAULT_MAX_PAGE_RESULTS = 25; +@ServiceClient(builder = KeyVaultAccessControlClientBuilder.class, isAsync = true) +public class KeyVaultAccessControlAsyncClient { // Please see here // for more information on Azure resource provider namespaces. private static final String KEYVAULT_TRACING_NAMESPACE_VALUE = "Microsoft.KeyVault"; @@ -40,12 +39,12 @@ public class AccessControlAsyncClient { /** * The logger to be used. */ - private final ClientLogger logger = new ClientLogger(AccessControlAsyncClient.class); + private final ClientLogger logger = new ClientLogger(KeyVaultAccessControlAsyncClient.class); /** * The underlying AutoRest client used to interact with the Key Vault service. */ - private final AccessControlRestClientImpl restClient; + private final KeyVaultAccessControlClientImpl clientImpl; /** * The Kay Vault URL this client is associated to. @@ -53,15 +52,15 @@ public class AccessControlAsyncClient { private final String vaultUrl; /** - * Package private constructor to be used by {@link AccessControlClientBuilder}. + * Package private constructor to be used by {@link KeyVaultAccessControlClientBuilder}. */ - AccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline) { + KeyVaultAccessControlAsyncClient(URL vaultUrl, HttpPipeline httpPipeline) { Objects.requireNonNull(vaultUrl, KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); this.vaultUrl = vaultUrl.toString(); - restClient = new AccessControlRestClientImplBuilder() + clientImpl = new KeyVaultAccessControlClientImplBuilder() .pipeline(httpPipeline) .buildClient(); } @@ -126,7 +125,7 @@ PagedFlux listRoleDefinitions(String scope, String filter, Conte Mono> listRoleDefinitionsFirstPage(String vaultUrl, String scope, String filter, Context context) { try { - return restClient.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope, filter, + return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope, filter, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) @@ -141,7 +140,7 @@ Mono> listRoleDefinitionsFirstPage(String vaultUrl /** * Gets all the role definitions given by the {@code nextPageLink} that was retrieved from a call to - * {@link AccessControlAsyncClient#listRoleDefinitions(String, String)} ()}. + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitions(String, String)} ()}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the listRoleDefinitions operations. @@ -150,7 +149,7 @@ Mono> listRoleDefinitionsFirstPage(String vaultUrl */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { - return restClient.getRoleDefinitions().listNextSinglePageAsync(continuationToken, + return clientImpl.getRoleDefinitions().listNextSinglePageAsync(continuationToken, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing next role definitions page - Page {}", continuationToken)) .doOnSuccess(response -> logger.info("Listed next role definitions page - Page {}", continuationToken)) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java similarity index 79% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java index 63f323517271..fcd9d7e75a21 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java @@ -3,21 +3,18 @@ import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; -public class AccessControlClient { - private final AccessControlAsyncClient asyncClient; +public class KeyVaultAccessControlClient { + private final KeyVaultAccessControlAsyncClient asyncClient; /** - * Creates an {@link AccessControlClient} that uses a {@code pipeline} to service requests + * Creates an {@link KeyVaultAccessControlClient} that uses a {@code pipeline} to service requests * - * @param asyncClient The {@link AccessControlAsyncClient} that the client routes its request through. + * @param asyncClient The {@link KeyVaultAccessControlAsyncClient} that the client routes its request through. */ - AccessControlClient(AccessControlAsyncClient asyncClient) { + KeyVaultAccessControlClient(KeyVaultAccessControlAsyncClient asyncClient) { this.asyncClient = asyncClient; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java similarity index 68% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java index f74f67578692..bb738ec6d2c0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/AccessControlClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClientBuilder.java @@ -20,41 +20,41 @@ /** * This class provides a fluent builder API to help aid the configuration and instantiation of the - * {@link AccessControlAsyncClient} and {@link AccessControlClient}, by calling - * {@link AccessControlClientBuilder#buildAsyncClient()} and {@link AccessControlClientBuilder#buildClient()} + * {@link KeyVaultAccessControlAsyncClient} and {@link KeyVaultAccessControlClient}, by calling + * {@link KeyVaultAccessControlClientBuilder#buildAsyncClient()} and {@link KeyVaultAccessControlClientBuilder#buildClient()} * respectively. It constructs an instance of the desired client. * - *

The minimal configuration options required by {@link AccessControlClientBuilder} to build an - * an {@link AccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

+ *

The minimal configuration options required by {@link KeyVaultAccessControlClientBuilder} to build an + * an {@link KeyVaultAccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

*

* {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.instantiation} * *

The {@link HttpLogDetailLevel}, multiple custom {@link HttpLoggingPolicy policies} and custom - * {@link HttpClient} can be optionally configured in the {@link AccessControlClientBuilder}.

+ * {@link HttpClient} can be optionally configured in the {@link KeyVaultAccessControlClientBuilder}.

*

* {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.withhttpclient.instantiation} * *

Alternatively, a custom {@link HttpPipeline} with custom {@link HttpPipelinePolicy} policies and {@link String - * vaultUrl} can be specified. It provides finer control over the construction of {@link AccessControlAsyncClient} - * and {@link AccessControlClient} instances.

+ * vaultUrl} can be specified. It provides finer control over the construction of {@link KeyVaultAccessControlAsyncClient} + * and {@link KeyVaultAccessControlClient} instances.

*

* {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.pipeline.instantiation} * - *

The minimal configuration options required by {@link AccessControlClientBuilder} to build an - * {@link AccessControlClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

+ *

The minimal configuration options required by {@link KeyVaultAccessControlClientBuilder} to build an + * {@link KeyVaultAccessControlClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

*

* {@codesnippet com.azure.security.keyvault.keys.accesscontrolclient.instantiation} * - * @see AccessControlAsyncClient - * @see AccessControlClient + * @see KeyVaultAccessControlAsyncClient + * @see KeyVaultAccessControlClient */ -public class AccessControlClientBuilder { +public class KeyVaultAccessControlClientBuilder { // This is the properties file name. private static final String AZURE_KEY_VAULT_RBAC = "azure-key-vault-administration.properties"; private static final String SDK_NAME = "name"; private static final String SDK_VERSION = "version"; - private final ClientLogger logger = new ClientLogger(AccessControlClientBuilder.class); + private final ClientLogger logger = new ClientLogger(KeyVaultAccessControlClientBuilder.class); private final List policies; private final Map properties; @@ -67,10 +67,10 @@ public class AccessControlClientBuilder { private Configuration configuration; /** - * Creates a {@link AccessControlClientBuilder} instance that is able to configure and construct - * instances of {@link AccessControlClient} and {@link AccessControlAsyncClient}. + * Creates a {@link KeyVaultAccessControlClientBuilder} instance that is able to configure and construct + * instances of {@link KeyVaultAccessControlClient} and {@link KeyVaultAccessControlAsyncClient}. */ - public AccessControlClientBuilder() { + public KeyVaultAccessControlClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); @@ -78,32 +78,32 @@ public AccessControlClientBuilder() { } /** - * Creates an {@link AccessControlClient} based on options set in the Builder. Every time {@code buildClient()} - * is called a new instance of {@link AccessControlClient} is created. + * Creates an {@link KeyVaultAccessControlClient} based on options set in the Builder. Every time {@code buildClient()} + * is called a new instance of {@link KeyVaultAccessControlClient} is created. *

* If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and - * {@link #vaultUrl(String) vaultUrl} are used to create the {@link AccessControlClient client}. All other + * {@link #vaultUrl(String) vaultUrl} are used to create the {@link KeyVaultAccessControlClient client}. All other * builder settings are ignored. * - * @return An {@link AccessControlClient} with the options set from the builder. + * @return An {@link KeyVaultAccessControlClient} with the options set from the builder. * @throws NullPointerException If {@code vaultUrl} is {@code null}. */ - public AccessControlClient buildClient() { - return new AccessControlClient(buildAsyncClient()); + public KeyVaultAccessControlClient buildClient() { + return new KeyVaultAccessControlClient(buildAsyncClient()); } /** - * Creates a {@link AccessControlAsyncClient} based on options set in the Builder. Every time {@code - * buildAsyncClient()} is called a new instance of {@link AccessControlAsyncClient} is created. + * Creates a {@link KeyVaultAccessControlAsyncClient} based on options set in the Builder. Every time {@code + * buildAsyncClient()} is called a new instance of {@link KeyVaultAccessControlAsyncClient} is created. *

* If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and - * {@link #vaultUrl(String) endpoint} are used to create the {@link AccessControlAsyncClient client}. All other + * {@link #vaultUrl(String) endpoint} are used to create the {@link KeyVaultAccessControlAsyncClient client}. All other * builder settings are ignored. * - * @return An {@link AccessControlAsyncClient} with the options set from the builder. + * @return An {@link KeyVaultAccessControlAsyncClient} with the options set from the builder. * @throws NullPointerException If {@code vaultUrl} is {@code null}. */ - public AccessControlAsyncClient buildAsyncClient() { + public KeyVaultAccessControlAsyncClient buildAsyncClient() { Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : configuration; @@ -117,7 +117,7 @@ public AccessControlAsyncClient buildAsyncClient() { } if (pipeline != null) { - return new AccessControlAsyncClient(vaultUrl, pipeline); + return new KeyVaultAccessControlAsyncClient(vaultUrl, pipeline); } // Closest to API goes first, closest to wire goes last. @@ -140,17 +140,17 @@ public AccessControlAsyncClient buildAsyncClient() { .httpClient(httpClient) .build(); - return new AccessControlAsyncClient(vaultUrl, buildPipeline); + return new KeyVaultAccessControlAsyncClient(vaultUrl, buildPipeline); } /** * Sets the URL to the Key Vault on which the client operates. Appears as "DNS Name" in the Azure portal. * * @param vaultUrl The vault URL is used as destination on Azure to send requests to. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. * @throws IllegalArgumentException If {@code vaultUrl} is null or it cannot be parsed into a valid URL. */ - public AccessControlClientBuilder vaultUrl(String vaultUrl) { + public KeyVaultAccessControlClientBuilder vaultUrl(String vaultUrl) { try { this.vaultUrl = new URL(vaultUrl); } catch (MalformedURLException e) { @@ -165,10 +165,10 @@ public AccessControlClientBuilder vaultUrl(String vaultUrl) { * Sets the credential to use when authenticating HTTP requests. * * @param credential The credential to use for authenticating HTTP requests. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. * @throws NullPointerException If {@code credential} is {@code null}. */ - public AccessControlClientBuilder credential(TokenCredential credential) { + public KeyVaultAccessControlClientBuilder credential(TokenCredential credential) { Objects.requireNonNull(credential); this.credential = credential; @@ -182,23 +182,23 @@ public AccessControlClientBuilder credential(TokenCredential credential) { *

If logLevel is not provided, default value of {@link HttpLogDetailLevel#NONE} is set.

* * @param logOptions The logging configuration to use when sending and receiving HTTP requests/responses. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. */ - public AccessControlClientBuilder httpLogOptions(HttpLogOptions logOptions) { + public KeyVaultAccessControlClientBuilder httpLogOptions(HttpLogOptions logOptions) { httpLogOptions = logOptions; return this; } /** - * Adds a policy to the set of existing policies that are executed after and {@link AccessControlClient} - * {@link AccessControlAsyncClient} required policies. + * Adds a policy to the set of existing policies that are executed after and {@link KeyVaultAccessControlClient} + * {@link KeyVaultAccessControlAsyncClient} required policies. * * @param policy The {@link HttpPipelinePolicy policy} to be added. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. * @throws NullPointerException If {@code policy} is {@code null}. */ - public AccessControlClientBuilder addPolicy(HttpPipelinePolicy policy) { + public KeyVaultAccessControlClientBuilder addPolicy(HttpPipelinePolicy policy) { Objects.requireNonNull(policy); policies.add(policy); @@ -210,10 +210,10 @@ public AccessControlClientBuilder addPolicy(HttpPipelinePolicy policy) { * Sets the HTTP client to use for sending and receiving requests to and from the service. * * @param client The HTTP client to use for requests. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. * @throws NullPointerException If {@code client} is {@code null}. */ - public AccessControlClientBuilder httpClient(HttpClient client) { + public KeyVaultAccessControlClientBuilder httpClient(HttpClient client) { Objects.requireNonNull(client); this.httpClient = client; @@ -225,13 +225,13 @@ public AccessControlClientBuilder httpClient(HttpClient client) { * Sets the HTTP pipeline to use for the service client. *

* If {@code pipeline} is set, all other settings are ignored, aside from - * {@link AccessControlClientBuilder#vaultUrl(String) vaultUrl} to build {@link AccessControlClient} or - * {@link AccessControlAsyncClient}. + * {@link KeyVaultAccessControlClientBuilder#vaultUrl(String) vaultUrl} to build {@link KeyVaultAccessControlClient} or + * {@link KeyVaultAccessControlAsyncClient}. * * @param pipeline The HTTP pipeline to use for sending service requests and receiving responses. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. */ - public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { + public KeyVaultAccessControlClientBuilder pipeline(HttpPipeline pipeline) { Objects.requireNonNull(pipeline); this.pipeline = pipeline; return this; @@ -244,9 +244,9 @@ public AccessControlClientBuilder pipeline(HttpPipeline pipeline) { * configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction. * * @param configuration The configuration store used to get configuration details. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. */ - public AccessControlClientBuilder configuration(Configuration configuration) { + public KeyVaultAccessControlClientBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; @@ -258,10 +258,10 @@ public AccessControlClientBuilder configuration(Configuration configuration) { * The default retry policy will be used in the pipeline, if not provided. * * @param retryPolicy User's retry policy applied to each request. - * @return The updated {@link AccessControlClientBuilder} object. + * @return The updated {@link KeyVaultAccessControlClientBuilder} object. * @throws NullPointerException If the specified {@code retryPolicy} is null. */ - public AccessControlClientBuilder retryPolicy(RetryPolicy retryPolicy) { + public KeyVaultAccessControlClientBuilder retryPolicy(RetryPolicy retryPolicy) { Objects.requireNonNull(retryPolicy, "The retry policy cannot be bull"); this.retryPolicy = retryPolicy; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java similarity index 85% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java index 5450b7bda636..95d20513347b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java @@ -10,8 +10,8 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; -/** Initializes a new instance of the AccessControlRestClient type. */ -public final class AccessControlRestClientImpl { +/** Initializes a new instance of the KeyVaultAccessControlClient type. */ +public final class KeyVaultAccessControlClientImpl { /** Api Version. */ private final String apiVersion; @@ -60,17 +60,17 @@ public RoleAssignmentsImpl getRoleAssignments() { return this.roleAssignments; } - /** Initializes an instance of AccessControlRestClient client. */ - AccessControlRestClientImpl() { + /** Initializes an instance of KeyVaultAccessControlClient client. */ + KeyVaultAccessControlClientImpl() { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build()); } /** - * Initializes an instance of AccessControlRestClient client. + * Initializes an instance of KeyVaultAccessControlClient client. * * @param httpPipeline The HTTP pipeline to send requests through. */ - AccessControlRestClientImpl(HttpPipeline httpPipeline) { + KeyVaultAccessControlClientImpl(HttpPipeline httpPipeline) { this.httpPipeline = httpPipeline; this.apiVersion = "7.2-preview"; this.roleDefinitions = new RoleDefinitionsImpl(this); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java similarity index 62% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java index 30ec136ab6b0..6b9669831f68 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/AccessControlRestClientImplBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java @@ -11,9 +11,9 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; -/** A builder for creating a new instance of the AccessControlRestClient type. */ -@ServiceClientBuilder(serviceClients = {AccessControlRestClientImpl.class}) -public final class AccessControlRestClientImplBuilder { +/** A builder for creating a new instance of the KeyVaultAccessControlClient type. */ +@ServiceClientBuilder(serviceClients = {KeyVaultAccessControlClientImpl.class}) +public final class KeyVaultAccessControlClientImplBuilder { /* * The HTTP pipeline to send requests through */ @@ -23,26 +23,26 @@ public final class AccessControlRestClientImplBuilder { * Sets The HTTP pipeline to send requests through. * * @param pipeline the pipeline value. - * @return the AccessControlRestClientImplBuilder. + * @return the KeyVaultAccessControlClientImplBuilder. */ - public AccessControlRestClientImplBuilder pipeline(HttpPipeline pipeline) { + public KeyVaultAccessControlClientImplBuilder pipeline(HttpPipeline pipeline) { this.pipeline = pipeline; return this; } /** - * Builds an instance of AccessControlRestClientImpl with the provided parameters. + * Builds an instance of KeyVaultAccessControlClientImpl with the provided parameters. * - * @return an instance of AccessControlRestClientImpl. + * @return an instance of KeyVaultAccessControlClientImpl. */ - public AccessControlRestClientImpl buildClient() { + public KeyVaultAccessControlClientImpl buildClient() { if (pipeline == null) { this.pipeline = new HttpPipelineBuilder() .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) .build(); } - AccessControlRestClientImpl client = new AccessControlRestClientImpl(pipeline); + KeyVaultAccessControlClientImpl client = new KeyVaultAccessControlClientImpl(pipeline); return client; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index 39a2ed99b0e1..38b6105e4132 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -34,24 +34,24 @@ public final class RoleAssignmentsImpl { private final RoleAssignmentsService service; /** The service client containing this operation class. */ - private final AccessControlRestClientImpl client; + private final KeyVaultAccessControlClientImpl client; /** * Initializes an instance of RoleAssignmentsImpl. * * @param client the instance of the service client containing this operation class. */ - RoleAssignmentsImpl(AccessControlRestClientImpl client) { + RoleAssignmentsImpl(KeyVaultAccessControlClientImpl client) { this.service = RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline()); this.client = client; } /** - * The interface defining all the services for AccessControlRestClientRoleAssignments to be used by the proxy + * The interface defining all the services for KeyVaultAccessControlClientRoleAssignments to be used by the proxy * service to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlRestCli") + @ServiceInterface(name = "KeyVaultAccessContro") private interface RoleAssignmentsService { @Delete("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 2859b31d4699..8ed6b52ed375 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -30,24 +30,24 @@ public final class RoleDefinitionsImpl { private final RoleDefinitionsService service; /** The service client containing this operation class. */ - private final AccessControlRestClientImpl client; + private final KeyVaultAccessControlClientImpl client; /** * Initializes an instance of RoleDefinitionsImpl. * * @param client the instance of the service client containing this operation class. */ - RoleDefinitionsImpl(AccessControlRestClientImpl client) { + RoleDefinitionsImpl(KeyVaultAccessControlClientImpl client) { this.service = RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline()); this.client = client; } /** - * The interface defining all the services for AccessControlRestClientRoleDefinitions to be used by the proxy + * The interface defining all the services for KeyVaultAccessControlClientRoleDefinitions to be used by the proxy * service to perform REST calls. */ @Host("{vaultBaseUrl}") - @ServiceInterface(name = "AccessControlRestCli") + @ServiceInterface(name = "KeyVaultAccessContro") private interface RoleDefinitionsService { @Get("/{scope}/providers/Microsoft.Authorization/roleDefinitions") @ExpectedResponses({200}) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java index e7a10a365184..3ad2fecedd55 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the data models for AccessControlRestClient. The key vault client performs cryptographic key + * Package containing the data models for KeyVaultAccessControlClient. The key vault client performs cryptographic key * operations and vault operations against the Key Vault service. */ package com.azure.security.keyvault.administration.implementation.models; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java index e0af89b93510..2f88bbe09355 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * Package containing the implementations and inner classes for AccessControlRestClient. The key vault client performs - * cryptographic key operations and vault operations against the Key Vault service. + * Package containing the implementations and inner classes for KeyVaultAccessControlClient. The key vault client + * performs cryptographic key operations and vault operations against the Key Vault service. */ package com.azure.security.keyvault.administration.implementation; diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md index 59a48b62c2c0..aecc4e6105a1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -47,5 +47,5 @@ These settings apply only when `--tag=package-2019-05-searchservice-preview` is ``` yaml $(tag) == 'rbac-preview' input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/rbac.json -title: AccessControlRestClient +title: KeyVaultAccessControlClient ``` From 42a7cba66c165f33e89dd45d407579459a155533 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 16:13:02 -0700 Subject: [PATCH 08/40] Added an API for listing role definitions. --- .../KeyVaultAccessControlAsyncClient.java | 101 ++++++++++++++++-- 1 file changed, 94 insertions(+), 7 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 10cf0f15d244..26593e834970 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -6,13 +6,12 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImpl; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; import reactor.core.publisher.Mono; @@ -80,7 +79,7 @@ public String getVaultUrl() { * @param scope The scope of the role definition. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. - * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. * {@link RoleDefinitionListResult list of role definitions}. * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the * operation is unsuccessful. @@ -103,7 +102,7 @@ public PagedFlux listRoleDefinitions(String scope, String filter * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A Mono containing a {@link SimpleResponse response} whose {@link Response#getValue() value} contains the + * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. * {@link RoleDefinitionListResult list of role definitions}. */ PagedFlux listRoleDefinitions(String scope, String filter, Context context) { @@ -120,7 +119,8 @@ PagedFlux listRoleDefinitions(String scope, String filter, Conte * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} of {@link PagedResponse} from the first page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the + * given scope from the first page of results. */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, String scope, String filter, Context context) { @@ -140,12 +140,13 @@ Mono> listRoleDefinitionsFirstPage(String vaultUrl /** * Gets all the role definitions given by the {@code nextPageLink} that was retrieved from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitions(String, String)} ()}. + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitions(String, String)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the listRoleDefinitions operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} of {@link PagedResponse} from the next page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the + * given scope from the next page of results. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -159,4 +160,90 @@ Mono> listRoleDefinitionsNextPage(String continuat return monoError(logger, e); } } + + /** + * Get all role assignments that are applicable at scope and above. + * + * @param scope The scope of the role assignment. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. + * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the + * operation is unsuccessful. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public PagedFlux listRoleAssignments(String scope, String filter) { + try { + return new PagedFlux<>( + () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, filter, context)), + continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); + } catch (RuntimeException e) { + return new PagedFlux<>(() -> monoError(logger, e)); + } + } + + /** + * Get all role assignments that are applicable at scope and above. + * + * @param scope The scope of the role assignment. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. + */ + PagedFlux listRoleAssignments(String scope, String filter, Context context) { + return new PagedFlux<>( + () -> listRoleAssignmentsFirstPage(vaultUrl, scope, filter, context), + continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); + } + + /** + * Gets role assignments in the first page. + * + * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param scope The scope of the role assignment. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the + * given scope from the first page of results. + */ + Mono> listRoleAssignmentsFirstPage(String vaultUrl, String scope, String filter, + Context context) { + try { + return clientImpl.getRoleAssignments().listForScopeSinglePageAsync(vaultUrl, scope, filter, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> + logger.info("Listing role assignments for scope - {}", scope)) + .doOnSuccess(response -> + logger.info("Listed role assignments for scope - {}", scope)) + .doOnError(error -> + logger.warning(String.format("Failed to list role assignments for scope - %s", scope), error)); + } catch (RuntimeException e) { + return monoError(logger, e); + } + } + + /** + * Gets all the role assignments given by the {@code nextPageLink} that was retrieved from a call to + * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(String, String)}. + * + * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, + * successful call to one of the listRoleAssignments operations. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the + * given scope from the first page of results. + */ + Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { + try { + return clientImpl.getRoleAssignments().listForScopeNextSinglePageAsync(continuationToken, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Listing next role assignments page - Page {}", continuationToken)) + .doOnSuccess(response -> logger.info("Listed next role assignments page - Page {}", continuationToken)) + .doOnError(error -> logger.warning("Failed to list next role assignments page - Page {}", + continuationToken, error)); + } catch (RuntimeException e) { + return monoError(logger, e); + } + } } From 0c75941c31a888b65a0f2b82898ca5a151fce083 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 18 Jun 2020 22:17:35 -0700 Subject: [PATCH 09/40] Added APIs for creating, getting, deleting and listing role assignments. --- .../KeyVaultAccessControlAsyncClient.java | 282 +++++++++++++++--- .../KeyVaultAccessControlClient.java | 133 ++++++++- .../swagger/README.md | 1 + 3 files changed, 366 insertions(+), 50 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 26593e834970..71180540c0c3 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -6,14 +6,14 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.Response; import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImpl; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; +import com.azure.security.keyvault.administration.implementation.models.*; import reactor.core.publisher.Mono; import java.net.URL; @@ -24,10 +24,9 @@ import static com.azure.core.util.tracing.Tracer.AZ_TRACING_NAMESPACE_KEY; /** - * The {@link KeyVaultAccessControlClient} provides synchronous and asynchronous methods to view and manage Role Based Access - * for the Azure Key Vault. The client supports creating, listing, updating, and deleting - * {@link com.azure.security.keyvault.administration.implementation.models.RoleAssignment}. Additionally, the - * client supports listing {@link com.azure.security.keyvault.administration.implementation.models.RoleDefinition}. + * The {@link KeyVaultAccessControlAsyncClient} provides asynchronous methods to view and manage Role Based Access + * for the Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment}. + * Additionally, the client supports listing {@link RoleDefinition}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class, isAsync = true) public class KeyVaultAccessControlAsyncClient { @@ -74,15 +73,15 @@ public String getVaultUrl() { } /** - * Get all role definitions that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} that are applicable at scope and above. * - * @param scope The scope of the role definition. + * @param scope The scope of the {@link RoleDefinition}. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. * {@link RoleDefinitionListResult list of role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ @ServiceMethod(returns = ReturnType.SINGLE) public PagedFlux listRoleDefinitions(String scope, String filter) { @@ -96,14 +95,16 @@ public PagedFlux listRoleDefinitions(String scope, String filter } /** - * Get all role definitions that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} that are applicable at scope and above. * - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param scope The scope of the {@link RoleDefinition}. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. * {@link RoleDefinitionListResult list of role definitions}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ PagedFlux listRoleDefinitions(String scope, String filter, Context context) { return new PagedFlux<>( @@ -112,41 +113,42 @@ PagedFlux listRoleDefinitions(String scope, String filter, Conte } /** - * Gets role definitions in the first page. + * Get all {@link RoleDefinition role definitions} in the first page that are applicable at scope and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The scope of the role definition. + * @param scope The scope of the {@link RoleDefinition}. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the * given scope from the first page of results. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, String scope, String filter, Context context) { try { return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope, filter, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> - logger.info("Listing role definitions for scope - {}", scope)) - .doOnSuccess(response -> - logger.info("Listed role definitions for scope - {}", scope)) - .doOnError(error -> - logger.warning(String.format("Failed to list role definitions for scope - %s", scope), error)); + .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) + .doOnSuccess(response -> logger.info("Listed role definitions for scope - {}", scope)) + .doOnError(error -> logger.warning(String.format("Failed to list role definitions for scope - %s", + scope), error)); } catch (RuntimeException e) { return monoError(logger, e); } } /** - * Gets all the role definitions given by the {@code nextPageLink} that was retrieved from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitions(String, String)}. + * Gets all the {@link RoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved from + * a call to {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, String, String, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the listRoleDefinitions operations. + * successful call to one of the {@code listRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the * given scope from the next page of results. + * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -162,14 +164,14 @@ Mono> listRoleDefinitionsNextPage(String continuat } /** - * Get all role assignments that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} that are applicable at scope and above. * - * @param scope The scope of the role assignment. + * @param scope The scope of the {@link RoleAssignment}. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ @ServiceMethod(returns = ReturnType.SINGLE) public PagedFlux listRoleAssignments(String scope, String filter) { @@ -183,13 +185,15 @@ public PagedFlux listRoleAssignments(String scope, String filter } /** - * Get all role assignments that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} that are applicable at scope and above. * - * @param scope The scope of the role assignment. + * @param scope The scope of the {@link RoleAssignment}. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ PagedFlux listRoleAssignments(String scope, String filter, Context context) { return new PagedFlux<>( @@ -198,41 +202,44 @@ PagedFlux listRoleAssignments(String scope, String filter, Conte } /** - * Gets role assignments in the first page. + * Get all {@link RoleAssignment role assignments} in the first page that are applicable at scope and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The scope of the role assignment. + * @param scope The scope of the {@link RoleAssignment}. * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the * given scope from the first page of results. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ Mono> listRoleAssignmentsFirstPage(String vaultUrl, String scope, String filter, Context context) { + Objects.requireNonNull(scope, "'scope' cannot be null."); + try { return clientImpl.getRoleAssignments().listForScopeSinglePageAsync(vaultUrl, scope, filter, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> - logger.info("Listing role assignments for scope - {}", scope)) - .doOnSuccess(response -> - logger.info("Listed role assignments for scope - {}", scope)) - .doOnError(error -> - logger.warning(String.format("Failed to list role assignments for scope - %s", scope), error)); + .doOnRequest(ignored -> logger.info("Listing role assignments for scope - {}", scope)) + .doOnSuccess(response -> logger.info("Listed role assignments for scope - {}", scope)) + .doOnError(error -> logger.warning(String.format("Failed to list role assignments for scope - %s", + scope), error)); } catch (RuntimeException e) { return monoError(logger, e); } } /** - * Gets all the role assignments given by the {@code nextPageLink} that was retrieved from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(String, String)}. + * Gets all the {@link RoleAssignment role assignments} given by the {@code nextPageLink} that was retrieved from + * a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(String, String)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the listRoleAssignments operations. + * successful call to one of the {@code listRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the * given scope from the first page of results. + * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { @@ -246,4 +253,191 @@ Mono> listRoleAssignmentsNextPage(String continuat return monoError(logger, e); } } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. + * @param properties Properties for the {@link RoleAssignment}. + * @return A {@link Mono} containing the created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createRoleAssignment(String scope, String name, RoleAssignmentProperties properties) { + try { + return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. + * @param properties Properties for the {@link RoleAssignment}. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createRoleAssignmentWithResponse(String scope, String name, + RoleAssignmentProperties properties) { + try { + return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. + * @param properties Properties for the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + */ + Mono> createRoleAssignmentWithResponse(String scope, String name, + RoleAssignmentProperties properties, + Context context) { + Objects.requireNonNull(scope, "'scope' cannot be null."); + Objects.requireNonNull(name, "'name' cannot be null."); + Objects.requireNonNull(properties, "'properties' cannot be null."); + + RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters().setProperties(properties); + return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope, name, parameters, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + } + + /** + * Gets a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name used of the {@link RoleAssignment}. + * @return A {@link Mono} containing the {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRoleAssignment(String scope, String name) { + try { + return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Gets a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRoleAssignmentWithResponse(String scope, String name) { + try { + return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Gets a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + Mono> getRoleAssignmentWithResponse(String scope, String name, + Context context) { + Objects.requireNonNull(scope, "'scope' cannot be null."); + Objects.requireNonNull(name, "'name' cannot be null."); + + return clientImpl.getRoleAssignments().getWithResponseAsync(vaultUrl, scope, name, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + } + + /** + * Deletes a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return A {@link Mono} containing the {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteRoleAssignment(String scope, String name) { + try { + return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteRoleAssignmentWithResponse(String scope, String name) { + try { + return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + Mono> deleteRoleAssignmentWithResponse(String scope, String name, + Context context) { + Objects.requireNonNull(scope, "'scope' cannot be null."); + Objects.requireNonNull(name, "'name' cannot be null."); + + return clientImpl.getRoleAssignments().deleteWithResponseAsync(vaultUrl, scope, name, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + } } 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 fcd9d7e75a21..cf102d1c6871 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 @@ -1,11 +1,22 @@ package com.azure.security.keyvault.administration; import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; import com.azure.core.util.Context; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentProperties; import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; +/** + * The {@link KeyVaultAccessControlClient} provides synchronous methods to view and manage Role Based Access for the + * Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment}. + * Additionally, the client supports listing {@link RoleDefinition}. + */ +@ServiceClient(builder = KeyVaultAccessControlClientBuilder.class) public class KeyVaultAccessControlClient { private final KeyVaultAccessControlAsyncClient asyncClient; @@ -33,10 +44,9 @@ public String getVaultUrl() { * @param scope The scope of the role definition. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ - @ServiceMethod(returns = ReturnType.SINGLE) public PagedIterable listRoleDefinitions(String scope, Context context) { return listRoleDefinitions(scope, null, context); } @@ -49,11 +59,122 @@ public PagedIterable listRoleDefinitions(String scope, Context c * scope as well. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. - * @throws com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException if the - * operation is unsuccessful. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. */ - @ServiceMethod(returns = ReturnType.SINGLE) public PagedIterable listRoleDefinitions(String scope, String filter, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, filter, context)); } + + /** + * Get all role definitions that are applicable at scope and above. + * + * @param scope The scope of the role definition. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. + */ + public PagedIterable listRoleAssignments(String scope, Context context) { + return listRoleAssignments(scope, null, context); + } + + /** + * Get all role assignments that are applicable at scope and above. + * + * @param scope The scope of the role assignment. + * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given + * scope as well. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} of {@link RoleAssignment role definitions}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} is null. + */ + public PagedIterable listRoleAssignments(String scope, String filter, Context context) { + return new PagedIterable<>(asyncClient.listRoleAssignments(scope, filter, context)); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @param properties Properties for the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment createRoleAssignment(String scope, String name, RoleAssignmentProperties properties) { + return createKeyWithResponse(scope, name, properties, Context.NONE).getValue(); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @param properties Properties for the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + */ + public Response createKeyWithResponse(String scope, String name, + RoleAssignmentProperties properties, Context context) { + return asyncClient.createRoleAssignmentWithResponse(scope, name, properties, context).block(); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment getRoleAssignment(String scope, String name) { + return getKeyWithResponse(scope, name, Context.NONE).getValue(); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + public Response getKeyWithResponse(String scope, String name, Context context) { + return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment deleteRoleAssignment(String scope, String name) { + return deleteKeyWithResponse(scope, name, Context.NONE).getValue(); + } + + /** + * Creates a {@link RoleAssignment}. + * + * @param scope The scope of the role assignment to create. + * @param name The name used to create the role assignment. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@code scope} or {@code name} are null. + */ + public Response deleteKeyWithResponse(String scope, String name, Context context) { + return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); + } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md index aecc4e6105a1..ed04a53f2a70 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md @@ -28,6 +28,7 @@ e.g. cd autorest --use=@microsoft.azure/autorest.java@4.0.0 --tag=rbac-preview ``` + ## Code generation settings ``` yaml java: true From 9d003dd7ebcbcdb89714eb98aabe93fd4f82eebc Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 22 Jun 2020 17:16:21 -0700 Subject: [PATCH 10/40] Polished README. --- .../azure-security-keyvault-administration/README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index f38c59e76fff..9e26844f39c3 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -68,23 +68,21 @@ Here is an [Azure Cloud Shell](https://shell.azure.com/bash) snippet below to #### Create Access Control client ## Key concepts -### Role definition - -### Role assignment - -### Access Control client +To be added. ## Examples ### Sync API -The following sections provide several code snippets covering some of the most common Azure Key Vault Key service tasks, including: +To be added. ### Async API -The following sections provide several code snippets covering some of the most common asynchronous Azure Key Vault Key service tasks, including: +To be added. ## Key concepts +To be added. ## Troubleshooting ### General +To be added. ### Default HTTP client All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the [HTTP clients wiki](https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients). From 0b1fd318bbcabf5f898bceae57ec47fe8d7f2d94 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 24 Jun 2020 13:38:16 -0700 Subject: [PATCH 11/40] Added the an entry for Key Vault Administration in version_client.txt --- eng/versioning/version_client.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 71d8222b31e8..bad0295b55a3 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -30,6 +30,7 @@ com.azure:azure-messaging-eventhubs;5.1.0;5.2.0-beta.1 com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.1.0;1.2.0-beta.1 com.azure:azure-messaging-servicebus;7.0.0-beta.3;7.0.0-beta.4 com.azure:azure-search-documents;1.0.0-beta.4;1.0.0-beta.5 +com.azure:azure-security-keyvault-administration;4.1.0-beta.1;4.1.0-beta.1 com.azure:azure-security-keyvault-certificates;4.1.0-beta.3;4.1.0-beta.4 com.azure:azure-security-keyvault-keys;4.2.0-beta.4;4.2.0-beta.5 com.azure:azure-security-keyvault-secrets;4.2.0-beta.3;4.2.0-beta.4 From 590045a6fa30346f7fa73562b93fdd956ce2a8e6 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 24 Jun 2020 15:13:41 -0700 Subject: [PATCH 12/40] Renamed to not break the CI build. --- .../swagger/{README.md => autorest.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/keyvault/azure-security-keyvault-administration/swagger/{README.md => autorest.md} (100%) diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/README.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md similarity index 100% rename from sdk/keyvault/azure-security-keyvault-administration/swagger/README.md rename to sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md From 8d556d46764bce208a8e38a9a3da7009030ac139 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Wed, 24 Jun 2020 22:39:27 -0700 Subject: [PATCH 13/40] Fixed copy/paste error on autorest.md --- .../azure-security-keyvault-administration/swagger/autorest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md index ed04a53f2a70..70a2f4efdd0a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md @@ -44,7 +44,7 @@ context-client-method-parameter: true ``` ### Tag: rbac-preview -These settings apply only when `--tag=package-2019-05-searchservice-preview` is specified on the command line. +These settings apply only when `--tag=rbac-preview` is specified on the command line. ``` yaml $(tag) == 'rbac-preview' input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/rbac.json From 614cf26a47f15beae2d34d52afc4cd7b0e4759ff Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 25 Jun 2020 11:58:55 -0700 Subject: [PATCH 14/40] Changed README references (keys -> administration). --- sdk/keyvault/azure-security-keyvault-administration/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index 9e26844f39c3..69c9af6f53ce 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -4,7 +4,7 @@ ### Adding the package to your project Maven dependency for the Azure Key Vault Administration client library. Add it to your project's POM file. -[//]: # ({x-version-update-start;com.azure:azure-security-keyvault-keys;current}) +[//]: # ({x-version-update-start;com.azure:azure-security-keyvault-administration;current}) ```xml com.azure @@ -120,7 +120,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope [azure_create_application_in_portal]: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal [azure_keyvault_cli]: https://docs.microsoft.com/azure/key-vault/quick-create-cli [azure_keyvault_cli_full]: https://docs.microsoft.com/cli/azure/keyvault?view=azure-cli-latest -[keys_samples]: src/samples/java/com/azure/security/keyvault/keys +[administration_samples]: src/samples/java/com/azure/security/keyvault/administration [samples_readme]: src/samples/README.md [performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning From 6273df0f12bc99fbc0b827cffba0b3f3237b8b93 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 26 Jun 2020 21:26:23 -0700 Subject: [PATCH 15/40] Addressed PR comments. Added a new ExpandableStringEnum: RoleScope. Corrected some of the Javadoc. --- .../KeyVaultAccessControlAsyncClient.java | 232 ++++++++++-------- .../KeyVaultAccessControlClient.java | 165 ++++++------- .../administration/models/RoleScope.java | 30 +++ 3 files changed, 237 insertions(+), 190 deletions(-) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 71180540c0c3..fe37b061ff26 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -14,10 +14,12 @@ import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import com.azure.security.keyvault.administration.implementation.models.*; +import com.azure.security.keyvault.administration.models.RoleScope; import reactor.core.publisher.Mono; import java.net.URL; import java.util.Objects; +import java.util.UUID; import static com.azure.core.util.FluxUtil.monoError; import static com.azure.core.util.FluxUtil.withContext; @@ -25,8 +27,8 @@ /** * The {@link KeyVaultAccessControlAsyncClient} provides asynchronous methods to view and manage Role Based Access - * for the Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment}. - * Additionally, the client supports listing {@link RoleDefinition}. + * for the Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment role + * assignments}. Additionally, the client supports listing {@link RoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class, isAsync = true) public class KeyVaultAccessControlAsyncClient { @@ -69,25 +71,24 @@ public class KeyVaultAccessControlAsyncClient { * @return The Key Vault URL. */ public String getVaultUrl() { - return this.vaultUrl; + return vaultUrl; } /** - * Get all {@link RoleDefinition role definitions} that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the {@link RoleDefinition}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. - * {@link RoleDefinitionListResult list of role definitions}. + * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. + * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedFlux listRoleDefinitions(String scope, String filter) { + public PagedFlux listRoleDefinitions(RoleScope scope) { try { return new PagedFlux<>( - () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, filter, context)), + () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); } catch (RuntimeException e) { return new PagedFlux<>(() -> monoError(logger, e)); @@ -95,40 +96,38 @@ public PagedFlux listRoleDefinitions(String scope, String filter } /** - * Get all {@link RoleDefinition role definitions} that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the {@link RoleDefinition}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} the given scope. - * {@link RoleDefinitionListResult list of role definitions}. + * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - PagedFlux listRoleDefinitions(String scope, String filter, Context context) { + PagedFlux listRoleDefinitions(RoleScope scope, Context context) { return new PagedFlux<>( - () -> listRoleDefinitionsFirstPage(vaultUrl, scope, filter, context), + () -> listRoleDefinitionsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); } /** - * Get all {@link RoleDefinition role definitions} in the first page that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} in the first page that are applicable at the given + * {@link RoleScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The scope of the {@link RoleDefinition}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. + * @param scope The {@link RoleScope scope} of the {@link RoleDefinition}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the - * given scope from the first page of results. + * given {@link RoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - Mono> listRoleDefinitionsFirstPage(String vaultUrl, String scope, String filter, + Mono> listRoleDefinitionsFirstPage(String vaultUrl, RoleScope scope, Context context) { try { - return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope, filter, + return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) .doOnSuccess(response -> logger.info("Listed role definitions for scope - {}", scope)) @@ -141,13 +140,14 @@ Mono> listRoleDefinitionsFirstPage(String vaultUrl /** * Gets all the {@link RoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved from - * a call to {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, String, String, Context)}. + * a call to + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, RoleScope, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the - * given scope from the next page of results. + * given {@link RoleScope scope} from the next page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { @@ -164,20 +164,20 @@ Mono> listRoleDefinitionsNextPage(String continuat } /** - * Get all {@link RoleAssignment role assignments} that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the {@link RoleAssignment}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedFlux listRoleAssignments(String scope, String filter) { + public PagedFlux listRoleAssignments(RoleScope scope) { try { return new PagedFlux<>( - () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, filter, context)), + () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); } catch (RuntimeException e) { return new PagedFlux<>(() -> monoError(logger, e)); @@ -185,41 +185,40 @@ public PagedFlux listRoleAssignments(String scope, String filter } /** - * Get all {@link RoleAssignment role assignments} that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the {@link RoleAssignment}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} the given scope. + * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - PagedFlux listRoleAssignments(String scope, String filter, Context context) { + PagedFlux listRoleAssignments(RoleScope scope, Context context) { return new PagedFlux<>( - () -> listRoleAssignmentsFirstPage(vaultUrl, scope, filter, context), + () -> listRoleAssignmentsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); } /** - * Get all {@link RoleAssignment role assignments} in the first page that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} in the first page that are applicable at + * the given {@link RoleScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The scope of the {@link RoleAssignment}. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the - * given scope from the first page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} in the + * given {@link RoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - Mono> listRoleAssignmentsFirstPage(String vaultUrl, String scope, String filter, + Mono> listRoleAssignmentsFirstPage(String vaultUrl, RoleScope scope, Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); try { - return clientImpl.getRoleAssignments().listForScopeSinglePageAsync(vaultUrl, scope, filter, + return clientImpl.getRoleAssignments().listForScopeSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing role assignments for scope - {}", scope)) .doOnSuccess(response -> logger.info("Listed role assignments for scope - {}", scope)) @@ -232,13 +231,13 @@ Mono> listRoleAssignmentsFirstPage(String vaultUrl /** * Gets all the {@link RoleAssignment role assignments} given by the {@code nextPageLink} that was retrieved from - * a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(String, String)}. + * a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(RoleScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the - * given scope from the first page of results. + * given {@link RoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { @@ -254,18 +253,34 @@ Mono> listRoleAssignmentsNextPage(String continuat } } + /** + * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param properties Properties for the {@link RoleAssignment}. + * @return A {@link Mono} containing the created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the operation is unsuccessful. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createRoleAssignment(RoleScope scope, RoleAssignmentProperties properties) { + return createRoleAssignment(scope, UUID.randomUUID(), properties); + } + /** * Creates a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link RoleAssignment}. * @return A {@link Mono} containing the created {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(String scope, String name, RoleAssignmentProperties properties) { + public Mono createRoleAssignment(RoleScope scope, UUID name, RoleAssignmentProperties properties) { try { return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -273,19 +288,37 @@ public Mono createRoleAssignment(String scope, String name, Role } } + /** + * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param properties Properties for the {@link RoleAssignment}. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createRoleAssignmentWithResponse(RoleScope scope, + RoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties); + } + /** * Creates a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link RoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(String scope, String name, + public Mono> createRoleAssignmentWithResponse(RoleScope scope, UUID name, RoleAssignmentProperties properties) { try { return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); @@ -297,16 +330,17 @@ public Mono> createRoleAssignmentWithResponse(String sc /** * Creates a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link RoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(String scope, String name, + Mono> createRoleAssignmentWithResponse(RoleScope scope, UUID name, RoleAssignmentProperties properties, Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); @@ -314,7 +348,7 @@ Mono> createRoleAssignmentWithResponse(String scope, St Objects.requireNonNull(properties, "'properties' cannot be null."); RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters().setProperties(properties); - return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope, name, parameters, + return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) @@ -324,14 +358,14 @@ Mono> createRoleAssignmentWithResponse(String scope, St /** * Gets a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param name The name used of the {@link RoleAssignment}. * @return A {@link Mono} containing the {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRoleAssignment(String scope, String name) { + public Mono getRoleAssignment(RoleScope scope, String name) { try { return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -342,15 +376,15 @@ public Mono getRoleAssignment(String scope, String name) { /** * Gets a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param name The name of the {@link RoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(String scope, String name) { + public Mono> getRoleAssignmentWithResponse(RoleScope scope, String name) { try { return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); } catch (RuntimeException ex) { @@ -361,20 +395,19 @@ public Mono> getRoleAssignmentWithResponse(String scope /** * Gets a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ - Mono> getRoleAssignmentWithResponse(String scope, String name, - Context context) { + Mono> getRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); - return clientImpl.getRoleAssignments().getWithResponseAsync(vaultUrl, scope, name, + return clientImpl.getRoleAssignments().getWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) @@ -384,14 +417,14 @@ Mono> getRoleAssignmentWithResponse(String scope, Strin /** * Deletes a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param name The name of the {@link RoleAssignment}. * @return A {@link Mono} containing the {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteRoleAssignment(String scope, String name) { + public Mono deleteRoleAssignment(RoleScope scope, String name) { try { return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -400,17 +433,17 @@ public Mono deleteRoleAssignment(String scope, String name) { } /** - * Creates a {@link RoleAssignment}. + * Deletes a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param name The name of the {@link RoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(String scope, String name) { + public Mono> deleteRoleAssignmentWithResponse(RoleScope scope, String name) { try { return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); } catch (RuntimeException ex) { @@ -419,22 +452,21 @@ public Mono> deleteRoleAssignmentWithResponse(String sc } /** - * Creates a {@link RoleAssignment}. + * Deletes a {@link RoleAssignment}. * - * @param scope The scope of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(String scope, String name, - Context context) { + Mono> deleteRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); - return clientImpl.getRoleAssignments().deleteWithResponseAsync(vaultUrl, scope, name, + return clientImpl.getRoleAssignments().deleteWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) 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 cf102d1c6871..d3a0e4dce99b 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 @@ -10,171 +10,156 @@ import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentProperties; import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; +import com.azure.security.keyvault.administration.models.RoleScope; +import reactor.core.publisher.Mono; + +import java.util.UUID; /** * The {@link KeyVaultAccessControlClient} provides synchronous methods to view and manage Role Based Access for the - * Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment}. - * Additionally, the client supports listing {@link RoleDefinition}. + * Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment role + * assignments}. Additionally, the client supports listing {@link RoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class) public class KeyVaultAccessControlClient { private final KeyVaultAccessControlAsyncClient asyncClient; /** - * Creates an {@link KeyVaultAccessControlClient} that uses a {@code pipeline} to service requests + * Creates an {@link KeyVaultAccessControlClient} that uses a {@link com.azure.core.http.HttpPipeline pipeline} + * to service requests. * - * @param asyncClient The {@link KeyVaultAccessControlAsyncClient} that the client routes its request through. + * @param asyncClient The {@link KeyVaultAccessControlAsyncClient} that this client routes its request through. */ KeyVaultAccessControlClient(KeyVaultAccessControlAsyncClient asyncClient) { this.asyncClient = asyncClient; } /** - * Get the vault endpoint URL. + * Gets the URL for the Key Vault this client is associated with. * - * @return The vault endpoint URL. + * @return The Key Vault URL. */ public String getVaultUrl() { return asyncClient.getVaultUrl(); } /** - * Get all role definitions that are applicable at scope and above. - * - * @param scope The scope of the role definition. - * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. - */ - public PagedIterable listRoleDefinitions(String scope, Context context) { - return listRoleDefinitions(scope, null, context); - } - - /** - * Get all role definitions that are applicable at scope and above. + * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the role definition. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. + * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} containing the {@link RoleDefinition role definitions} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - public PagedIterable listRoleDefinitions(String scope, String filter, Context context) { - return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, filter, context)); + public PagedIterable listRoleDefinitions(RoleScope scope, Context context) { + return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, context)); } /** - * Get all role definitions that are applicable at scope and above. + * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * scope} and above. * - * @param scope The scope of the role definition. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedIterable} of {@link RoleDefinition role definitions}. + * @return A {@link PagedIterable} containing the {@link RoleAssignment role assignments} for the given + * {@link RoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. + * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. */ - public PagedIterable listRoleAssignments(String scope, Context context) { - return listRoleAssignments(scope, null, context); - } - - /** - * Get all role assignments that are applicable at scope and above. - * - * @param scope The scope of the role assignment. - * @param filter The filter to apply on the operation. Use a "atScopeAndBelow" filter to search below the given - * scope as well. - * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedIterable} of {@link RoleAssignment role definitions}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} is null. - */ - public PagedIterable listRoleAssignments(String scope, String filter, Context context) { - return new PagedIterable<>(asyncClient.listRoleAssignments(scope, filter, context)); + public PagedIterable listRoleAssignments(RoleScope scope, Context context) { + return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); } /** * Creates a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @param properties Properties for the role assignment. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link RoleAssignment}. * @return The created {@link RoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment createRoleAssignment(String scope, String name, RoleAssignmentProperties properties) { - return createKeyWithResponse(scope, name, properties, Context.NONE).getValue(); + public RoleAssignment createRoleAssignment(RoleScope scope, UUID name, + RoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(scope, name, properties, Context.NONE).getValue(); } /** * Creates a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @param properties Properties for the role assignment. - * @return The created {@link RoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope}, {@code name} or {@code properties} are null. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link RoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created + * {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * {@link RoleAssignmentProperties properties} are {@code null}. */ - public Response createKeyWithResponse(String scope, String name, - RoleAssignmentProperties properties, Context context) { + public Response createRoleAssignmentWithResponse(RoleScope scope, UUID name, + RoleAssignmentProperties properties, + Context context) { return asyncClient.createRoleAssignmentWithResponse(scope, name, properties, context).block(); } /** - * Creates a {@link RoleAssignment}. + * Gets a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @return The created {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return The {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment getRoleAssignment(String scope, String name) { - return getKeyWithResponse(scope, name, Context.NONE).getValue(); + public RoleAssignment getRoleAssignment(RoleScope scope, String name) { + return getRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** - * Creates a {@link RoleAssignment}. + * Gets a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @return The created {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return The {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ - public Response getKeyWithResponse(String scope, String name, Context context) { + public Response getRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); } /** - * Creates a {@link RoleAssignment}. + * Deletes a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @return The created {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return The {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment deleteRoleAssignment(String scope, String name) { - return deleteKeyWithResponse(scope, name, Context.NONE).getValue(); + public RoleAssignment deleteRoleAssignment(RoleScope scope, String name) { + return deleteRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** - * Creates a {@link RoleAssignment}. + * Deletes a {@link RoleAssignment}. * - * @param scope The scope of the role assignment to create. - * @param name The name used to create the role assignment. - * @return The created {@link RoleAssignment}. + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param name The name of the {@link RoleAssignment}. + * @return The {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@code scope} or {@code name} are null. + * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. */ - public Response deleteKeyWithResponse(String scope, String name, Context context) { + public Response deleteRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java new file mode 100644 index 000000000000..f430c63fa827 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java @@ -0,0 +1,30 @@ +package com.azure.security.keyvault.administration.models; + +import com.azure.core.util.ExpandableStringEnum; + +import java.net.URI; + +public final class RoleScope extends ExpandableStringEnum { + public static final RoleScope GLOBAL = fromString("/"); + public static final RoleScope KEYS = fromString("/keys"); + + /** + * Creates or finds a {@link RoleScope} from its string representation. + * + * @param name A name to look for. + * @return The corresponding {@link RoleScope} + */ + public static RoleScope fromString(String name) { + return fromString(name, RoleScope.class); + } + + /** + * Creates or finds a {@link RoleScope} from its string representation. + * + * @param uri A URI to look for. + * @return The corresponding {@link RoleScope} + */ + public static RoleScope fromUri(URI uri) { + return fromString(uri.getRawPath(), RoleScope.class); + } +} From 346b768f18d9d887ef686c78cc7f0dcdb24cd944 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 27 Aug 2020 03:03:45 -0700 Subject: [PATCH 16/40] Addressed more PR feedback. --- .../README.md | 4 +-- .../KeyVaultAccessControlAsyncClient.java | 7 +++-- .../KeyVaultAccessControlClient.java | 18 +++++++++++++ .../KeyVaultAccessControlClientBuilder.java | 3 +++ .../KeyVaultCredentialPolicy.java | 27 ++++++++++++------- .../administration/models/RoleScope.java | 3 +++ 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index 69c9af6f53ce..fcf9067f565d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -1,8 +1,8 @@ -# Azure Key Vault Administration client library for Java +# Azure Key Vault Administration library for Java ## Getting started ### Adding the package to your project -Maven dependency for the Azure Key Vault Administration client library. Add it to your project's POM file. +Maven dependency for the Azure Key Vault Administration library. Add it to your project's POM file. [//]: # ({x-version-update-start;com.azure:azure-security-keyvault-administration;current}) ```xml diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index fe37b061ff26..9cbf275c44b4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.administration; import com.azure.core.annotation.ReturnType; @@ -260,7 +263,7 @@ Mono> listRoleAssignmentsNextPage(String continuat * @param properties Properties for the {@link RoleAssignment}. * @return A {@link Mono} containing the created {@link RoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link RoleScope scope} or * {@link RoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -296,7 +299,7 @@ public Mono createRoleAssignment(RoleScope scope, UUID name, Rol * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link RoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link RoleScope scope} or * {@link RoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) 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 d3a0e4dce99b..70cf6454df7d 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 @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.administration; import com.azure.core.annotation.ReturnType; @@ -73,6 +76,21 @@ public PagedIterable listRoleAssignments(RoleScope scope, Contex return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); } + /** + * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * + * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. + * @param properties Properties for the {@link RoleAssignment}. + * @return The created {@link RoleAssignment}. + * @throws KeyVaultErrorException if the request is rejected by the server. + * @throws NullPointerException if the {@link RoleScope scope} or + * {@link RoleAssignmentProperties properties} are {@code null}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RoleAssignment createRoleAssignment(RoleScope scope, RoleAssignmentProperties properties) { + return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties, Context.NONE).getValue(); + } + /** * Creates a {@link RoleAssignment}. * 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 bb738ec6d2c0..5f9853b0ab86 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 @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.administration; import com.azure.core.credential.TokenCredential; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java index cb97c84877f0..9168ba3065af 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.security.keyvault.administration.implementation; import com.azure.core.credential.TokenCredential; @@ -18,8 +19,8 @@ import java.util.Objects; /** - * A policy that authenticates requests with Azure Key Vault service. The content added by this policy - * is leveraged in {@link TokenCredential} to get and set the correct "Authorization" header value. + * A policy that authenticates requests with Azure Key Vault service. The content added by this policy is leveraged + * in {@link TokenCredential} to get and set the correct "Authorization" header value. * * @see TokenCredential */ @@ -37,21 +38,24 @@ public final class KeyVaultCredentialPolicy implements HttpPipelinePolicy { */ public KeyVaultCredentialPolicy(TokenCredential credential) { Objects.requireNonNull(credential); - this.cache = new ScopeTokenCache((request) -> credential.getToken(request)); + + this.cache = new ScopeTokenCache(credential::getToken); } /** * Adds the required header to authenticate a request to Azure Key Vault service. * - * @param context The request context - * @param next The next HTTP pipeline policy to process the {@code context's} request after this policy completes. - * @return A {@link Mono} representing the HTTP response that will arrive asynchronously. + * @param context The request {@link HttpPipelineCallContext context}. + * @param next The next HTTP pipeline policy to process the {@link HttpPipelineCallContext context's} request + * after this policy completes. + * @return A {@link Mono} representing the {@link HttpResponse HTTP response} that will arrive asynchronously. */ @Override public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) { + if (context.getHttpRequest().getUrl().getProtocol().startsWith("http")) { return Mono.error(new RuntimeException("Token credentials require a URL using the HTTPS protocol scheme")); } + return next.clone().process() .doOnNext(httpResponse -> { // KV follows challenge based auth. Currently every service @@ -84,30 +88,33 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN /** * Extracts the challenge off the authentication header. * - * @param authenticateHeader The authentication header containing all the challenges. + * @param authenticateHeader The authentication header containing all the challenges. * @param authChallengePrefix The authentication challenge name. - * @return a challenge map. + * @return A challenge map. */ private static Map extractChallenge(String authenticateHeader, String authChallengePrefix) { if (!isValidChallenge(authenticateHeader, authChallengePrefix)) { return null; } + authenticateHeader = authenticateHeader.toLowerCase(Locale.ROOT).replace(authChallengePrefix.toLowerCase(Locale.ROOT), ""); String[] challenges = authenticateHeader.split(", "); Map challengeMap = new HashMap<>(); + for (String pair : challenges) { String[] keyValue = pair.split("="); challengeMap.put(keyValue[0].replaceAll("\"", ""), keyValue[1].replaceAll("\"", "")); } + return challengeMap; } /** * Verifies whether a challenge is bearer or not. * - * @param authenticateHeader The authentication header containing all the challenges. + * @param authenticateHeader The authentication header containing all the challenges. * @param authChallengePrefix The authentication challenge name. * @return A boolean indicating tha challenge is valid or not. */ diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java index f430c63fa827..5cef6c2ed1b4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.administration.models; import com.azure.core.util.ExpandableStringEnum; From 32084ad544aeff4626ce8a62a157334b6db7897d Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 27 Aug 2020 03:06:08 -0700 Subject: [PATCH 17/40] Added the new Key Vault Administration library to eng/jacoco-test-coverage/pom.xml --- eng/jacoco-test-coverage/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index 21d1c7195ac5..3423ca31b060 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -161,6 +161,11 @@ azure-search-documents 11.1.0-beta.2 + + com.azure + azure-security-keyvault-administration + 4.1.0-beta.1 + com.azure azure-security-keyvault-certificates From 14266a098b6b7cf6684ed8dd7fa9f70ea4764f87 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 27 Aug 2020 03:25:28 -0700 Subject: [PATCH 18/40] Re-generated code from the Swagger specification. --- .../KeyVaultAccessControlClientImpl.java | 31 ++++++++++++++++++- ...eyVaultAccessControlClientImplBuilder.java | 23 +++++++++++++- .../implementation/RoleAssignmentsImpl.java | 3 +- .../implementation/RoleDefinitionsImpl.java | 3 +- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java index 95d20513347b..1eedce941db5 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImpl.java @@ -9,6 +9,8 @@ import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; /** Initializes a new instance of the KeyVaultAccessControlClient type. */ public final class KeyVaultAccessControlClientImpl { @@ -36,6 +38,18 @@ public HttpPipeline getHttpPipeline() { return this.httpPipeline; } + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + /** The RoleDefinitionsImpl object to access its operations. */ private final RoleDefinitionsImpl roleDefinitions; @@ -62,7 +76,11 @@ public RoleAssignmentsImpl getRoleAssignments() { /** Initializes an instance of KeyVaultAccessControlClient client. */ KeyVaultAccessControlClientImpl() { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()).build()); + this( + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(), + JacksonAdapter.createDefaultSerializerAdapter()); } /** @@ -71,7 +89,18 @@ public RoleAssignmentsImpl getRoleAssignments() { * @param httpPipeline The HTTP pipeline to send requests through. */ KeyVaultAccessControlClientImpl(HttpPipeline httpPipeline) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + } + + /** + * Initializes an instance of KeyVaultAccessControlClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + */ + KeyVaultAccessControlClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter) { this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; this.apiVersion = "7.2-preview"; this.roleDefinitions = new RoleDefinitionsImpl(this); this.roleAssignments = new RoleAssignmentsImpl(this); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java index 6b9669831f68..d135ff4387b1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultAccessControlClientImplBuilder.java @@ -10,6 +10,8 @@ import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; /** A builder for creating a new instance of the KeyVaultAccessControlClient type. */ @ServiceClientBuilder(serviceClients = {KeyVaultAccessControlClientImpl.class}) @@ -30,6 +32,22 @@ public KeyVaultAccessControlClientImplBuilder pipeline(HttpPipeline pipeline) { return this; } + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the KeyVaultAccessControlClientImplBuilder. + */ + public KeyVaultAccessControlClientImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + /** * Builds an instance of KeyVaultAccessControlClientImpl with the provided parameters. * @@ -42,7 +60,10 @@ public KeyVaultAccessControlClientImpl buildClient() { .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) .build(); } - KeyVaultAccessControlClientImpl client = new KeyVaultAccessControlClientImpl(pipeline); + if (serializerAdapter == null) { + this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter(); + } + KeyVaultAccessControlClientImpl client = new KeyVaultAccessControlClientImpl(pipeline, serializerAdapter); return client; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index 38b6105e4132..ef7d31d6b48b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -42,7 +42,8 @@ public final class RoleAssignmentsImpl { * @param client the instance of the service client containing this operation class. */ RoleAssignmentsImpl(KeyVaultAccessControlClientImpl client) { - this.service = RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline()); + this.service = + RestProxy.create(RoleAssignmentsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 8ed6b52ed375..0bb245c326f4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -38,7 +38,8 @@ public final class RoleDefinitionsImpl { * @param client the instance of the service client containing this operation class. */ RoleDefinitionsImpl(KeyVaultAccessControlClientImpl client) { - this.service = RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline()); + this.service = + RestProxy.create(RoleDefinitionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); this.client = client; } From 563f00de09a4888872e3b0b6341b8bc48ae0f850 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 12:48:21 -0700 Subject: [PATCH 19/40] Renamed many of the implementation models. --- .../CHANGELOG.md | 2 +- .../README.md | 2 +- .../pom.xml | 17 +- .../KeyVaultAccessControlAsyncClient.java | 280 +++++++++--------- .../KeyVaultAccessControlClient.java | 139 ++++----- .../KeyVaultAccessControlClientBuilder.java | 21 +- .../KeyVaultCredentialPolicy.java | 2 +- .../KeyVaultErrorCodeStrings.java | 9 +- .../implementation/RoleAssignmentsImpl.java | 31 +- .../implementation/RoleDefinitionsImpl.java | 12 +- .../implementation/ScopeTokenCache.java | 7 +- ...ermission.java => KeyVaultPermission.java} | 20 +- ...nment.java => KeyVaultRoleAssignment.java} | 12 +- ...yVaultRoleAssignmentCreateParameters.java} | 12 +- ...java => KeyVaultRoleAssignmentFilter.java} | 8 +- ... => KeyVaultRoleAssignmentListResult.java} | 16 +- ... => KeyVaultRoleAssignmentProperties.java} | 12 +- ...ultRoleAssignmentPropertiesWithScope.java} | 16 +- ...ition.java => KeyVaultRoleDefinition.java} | 28 +- ...java => KeyVaultRoleDefinitionFilter.java} | 8 +- ... => KeyVaultRoleDefinitionListResult.java} | 16 +- .../models/KeyVaultRoleScope.java | 33 +++ .../administration/models/RoleScope.java | 33 --- .../swagger/autorest.md | 34 +++ 24 files changed, 407 insertions(+), 363 deletions(-) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{Permission.java => KeyVaultPermission.java} (81%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignment.java => KeyVaultRoleAssignment.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignmentCreateParameters.java => KeyVaultRoleAssignmentCreateParameters.java} (65%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignmentFilter.java => KeyVaultRoleAssignmentFilter.java} (79%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignmentListResult.java => KeyVaultRoleAssignmentListResult.java} (72%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignmentProperties.java => KeyVaultRoleAssignmentProperties.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleAssignmentPropertiesWithScope.java => KeyVaultRoleAssignmentPropertiesWithScope.java} (75%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleDefinition.java => KeyVaultRoleDefinition.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleDefinitionFilter.java => KeyVaultRoleDefinitionFilter.java} (79%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{RoleDefinitionListResult.java => KeyVaultRoleDefinitionListResult.java} (72%) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md b/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md index b9bbe3a8243f..6844fbdfbbd0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md +++ b/sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md @@ -1,3 +1,3 @@ # Release History -## 4.1.0-beta.1 (Unreleased) +## 4.0.0-beta.1 (Unreleased) - Added `KeyVaultAccessControlClient`. diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index fcf9067f565d..ee1e5f901557 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -9,7 +9,7 @@ Maven dependency for the Azure Key Vault Administration library. Add it to your com.azure azure-security-keyvault-administration - 4.1.0-beta.1 + 4.0.0-beta.1 ``` [//]: # ({x-version-update-end}) diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml index b7a0acfd6d8e..3a340d75ee46 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -13,7 +13,7 @@ com.azure azure-security-keyvault-administration - 4.1.0-beta.1 + 4.0.0-beta.1 Microsoft Azure client library for KeyVault Administration This module contains client library for Microsoft Azure KeyVault Administration. @@ -38,9 +38,6 @@ org.apache.maven.plugins maven-surefire-plugin 3.0.0-M3 - - 3 - @@ -49,12 +46,12 @@ com.azure azure-core - 1.5.1 + 1.7.0 com.azure azure-core-http-netty - 1.5.2 + 1.5.4 @@ -84,25 +81,25 @@ io.projectreactor reactor-test - 3.3.5.RELEASE + 3.3.9.RELEASE test com.azure azure-core-test - 1.3.0 + 1.4.0 test com.azure azure-core-http-okhttp - 1.2.3 + 1.2.5 test com.azure azure-identity - 1.0.7 + 1.1.0 test diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 9cbf275c44b4..cd097c8ef584 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -17,7 +17,7 @@ import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import com.azure.security.keyvault.administration.implementation.models.*; -import com.azure.security.keyvault.administration.models.RoleScope; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import reactor.core.publisher.Mono; import java.net.URL; @@ -30,8 +30,9 @@ /** * The {@link KeyVaultAccessControlAsyncClient} provides asynchronous methods to view and manage Role Based Access - * for the Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment role - * assignments}. Additionally, the client supports listing {@link RoleDefinition role definitions}. + * for the Azure Key Vault. The client supports creating, listing, updating, and deleting + * {@link KeyVaultRoleAssignment role assignments}. Additionally, the client supports listing + * {@link KeyVaultRoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class, isAsync = true) public class KeyVaultAccessControlAsyncClient { @@ -78,17 +79,17 @@ public String getVaultUrl() { } /** - * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. - * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} for the given - * {@link RoleScope scope}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. + * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedFlux listRoleDefinitions(RoleScope scope) { + public PagedFlux listRoleDefinitions(KeyVaultRoleScope scope) { try { return new PagedFlux<>( () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), @@ -99,36 +100,36 @@ public PagedFlux listRoleDefinitions(RoleScope scope) { } /** - * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. + * @param scope 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. - * @return A {@link PagedFlux} containing the {@link RoleDefinition role definitions} for the given - * {@link RoleScope scope}. + * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - PagedFlux listRoleDefinitions(RoleScope scope, Context context) { + PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, Context context) { return new PagedFlux<>( () -> listRoleDefinitionsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); } /** - * Get all {@link RoleDefinition role definitions} in the first page that are applicable at the given - * {@link RoleScope scope} and above. + * Get all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given + * {@link KeyVaultRoleScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link RoleScope scope} of the {@link RoleDefinition}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the - * given {@link RoleScope scope} from the first page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} + * for the given {@link KeyVaultRoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - Mono> listRoleDefinitionsFirstPage(String vaultUrl, RoleScope scope, - Context context) { + Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope scope, + Context context) { try { return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -142,18 +143,18 @@ Mono> listRoleDefinitionsFirstPage(String vaultUrl } /** - * Gets all the {@link RoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved from - * a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, RoleScope, Context)}. + * Gets all the {@link KeyVaultRoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved + * from a call to + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleScope, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the {@code listRoleDefinitions} operations. + * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleDefinition role definitions} for the - * given {@link RoleScope scope} from the next page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} + * for the given {@link KeyVaultRoleScope scope} from the next page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. */ - Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { + Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { return clientImpl.getRoleDefinitions().listNextSinglePageAsync(continuationToken, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -167,17 +168,17 @@ Mono> listRoleDefinitionsNextPage(String continuat } /** - * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} for the given - * {@link RoleScope scope}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public PagedFlux listRoleAssignments(RoleScope scope) { + public PagedFlux listRoleAssignments(KeyVaultRoleScope scope) { try { return new PagedFlux<>( () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), @@ -188,36 +189,36 @@ public PagedFlux listRoleAssignments(RoleScope scope) { } /** - * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedFlux} containing the {@link RoleAssignment role assignments} for the given - * {@link RoleScope scope}. + * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - PagedFlux listRoleAssignments(RoleScope scope, Context context) { + PagedFlux listRoleAssignments(KeyVaultRoleScope scope, Context context) { return new PagedFlux<>( () -> listRoleAssignmentsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); } /** - * Get all {@link RoleAssignment role assignments} in the first page that are applicable at - * the given {@link RoleScope scope} and above. + * Get all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at + * the given {@link KeyVaultRoleScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} in the - * given {@link RoleScope scope} from the first page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} + * in the given {@link KeyVaultRoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - Mono> listRoleAssignmentsFirstPage(String vaultUrl, RoleScope scope, - Context context) { + Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleScope scope, + Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); try { @@ -233,17 +234,17 @@ Mono> listRoleAssignmentsFirstPage(String vaultUrl } /** - * Gets all the {@link RoleAssignment role assignments} given by the {@code nextPageLink} that was retrieved from - * a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(RoleScope)}. + * Gets all the {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was + * retrieved from a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the {@code listRoleAssignments} operations. + * successful call to one of the {@code listKeyVaultRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link Mono} containing a {@link PagedResponse} of {@link RoleAssignment role assignments} for the - * given {@link RoleScope scope} from the first page of results. + * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} + * for the given {@link KeyVaultRoleScope scope} from the first page of results. * @throws KeyVaultErrorException if the operation is unsuccessful. */ - Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { + Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { return clientImpl.getRoleAssignments().listForScopeNextSinglePageAsync(continuationToken, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -257,33 +258,35 @@ Mono> listRoleAssignmentsNextPage(String continuat } /** - * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param properties Properties for the {@link RoleAssignment}. - * @return A {@link Mono} containing the created {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(RoleScope scope, RoleAssignmentProperties properties) { + public Mono createRoleAssignment(KeyVaultRoleScope scope, + KeyVaultRoleAssignmentProperties properties) { return createRoleAssignment(scope, UUID.randomUUID(), properties); } /** - * Creates a {@link RoleAssignment}. + * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. - * @param properties Properties for the {@link RoleAssignment}. - * @return A {@link Mono} containing the created {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(RoleScope scope, UUID name, RoleAssignmentProperties properties) { + public Mono createRoleAssignment(KeyVaultRoleScope scope, UUID name, + KeyVaultRoleAssignmentProperties properties) { try { return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -292,37 +295,37 @@ public Mono createRoleAssignment(RoleScope scope, UUID name, Rol } /** - * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param properties Properties for the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(RoleScope scope, - RoleAssignmentProperties properties) { + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, + KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties); } /** - * Creates a {@link RoleAssignment}. + * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. - * @param properties Properties for the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(RoleScope scope, UUID name, - RoleAssignmentProperties properties) { + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + KeyVaultRoleAssignmentProperties properties) { try { return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); } catch (RuntimeException ex) { @@ -331,44 +334,44 @@ public Mono> createRoleAssignmentWithResponse(RoleScope } /** - * Creates a {@link RoleAssignment}. + * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. - * @param properties Properties for the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(RoleScope scope, UUID name, - RoleAssignmentProperties properties, - Context context) { + Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + KeyVaultRoleAssignmentProperties properties, + Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); Objects.requireNonNull(properties, "'properties' cannot be null."); - RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters().setProperties(properties); - return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), parameters, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + KeyVaultRoleAssignmentCreateParameters parameters = new KeyVaultRoleAssignmentCreateParameters().setProperties(properties); + return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), + parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); } /** - * Gets a {@link RoleAssignment}. + * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name used of the {@link RoleAssignment}. - * @return A {@link Mono} containing the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name used of the {@link KeyVaultRoleAssignment}. + * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRoleAssignment(RoleScope scope, String name) { + public Mono getRoleAssignment(KeyVaultRoleScope scope, String name) { try { return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -377,17 +380,17 @@ public Mono getRoleAssignment(RoleScope scope, String name) { } /** - * Gets a {@link RoleAssignment}. + * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(RoleScope scope, String name) { + public Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name) { try { return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); } catch (RuntimeException ex) { @@ -396,17 +399,18 @@ public Mono> getRoleAssignmentWithResponse(RoleScope sc } /** - * Gets a {@link RoleAssignment}. + * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ - Mono> getRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { + Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); @@ -418,16 +422,16 @@ Mono> getRoleAssignmentWithResponse(RoleScope scope, St } /** - * Deletes a {@link RoleAssignment}. + * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @return A {@link Mono} containing the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteRoleAssignment(RoleScope scope, String name) { + public Mono deleteRoleAssignment(KeyVaultRoleScope scope, String name) { try { return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { @@ -436,17 +440,18 @@ public Mono deleteRoleAssignment(RoleScope scope, String name) { } /** - * Deletes a {@link RoleAssignment}. + * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(RoleScope scope, String name) { + public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, + String name) { try { return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); } catch (RuntimeException ex) { @@ -455,17 +460,18 @@ public Mono> deleteRoleAssignmentWithResponse(RoleScope } /** - * Deletes a {@link RoleAssignment}. + * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { + Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Context context) { Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); 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 70cf6454df7d..8ec535834e15 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 @@ -10,18 +10,18 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentProperties; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; -import com.azure.security.keyvault.administration.models.RoleScope; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignment; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentProperties; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinition; +import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; import reactor.core.publisher.Mono; import java.util.UUID; /** * The {@link KeyVaultAccessControlClient} provides synchronous methods to view and manage Role Based Access for the - * Azure Key Vault. The client supports creating, listing, updating, and deleting {@link RoleAssignment role - * assignments}. Additionally, the client supports listing {@link RoleDefinition role definitions}. + * Azure Key Vault. The client supports creating, listing, updating, and deleting {@link KeyVaultRoleAssignment role + * assignments}. Additionally, the client supports listing {@link KeyVaultRoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class) public class KeyVaultAccessControlClient { @@ -47,137 +47,140 @@ public String getVaultUrl() { } /** - * Get all {@link RoleDefinition role definitions} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleDefinition role definitions}. + * @param scope 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. - * @return A {@link PagedIterable} containing the {@link RoleDefinition role definitions} for the given - * {@link RoleScope scope}. + * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - public PagedIterable listRoleDefinitions(RoleScope scope, Context context) { + public PagedIterable listRoleDefinitions(KeyVaultRoleScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, context)); } /** - * Get all {@link RoleAssignment role assignments} that are applicable at the given {@link RoleScope + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope * scope} and above. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. - * @return A {@link PagedIterable} containing the {@link RoleAssignment role assignments} for the given - * {@link RoleScope scope}. + * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given + * {@link KeyVaultRoleScope scope}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - public PagedIterable listRoleAssignments(RoleScope scope, Context context) { + public PagedIterable listRoleAssignments(KeyVaultRoleScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); } /** - * Creates a {@link RoleAssignment} with a randomly generated {@link UUID name}. + * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param properties Properties for the {@link RoleAssignment}. - * @return The created {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @return The created {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment createRoleAssignment(RoleScope scope, RoleAssignmentProperties properties) { + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, + KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties, Context.NONE).getValue(); } /** - * Creates a {@link RoleAssignment}. + * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. - * @param properties Properties for the {@link RoleAssignment}. - * @return The created {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. + * @return The created {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment createRoleAssignment(RoleScope scope, UUID name, - RoleAssignmentProperties properties) { + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID name, + KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, name, properties, Context.NONE).getValue(); } /** - * Creates a {@link RoleAssignment}. + * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment} to create. - * @param name The name used to create the {@link RoleAssignment}. It can be any valid UUID. - * @param properties Properties for the {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created - * {@link RoleAssignment}. + * {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link RoleScope scope}, {@link UUID name} or - * {@link RoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - public Response createRoleAssignmentWithResponse(RoleScope scope, UUID name, - RoleAssignmentProperties properties, - Context context) { + public Response createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + KeyVaultRoleAssignmentProperties properties, + Context context) { return asyncClient.createRoleAssignmentWithResponse(scope, name, properties, context).block(); } /** - * Gets a {@link RoleAssignment}. + * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @return The {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @return The {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment getRoleAssignment(RoleScope scope, String name) { + public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope scope, String name) { return getRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** - * Gets a {@link RoleAssignment}. + * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @return The {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @return The {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ - public Response getRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { + public Response getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Context context) { return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); } /** - * Deletes a {@link RoleAssignment}. + * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @return The {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @return The {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public RoleAssignment deleteRoleAssignment(RoleScope scope, String name) { + public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope scope, String name) { return deleteRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** - * Deletes a {@link RoleAssignment}. + * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link RoleScope scope} of the {@link RoleAssignment}. - * @param name The name of the {@link RoleAssignment}. - * @return The {@link RoleAssignment}. + * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @return The {@link KeyVaultRoleAssignment}. * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link RoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ - public Response deleteRoleAssignmentWithResponse(RoleScope scope, String name, Context context) { + public Response deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Context context) { return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); } } 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 5f9853b0ab86..67283bba4f58 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 @@ -24,8 +24,9 @@ /** * This class provides a fluent builder API to help aid the configuration and instantiation of the * {@link KeyVaultAccessControlAsyncClient} and {@link KeyVaultAccessControlClient}, by calling - * {@link KeyVaultAccessControlClientBuilder#buildAsyncClient()} and {@link KeyVaultAccessControlClientBuilder#buildClient()} - * respectively. It constructs an instance of the desired client. + * {@link KeyVaultAccessControlClientBuilder#buildAsyncClient()} and + * {@link KeyVaultAccessControlClientBuilder#buildClient()} respectively. It constructs an instance of the desired + * client. * *

The minimal configuration options required by {@link KeyVaultAccessControlClientBuilder} to build an * an {@link KeyVaultAccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

@@ -38,8 +39,8 @@ * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.withhttpclient.instantiation} * *

Alternatively, a custom {@link HttpPipeline} with custom {@link HttpPipelinePolicy} policies and {@link String - * vaultUrl} can be specified. It provides finer control over the construction of {@link KeyVaultAccessControlAsyncClient} - * and {@link KeyVaultAccessControlClient} instances.

+ * vaultUrl} can be specified. It provides finer control over the construction of + * {@link KeyVaultAccessControlAsyncClient} and {@link KeyVaultAccessControlClient} instances.

*

* {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.pipeline.instantiation} * @@ -81,8 +82,8 @@ public KeyVaultAccessControlClientBuilder() { } /** - * Creates an {@link KeyVaultAccessControlClient} based on options set in the Builder. Every time {@code buildClient()} - * is called a new instance of {@link KeyVaultAccessControlClient} is created. + * Creates an {@link KeyVaultAccessControlClient} based on options set in the Builder. Every time {@code + * buildClient()} is called a new instance of {@link KeyVaultAccessControlClient} is created. *

* If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and * {@link #vaultUrl(String) vaultUrl} are used to create the {@link KeyVaultAccessControlClient client}. All other @@ -100,8 +101,8 @@ public KeyVaultAccessControlClient buildClient() { * buildAsyncClient()} is called a new instance of {@link KeyVaultAccessControlAsyncClient} is created. *

* If {@link #pipeline(HttpPipeline) pipeline} is set, then only the {@code pipeline} and - * {@link #vaultUrl(String) endpoint} are used to create the {@link KeyVaultAccessControlAsyncClient client}. All other - * builder settings are ignored. + * {@link #vaultUrl(String) endpoint} are used to create the {@link KeyVaultAccessControlAsyncClient client}. All + * other builder settings are ignored. * * @return An {@link KeyVaultAccessControlAsyncClient} with the options set from the builder. * @throws NullPointerException If {@code vaultUrl} is {@code null}. @@ -228,8 +229,8 @@ public KeyVaultAccessControlClientBuilder httpClient(HttpClient client) { * Sets the HTTP pipeline to use for the service client. *

* If {@code pipeline} is set, all other settings are ignored, aside from - * {@link KeyVaultAccessControlClientBuilder#vaultUrl(String) vaultUrl} to build {@link KeyVaultAccessControlClient} or - * {@link KeyVaultAccessControlAsyncClient}. + * {@link KeyVaultAccessControlClientBuilder#vaultUrl(String) vaultUrl} to build {@link KeyVaultAccessControlClient} + * or {@link KeyVaultAccessControlAsyncClient}. * * @param pipeline The HTTP pipeline to use for sending service requests and receiving responses. * @return The updated {@link KeyVaultAccessControlClientBuilder} object. diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java index 9168ba3065af..947721a0cdc4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java @@ -52,7 +52,7 @@ public KeyVaultCredentialPolicy(TokenCredential credential) { */ @Override public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - if (context.getHttpRequest().getUrl().getProtocol().startsWith("http")) { + if (!context.getHttpRequest().getUrl().getProtocol().startsWith("https")) { return Mono.error(new RuntimeException("Token credentials require a URL using the HTTPS protocol scheme")); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java index a1a61ce929e8..1caab79ba8bb 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java @@ -19,12 +19,12 @@ public class KeyVaultErrorCodeStrings { /** * The property name of Azure Key Vault Endpoint required error string. */ - public static final String VAULT_END_POINT_REQUIRED = "vault_endpoint_required"; + public static final String VAULT_END_POINT_REQUIRED = "vault_endpoint_required"; /** - * Gets the error String for the specified property. + * Gets the error String for the specified property. * - * @param propertyName the property name for which error string is required. + * @param propertyName The property name for which error string is required. * @return The {@link String value} containing the error message. */ public static String getErrorString(String propertyName) { @@ -32,10 +32,11 @@ public static String getErrorString(String propertyName) { return errorStrings.getProperty(propertyName); } + @SuppressWarnings("ConstantConditions") private static synchronized void loadProperties() { if (errorStrings == null) { try (InputStream fileInputStream = - KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { + KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { errorStrings = new Properties(); errorStrings.load(fileInputStream); } catch (IOException ex) { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index ef7d31d6b48b..f594fcabd95b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -23,9 +23,9 @@ import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentCreateParameters; -import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentListResult; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignment; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentCreateParameters; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentListResult; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in RoleAssignments. */ @@ -57,7 +57,7 @@ private interface RoleAssignmentsService { @Delete("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> delete( + Mono> delete( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @@ -67,18 +67,18 @@ Mono> delete( @Put("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({201}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> create( + Mono> create( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") RoleAssignmentCreateParameters parameters, + @BodyParam("application/json") KeyVaultRoleAssignmentCreateParameters parameters, Context context); @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> get( + Mono> get( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @@ -88,7 +88,7 @@ Mono> get( @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listForScope( + Mono> listForScope( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @QueryParam("$filter") String filter, @@ -98,7 +98,7 @@ Mono> listForScope( @Get("{nextLink}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listForScopeNext( + Mono> listForScopeNext( @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } @@ -115,7 +115,7 @@ Mono> listForScopeNext( * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync( + public Mono> deleteWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { return service.delete(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } @@ -134,11 +134,11 @@ public Mono> deleteWithResponseAsync( * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync( + public Mono> createWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, - RoleAssignmentCreateParameters parameters, + KeyVaultRoleAssignmentCreateParameters parameters, Context context) { return service.create( vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), parameters, context); @@ -157,7 +157,7 @@ public Mono> createWithResponseAsync( * @return the specified role assignment. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync( + public Mono> getWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { return service.get(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } @@ -177,7 +177,7 @@ public Mono> getWithResponseAsync( * @return role assignments for a scope. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeSinglePageAsync( + public Mono> listForScopeSinglePageAsync( String vaultBaseUrl, String scope, String filter, Context context) { return service.listForScope(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) .map( @@ -202,7 +202,8 @@ public Mono> listForScopeSinglePageAsync( * @return role assignment list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeNextSinglePageAsync(String nextLink, Context context) { + public Mono> listForScopeNextSinglePageAsync( + String nextLink, Context context) { return service.listForScopeNext(nextLink, context) .map( res -> diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 0bb245c326f4..63f98bc31b20 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -20,8 +20,8 @@ import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; -import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinition; +import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinitionListResult; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in RoleDefinitions. */ @@ -53,7 +53,7 @@ private interface RoleDefinitionsService { @Get("/{scope}/providers/Microsoft.Authorization/roleDefinitions") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> list( + Mono> list( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @QueryParam("$filter") String filter, @@ -63,7 +63,7 @@ Mono> list( @Get("{nextLink}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listNext( + Mono> listNext( @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } @@ -81,7 +81,7 @@ Mono> listNext( * @return all role definitions that are applicable at scope and above. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listSinglePageAsync( + public Mono> listSinglePageAsync( String vaultBaseUrl, String scope, String filter, Context context) { return service.list(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) .map( @@ -106,7 +106,7 @@ public Mono> listSinglePageAsync( * @return role definition list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listNextSinglePageAsync(String nextLink, Context context) { + public Mono> listNextSinglePageAsync(String nextLink, Context context) { return service.listNext(nextLink, context) .map( res -> diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java index c7f1aaba7b6d..a6a86ac4162f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java @@ -40,6 +40,7 @@ public void setTokenRequest(TokenRequestContext request) { /** * Asynchronously get a token from either the cache or replenish the cache with a new token. + * * @return a Publisher that emits an AccessToken */ public Mono getToken() { @@ -49,9 +50,9 @@ public Mono getToken() { return Mono.defer(() -> { if (!wip.getAndSet(true)) { return getNew.apply(request).doOnNext(ac -> cache = ac) - .doOnNext(sink::next) - .doOnError(sink::error) - .doOnTerminate(() -> wip.set(false)); + .doOnNext(sink::next) + .doOnError(sink::error) + .doOnTerminate(() -> wip.set(false)); } else { return emitterProcessor.next(); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java similarity index 81% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java index d1feaf6d24e4..39d297ab1f70 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java @@ -8,9 +8,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The Permission model. */ +/** The KeyVaultPermission model. */ @Fluent -public final class Permission { +public final class KeyVaultPermission { /* * Allowed actions. */ @@ -48,9 +48,9 @@ public List getActions() { * Set the actions property: Allowed actions. * * @param actions the actions value to set. - * @return the Permission object itself. + * @return the KeyVaultPermission object itself. */ - public Permission setActions(List actions) { + public KeyVaultPermission setActions(List actions) { this.actions = actions; return this; } @@ -68,9 +68,9 @@ public List getNotActions() { * Set the notActions property: Denied actions. * * @param notActions the notActions value to set. - * @return the Permission object itself. + * @return the KeyVaultPermission object itself. */ - public Permission setNotActions(List notActions) { + public KeyVaultPermission setNotActions(List notActions) { this.notActions = notActions; return this; } @@ -88,9 +88,9 @@ public List getDataActions() { * Set the dataActions property: Allowed Data actions. * * @param dataActions the dataActions value to set. - * @return the Permission object itself. + * @return the KeyVaultPermission object itself. */ - public Permission setDataActions(List dataActions) { + public KeyVaultPermission setDataActions(List dataActions) { this.dataActions = dataActions; return this; } @@ -108,9 +108,9 @@ public List getNotDataActions() { * Set the notDataActions property: Denied Data actions. * * @param notDataActions the notDataActions value to set. - * @return the Permission object itself. + * @return the KeyVaultPermission object itself. */ - public Permission setNotDataActions(List notDataActions) { + public KeyVaultPermission setNotDataActions(List notDataActions) { this.notDataActions = notDataActions; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java index 1d06ce14088f..45af1a2825bf 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleAssignment model. */ +/** The KeyVaultRoleAssignment model. */ @Fluent -public final class RoleAssignment { +public final class KeyVaultRoleAssignment { /* * The role assignment ID. */ @@ -32,7 +32,7 @@ public final class RoleAssignment { * Role assignment properties. */ @JsonProperty(value = "properties") - private RoleAssignmentPropertiesWithScope properties; + private KeyVaultRoleAssignmentPropertiesWithScope properties; /** * Get the id property: The role assignment ID. @@ -66,7 +66,7 @@ public String getType() { * * @return the properties value. */ - public RoleAssignmentPropertiesWithScope getProperties() { + public KeyVaultRoleAssignmentPropertiesWithScope getProperties() { return this.properties; } @@ -74,9 +74,9 @@ public RoleAssignmentPropertiesWithScope getProperties() { * Set the properties property: Role assignment properties. * * @param properties the properties value to set. - * @return the RoleAssignment object itself. + * @return the KeyVaultRoleAssignment object itself. */ - public RoleAssignment setProperties(RoleAssignmentPropertiesWithScope properties) { + public KeyVaultRoleAssignment setProperties(KeyVaultRoleAssignmentPropertiesWithScope properties) { this.properties = properties; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java similarity index 65% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java index 56d16b847a06..7be49299e176 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java @@ -7,21 +7,21 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleAssignmentCreateParameters model. */ +/** The KeyVaultRoleAssignmentCreateParameters model. */ @Fluent -public final class RoleAssignmentCreateParameters { +public final class KeyVaultRoleAssignmentCreateParameters { /* * Role assignment properties. */ @JsonProperty(value = "properties", required = true) - private RoleAssignmentProperties properties; + private KeyVaultRoleAssignmentProperties properties; /** * Get the properties property: Role assignment properties. * * @return the properties value. */ - public RoleAssignmentProperties getProperties() { + public KeyVaultRoleAssignmentProperties getProperties() { return this.properties; } @@ -29,9 +29,9 @@ public RoleAssignmentProperties getProperties() { * Set the properties property: Role assignment properties. * * @param properties the properties value to set. - * @return the RoleAssignmentCreateParameters object itself. + * @return the KeyVaultRoleAssignmentCreateParameters object itself. */ - public RoleAssignmentCreateParameters setProperties(RoleAssignmentProperties properties) { + public KeyVaultRoleAssignmentCreateParameters setProperties(KeyVaultRoleAssignmentProperties properties) { this.properties = properties; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java similarity index 79% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java index c04d69f36bd9..a8440c925b16 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleAssignmentFilter model. */ +/** The KeyVaultRoleAssignmentFilter model. */ @Fluent -public final class RoleAssignmentFilter { +public final class KeyVaultRoleAssignmentFilter { /* * Returns role assignment of the specific principal. */ @@ -29,9 +29,9 @@ public String getPrincipalId() { * Set the principalId property: Returns role assignment of the specific principal. * * @param principalId the principalId value to set. - * @return the RoleAssignmentFilter object itself. + * @return the KeyVaultRoleAssignmentFilter object itself. */ - public RoleAssignmentFilter setPrincipalId(String principalId) { + public KeyVaultRoleAssignmentFilter setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java similarity index 72% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java index 72a6eb8440a6..9a9801156e6c 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java @@ -8,14 +8,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The RoleAssignmentListResult model. */ +/** The KeyVaultRoleAssignmentListResult model. */ @Fluent -public final class RoleAssignmentListResult { +public final class KeyVaultRoleAssignmentListResult { /* * Role assignment list. */ @JsonProperty(value = "value") - private List value; + private List value; /* * The URL to use for getting the next set of results. @@ -28,7 +28,7 @@ public final class RoleAssignmentListResult { * * @return the value value. */ - public List getValue() { + public List getValue() { return this.value; } @@ -36,9 +36,9 @@ public List getValue() { * Set the value property: Role assignment list. * * @param value the value value to set. - * @return the RoleAssignmentListResult object itself. + * @return the KeyVaultRoleAssignmentListResult object itself. */ - public RoleAssignmentListResult setValue(List value) { + public KeyVaultRoleAssignmentListResult setValue(List value) { this.value = value; return this; } @@ -56,9 +56,9 @@ public String getNextLink() { * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. - * @return the RoleAssignmentListResult object itself. + * @return the KeyVaultRoleAssignmentListResult object itself. */ - public RoleAssignmentListResult setNextLink(String nextLink) { + public KeyVaultRoleAssignmentListResult setNextLink(String nextLink) { this.nextLink = nextLink; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java index 0ab892817a1e..b8a99d1ab864 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleAssignmentProperties model. */ +/** The KeyVaultRoleAssignmentProperties model. */ @Fluent -public final class RoleAssignmentProperties { +public final class KeyVaultRoleAssignmentProperties { /* * The role definition ID used in the role assignment. */ @@ -37,9 +37,9 @@ public String getRoleDefinitionId() { * Set the roleDefinitionId property: The role definition ID used in the role assignment. * * @param roleDefinitionId the roleDefinitionId value to set. - * @return the RoleAssignmentProperties object itself. + * @return the KeyVaultRoleAssignmentProperties object itself. */ - public RoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { + public KeyVaultRoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { this.roleDefinitionId = roleDefinitionId; return this; } @@ -59,9 +59,9 @@ public String getPrincipalId() { * Directory. It can point to a user, service principal, or security group. * * @param principalId the principalId value to set. - * @return the RoleAssignmentProperties object itself. + * @return the KeyVaultRoleAssignmentProperties object itself. */ - public RoleAssignmentProperties setPrincipalId(String principalId) { + public KeyVaultRoleAssignmentProperties setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java similarity index 75% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java index ff50c91dc2ae..1c92c0cf849d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleAssignmentPropertiesWithScope model. */ +/** The KeyVaultRoleAssignmentPropertiesWithScope model. */ @Fluent -public final class RoleAssignmentPropertiesWithScope { +public final class KeyVaultRoleAssignmentPropertiesWithScope { /* * The role assignment scope. */ @@ -41,9 +41,9 @@ public String getScope() { * Set the scope property: The role assignment scope. * * @param scope the scope value to set. - * @return the RoleAssignmentPropertiesWithScope object itself. + * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. */ - public RoleAssignmentPropertiesWithScope setScope(String scope) { + public KeyVaultRoleAssignmentPropertiesWithScope setScope(String scope) { this.scope = scope; return this; } @@ -61,9 +61,9 @@ public String getRoleDefinitionId() { * Set the roleDefinitionId property: The role definition ID. * * @param roleDefinitionId the roleDefinitionId value to set. - * @return the RoleAssignmentPropertiesWithScope object itself. + * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. */ - public RoleAssignmentPropertiesWithScope setRoleDefinitionId(String roleDefinitionId) { + public KeyVaultRoleAssignmentPropertiesWithScope setRoleDefinitionId(String roleDefinitionId) { this.roleDefinitionId = roleDefinitionId; return this; } @@ -81,9 +81,9 @@ public String getPrincipalId() { * Set the principalId property: The principal ID. * * @param principalId the principalId value to set. - * @return the RoleAssignmentPropertiesWithScope object itself. + * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. */ - public RoleAssignmentPropertiesWithScope setPrincipalId(String principalId) { + public KeyVaultRoleAssignmentPropertiesWithScope setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java index 5383e4acbb8a..739029113427 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java @@ -9,10 +9,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The RoleDefinition model. */ +/** The KeyVaultRoleDefinition model. */ @JsonFlatten @Fluent -public class RoleDefinition { +public class KeyVaultRoleDefinition { /* * The role definition ID. */ @@ -53,7 +53,7 @@ public class RoleDefinition { * Role definition permissions. */ @JsonProperty(value = "properties.permissions") - private List permissions; + private List permissions; /* * Role definition assignable scopes. @@ -101,9 +101,9 @@ public String getRoleName() { * Set the roleName property: The role name. * * @param roleName the roleName value to set. - * @return the RoleDefinition object itself. + * @return the KeyVaultRoleDefinition object itself. */ - public RoleDefinition setRoleName(String roleName) { + public KeyVaultRoleDefinition setRoleName(String roleName) { this.roleName = roleName; return this; } @@ -121,9 +121,9 @@ public String getDescription() { * Set the description property: The role definition description. * * @param description the description value to set. - * @return the RoleDefinition object itself. + * @return the KeyVaultRoleDefinition object itself. */ - public RoleDefinition setDescription(String description) { + public KeyVaultRoleDefinition setDescription(String description) { this.description = description; return this; } @@ -141,9 +141,9 @@ public String getRoleType() { * Set the roleType property: The role type. * * @param roleType the roleType value to set. - * @return the RoleDefinition object itself. + * @return the KeyVaultRoleDefinition object itself. */ - public RoleDefinition setRoleType(String roleType) { + public KeyVaultRoleDefinition setRoleType(String roleType) { this.roleType = roleType; return this; } @@ -153,7 +153,7 @@ public RoleDefinition setRoleType(String roleType) { * * @return the permissions value. */ - public List getPermissions() { + public List getPermissions() { return this.permissions; } @@ -161,9 +161,9 @@ public List getPermissions() { * Set the permissions property: Role definition permissions. * * @param permissions the permissions value to set. - * @return the RoleDefinition object itself. + * @return the KeyVaultRoleDefinition object itself. */ - public RoleDefinition setPermissions(List permissions) { + public KeyVaultRoleDefinition setPermissions(List permissions) { this.permissions = permissions; return this; } @@ -181,9 +181,9 @@ public List getAssignableScopes() { * Set the assignableScopes property: Role definition assignable scopes. * * @param assignableScopes the assignableScopes value to set. - * @return the RoleDefinition object itself. + * @return the KeyVaultRoleDefinition object itself. */ - public RoleDefinition setAssignableScopes(List assignableScopes) { + public KeyVaultRoleDefinition setAssignableScopes(List assignableScopes) { this.assignableScopes = assignableScopes; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java similarity index 79% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java index ce01792ed37f..c79e113bb6bc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The RoleDefinitionFilter model. */ +/** The KeyVaultRoleDefinitionFilter model. */ @Fluent -public final class RoleDefinitionFilter { +public final class KeyVaultRoleDefinitionFilter { /* * Returns role definition with the specific name. */ @@ -29,9 +29,9 @@ public String getRoleName() { * Set the roleName property: Returns role definition with the specific name. * * @param roleName the roleName value to set. - * @return the RoleDefinitionFilter object itself. + * @return the KeyVaultRoleDefinitionFilter object itself. */ - public RoleDefinitionFilter setRoleName(String roleName) { + public KeyVaultRoleDefinitionFilter setRoleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java similarity index 72% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java index fa52f012f154..f75a60785b38 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java @@ -8,14 +8,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The RoleDefinitionListResult model. */ +/** The KeyVaultRoleDefinitionListResult model. */ @Fluent -public final class RoleDefinitionListResult { +public final class KeyVaultRoleDefinitionListResult { /* * Role definition list. */ @JsonProperty(value = "value") - private List value; + private List value; /* * The URL to use for getting the next set of results. @@ -28,7 +28,7 @@ public final class RoleDefinitionListResult { * * @return the value value. */ - public List getValue() { + public List getValue() { return this.value; } @@ -36,9 +36,9 @@ public List getValue() { * Set the value property: Role definition list. * * @param value the value value to set. - * @return the RoleDefinitionListResult object itself. + * @return the KeyVaultRoleDefinitionListResult object itself. */ - public RoleDefinitionListResult setValue(List value) { + public KeyVaultRoleDefinitionListResult setValue(List value) { this.value = value; return this; } @@ -56,9 +56,9 @@ public String getNextLink() { * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. - * @return the RoleDefinitionListResult object itself. + * @return the KeyVaultRoleDefinitionListResult object itself. */ - public RoleDefinitionListResult setNextLink(String nextLink) { + public KeyVaultRoleDefinitionListResult setNextLink(String nextLink) { this.nextLink = nextLink; return this; } 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 new file mode 100644 index 000000000000..af9d9fb4c36f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import com.azure.core.util.ExpandableStringEnum; + +import java.net.URI; + +public final class KeyVaultRoleScope extends ExpandableStringEnum { + public static final KeyVaultRoleScope GLOBAL = fromString("/"); + public static final KeyVaultRoleScope KEYS = fromString("/keys"); + + /** + * Creates or finds a {@link KeyVaultRoleScope} from its string representation. + * + * @param name A name to look for. + * @return The corresponding {@link KeyVaultRoleScope} + */ + public static KeyVaultRoleScope fromString(String name) { + return fromString(name, KeyVaultRoleScope.class); + } + + /** + * Creates or finds a {@link KeyVaultRoleScope} from its string representation. + * + * @param uri A URI to look for. + * @return The corresponding {@link KeyVaultRoleScope} + */ + public static KeyVaultRoleScope fromUri(URI uri) { + return fromString(uri.getRawPath(), KeyVaultRoleScope.class); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java deleted file mode 100644 index 5cef6c2ed1b4..000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/RoleScope.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.administration.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.net.URI; - -public final class RoleScope extends ExpandableStringEnum { - public static final RoleScope GLOBAL = fromString("/"); - public static final RoleScope KEYS = fromString("/keys"); - - /** - * Creates or finds a {@link RoleScope} from its string representation. - * - * @param name A name to look for. - * @return The corresponding {@link RoleScope} - */ - public static RoleScope fromString(String name) { - return fromString(name, RoleScope.class); - } - - /** - * Creates or finds a {@link RoleScope} from its string representation. - * - * @param uri A URI to look for. - * @return The corresponding {@link RoleScope} - */ - public static RoleScope fromUri(URI uri) { - return fromString(uri.getRawPath(), RoleScope.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md index 70a2f4efdd0a..6d57060910e9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md @@ -41,6 +41,40 @@ generate-client-as-impl: true sync-methods: none add-context-parameter: true context-client-method-parameter: true +directive : + - rename-model: + from: Permission + to: KeyVaultPermission + - rename-model: + from: RoleAssignment + to: KeyVaultRoleAssignment + - rename-model: + from: RoleAssignmentCreateParameters + to: KeyVaultRoleAssignmentCreateParameters + - rename-model: + from: RoleAssignmentFilter + to: KeyVaultRoleAssignmentFilter + - rename-model: + from: RoleAssignmentListResult + to: KeyVaultRoleAssignmentListResult + - rename-model: + from: RoleAssignmentProperties + to: KeyVaultRoleAssignmentProperties + - rename-model: + from: RoleAssignmentPropertiesWithScope + to: KeyVaultRoleAssignmentPropertiesWithScope + - rename-model: + from: RoleAssignmentProperties + to: KeyVaultRoleAssignmentProperties + - rename-model: + from: RoleDefinition + to: KeyVaultRoleDefinition + - rename-model: + from: RoleDefinitionFilter + to: KeyVaultRoleDefinitionFilter + - rename-model: + from: RoleDefinitionListResult + to: KeyVaultRoleDefinitionListResult ``` ### Tag: rbac-preview From c6915b21182175696faea7a6dd7238df325f59c7 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 13:01:25 -0700 Subject: [PATCH 20/40] Added additional null checks for members in public methods that accept KeyVaultRoleAssignmentProperties. --- .../administration/KeyVaultAccessControlAsyncClient.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index cd097c8ef584..25a300244b5b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -130,6 +130,8 @@ PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, C */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope scope, Context context) { + Objects.requireNonNull(scope, "'scope' cannot be null."); + try { return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -352,6 +354,8 @@ Mono> createRoleAssignmentWithResponse(KeyVault Objects.requireNonNull(scope, "'scope' cannot be null."); Objects.requireNonNull(name, "'name' cannot be null."); Objects.requireNonNull(properties, "'properties' cannot be null."); + Objects.requireNonNull(properties.getRoleDefinitionId(), "'roleDefinitionId' in 'properties' cannot be null."); + Objects.requireNonNull(properties.getPrincipalId(), "'roleDefinitionId' in 'properties' cannot be null."); KeyVaultRoleAssignmentCreateParameters parameters = new KeyVaultRoleAssignmentCreateParameters().setProperties(properties); return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), From 37b6be0fd19fb9de56c326d93e69d22fa7d68b23 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 14:19:56 -0700 Subject: [PATCH 21/40] Added a module-info file. --- .../pom.xml | 1 - .../src/main/java/module-info.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml index 3a340d75ee46..6b6f627bd4e2 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -11,7 +11,6 @@ 4.0.0 - com.azure azure-security-keyvault-administration 4.0.0-beta.1 diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java new file mode 100644 index 000000000000..36378c9193ad --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +module com.azure.security.keyvault.administration { + requires transitive com.azure.core; + + exports com.azure.security.keyvault.administration; + exports com.azure.security.keyvault.administration.implementation; + exports com.azure.security.keyvault.administration.implementation.models; + exports com.azure.security.keyvault.administration.models; + + opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; +} + From ea4a103e1fa2e378b72772b1cad8512c8ec61b75 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 17:20:48 -0700 Subject: [PATCH 22/40] Made small formatting corrections. --- .../implementation/KeyVaultErrorCodeStrings.java | 10 +++++++--- .../administration/implementation/ScopeTokenCache.java | 7 +++---- .../src/main/java/module-info.java | 5 ++--- .../src/main/resources/kvErrorStrings.properties | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java index 1caab79ba8bb..9421a205af76 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/KeyVaultErrorCodeStrings.java @@ -21,10 +21,15 @@ public class KeyVaultErrorCodeStrings { */ public static final String VAULT_END_POINT_REQUIRED = "vault_endpoint_required"; + /** + * The property name of Azure Key Vault Parameter required error string. + */ + public static final String PARAMETER_REQUIRED = "parameter_required"; + /** * Gets the error String for the specified property. * - * @param propertyName The property name for which error string is required. + * @param propertyName the property name for which error string is required. * @return The {@link String value} containing the error message. */ public static String getErrorString(String propertyName) { @@ -32,11 +37,10 @@ public static String getErrorString(String propertyName) { return errorStrings.getProperty(propertyName); } - @SuppressWarnings("ConstantConditions") private static synchronized void loadProperties() { if (errorStrings == null) { try (InputStream fileInputStream = - KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { + KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { errorStrings = new Properties(); errorStrings.load(fileInputStream); } catch (IOException ex) { diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java index a6a86ac4162f..c7f1aaba7b6d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/ScopeTokenCache.java @@ -40,7 +40,6 @@ public void setTokenRequest(TokenRequestContext request) { /** * Asynchronously get a token from either the cache or replenish the cache with a new token. - * * @return a Publisher that emits an AccessToken */ public Mono getToken() { @@ -50,9 +49,9 @@ public Mono getToken() { return Mono.defer(() -> { if (!wip.getAndSet(true)) { return getNew.apply(request).doOnNext(ac -> cache = ac) - .doOnNext(sink::next) - .doOnError(sink::error) - .doOnTerminate(() -> wip.set(false)); + .doOnNext(sink::next) + .doOnError(sink::error) + .doOnTerminate(() -> wip.set(false)); } else { return emitterProcessor.next(); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index 36378c9193ad..926cedd26ddb 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -5,12 +5,11 @@ requires transitive com.azure.core; exports com.azure.security.keyvault.administration; + exports com.azure.security.keyvault.administration.models; exports com.azure.security.keyvault.administration.implementation; exports com.azure.security.keyvault.administration.implementation.models; - exports com.azure.security.keyvault.administration.models; opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; - opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; } - diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties index ff2560ce762e..664cfe25c2c1 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/resources/kvErrorStrings.properties @@ -1,2 +1,3 @@ credential_required=Azure Key Vault credentials are required. vault_endpoint_required=Azure Key Vault endpoint url is required. +parameter_required=%s cannot be null. From 19ed63bca34c36ec73bd3d846e185d7af49810ba Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 17:34:23 -0700 Subject: [PATCH 23/40] Removed an entry from module-info.java. Modified how KeyVaultAccessControlAsyncClient get error messages for parameter validation. --- .../KeyVaultAccessControlAsyncClient.java | 41 ++++++++++++++----- .../src/main/java/module-info.java | 1 - 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 25a300244b5b..c0f5c3712cbb 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -130,7 +130,9 @@ PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, C */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope scope, Context context) { - Objects.requireNonNull(scope, "'scope' cannot be null."); + Objects.requireNonNull(scope, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'scope'")); try { return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope.toString(), null, @@ -351,13 +353,24 @@ public Mono> createRoleAssignmentWithResponse(K Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { - Objects.requireNonNull(scope, "'scope' cannot be null."); - Objects.requireNonNull(name, "'name' cannot be null."); - Objects.requireNonNull(properties, "'properties' cannot be null."); - Objects.requireNonNull(properties.getRoleDefinitionId(), "'roleDefinitionId' in 'properties' cannot be null."); - Objects.requireNonNull(properties.getPrincipalId(), "'roleDefinitionId' in 'properties' cannot be null."); + Objects.requireNonNull(scope, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'scope'")); + Objects.requireNonNull(name, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'name'")); + Objects.requireNonNull(properties, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'properties'")); + Objects.requireNonNull(properties.getRoleDefinitionId(), + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'roleDefinitionId' in 'properties'")); + Objects.requireNonNull(properties.getPrincipalId(), + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'principalId' in 'properties'")); KeyVaultRoleAssignmentCreateParameters parameters = new KeyVaultRoleAssignmentCreateParameters().setProperties(properties); + return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) @@ -415,8 +428,12 @@ public Mono> getRoleAssignmentWithResponse(KeyV */ Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { - Objects.requireNonNull(scope, "'scope' cannot be null."); - Objects.requireNonNull(name, "'name' cannot be null."); + Objects.requireNonNull(scope, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'scope'")); + Objects.requireNonNull(name, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'name'")); return clientImpl.getRoleAssignments().getWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -476,8 +493,12 @@ public Mono> deleteRoleAssignmentWithResponse(K */ Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { - Objects.requireNonNull(scope, "'scope' cannot be null."); - Objects.requireNonNull(name, "'name' cannot be null."); + Objects.requireNonNull(scope, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'scope'")); + Objects.requireNonNull(name, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'name'")); return clientImpl.getRoleAssignments().deleteWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index 926cedd26ddb..f482660398ce 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -6,7 +6,6 @@ exports com.azure.security.keyvault.administration; exports com.azure.security.keyvault.administration.models; - exports com.azure.security.keyvault.administration.implementation; exports com.azure.security.keyvault.administration.implementation.models; opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; From 5e5389269da35262ed36b43a7dcf9418b4741a4f Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 17:48:29 -0700 Subject: [PATCH 24/40] Added missing package-info.java files. --- .../keyvault/administration/models/package-info.java | 7 +++++++ .../security/keyvault/administration/package-info.java | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java new file mode 100644 index 000000000000..020a9f6b9fa7 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package containing classes used in access control clients for Azure Key Vault. + */ +package com.azure.security.keyvault.administration.models; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java new file mode 100644 index 000000000000..217c64d41f52 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package containing classes for creating + * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlAsyncClient} + * and {@link com.azure.security.keyvault.administration.KeyVaultAccessControlClient} to perform operations on Azure + * Key Vault. + */ +package com.azure.security.keyvault.administration; From e57a0fe827d2a0ba2978779adade3842d8807bb9 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 28 Aug 2020 18:25:17 -0700 Subject: [PATCH 25/40] Corrected errors highlighted by APIView. --- .../administration/KeyVaultAccessControlAsyncClient.java | 6 +++--- .../administration/KeyVaultAccessControlClient.java | 7 ++++++- .../administration/KeyVaultAccessControlClientBuilder.java | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index c0f5c3712cbb..943dd0b997df 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -35,7 +35,7 @@ * {@link KeyVaultRoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class, isAsync = true) -public class KeyVaultAccessControlAsyncClient { +public final class KeyVaultAccessControlAsyncClient { // Please see here // for more information on Azure resource provider namespaces. private static final String KEYVAULT_TRACING_NAMESPACE_VALUE = "Microsoft.KeyVault"; @@ -88,7 +88,7 @@ public String getVaultUrl() { * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - @ServiceMethod(returns = ReturnType.SINGLE) + @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleDefinitions(KeyVaultRoleScope scope) { try { return new PagedFlux<>( @@ -181,7 +181,7 @@ Mono> listRoleDefinitionsNextPage(String c * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ - @ServiceMethod(returns = ReturnType.SINGLE) + @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleAssignments(KeyVaultRoleScope scope) { try { return new PagedFlux<>( 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 8ec535834e15..06a1a3a73342 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 @@ -24,7 +24,7 @@ * assignments}. Additionally, the client supports listing {@link KeyVaultRoleDefinition role definitions}. */ @ServiceClient(builder = KeyVaultAccessControlClientBuilder.class) -public class KeyVaultAccessControlClient { +public final class KeyVaultAccessControlClient { private final KeyVaultAccessControlAsyncClient asyncClient; /** @@ -57,6 +57,7 @@ public String getVaultUrl() { * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ + @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRoleDefinitions(KeyVaultRoleScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, context)); } @@ -72,6 +73,7 @@ public PagedIterable listRoleDefinitions(KeyVaultRoleSco * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ + @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRoleAssignments(KeyVaultRoleScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); } @@ -122,6 +124,7 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { @@ -151,6 +154,7 @@ public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope scope, String * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); @@ -179,6 +183,7 @@ public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope scope, Stri * @throws KeyVaultErrorException if the operation is unsuccessful. * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); 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 67283bba4f58..61ff9273a355 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 @@ -3,6 +3,7 @@ package com.azure.security.keyvault.administration; +import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; @@ -52,7 +53,8 @@ * @see KeyVaultAccessControlAsyncClient * @see KeyVaultAccessControlClient */ -public class KeyVaultAccessControlClientBuilder { +@ServiceClientBuilder(serviceClients = {KeyVaultAccessControlClient.class, KeyVaultAccessControlAsyncClient.class}) +public final class KeyVaultAccessControlClientBuilder { // This is the properties file name. private static final String AZURE_KEY_VAULT_RBAC = "azure-key-vault-administration.properties"; private static final String SDK_NAME = "name"; From 427ffdcac08e3ac2ba72c7abac3f6305fa9ff6a3 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 31 Aug 2020 20:34:26 -0700 Subject: [PATCH 26/40] Reverted implementation classes to their original names and hid them from public API signatures. Added convenience layer models to be exposed as public API. --- .../KeyVaultAccessControlAsyncClient.java | 354 ++++++++++++------ .../KeyVaultAccessControlClient.java | 39 +- .../implementation/RoleAssignmentsImpl.java | 31 +- .../implementation/RoleDefinitionsImpl.java | 12 +- ...eyVaultPermission.java => Permission.java} | 20 +- ...oleAssignment.java => RoleAssignment.java} | 12 +- ...va => RoleAssignmentCreateParameters.java} | 12 +- ...tFilter.java => RoleAssignmentFilter.java} | 8 +- ...ult.java => RoleAssignmentListResult.java} | 16 +- ...ies.java => RoleAssignmentProperties.java} | 12 +- ...=> RoleAssignmentPropertiesWithScope.java} | 16 +- ...oleDefinition.java => RoleDefinition.java} | 28 +- ...nFilter.java => RoleDefinitionFilter.java} | 8 +- ...ult.java => RoleDefinitionListResult.java} | 16 +- .../models/KeyVaultPermission.java | 68 ++++ .../models/KeyVaultRoleAssignment.java | 79 ++++ .../KeyVaultRoleAssignmentProperties.java | 56 +++ .../models/KeyVaultRoleDefinition.java | 69 ++++ .../KeyVaultRoleDefinitionProperties.java | 83 ++++ .../models/KeyVaultRoleScope.java | 3 + .../src/main/java/module-info.java | 1 - .../swagger/autorest.md | 34 -- 22 files changed, 701 insertions(+), 276 deletions(-) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultPermission.java => Permission.java} (81%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignment.java => RoleAssignment.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignmentCreateParameters.java => RoleAssignmentCreateParameters.java} (65%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignmentFilter.java => RoleAssignmentFilter.java} (79%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignmentListResult.java => RoleAssignmentListResult.java} (72%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignmentProperties.java => RoleAssignmentProperties.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleAssignmentPropertiesWithScope.java => RoleAssignmentPropertiesWithScope.java} (75%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleDefinition.java => RoleDefinition.java} (82%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleDefinitionFilter.java => RoleDefinitionFilter.java} (79%) rename sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/{KeyVaultRoleDefinitionListResult.java => RoleDefinitionListResult.java} (72%) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 943dd0b997df..7d60d2013aba 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -6,21 +6,27 @@ import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; +import com.azure.core.util.IterableStream; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImpl; import com.azure.security.keyvault.administration.implementation.KeyVaultAccessControlClientImplBuilder; import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; import com.azure.security.keyvault.administration.implementation.models.*; -import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; +import com.azure.security.keyvault.administration.models.*; import reactor.core.publisher.Mono; +import java.io.IOException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.UUID; @@ -85,18 +91,13 @@ public String getVaultUrl() { * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleDefinitions(KeyVaultRoleScope scope) { - try { - return new PagedFlux<>( - () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), - continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); - } catch (RuntimeException e) { - return new PagedFlux<>(() -> monoError(logger, e)); - } + return new PagedFlux<>( + () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), + continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); } /** @@ -107,8 +108,7 @@ public PagedFlux listRoleDefinitions(KeyVaultRoleScope s * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, Context context) { return new PagedFlux<>( @@ -125,8 +125,7 @@ PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, C * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} * for the given {@link KeyVaultRoleScope scope} from the first page of results. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope scope, Context context) { @@ -135,12 +134,14 @@ Mono> listRoleDefinitionsFirstPage(String "'scope'")); try { - return clientImpl.getRoleDefinitions().listSinglePageAsync(vaultUrl, scope.toString(), null, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + return clientImpl.getRoleDefinitions() + .listSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) .doOnSuccess(response -> logger.info("Listed role definitions for scope - {}", scope)) .doOnError(error -> logger.warning(String.format("Failed to list role definitions for scope - %s", - scope), error)); + scope), error)) + .map(this::transformRoleDefinitionsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); } @@ -156,16 +157,17 @@ Mono> listRoleDefinitionsFirstPage(String * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} * for the given {@link KeyVaultRoleScope scope} from the next page of results. - * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { - return clientImpl.getRoleDefinitions().listNextSinglePageAsync(continuationToken, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + return clientImpl.getRoleDefinitions() + .listNextSinglePageAsync(continuationToken, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing next role definitions page - Page {}", continuationToken)) .doOnSuccess(response -> logger.info("Listed next role definitions page - Page {}", continuationToken)) .doOnError(error -> logger.warning("Failed to list next role definitions page - Page {}", - continuationToken, error)); + continuationToken, error)) + .map(this::transformRoleDefinitionsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); } @@ -178,18 +180,13 @@ Mono> listRoleDefinitionsNextPage(String c * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listRoleAssignments(KeyVaultRoleScope scope) { - try { - return new PagedFlux<>( - () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), - continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); - } catch (RuntimeException e) { - return new PagedFlux<>(() -> monoError(logger, e)); - } + return new PagedFlux<>( + () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), + continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); } /** @@ -200,8 +197,7 @@ public PagedFlux listRoleAssignments(KeyVaultRoleScope s * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ PagedFlux listRoleAssignments(KeyVaultRoleScope scope, Context context) { return new PagedFlux<>( @@ -218,20 +214,23 @@ PagedFlux listRoleAssignments(KeyVaultRoleScope scope, C * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} * in the given {@link KeyVaultRoleScope scope} from the first page of results. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleScope scope, Context context) { - Objects.requireNonNull(scope, "'scope' cannot be null."); + Objects.requireNonNull(scope, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'scope'")); try { - return clientImpl.getRoleAssignments().listForScopeSinglePageAsync(vaultUrl, scope.toString(), null, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + return clientImpl.getRoleAssignments() + .listForScopeSinglePageAsync(vaultUrl, scope.toString(), null, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing role assignments for scope - {}", scope)) .doOnSuccess(response -> logger.info("Listed role assignments for scope - {}", scope)) .doOnError(error -> logger.warning(String.format("Failed to list role assignments for scope - %s", - scope), error)); + scope), error)) + .map(this::transformRoleAssignmentsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); } @@ -246,16 +245,17 @@ Mono> listRoleAssignmentsFirstPage(String * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} * for the given {@link KeyVaultRoleScope scope} from the first page of results. - * @throws KeyVaultErrorException if the operation is unsuccessful. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { - return clientImpl.getRoleAssignments().listForScopeNextSinglePageAsync(continuationToken, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + return clientImpl.getRoleAssignments() + .listForScopeNextSinglePageAsync(continuationToken, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Listing next role assignments page - Page {}", continuationToken)) .doOnSuccess(response -> logger.info("Listed next role assignments page - Page {}", continuationToken)) .doOnError(error -> logger.warning("Failed to list next role assignments page - Page {}", - continuationToken, error)); + continuationToken, error)) + .map(this::transformRoleAssignmentsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); } @@ -267,9 +267,8 @@ Mono> listRoleAssignmentsNextPage(String c * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono createRoleAssignment(KeyVaultRoleScope scope, @@ -284,18 +283,13 @@ public Mono createRoleAssignment(KeyVaultRoleScope scope * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono createRoleAssignment(KeyVaultRoleScope scope, UUID name, KeyVaultRoleAssignmentProperties properties) { - try { - return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); } /** @@ -305,9 +299,8 @@ public Mono createRoleAssignment(KeyVaultRoleScope scope * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, @@ -323,18 +316,13 @@ public Mono> createRoleAssignmentWithResponse(K * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, KeyVaultRoleAssignmentProperties properties) { - try { - return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); } /** @@ -346,9 +334,8 @@ public Mono> createRoleAssignmentWithResponse(K * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, KeyVaultRoleAssignmentProperties properties, @@ -362,20 +349,22 @@ Mono> createRoleAssignmentWithResponse(KeyVault Objects.requireNonNull(properties, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'properties'")); - Objects.requireNonNull(properties.getRoleDefinitionId(), - String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'roleDefinitionId' in 'properties'")); - Objects.requireNonNull(properties.getPrincipalId(), - String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'principalId' in 'properties'")); - KeyVaultRoleAssignmentCreateParameters parameters = new KeyVaultRoleAssignmentCreateParameters().setProperties(properties); + RoleAssignmentProperties roleAssignmentProperties = + new RoleAssignmentProperties() + .setRoleDefinitionId(properties.getRoleDefinitionId()) + .setPrincipalId(properties.getRoleDefinitionId()); + RoleAssignmentCreateParameters parameters = + new RoleAssignmentCreateParameters() + .setProperties(roleAssignmentProperties); - return clientImpl.getRoleAssignments().createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), - parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + return clientImpl.getRoleAssignments() + .createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), parameters, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .map(this::transformRoleAssignmentResponse); } /** @@ -384,16 +373,11 @@ Mono> createRoleAssignmentWithResponse(KeyVault * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getRoleAssignment(KeyVaultRoleScope scope, String name) { - try { - return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } /** @@ -403,16 +387,11 @@ public Mono getRoleAssignment(KeyVaultRoleScope scope, S * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name) { - try { - return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); } /** @@ -423,8 +402,7 @@ public Mono> getRoleAssignmentWithResponse(KeyV * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { @@ -435,11 +413,17 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'name'")); - return clientImpl.getRoleAssignments().getWithResponseAsync(vaultUrl, scope.toString(), name, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) - .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + try { + return clientImpl.getRoleAssignments() + .getWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .map(this::transformRoleAssignmentResponse); + } catch (RuntimeException e) { + return monoError(logger, e); + } } /** @@ -448,16 +432,11 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono deleteRoleAssignment(KeyVaultRoleScope scope, String name) { - try { - return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } /** @@ -467,17 +446,12 @@ public Mono deleteRoleAssignment(KeyVaultRoleScope scope * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name) { - try { - return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); - } catch (RuntimeException ex) { - return monoError(logger, ex); - } + return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); } /** @@ -488,8 +462,7 @@ public Mono> deleteRoleAssignmentWithResponse(K * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. */ Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, Context context) { @@ -500,10 +473,153 @@ Mono> deleteRoleAssignmentWithResponse(KeyVault String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'name'")); - return clientImpl.getRoleAssignments().deleteWithResponseAsync(vaultUrl, scope.toString(), name, - context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) - .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)); + try { + return clientImpl.getRoleAssignments() + .deleteWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .map(this::transformRoleAssignmentResponse); + } catch (RuntimeException e) { + return monoError(logger, e); + } + } + + private PagedResponse transformRoleDefinitionsPagedResponse(PagedResponse pagedResponse) { + List keyVaultRoleDefinitions = new ArrayList<>(); + + for (RoleDefinition roleDefinition : pagedResponse.getValue()) { + keyVaultRoleDefinitions.add(roleDefinitionToKeyVaultRoleDefinition(roleDefinition)); + } + + return new PagedResponse<>() { + @Override + public void close() throws IOException { + } + + @Override + public IterableStream getElements() { + return new IterableStream<>(keyVaultRoleDefinitions); + } + + @Override + public String getContinuationToken() { + return pagedResponse.getContinuationToken(); + } + + @Override + public int getStatusCode() { + return pagedResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return pagedResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return pagedResponse.getRequest(); + } + + @Override + public List getValue() { + return keyVaultRoleDefinitions; + } + }; + } + + private Response transformRoleAssignmentResponse(Response response) { + KeyVaultRoleAssignment keyVaultRoleAssignment = roleAssignmentToKeyVaultRoleAssignment(response.getValue()); + + return new Response<>() { + @Override + public int getStatusCode() { + return response.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return response.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return response.getRequest(); + } + + @Override + public KeyVaultRoleAssignment getValue() { + return keyVaultRoleAssignment; + } + }; + } + + private KeyVaultRoleDefinition roleDefinitionToKeyVaultRoleDefinition(RoleDefinition roleDefinition) { + List keyVaultPermissions = new ArrayList<>(); + + for (Permission permission : roleDefinition.getPermissions()) { + keyVaultPermissions.add( + new KeyVaultPermission(permission.getActions(), permission.getDataActions(), + permission.getDataActions(), permission.getNotDataActions())); + } + + return new KeyVaultRoleDefinition(roleDefinition.getId(), roleDefinition.getName(), roleDefinition.getType(), + new KeyVaultRoleDefinitionProperties(roleDefinition.getRoleName(), + roleDefinition.getDescription(), roleDefinition.getRoleType(), keyVaultPermissions, + roleDefinition.getAssignableScopes())); + } + + private PagedResponse transformRoleAssignmentsPagedResponse(PagedResponse pagedResponse) { + List keyVaultRoleAssignments = new ArrayList<>(); + + for (RoleAssignment roleAssignment : pagedResponse.getValue()) { + keyVaultRoleAssignments.add(roleAssignmentToKeyVaultRoleAssignment(roleAssignment)); + } + + return new PagedResponse<>() { + @Override + public void close() throws IOException { + } + + @Override + public IterableStream getElements() { + return new IterableStream<>(keyVaultRoleAssignments); + } + + @Override + public String getContinuationToken() { + return pagedResponse.getContinuationToken(); + } + + @Override + public int getStatusCode() { + return pagedResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return pagedResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return pagedResponse.getRequest(); + } + + @Override + public List getValue() { + return keyVaultRoleAssignments; + } + }; + } + + private KeyVaultRoleAssignment roleAssignmentToKeyVaultRoleAssignment(RoleAssignment roleAssignment) { + RoleAssignmentPropertiesWithScope propertiesWithScope = roleAssignment.getProperties(); + + return new KeyVaultRoleAssignment(roleAssignment.getId(), roleAssignment.getName(), roleAssignment.getType(), + new KeyVaultRoleAssignmentProperties(propertiesWithScope.getRoleDefinitionId(), + propertiesWithScope.getPrincipalId()), KeyVaultRoleScope.fromString(propertiesWithScope.getScope())); } } 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 06a1a3a73342..5cd60c10a277 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 @@ -9,11 +9,7 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignment; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentProperties; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinition; -import com.azure.security.keyvault.administration.models.KeyVaultRoleScope; +import com.azure.security.keyvault.administration.models.*; import reactor.core.publisher.Mono; import java.util.UUID; @@ -54,8 +50,7 @@ public String getVaultUrl() { * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRoleDefinitions(KeyVaultRoleScope scope, Context context) { @@ -70,8 +65,7 @@ public PagedIterable listRoleDefinitions(KeyVaultRoleSco * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleScope scope}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRoleAssignments(KeyVaultRoleScope scope, Context context) { @@ -84,9 +78,8 @@ public PagedIterable listRoleAssignments(KeyVaultRoleSco * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, @@ -101,9 +94,8 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID name, @@ -120,9 +112,8 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the request is rejected by the server. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, @@ -137,8 +128,7 @@ public Response createRoleAssignmentWithResponse(KeyVaul * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope scope, String name) { @@ -151,8 +141,7 @@ public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope scope, String * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, @@ -166,8 +155,7 @@ public Response getRoleAssignmentWithResponse(KeyVaultRo * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope scope, String name) { @@ -180,8 +168,7 @@ public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope scope, Stri * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws KeyVaultErrorException if the operation is unsuccessful. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java index f594fcabd95b..ef7d31d6b48b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleAssignmentsImpl.java @@ -23,9 +23,9 @@ import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignment; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentCreateParameters; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleAssignmentListResult; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignment; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentCreateParameters; +import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentListResult; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in RoleAssignments. */ @@ -57,7 +57,7 @@ private interface RoleAssignmentsService { @Delete("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> delete( + Mono> delete( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @@ -67,18 +67,18 @@ Mono> delete( @Put("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({201}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> create( + Mono> create( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") KeyVaultRoleAssignmentCreateParameters parameters, + @BodyParam("application/json") RoleAssignmentCreateParameters parameters, Context context); @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> get( + Mono> get( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @PathParam("roleAssignmentName") String roleAssignmentName, @@ -88,7 +88,7 @@ Mono> get( @Get("/{scope}/providers/Microsoft.Authorization/roleAssignments") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listForScope( + Mono> listForScope( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @QueryParam("$filter") String filter, @@ -98,7 +98,7 @@ Mono> listForScope( @Get("{nextLink}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listForScopeNext( + Mono> listForScopeNext( @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } @@ -115,7 +115,7 @@ Mono> listForScopeNext( * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync( + public Mono> deleteWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { return service.delete(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } @@ -134,11 +134,11 @@ public Mono> deleteWithResponseAsync( * @return role Assignments. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync( + public Mono> createWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, - KeyVaultRoleAssignmentCreateParameters parameters, + RoleAssignmentCreateParameters parameters, Context context) { return service.create( vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), parameters, context); @@ -157,7 +157,7 @@ public Mono> createWithResponseAsync( * @return the specified role assignment. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync( + public Mono> getWithResponseAsync( String vaultBaseUrl, String scope, String roleAssignmentName, Context context) { return service.get(vaultBaseUrl, scope, roleAssignmentName, this.client.getApiVersion(), context); } @@ -177,7 +177,7 @@ public Mono> getWithResponseAsync( * @return role assignments for a scope. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeSinglePageAsync( + public Mono> listForScopeSinglePageAsync( String vaultBaseUrl, String scope, String filter, Context context) { return service.listForScope(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) .map( @@ -202,8 +202,7 @@ public Mono> listForScopeSinglePageAsync( * @return role assignment list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listForScopeNextSinglePageAsync( - String nextLink, Context context) { + public Mono> listForScopeNextSinglePageAsync(String nextLink, Context context) { return service.listForScopeNext(nextLink, context) .map( res -> diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java index 63f98bc31b20..0bb245c326f4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/RoleDefinitionsImpl.java @@ -20,8 +20,8 @@ import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinition; -import com.azure.security.keyvault.administration.implementation.models.KeyVaultRoleDefinitionListResult; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinition; +import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionListResult; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in RoleDefinitions. */ @@ -53,7 +53,7 @@ private interface RoleDefinitionsService { @Get("/{scope}/providers/Microsoft.Authorization/roleDefinitions") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> list( + Mono> list( @HostParam("vaultBaseUrl") String vaultBaseUrl, @PathParam(value = "scope", encoded = true) String scope, @QueryParam("$filter") String filter, @@ -63,7 +63,7 @@ Mono> list( @Get("{nextLink}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> listNext( + Mono> listNext( @PathParam(value = "nextLink", encoded = true) String nextLink, Context context); } @@ -81,7 +81,7 @@ Mono> listNext( * @return all role definitions that are applicable at scope and above. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listSinglePageAsync( + public Mono> listSinglePageAsync( String vaultBaseUrl, String scope, String filter, Context context) { return service.list(vaultBaseUrl, scope, filter, this.client.getApiVersion(), context) .map( @@ -106,7 +106,7 @@ public Mono> listSinglePageAsync( * @return role definition list operation result. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> listNextSinglePageAsync(String nextLink, Context context) { + public Mono> listNextSinglePageAsync(String nextLink, Context context) { return service.listNext(nextLink, context) .map( res -> diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java similarity index 81% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java index 39d297ab1f70..d1feaf6d24e4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultPermission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/Permission.java @@ -8,9 +8,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The KeyVaultPermission model. */ +/** The Permission model. */ @Fluent -public final class KeyVaultPermission { +public final class Permission { /* * Allowed actions. */ @@ -48,9 +48,9 @@ public List getActions() { * Set the actions property: Allowed actions. * * @param actions the actions value to set. - * @return the KeyVaultPermission object itself. + * @return the Permission object itself. */ - public KeyVaultPermission setActions(List actions) { + public Permission setActions(List actions) { this.actions = actions; return this; } @@ -68,9 +68,9 @@ public List getNotActions() { * Set the notActions property: Denied actions. * * @param notActions the notActions value to set. - * @return the KeyVaultPermission object itself. + * @return the Permission object itself. */ - public KeyVaultPermission setNotActions(List notActions) { + public Permission setNotActions(List notActions) { this.notActions = notActions; return this; } @@ -88,9 +88,9 @@ public List getDataActions() { * Set the dataActions property: Allowed Data actions. * * @param dataActions the dataActions value to set. - * @return the KeyVaultPermission object itself. + * @return the Permission object itself. */ - public KeyVaultPermission setDataActions(List dataActions) { + public Permission setDataActions(List dataActions) { this.dataActions = dataActions; return this; } @@ -108,9 +108,9 @@ public List getNotDataActions() { * Set the notDataActions property: Denied Data actions. * * @param notDataActions the notDataActions value to set. - * @return the KeyVaultPermission object itself. + * @return the Permission object itself. */ - public KeyVaultPermission setNotDataActions(List notDataActions) { + public Permission setNotDataActions(List notDataActions) { this.notDataActions = notDataActions; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java index 45af1a2825bf..1d06ce14088f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignment.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleAssignment model. */ +/** The RoleAssignment model. */ @Fluent -public final class KeyVaultRoleAssignment { +public final class RoleAssignment { /* * The role assignment ID. */ @@ -32,7 +32,7 @@ public final class KeyVaultRoleAssignment { * Role assignment properties. */ @JsonProperty(value = "properties") - private KeyVaultRoleAssignmentPropertiesWithScope properties; + private RoleAssignmentPropertiesWithScope properties; /** * Get the id property: The role assignment ID. @@ -66,7 +66,7 @@ public String getType() { * * @return the properties value. */ - public KeyVaultRoleAssignmentPropertiesWithScope getProperties() { + public RoleAssignmentPropertiesWithScope getProperties() { return this.properties; } @@ -74,9 +74,9 @@ public KeyVaultRoleAssignmentPropertiesWithScope getProperties() { * Set the properties property: Role assignment properties. * * @param properties the properties value to set. - * @return the KeyVaultRoleAssignment object itself. + * @return the RoleAssignment object itself. */ - public KeyVaultRoleAssignment setProperties(KeyVaultRoleAssignmentPropertiesWithScope properties) { + public RoleAssignment setProperties(RoleAssignmentPropertiesWithScope properties) { this.properties = properties; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java similarity index 65% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java index 7be49299e176..56d16b847a06 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentCreateParameters.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentCreateParameters.java @@ -7,21 +7,21 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleAssignmentCreateParameters model. */ +/** The RoleAssignmentCreateParameters model. */ @Fluent -public final class KeyVaultRoleAssignmentCreateParameters { +public final class RoleAssignmentCreateParameters { /* * Role assignment properties. */ @JsonProperty(value = "properties", required = true) - private KeyVaultRoleAssignmentProperties properties; + private RoleAssignmentProperties properties; /** * Get the properties property: Role assignment properties. * * @return the properties value. */ - public KeyVaultRoleAssignmentProperties getProperties() { + public RoleAssignmentProperties getProperties() { return this.properties; } @@ -29,9 +29,9 @@ public KeyVaultRoleAssignmentProperties getProperties() { * Set the properties property: Role assignment properties. * * @param properties the properties value to set. - * @return the KeyVaultRoleAssignmentCreateParameters object itself. + * @return the RoleAssignmentCreateParameters object itself. */ - public KeyVaultRoleAssignmentCreateParameters setProperties(KeyVaultRoleAssignmentProperties properties) { + public RoleAssignmentCreateParameters setProperties(RoleAssignmentProperties properties) { this.properties = properties; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java similarity index 79% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java index a8440c925b16..c04d69f36bd9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentFilter.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleAssignmentFilter model. */ +/** The RoleAssignmentFilter model. */ @Fluent -public final class KeyVaultRoleAssignmentFilter { +public final class RoleAssignmentFilter { /* * Returns role assignment of the specific principal. */ @@ -29,9 +29,9 @@ public String getPrincipalId() { * Set the principalId property: Returns role assignment of the specific principal. * * @param principalId the principalId value to set. - * @return the KeyVaultRoleAssignmentFilter object itself. + * @return the RoleAssignmentFilter object itself. */ - public KeyVaultRoleAssignmentFilter setPrincipalId(String principalId) { + public RoleAssignmentFilter setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java similarity index 72% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java index 9a9801156e6c..72a6eb8440a6 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentListResult.java @@ -8,14 +8,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The KeyVaultRoleAssignmentListResult model. */ +/** The RoleAssignmentListResult model. */ @Fluent -public final class KeyVaultRoleAssignmentListResult { +public final class RoleAssignmentListResult { /* * Role assignment list. */ @JsonProperty(value = "value") - private List value; + private List value; /* * The URL to use for getting the next set of results. @@ -28,7 +28,7 @@ public final class KeyVaultRoleAssignmentListResult { * * @return the value value. */ - public List getValue() { + public List getValue() { return this.value; } @@ -36,9 +36,9 @@ public List getValue() { * Set the value property: Role assignment list. * * @param value the value value to set. - * @return the KeyVaultRoleAssignmentListResult object itself. + * @return the RoleAssignmentListResult object itself. */ - public KeyVaultRoleAssignmentListResult setValue(List value) { + public RoleAssignmentListResult setValue(List value) { this.value = value; return this; } @@ -56,9 +56,9 @@ public String getNextLink() { * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. - * @return the KeyVaultRoleAssignmentListResult object itself. + * @return the RoleAssignmentListResult object itself. */ - public KeyVaultRoleAssignmentListResult setNextLink(String nextLink) { + public RoleAssignmentListResult setNextLink(String nextLink) { this.nextLink = nextLink; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java index b8a99d1ab864..0ab892817a1e 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentProperties.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleAssignmentProperties model. */ +/** The RoleAssignmentProperties model. */ @Fluent -public final class KeyVaultRoleAssignmentProperties { +public final class RoleAssignmentProperties { /* * The role definition ID used in the role assignment. */ @@ -37,9 +37,9 @@ public String getRoleDefinitionId() { * Set the roleDefinitionId property: The role definition ID used in the role assignment. * * @param roleDefinitionId the roleDefinitionId value to set. - * @return the KeyVaultRoleAssignmentProperties object itself. + * @return the RoleAssignmentProperties object itself. */ - public KeyVaultRoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { + public RoleAssignmentProperties setRoleDefinitionId(String roleDefinitionId) { this.roleDefinitionId = roleDefinitionId; return this; } @@ -59,9 +59,9 @@ public String getPrincipalId() { * Directory. It can point to a user, service principal, or security group. * * @param principalId the principalId value to set. - * @return the KeyVaultRoleAssignmentProperties object itself. + * @return the RoleAssignmentProperties object itself. */ - public KeyVaultRoleAssignmentProperties setPrincipalId(String principalId) { + public RoleAssignmentProperties setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java similarity index 75% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java index 1c92c0cf849d..ff50c91dc2ae 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleAssignmentPropertiesWithScope.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleAssignmentPropertiesWithScope.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleAssignmentPropertiesWithScope model. */ +/** The RoleAssignmentPropertiesWithScope model. */ @Fluent -public final class KeyVaultRoleAssignmentPropertiesWithScope { +public final class RoleAssignmentPropertiesWithScope { /* * The role assignment scope. */ @@ -41,9 +41,9 @@ public String getScope() { * Set the scope property: The role assignment scope. * * @param scope the scope value to set. - * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. + * @return the RoleAssignmentPropertiesWithScope object itself. */ - public KeyVaultRoleAssignmentPropertiesWithScope setScope(String scope) { + public RoleAssignmentPropertiesWithScope setScope(String scope) { this.scope = scope; return this; } @@ -61,9 +61,9 @@ public String getRoleDefinitionId() { * Set the roleDefinitionId property: The role definition ID. * * @param roleDefinitionId the roleDefinitionId value to set. - * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. + * @return the RoleAssignmentPropertiesWithScope object itself. */ - public KeyVaultRoleAssignmentPropertiesWithScope setRoleDefinitionId(String roleDefinitionId) { + public RoleAssignmentPropertiesWithScope setRoleDefinitionId(String roleDefinitionId) { this.roleDefinitionId = roleDefinitionId; return this; } @@ -81,9 +81,9 @@ public String getPrincipalId() { * Set the principalId property: The principal ID. * * @param principalId the principalId value to set. - * @return the KeyVaultRoleAssignmentPropertiesWithScope object itself. + * @return the RoleAssignmentPropertiesWithScope object itself. */ - public KeyVaultRoleAssignmentPropertiesWithScope setPrincipalId(String principalId) { + public RoleAssignmentPropertiesWithScope setPrincipalId(String principalId) { this.principalId = principalId; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java similarity index 82% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java index 739029113427..5383e4acbb8a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinition.java @@ -9,10 +9,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The KeyVaultRoleDefinition model. */ +/** The RoleDefinition model. */ @JsonFlatten @Fluent -public class KeyVaultRoleDefinition { +public class RoleDefinition { /* * The role definition ID. */ @@ -53,7 +53,7 @@ public class KeyVaultRoleDefinition { * Role definition permissions. */ @JsonProperty(value = "properties.permissions") - private List permissions; + private List permissions; /* * Role definition assignable scopes. @@ -101,9 +101,9 @@ public String getRoleName() { * Set the roleName property: The role name. * * @param roleName the roleName value to set. - * @return the KeyVaultRoleDefinition object itself. + * @return the RoleDefinition object itself. */ - public KeyVaultRoleDefinition setRoleName(String roleName) { + public RoleDefinition setRoleName(String roleName) { this.roleName = roleName; return this; } @@ -121,9 +121,9 @@ public String getDescription() { * Set the description property: The role definition description. * * @param description the description value to set. - * @return the KeyVaultRoleDefinition object itself. + * @return the RoleDefinition object itself. */ - public KeyVaultRoleDefinition setDescription(String description) { + public RoleDefinition setDescription(String description) { this.description = description; return this; } @@ -141,9 +141,9 @@ public String getRoleType() { * Set the roleType property: The role type. * * @param roleType the roleType value to set. - * @return the KeyVaultRoleDefinition object itself. + * @return the RoleDefinition object itself. */ - public KeyVaultRoleDefinition setRoleType(String roleType) { + public RoleDefinition setRoleType(String roleType) { this.roleType = roleType; return this; } @@ -153,7 +153,7 @@ public KeyVaultRoleDefinition setRoleType(String roleType) { * * @return the permissions value. */ - public List getPermissions() { + public List getPermissions() { return this.permissions; } @@ -161,9 +161,9 @@ public List getPermissions() { * Set the permissions property: Role definition permissions. * * @param permissions the permissions value to set. - * @return the KeyVaultRoleDefinition object itself. + * @return the RoleDefinition object itself. */ - public KeyVaultRoleDefinition setPermissions(List permissions) { + public RoleDefinition setPermissions(List permissions) { this.permissions = permissions; return this; } @@ -181,9 +181,9 @@ public List getAssignableScopes() { * Set the assignableScopes property: Role definition assignable scopes. * * @param assignableScopes the assignableScopes value to set. - * @return the KeyVaultRoleDefinition object itself. + * @return the RoleDefinition object itself. */ - public KeyVaultRoleDefinition setAssignableScopes(List assignableScopes) { + public RoleDefinition setAssignableScopes(List assignableScopes) { this.assignableScopes = assignableScopes; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java similarity index 79% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java index c79e113bb6bc..ce01792ed37f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionFilter.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionFilter.java @@ -7,9 +7,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** The KeyVaultRoleDefinitionFilter model. */ +/** The RoleDefinitionFilter model. */ @Fluent -public final class KeyVaultRoleDefinitionFilter { +public final class RoleDefinitionFilter { /* * Returns role definition with the specific name. */ @@ -29,9 +29,9 @@ public String getRoleName() { * Set the roleName property: Returns role definition with the specific name. * * @param roleName the roleName value to set. - * @return the KeyVaultRoleDefinitionFilter object itself. + * @return the RoleDefinitionFilter object itself. */ - public KeyVaultRoleDefinitionFilter setRoleName(String roleName) { + public RoleDefinitionFilter setRoleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java similarity index 72% rename from sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java rename to sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java index f75a60785b38..fa52f012f154 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/KeyVaultRoleDefinitionListResult.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/implementation/models/RoleDefinitionListResult.java @@ -8,14 +8,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The KeyVaultRoleDefinitionListResult model. */ +/** The RoleDefinitionListResult model. */ @Fluent -public final class KeyVaultRoleDefinitionListResult { +public final class RoleDefinitionListResult { /* * Role definition list. */ @JsonProperty(value = "value") - private List value; + private List value; /* * The URL to use for getting the next set of results. @@ -28,7 +28,7 @@ public final class KeyVaultRoleDefinitionListResult { * * @return the value value. */ - public List getValue() { + public List getValue() { return this.value; } @@ -36,9 +36,9 @@ public List getValue() { * Set the value property: Role definition list. * * @param value the value value to set. - * @return the KeyVaultRoleDefinitionListResult object itself. + * @return the RoleDefinitionListResult object itself. */ - public KeyVaultRoleDefinitionListResult setValue(List value) { + public RoleDefinitionListResult setValue(List value) { this.value = value; return this; } @@ -56,9 +56,9 @@ public String getNextLink() { * Set the nextLink property: The URL to use for getting the next set of results. * * @param nextLink the nextLink value to set. - * @return the KeyVaultRoleDefinitionListResult object itself. + * @return the RoleDefinitionListResult object itself. */ - public KeyVaultRoleDefinitionListResult setNextLink(String nextLink) { + public RoleDefinitionListResult setNextLink(String nextLink) { this.nextLink = nextLink; return this; } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java new file mode 100644 index 000000000000..ad3c463b4b99 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import java.util.List; + +/** + * A class describing allowed and denied actions and data actions of a {@link KeyVaultRoleDefinition}. + */ +public class KeyVaultPermission { + private List actions; + private List deniedActions; + private List dataActions; + private List deniedDataActions; + + /** + * Creates a new {@link KeyVaultPermission} with the specified allowed and denied actions and data actions. + * + * @param actions The actions this {@link KeyVaultPermission permission} allows. + * @param deniedActions The actions this {@link KeyVaultPermission permission} denies. + * @param dataActions The data actions this {@link KeyVaultPermission permission} allows. + * @param deniedDataActions The data actions this {@link KeyVaultPermission permission} denies. + */ + public KeyVaultPermission(List actions, List deniedActions, List dataActions, + List deniedDataActions) { + this.actions = actions; + this.deniedActions = deniedActions; + this.dataActions = dataActions; + this.deniedDataActions = deniedDataActions; + } + + /** + * Get the actions this {@link KeyVaultPermission permission} allows. + * + * @return The allowed actions. + */ + public List getActions() { + return actions; + } + + /** + * Get the actions this {@link KeyVaultPermission permission} denies. + * + * @return The denied actions. + */ + public List getDeniedActions() { + return deniedActions; + } + + /** + * Get the data actions this {@link KeyVaultPermission permission} allows. + * + * @return The allowed data actions. + */ + public List getDataActions() { + return dataActions; + } + + /** + * Get the data actions this {@link KeyVaultPermission permission} denies. + * + * @return The denied data actions. + */ + public List getDeniedDataActions() { + return deniedDataActions; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java new file mode 100644 index 000000000000..d6bdd474373f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +/** + * A class that defines a role assignment. + */ +public class KeyVaultRoleAssignment { + private String id; + private String name; + private String type; + private KeyVaultRoleAssignmentProperties properties; + private KeyVaultRoleScope scope; + + /** + * Creates a new {@link KeyVaultRoleAssignment role assignment} with the specified details. + * + * @param id The ID for this {@link KeyVaultRoleAssignment role assignment}. + * @param name The name of this {@link KeyVaultRoleAssignment role assignment}. + * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. + * @param properties {@link KeyVaultRoleAssignmentProperties properties} of this {@link KeyVaultRoleAssignment + * role assignment}. + * @param roleScope The {@link KeyVaultRoleScope scope} of this {@link KeyVaultRoleAssignment role assignment}. + */ + public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, + KeyVaultRoleScope roleScope) { + this.id = id; + this.name = name; + this.type = type; + this.properties = properties; + this.scope = roleScope; + } + + /** + * Get the {@link KeyVaultRoleAssignment role assignment} ID. + * + * @return The {@link KeyVaultRoleAssignment role assignment} ID. + */ + public String getId() { + return id; + } + + /** + * Get the {@link KeyVaultRoleAssignment role assignment} name. + * + * @return The {@link KeyVaultRoleAssignment role assignment} name. + */ + public String getName() { + return name; + } + + /** + * Get the {@link KeyVaultRoleAssignment role assignment} type. + * + * @return The {@link KeyVaultRoleAssignment role assignment} type. + */ + public String getType() { + return type; + } + + /** + * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentProperties properties}. + * + * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentProperties properties}. + */ + public KeyVaultRoleAssignmentProperties getProperties() { + return properties; + } + + /** + * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. + * + * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. + */ + public KeyVaultRoleScope getScope() { + return scope; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java new file mode 100644 index 000000000000..31836a33550b --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings; + +import java.util.Objects; + +/** + * A class that defines a role assignment's properties. + */ +public class KeyVaultRoleAssignmentProperties { + private String roleDefinitionId; + private String principalId; + + /** + * Creates a new {@link KeyVaultRoleAssignmentProperties role assignment properties} object with the specified + * details. + * + * @param roleDefinitionId The {@link KeyVaultRoleDefinition role definition} ID used in the + * {@link KeyVaultRoleAssignment role assignment}. + * @param principalId The principal ID assigned to the role. This maps to the ID inside the Active Directory. + * It can point to a user, service principal, or security group. + */ + public KeyVaultRoleAssignmentProperties(String roleDefinitionId, String principalId) { + Objects.requireNonNull(roleDefinitionId, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'roleDefinitionId' in 'properties'")); + Objects.requireNonNull(principalId, + String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), + "'principalId' in 'properties'")); + + this.roleDefinitionId = roleDefinitionId; + this.principalId = principalId; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition} ID used in the {@link KeyVaultRoleAssignment role + * assignment}. + * + * @return The {@link KeyVaultRoleDefinition role definition} ID. + */ + public String getRoleDefinitionId() { + return roleDefinitionId; + } + + /** + * Get the principal ID assigned to the role. + * + * @return The principal ID. + */ + public String getPrincipalId() { + return principalId; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java new file mode 100644 index 000000000000..adf9208986f8 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import java.util.List; + +/** + * A class that defines a role. + */ +public class KeyVaultRoleDefinition { + private String id; + private String name; + private String type; + private KeyVaultRoleDefinitionProperties properties; + private List scopes; + + /** + * Creates a new {@link KeyVaultRoleDefinition role definition} with the specified details. + * + * @param id The ID for this {@link KeyVaultRoleDefinition role definition}. + * @param name The name for this {@link KeyVaultRoleDefinition role definition}. + * @param type The type for this {@link KeyVaultRoleDefinition role definition}. + * @param properties {@link KeyVaultRoleDefinitionProperties properties} of this {@link KeyVaultRoleDefinition + * role assignment}. + */ + public KeyVaultRoleDefinition(String id, String name, String type, KeyVaultRoleDefinitionProperties properties) { + this.id = id; + this.name = name; + this.type = type; + this.properties = properties; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition} ID. + * + * @return The {@link KeyVaultRoleDefinition role definition} ID. + */ + public String getId() { + return id; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition} name. + * + * @return The {@link KeyVaultRoleDefinition role definition} name. + */ + public String getName() { + return name; + } + + /** + * Get the {@link KeyVaultRoleDefinition role assignment} type. + * + * @return The {@link KeyVaultRoleDefinition role assignment} type. + */ + public String getType() { + return type; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition} {@link KeyVaultRoleDefinitionProperties properties}. + * + * @return The {@link KeyVaultRoleDefinition role assignment} {@link KeyVaultRoleDefinitionProperties properties}. + */ + public KeyVaultRoleDefinitionProperties getProperties() { + return properties; + } +} diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java new file mode 100644 index 000000000000..e5cdd41c8936 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import java.util.List; + +/** + * A class that defines a role definition's properties. + */ +public class KeyVaultRoleDefinitionProperties { + private String roleName; + private String description; + private String roleType; + private List permissions; + private List assignableScopes; + + /** + * Creates a new {@link KeyVaultRoleDefinitionProperties role definition properties} object with the specified + * details. + * + * @param roleName The name of the role. + * @param roleDescription The description of the role. + * @param roleType The type of the role. + * @param permissions The {@link KeyVaultPermission permissions} the {@link KeyVaultRoleDefinition role + * definition} has. + * @param assignableScopes The assignable scopes of the {@link KeyVaultRoleDefinition role definition}. + */ + public KeyVaultRoleDefinitionProperties(String roleName, String roleDescription, String roleType, + List permissions, + List assignableScopes) { + this.roleName = roleName; + this.description = roleDescription; + this.roleType = roleType; + this.permissions = permissions; + this.assignableScopes = assignableScopes; + } + + /** + * Get the role name. + * + * @return The role name. + */ + public String getRoleName() { + return roleName; + } + + /** + * Get the role description. + * + * @return The role description. + */ + public String getDescription() { + return description; + } + + /** + * Get the role type. + * + * @return The role type. + */ + public String getRoleType() { + return roleType; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition}'s {@link KeyVaultPermission permissions}. + * + * @return The {@link KeyVaultRoleDefinition role definition}'s {@link KeyVaultPermission permissions}. + */ + public List getPermissions() { + return permissions; + } + + /** + * Get the {@link KeyVaultRoleDefinition role definition}'s assignable scopes. + * + * @return The {@link KeyVaultRoleDefinition role definition}'s assignable scopes. + */ + public List getAssignableScopes() { + return assignableScopes; + } +} 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 af9d9fb4c36f..391df5993d8b 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 @@ -7,6 +7,9 @@ import java.net.URI; +/** + * A class that defines the scope of a role. + */ public final class KeyVaultRoleScope extends ExpandableStringEnum { public static final KeyVaultRoleScope GLOBAL = fromString("/"); public static final KeyVaultRoleScope KEYS = fromString("/keys"); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index f482660398ce..cb14851d2a67 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -6,7 +6,6 @@ exports com.azure.security.keyvault.administration; exports com.azure.security.keyvault.administration.models; - exports com.azure.security.keyvault.administration.implementation.models; opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md index 6d57060910e9..70a2f4efdd0a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md @@ -41,40 +41,6 @@ generate-client-as-impl: true sync-methods: none add-context-parameter: true context-client-method-parameter: true -directive : - - rename-model: - from: Permission - to: KeyVaultPermission - - rename-model: - from: RoleAssignment - to: KeyVaultRoleAssignment - - rename-model: - from: RoleAssignmentCreateParameters - to: KeyVaultRoleAssignmentCreateParameters - - rename-model: - from: RoleAssignmentFilter - to: KeyVaultRoleAssignmentFilter - - rename-model: - from: RoleAssignmentListResult - to: KeyVaultRoleAssignmentListResult - - rename-model: - from: RoleAssignmentProperties - to: KeyVaultRoleAssignmentProperties - - rename-model: - from: RoleAssignmentPropertiesWithScope - to: KeyVaultRoleAssignmentPropertiesWithScope - - rename-model: - from: RoleAssignmentProperties - to: KeyVaultRoleAssignmentProperties - - rename-model: - from: RoleDefinition - to: KeyVaultRoleDefinition - - rename-model: - from: RoleDefinitionFilter - to: KeyVaultRoleDefinitionFilter - - rename-model: - from: RoleDefinitionListResult - to: KeyVaultRoleDefinitionListResult ``` ### Tag: rbac-preview From 0d75b43e84ca148f8c82948d758cfdbbdf405bd3 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 31 Aug 2020 20:41:11 -0700 Subject: [PATCH 27/40] Renamed KeyVaultRoleScope to KeyVaultRoleAssignmentScope. --- .../KeyVaultAccessControlAsyncClient.java | 155 ++++++++++-------- .../KeyVaultAccessControlClient.java | 62 +++---- .../models/KeyVaultRoleAssignment.java | 13 +- .../models/KeyVaultRoleAssignmentScope.java | 36 ++++ .../models/KeyVaultRoleScope.java | 36 ---- 5 files changed, 157 insertions(+), 145 deletions(-) create mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java delete mode 100644 sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 7d60d2013aba..79b0250251f4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -85,32 +85,33 @@ public String getVaultUrl() { } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope - * scope} and above. + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleDefinitions(KeyVaultRoleScope scope) { + public PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope scope) { return new PagedFlux<>( () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope - * scope} and above. + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role + * definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ - PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, Context context) { + PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope scope, Context context) { return new PagedFlux<>( () -> listRoleDefinitionsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); @@ -118,16 +119,17 @@ PagedFlux listRoleDefinitions(KeyVaultRoleScope scope, C /** * Get all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given - * {@link KeyVaultRoleScope scope} and above. + * {@link KeyVaultRoleAssignmentScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleScope scope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * for the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ - Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleScope scope, + Mono> listRoleDefinitionsFirstPage(String vaultUrl, + KeyVaultRoleAssignmentScope scope, Context context) { Objects.requireNonNull(scope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), @@ -150,13 +152,13 @@ Mono> listRoleDefinitionsFirstPage(String /** * Gets all the {@link KeyVaultRoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved * from a call to - * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleScope, Context)}. + * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleAssignmentScope, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleScope scope} from the next page of results. + * for the given {@link KeyVaultRoleAssignmentScope scope} from the next page of results. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -174,32 +176,32 @@ Mono> listRoleDefinitionsNextPage(String c } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope - * scope} and above. + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleAssignments(KeyVaultRoleScope scope) { + public PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope scope) { return new PagedFlux<>( () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope - * scope} and above. + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ - PagedFlux listRoleAssignments(KeyVaultRoleScope scope, Context context) { + PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope scope, Context context) { return new PagedFlux<>( () -> listRoleAssignmentsFirstPage(vaultUrl, scope, context), continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); @@ -207,16 +209,17 @@ PagedFlux listRoleAssignments(KeyVaultRoleScope scope, C /** * Get all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at - * the given {@link KeyVaultRoleScope scope} and above. + * the given {@link KeyVaultRoleAssignmentScope scope} and above. * * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * in the given {@link KeyVaultRoleScope scope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * in the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ - Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleScope scope, + Mono> listRoleAssignmentsFirstPage(String vaultUrl, + KeyVaultRoleAssignmentScope scope, Context context) { Objects.requireNonNull(scope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), @@ -238,13 +241,14 @@ Mono> listRoleAssignmentsFirstPage(String /** * Gets all the {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was - * retrieved from a call to {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleScope)}. + * retrieved from a call to + * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleAssignmentScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, * successful call to one of the {@code listKeyVaultRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * for the given {@link KeyVaultRoleScope scope} from the first page of results. + * for the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { @@ -264,14 +268,14 @@ Mono> listRoleAssignmentsNextPage(String c /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleScope scope, + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope scope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignment(scope, UUID.randomUUID(), properties); } @@ -279,15 +283,15 @@ public Mono createRoleAssignment(KeyVaultRoleScope scope /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleScope scope, UUID name, + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope scope, UUID name, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); } @@ -295,15 +299,15 @@ public Mono createRoleAssignment(KeyVaultRoleScope scope /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties); } @@ -311,16 +315,17 @@ public Mono> createRoleAssignmentWithResponse(K /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, + UUID name, KeyVaultRoleAssignmentProperties properties) { return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); } @@ -328,16 +333,16 @@ public Mono> createRoleAssignmentWithResponse(K /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { Objects.requireNonNull(scope, @@ -370,41 +375,44 @@ Mono> createRoleAssignmentWithResponse(KeyVault /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRoleAssignment(KeyVaultRoleScope scope, String name) { + public Mono getRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name) { + public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name) { return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ - Mono> getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, Context context) { Objects.requireNonNull(scope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), @@ -429,27 +437,29 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteRoleAssignment(KeyVaultRoleScope scope, String name) { + public Mono deleteRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, + public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name) { return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); } @@ -457,14 +467,15 @@ public Mono> deleteRoleAssignmentWithResponse(K /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link String name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are + * {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, Context context) { Objects.requireNonNull(scope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), @@ -620,6 +631,6 @@ private KeyVaultRoleAssignment roleAssignmentToKeyVaultRoleAssignment(RoleAssign return new KeyVaultRoleAssignment(roleAssignment.getId(), roleAssignment.getName(), roleAssignment.getType(), new KeyVaultRoleAssignmentProperties(propertiesWithScope.getRoleDefinitionId(), - propertiesWithScope.getPrincipalId()), KeyVaultRoleScope.fromString(propertiesWithScope.getScope())); + propertiesWithScope.getPrincipalId()), KeyVaultRoleAssignmentScope.fromString(propertiesWithScope.getScope())); } } 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 5cd60c10a277..34d22a762429 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 @@ -43,46 +43,46 @@ public String getVaultUrl() { } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleScope + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleAssignmentScope * scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleDefinition role definitions}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role definitions}. * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleDefinitions(KeyVaultRoleScope scope, Context context) { + public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, context)); } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleScope + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleAssignmentScope * scope} and above. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope scope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleAssignments(KeyVaultRoleScope scope, Context context) { + public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope scope, Context context) { return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); } /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope scope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties, Context.NONE).getValue(); } @@ -90,15 +90,15 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID name, + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope scope, UUID name, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(scope, name, properties, Context.NONE).getValue(); } @@ -106,17 +106,17 @@ public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleScope scope, UUID /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope}, {@link UUID name} or + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createRoleAssignmentWithResponse(KeyVaultRoleScope scope, UUID name, + public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { return asyncClient.createRoleAssignmentWithResponse(scope, name, properties, context).block(); @@ -125,26 +125,26 @@ public Response createRoleAssignmentWithResponse(KeyVaul /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleScope scope, String name) { + public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { return getRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, Context context) { return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); } @@ -152,26 +152,26 @@ public Response getRoleAssignmentWithResponse(KeyVaultRo /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleScope scope, String name) { + public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { return deleteRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleScope scope} of the {@link KeyVaultRoleAssignment}. + * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteRoleAssignmentWithResponse(KeyVaultRoleScope scope, String name, + public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, Context context) { return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index d6bdd474373f..a2614f641df6 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -11,7 +11,7 @@ public class KeyVaultRoleAssignment { private String name; private String type; private KeyVaultRoleAssignmentProperties properties; - private KeyVaultRoleScope scope; + private KeyVaultRoleAssignmentScope scope; /** * Creates a new {@link KeyVaultRoleAssignment role assignment} with the specified details. @@ -21,10 +21,11 @@ public class KeyVaultRoleAssignment { * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. * @param properties {@link KeyVaultRoleAssignmentProperties properties} of this {@link KeyVaultRoleAssignment * role assignment}. - * @param roleScope The {@link KeyVaultRoleScope scope} of this {@link KeyVaultRoleAssignment role assignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope scope} of this {@link KeyVaultRoleAssignment role + * assignment}. */ public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, - KeyVaultRoleScope roleScope) { + KeyVaultRoleAssignmentScope roleScope) { this.id = id; this.name = name; this.type = type; @@ -69,11 +70,11 @@ public KeyVaultRoleAssignmentProperties getProperties() { } /** - * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. + * Get the {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentScope scope}. * - * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleScope scope}. + * @return The {@link KeyVaultRoleAssignment role assignment} {@link KeyVaultRoleAssignmentScope scope}. */ - public KeyVaultRoleScope getScope() { + public KeyVaultRoleAssignmentScope getScope() { return scope; } } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java new file mode 100644 index 000000000000..0356d3fde614 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentScope.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.administration.models; + +import com.azure.core.util.ExpandableStringEnum; + +import java.net.URI; + +/** + * A class that defines the scope of a role. + */ +public final class KeyVaultRoleAssignmentScope extends ExpandableStringEnum { + public static final KeyVaultRoleAssignmentScope GLOBAL = fromString("/"); + public static final KeyVaultRoleAssignmentScope KEYS = fromString("/keys"); + + /** + * Creates or finds a {@link KeyVaultRoleAssignmentScope} from its string representation. + * + * @param name A name to look for. + * @return The corresponding {@link KeyVaultRoleAssignmentScope} + */ + public static KeyVaultRoleAssignmentScope fromString(String name) { + return fromString(name, KeyVaultRoleAssignmentScope.class); + } + + /** + * Creates or finds a {@link KeyVaultRoleAssignmentScope} from its string representation. + * + * @param uri A URI to look for. + * @return The corresponding {@link KeyVaultRoleAssignmentScope} + */ + public static KeyVaultRoleAssignmentScope fromUri(URI uri) { + return fromString(uri.getRawPath(), KeyVaultRoleAssignmentScope.class); + } +} 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 deleted file mode 100644 index 391df5993d8b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.administration.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.net.URI; - -/** - * A class that defines the scope of a role. - */ -public final class KeyVaultRoleScope extends ExpandableStringEnum { - public static final KeyVaultRoleScope GLOBAL = fromString("/"); - public static final KeyVaultRoleScope KEYS = fromString("/keys"); - - /** - * Creates or finds a {@link KeyVaultRoleScope} from its string representation. - * - * @param name A name to look for. - * @return The corresponding {@link KeyVaultRoleScope} - */ - public static KeyVaultRoleScope fromString(String name) { - return fromString(name, KeyVaultRoleScope.class); - } - - /** - * Creates or finds a {@link KeyVaultRoleScope} from its string representation. - * - * @param uri A URI to look for. - * @return The corresponding {@link KeyVaultRoleScope} - */ - public static KeyVaultRoleScope fromUri(URI uri) { - return fromString(uri.getRawPath(), KeyVaultRoleScope.class); - } -} From 0e42b1a82d904df89f45a3fba62584025c16b54a Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 1 Sep 2020 11:30:22 -0700 Subject: [PATCH 28/40] Fixed build issues. --- .../administration/KeyVaultAccessControlAsyncClient.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 79b0250251f4..c183e89d93bc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -504,7 +504,7 @@ private PagedResponse transformRoleDefinitionsPagedRespo keyVaultRoleDefinitions.add(roleDefinitionToKeyVaultRoleDefinition(roleDefinition)); } - return new PagedResponse<>() { + return new PagedResponse() { @Override public void close() throws IOException { } @@ -544,7 +544,7 @@ public List getValue() { private Response transformRoleAssignmentResponse(Response response) { KeyVaultRoleAssignment keyVaultRoleAssignment = roleAssignmentToKeyVaultRoleAssignment(response.getValue()); - return new Response<>() { + return new Response() { @Override public int getStatusCode() { return response.getStatusCode(); @@ -589,7 +589,7 @@ private PagedResponse transformRoleAssignmentsPagedRespo keyVaultRoleAssignments.add(roleAssignmentToKeyVaultRoleAssignment(roleAssignment)); } - return new PagedResponse<>() { + return new PagedResponse() { @Override public void close() throws IOException { } From b3dcfc7c6ad9325526ff0e68970a15a77b60d4d4 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 1 Sep 2020 11:32:03 -0700 Subject: [PATCH 29/40] Made model classes final. --- .../keyvault/administration/models/KeyVaultPermission.java | 2 +- .../keyvault/administration/models/KeyVaultRoleAssignment.java | 2 +- .../administration/models/KeyVaultRoleAssignmentProperties.java | 2 +- .../keyvault/administration/models/KeyVaultRoleDefinition.java | 2 +- .../administration/models/KeyVaultRoleDefinitionProperties.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java index ad3c463b4b99..2bf23f09d933 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java @@ -8,7 +8,7 @@ /** * A class describing allowed and denied actions and data actions of a {@link KeyVaultRoleDefinition}. */ -public class KeyVaultPermission { +public final class KeyVaultPermission { private List actions; private List deniedActions; private List dataActions; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index a2614f641df6..68fb7c6c6b27 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -6,7 +6,7 @@ /** * A class that defines a role assignment. */ -public class KeyVaultRoleAssignment { +public final class KeyVaultRoleAssignment { private String id; private String name; private String type; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java index 31836a33550b..cc0a945730e7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignmentProperties.java @@ -10,7 +10,7 @@ /** * A class that defines a role assignment's properties. */ -public class KeyVaultRoleAssignmentProperties { +public final class KeyVaultRoleAssignmentProperties { private String roleDefinitionId; private String principalId; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java index adf9208986f8..9433fc9873c7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java @@ -8,7 +8,7 @@ /** * A class that defines a role. */ -public class KeyVaultRoleDefinition { +public final class KeyVaultRoleDefinition { private String id; private String name; private String type; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java index e5cdd41c8936..430f4e766fe8 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java @@ -8,7 +8,7 @@ /** * A class that defines a role definition's properties. */ -public class KeyVaultRoleDefinitionProperties { +public final class KeyVaultRoleDefinitionProperties { private String roleName; private String description; private String roleType; From 4546a8c54e8c36c6e9616a079e609227bcf94b1c Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 1 Sep 2020 11:43:05 -0700 Subject: [PATCH 30/40] Updated module-info.java --- .../src/main/java/module-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index cb14851d2a67..af1b771413c4 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -10,4 +10,5 @@ opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.implementation to com.fasterxml.jackson.databind; + opens com.azure.security.keyvault.administration.implementation.models to com.fasterxml.jackson.databind; } From cbc29236ea2027deec8f7f87cc8273a014d2a4b6 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 1 Sep 2020 22:46:37 -0700 Subject: [PATCH 31/40] Renamed input parameter "scope" to "roleScope" in a multitude of public APIs. Corrected version number in files inside /eng. --- eng/jacoco-test-coverage/pom.xml | 2 +- eng/versioning/version_client.txt | 2 +- .../KeyVaultAccessControlAsyncClient.java | 266 +++++++++--------- .../KeyVaultAccessControlClient.java | 117 ++++---- 4 files changed, 203 insertions(+), 184 deletions(-) diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index 3423ca31b060..fbe6ce2dced3 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -164,7 +164,7 @@ com.azure azure-security-keyvault-administration - 4.1.0-beta.1 + 4.0.0-beta.1 com.azure diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index dec64e6dd2ca..83a71fd48b15 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -35,7 +35,7 @@ com.azure:azure-messaging-eventhubs;5.1.2;5.2.0-beta.3 com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.1.2;1.2.0-beta.3 com.azure:azure-messaging-servicebus;7.0.0-beta.5;7.0.0-beta.6 com.azure:azure-search-documents;11.0.0;11.1.0-beta.2 -com.azure:azure-security-keyvault-administration;4.1.0-beta.1;4.1.0-beta.1 +com.azure:azure-security-keyvault-administration;4.0.0-beta.1;4.0.0-beta.1 com.azure:azure-security-keyvault-certificates;4.1.0;4.2.0-beta.1 com.azure:azure-security-keyvault-keys;4.2.0;4.3.0-beta.1 com.azure:azure-security-keyvault-secrets;4.2.0;4.3.0-beta.1 diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index c183e89d93bc..57331939be5a 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -86,63 +86,64 @@ public String getVaultUrl() { /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope scope} and above. + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role definitions}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope scope) { + public PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope) { return new PagedFlux<>( - () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, scope, context)), + () -> withContext(context -> listRoleDefinitionsFirstPage(vaultUrl, roleScope, context)), continuationToken -> withContext(context -> listRoleDefinitionsNextPage(continuationToken, context))); } /** * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope scope} and above. + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role - * definitions}. - * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ - PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope scope, Context context) { + PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, Context context) { return new PagedFlux<>( - () -> listRoleDefinitionsFirstPage(vaultUrl, scope, context), + () -> listRoleDefinitionsFirstPage(vaultUrl, roleScope, context), continuationToken -> listRoleDefinitionsNextPage(continuationToken, context)); } /** * Get all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given - * {@link KeyVaultRoleAssignmentScope scope} and above. + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ Mono> listRoleDefinitionsFirstPage(String vaultUrl, - KeyVaultRoleAssignmentScope scope, + KeyVaultRoleAssignmentScope roleScope, Context context) { - Objects.requireNonNull(scope, + Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'scope'")); + "'roleScope'")); try { return clientImpl.getRoleDefinitions() - .listSinglePageAsync(vaultUrl, scope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, - KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Listing role definitions for scope - {}", scope)) - .doOnSuccess(response -> logger.info("Listed role definitions for scope - {}", scope)) - .doOnError(error -> logger.warning(String.format("Failed to list role definitions for scope - %s", - scope), error)) + .listSinglePageAsync(vaultUrl, roleScope.toString(), null, + context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) + .doOnRequest(ignored -> logger.info("Listing role definitions for roleScope - {}", roleScope)) + .doOnSuccess(response -> logger.info("Listed role definitions for roleScope - {}", roleScope)) + .doOnError(error -> logger.warning(String.format("Failed to list role definitions for roleScope - %s", + roleScope), error)) .map(this::transformRoleDefinitionsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -158,7 +159,7 @@ Mono> listRoleDefinitionsFirstPage(String * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} - * for the given {@link KeyVaultRoleAssignmentScope scope} from the next page of results. + * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the next page of results. */ Mono> listRoleDefinitionsNextPage(String continuationToken, Context context) { try { @@ -177,62 +178,62 @@ Mono> listRoleDefinitionsNextPage(String c /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope scope} and above. + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope scope) { + public PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope roleScope) { return new PagedFlux<>( - () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, scope, context)), + () -> withContext(context -> listRoleAssignmentsFirstPage(vaultUrl, roleScope, context)), continuationToken -> withContext(context -> listRoleAssignmentsNextPage(continuationToken, context))); } /** * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given - * {@link KeyVaultRoleAssignmentScope scope} and above. + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ - PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope scope, Context context) { + PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, Context context) { return new PagedFlux<>( - () -> listRoleAssignmentsFirstPage(vaultUrl, scope, context), + () -> listRoleAssignmentsFirstPage(vaultUrl, roleScope, context), continuationToken -> listRoleAssignmentsNextPage(continuationToken, context)); } /** * Get all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at - * the given {@link KeyVaultRoleAssignmentScope scope} and above. + * the given {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param vaultUrl The URL for the Key Vault this client is associated with. - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * in the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * in the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ Mono> listRoleAssignmentsFirstPage(String vaultUrl, - KeyVaultRoleAssignmentScope scope, + KeyVaultRoleAssignmentScope roleScope, Context context) { - Objects.requireNonNull(scope, + Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'scope'")); + "'roleScope'")); try { return clientImpl.getRoleAssignments() - .listForScopeSinglePageAsync(vaultUrl, scope.toString(), null, + .listForScopeSinglePageAsync(vaultUrl, roleScope.toString(), null, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Listing role assignments for scope - {}", scope)) - .doOnSuccess(response -> logger.info("Listed role assignments for scope - {}", scope)) - .doOnError(error -> logger.warning(String.format("Failed to list role assignments for scope - %s", - scope), error)) + .doOnRequest(ignored -> logger.info("Listing role assignments for roleScope - {}", roleScope)) + .doOnSuccess(response -> logger.info("Listed role assignments for roleScope - {}", roleScope)) + .doOnError(error -> logger.warning(String.format("Failed to list role assignments for roleScope - %s", + roleScope), error)) .map(this::transformRoleAssignmentsPagedResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -248,7 +249,7 @@ Mono> listRoleAssignmentsFirstPage(String * successful call to one of the {@code listKeyVaultRoleAssignments} operations. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} - * for the given {@link KeyVaultRoleAssignmentScope scope} from the first page of results. + * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. */ Mono> listRoleAssignmentsNextPage(String continuationToken, Context context) { try { @@ -268,86 +269,92 @@ Mono> listRoleAssignmentsNextPage(String c /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope scope, + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignment(scope, UUID.randomUUID(), properties); + return createRoleAssignment(roleScope, UUID.randomUUID(), properties); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope scope, UUID name, + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(scope, name, properties).flatMap(FluxUtil::toMono); + return createRoleAssignmentWithResponse(roleScope, name, properties).flatMap(FluxUtil::toMono); } /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties); + return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return withContext(context -> createRoleAssignmentWithResponse(scope, name, properties, context)); + return withContext(context -> createRoleAssignmentWithResponse(roleScope, name, properties, context)); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, UUID name, + Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { - Objects.requireNonNull(scope, + Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'scope'")); + "'roleScope'")); Objects.requireNonNull(name, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'name'")); @@ -364,7 +371,7 @@ Mono> createRoleAssignmentWithResponse(KeyVault .setProperties(roleAssignmentProperties); return clientImpl.getRoleAssignments() - .createWithResponseAsync(vaultUrl, scope.toString(), name.toString(), parameters, + .createWithResponseAsync(vaultUrl, roleScope.toString(), name.toString(), parameters, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) @@ -375,55 +382,56 @@ Mono> createRoleAssignmentWithResponse(KeyVault /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name used of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { - return getRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); + public Mono getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { + return getRoleAssignmentWithResponse(roleScope, name).flatMap(FluxUtil::toMono); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name) { - return withContext(context -> getRoleAssignmentWithResponse(scope, name, context)); + public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + String name) { + return withContext(context -> getRoleAssignmentWithResponse(roleScope, name, context)); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ - Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, - Context context) { - Objects.requireNonNull(scope, + Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + String name, Context context) { + Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'scope'")); + "'roleScope'")); Objects.requireNonNull(name, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'name'")); try { return clientImpl.getRoleAssignments() - .getWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + .getWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) @@ -437,56 +445,56 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { - return deleteRoleAssignmentWithResponse(scope, name).flatMap(FluxUtil::toMono); + public Mono deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { + return deleteRoleAssignmentWithResponse(roleScope, name).flatMap(FluxUtil::toMono); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, + public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name) { - return withContext(context -> deleteRoleAssignmentWithResponse(scope, name, context)); + return withContext(context -> deleteRoleAssignmentWithResponse(roleScope, name, context)); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link String name} are - * {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are + * {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, - Context context) { - Objects.requireNonNull(scope, + Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + String name, Context context) { + Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), - "'scope'")); + "'roleScope'")); Objects.requireNonNull(name, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'name'")); try { return clientImpl.getRoleAssignments() - .deleteWithResponseAsync(vaultUrl, scope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, + .deleteWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) 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 34d22a762429..4fd56aaef3b3 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 @@ -43,136 +43,147 @@ public String getVaultUrl() { } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given {@link KeyVaultRoleAssignmentScope - * scope} and above. + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleDefinition role definitions}. - * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope scope, Context context) { - return new PagedIterable<>(asyncClient.listRoleDefinitions(scope, context)); + public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, + Context context) { + return new PagedIterable<>(asyncClient.listRoleDefinitions(roleScope, context)); } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given {@link KeyVaultRoleAssignmentScope - * scope} and above. + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given - * {@link KeyVaultRoleAssignmentScope scope}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} is {@code null}. + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope scope, Context context) { - return new PagedIterable<>(asyncClient.listRoleAssignments(scope, context)); + public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, + Context context) { + return new PagedIterable<>(asyncClient.listRoleAssignments(roleScope, context)); } /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope scope, + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(scope, UUID.randomUUID(), properties, Context.NONE).getValue(); + return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope scope, UUID name, + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { - return createRoleAssignmentWithResponse(scope, name, properties, Context.NONE).getValue(); + return createRoleAssignmentWithResponse(roleScope, name, properties, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment} to create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, UUID name, + public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { - return asyncClient.createRoleAssignmentWithResponse(scope, name, properties, context).block(); + return asyncClient.createRoleAssignmentWithResponse(roleScope, name, properties, context).block(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { - return getRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); + public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { + return getRoleAssignmentWithResponse(roleScope, name, Context.NONE).getValue(); } /** * Gets a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, - Context context) { - return asyncClient.getRoleAssignmentWithResponse(scope, name, context).block(); + public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + String name, Context context) { + return asyncClient.getRoleAssignmentWithResponse(roleScope, name, context).block(); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope scope, String name) { - return deleteRoleAssignmentWithResponse(scope, name, Context.NONE).getValue(); + public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { + return deleteRoleAssignmentWithResponse(roleScope, name, Context.NONE).getValue(); } /** * Deletes a {@link KeyVaultRoleAssignment}. * - * @param scope The {@link KeyVaultRoleAssignmentScope scope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. - * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope scope} or {@link UUID name} are {@code null}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope scope, String name, - Context context) { - return asyncClient.deleteRoleAssignmentWithResponse(scope, name, context).block(); + public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, + String name, Context context) { + return asyncClient.deleteRoleAssignmentWithResponse(roleScope, name, context).block(); } } From 8a742681ef54ced96ad1e672839b20d56f773b8a Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 1 Sep 2020 22:59:30 -0700 Subject: [PATCH 32/40] Fixed package-info.java Javadoc. --- .../keyvault/administration/models/package-info.java | 5 ++++- .../security/keyvault/administration/package-info.java | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java index 020a9f6b9fa7..a53d8c9c2c32 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/package-info.java @@ -2,6 +2,9 @@ // Licensed under the MIT License. /** - * Package containing classes used in access control clients for Azure Key Vault. + * Package containing classes used by + * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlAsyncClient} and + * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlClient} to perform access control + * operations on Azure Key Vault resources. */ package com.azure.security.keyvault.administration.models; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java index 217c64d41f52..b1e6ea894df0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/package-info.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. /** - * Package containing classes for creating - * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlAsyncClient} - * and {@link com.azure.security.keyvault.administration.KeyVaultAccessControlClient} to perform operations on Azure - * Key Vault. + * Package containing classes for creating clients + * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlAsyncClient} and + * {@link com.azure.security.keyvault.administration.KeyVaultAccessControlClient} that perform access control + * operations on Azure Key Vault resources. */ package com.azure.security.keyvault.administration; From 01e3e7641b80127033b0a2046476b637e549e9c8 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 3 Sep 2020 11:07:54 -0700 Subject: [PATCH 33/40] Fixed some strings used for logging. --- .../KeyVaultAccessControlAsyncClient.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 57331939be5a..ff34ec487dc0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -433,9 +433,9 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol return clientImpl.getRoleAssignments() .getWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) - .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .doOnRequest(ignored -> logger.info("Retrieving role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Retrieved role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to retrieved role assignment - {}", name, error)) .map(this::transformRoleAssignmentResponse); } catch (RuntimeException e) { return monoError(logger, e); @@ -496,9 +496,9 @@ Mono> deleteRoleAssignmentWithResponse(KeyVault return clientImpl.getRoleAssignments() .deleteWithResponseAsync(vaultUrl, roleScope.toString(), name, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.info("Creating role assignment - {}", name)) - .doOnSuccess(response -> logger.info("Created role assignment - {}", response.getValue().getName())) - .doOnError(error -> logger.warning("Failed to create role assignment - {}", name, error)) + .doOnRequest(ignored -> logger.info("Deleting role assignment - {}", name)) + .doOnSuccess(response -> logger.info("Deleted role assignment - {}", response.getValue().getName())) + .doOnError(error -> logger.warning("Failed to delete role assignment - {}", name, error)) .map(this::transformRoleAssignmentResponse); } catch (RuntimeException e) { return monoError(logger, e); From 2ee7459c1104d373ec41c0414bf146fb33bf02dd Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 3 Sep 2020 13:46:33 -0700 Subject: [PATCH 34/40] Fixed JavaDoc formatting issues pointed out by @g2vinay. --- .../KeyVaultAccessControlAsyncClient.java | 144 ++++++++---------- .../KeyVaultAccessControlClient.java | 98 +++++++----- .../KeyVaultAccessControlClientBuilder.java | 8 - .../models/KeyVaultPermission.java | 9 +- .../models/KeyVaultRoleAssignment.java | 13 +- .../models/KeyVaultRoleDefinition.java | 8 +- .../KeyVaultRoleDefinitionProperties.java | 14 +- 7 files changed, 143 insertions(+), 151 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index ff34ec487dc0..1ae65b512915 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -85,11 +85,11 @@ public String getVaultUrl() { } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. + * definitions}. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleAssignmentScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. @@ -102,12 +102,12 @@ public PagedFlux listRoleDefinitions(KeyVaultRoleAssignm } /** - * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * Lists all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. - * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleAssignmentScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. @@ -119,19 +119,17 @@ PagedFlux listRoleDefinitions(KeyVaultRoleAssignmentScop } /** - * Get all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given + * Lists all {@link KeyVaultRoleDefinition role definitions} in the first page that are applicable at the given * {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param vaultUrl The URL for the Key Vault this client is associated with. * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ - Mono> listRoleDefinitionsFirstPage(String vaultUrl, - KeyVaultRoleAssignmentScope roleScope, - Context context) { + Mono> listRoleDefinitionsFirstPage(String vaultUrl, KeyVaultRoleAssignmentScope roleScope, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -151,13 +149,13 @@ Mono> listRoleDefinitionsFirstPage(String } /** - * Gets all the {@link KeyVaultRoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved + * Lists all {@link KeyVaultRoleDefinition role definitions} given by the {@code nextPageLink} that was retrieved * from a call to * {@link KeyVaultAccessControlAsyncClient#listRoleDefinitionsFirstPage(String, KeyVaultRoleAssignmentScope, Context)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * successful call to one of the {@code listKeyVaultRoleDefinitions} operations. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleDefinition role definitions} * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the next page of results. */ @@ -177,7 +175,7 @@ Mono> listRoleDefinitionsNextPage(String c } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. @@ -193,11 +191,11 @@ public PagedFlux listRoleAssignments(KeyVaultRoleAssignm } /** - * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * Lists all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedFlux} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleAssignmentScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. @@ -209,19 +207,17 @@ PagedFlux listRoleAssignments(KeyVaultRoleAssignmentScop } /** - * Get all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at + * Lists all {@link KeyVaultRoleAssignment role assignments} in the first page that are applicable at * the given {@link KeyVaultRoleAssignmentScope roleScope} and above. * - * @param vaultUrl The URL for the Key Vault this client is associated with. + * @param vaultUrl The URL for the Key Vault this client is associated with. * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} * in the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ - Mono> listRoleAssignmentsFirstPage(String vaultUrl, - KeyVaultRoleAssignmentScope roleScope, - Context context) { + Mono> listRoleAssignmentsFirstPage(String vaultUrl, KeyVaultRoleAssignmentScope roleScope, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -241,13 +237,13 @@ Mono> listRoleAssignmentsFirstPage(String } /** - * Gets all the {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was + * Lists all {@link KeyVaultRoleAssignment role assignments} given by the {@code nextPageLink} that was * retrieved from a call to * {@link KeyVaultAccessControlAsyncClient#listRoleAssignments(KeyVaultRoleAssignmentScope)}. * * @param continuationToken The {@link PagedResponse#getContinuationToken() continuationToken} from a previous, - * successful call to one of the {@code listKeyVaultRoleAssignments} operations. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * successful call to one of the {@code listKeyVaultRoleAssignments} operations. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link PagedResponse} of {@link KeyVaultRoleAssignment role assignments} * for the given {@link KeyVaultRoleAssignmentScope roleScope} from the first page of results. */ @@ -269,89 +265,81 @@ Mono> listRoleAssignmentsNextPage(String c /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, - KeyVaultRoleAssignmentProperties properties) { + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignment(roleScope, UUID.randomUUID(), properties); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the created {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, - KeyVaultRoleAssignmentProperties properties) { + public Mono createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(roleScope, name, properties).flatMap(FluxUtil::toMono); } /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - KeyVaultRoleAssignmentProperties properties) { + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - UUID name, - KeyVaultRoleAssignmentProperties properties) { + public Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { return withContext(context -> createRoleAssignmentWithResponse(roleScope, name, properties, context)); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ - Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - UUID name, - KeyVaultRoleAssignmentProperties properties, - Context context) { + Mono> createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -383,10 +371,10 @@ Mono> createRoleAssignmentWithResponse(KeyVault * Gets a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name used of the {@link KeyVaultRoleAssignment}. + * @param name The name used of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { @@ -397,15 +385,14 @@ public Mono getRoleAssignment(KeyVaultRoleAssignmentScop * Gets a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name) { + public Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name) { return withContext(context -> getRoleAssignmentWithResponse(roleScope, name, context)); } @@ -413,15 +400,14 @@ public Mono> getRoleAssignmentWithResponse(KeyV * Gets a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ - Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name, Context context) { + Mono> getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); @@ -446,10 +432,10 @@ Mono> getRoleAssignmentWithResponse(KeyVaultRol * Deletes a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing the {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { @@ -460,15 +446,14 @@ public Mono deleteRoleAssignment(KeyVaultRoleAssignmentS * Deletes a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name) { + public Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name) { return withContext(context -> deleteRoleAssignmentWithResponse(roleScope, name, context)); } @@ -476,15 +461,14 @@ public Mono> deleteRoleAssignmentWithResponse(K * Deletes a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link String name} are - * {@code null}. + * {@code null}. */ - Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name, Context context) { + Mono> deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { Objects.requireNonNull(roleScope, String.format(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.PARAMETER_REQUIRED), "'roleScope'")); 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 4fd56aaef3b3..d4cdcff2808a 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 @@ -47,15 +47,29 @@ public String getVaultUrl() { * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role - * definitions}. - * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * definitions}. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given * {@link KeyVaultRoleAssignmentScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, - Context context) { + public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope) { + return new PagedIterable<>(asyncClient.listRoleDefinitions(roleScope, Context.NONE)); + } + + /** + * Get all {@link KeyVaultRoleDefinition role definitions} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleDefinition role + * definitions}. + * @param context Additional {@link Context} that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} containing the {@link KeyVaultRoleDefinition role definitions} for the given + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoleDefinitions(KeyVaultRoleAssignmentScope roleScope, Context context) { return new PagedIterable<>(asyncClient.listRoleDefinitions(roleScope, context)); } @@ -64,68 +78,76 @@ public PagedIterable listRoleDefinitions(KeyVaultRoleAss * {@link KeyVaultRoleAssignmentScope roleScope} and above. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given * {@link KeyVaultRoleAssignmentScope roleScope}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, - Context context) { + public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope) { + return new PagedIterable<>(asyncClient.listRoleAssignments(roleScope, Context.NONE)); + } + + /** + * Get all {@link KeyVaultRoleAssignment role assignments} that are applicable at the given + * {@link KeyVaultRoleAssignmentScope roleScope} and above. + * + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. + * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @return A {@link PagedIterable} containing the {@link KeyVaultRoleAssignment role assignments} for the given + * {@link KeyVaultRoleAssignmentScope roleScope}. + * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} is {@code null}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoleAssignments(KeyVaultRoleAssignmentScope roleScope, Context context) { return new PagedIterable<>(asyncClient.listRoleAssignments(roleScope, context)); } /** * Creates a {@link KeyVaultRoleAssignment} with a randomly generated {@link UUID name}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, - KeyVaultRoleAssignmentProperties properties) { + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(roleScope, UUID.randomUUID(), properties, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. * @return The created {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, - KeyVaultRoleAssignmentProperties properties) { + public KeyVaultRoleAssignment createRoleAssignment(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties) { return createRoleAssignmentWithResponse(roleScope, name, properties, Context.NONE).getValue(); } /** * Creates a {@link KeyVaultRoleAssignment}. * - * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to - * create. - * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. + * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment} to + * create. + * @param name The name used to create the {@link KeyVaultRoleAssignment}. It can be any valid UUID. * @param properties Properties for the {@link KeyVaultRoleAssignment}. - * @param context Additional context that is passed through the HTTP pipeline during the service call. + * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the created * {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope}, {@link UUID name} or - * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. + * {@link KeyVaultRoleAssignmentProperties properties} are {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - UUID name, - KeyVaultRoleAssignmentProperties properties, - Context context) { + public Response createRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, UUID name, KeyVaultRoleAssignmentProperties properties, Context context) { return asyncClient.createRoleAssignmentWithResponse(roleScope, name, properties, context).block(); } @@ -133,10 +155,10 @@ public Response createRoleAssignmentWithResponse(KeyVaul * Gets a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { @@ -147,14 +169,13 @@ public KeyVaultRoleAssignment getRoleAssignment(KeyVaultRoleAssignmentScope role * Gets a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name, Context context) { + public Response getRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { return asyncClient.getRoleAssignmentWithResponse(roleScope, name, context).block(); } @@ -162,10 +183,10 @@ public Response getRoleAssignmentWithResponse(KeyVaultRo * Deletes a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope roleScope, String name) { @@ -176,14 +197,13 @@ public KeyVaultRoleAssignment deleteRoleAssignment(KeyVaultRoleAssignmentScope r * Deletes a {@link KeyVaultRoleAssignment}. * * @param roleScope The {@link KeyVaultRoleAssignmentScope roleScope} of the {@link KeyVaultRoleAssignment}. - * @param name The name of the {@link KeyVaultRoleAssignment}. + * @param name The name of the {@link KeyVaultRoleAssignment}. * @return The {@link KeyVaultRoleAssignment}. * @throws NullPointerException if the {@link KeyVaultRoleAssignmentScope roleScope} or {@link UUID name} are - * {@code null}. + * {@code null}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, - String name, Context context) { + public Response deleteRoleAssignmentWithResponse(KeyVaultRoleAssignmentScope roleScope, String name, Context context) { return asyncClient.deleteRoleAssignmentWithResponse(roleScope, name, context).block(); } } 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 61ff9273a355..2bfa61f3a75f 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 @@ -31,24 +31,16 @@ * *

The minimal configuration options required by {@link KeyVaultAccessControlClientBuilder} to build an * an {@link KeyVaultAccessControlAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

- *

- * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.instantiation} * *

The {@link HttpLogDetailLevel}, multiple custom {@link HttpLoggingPolicy policies} and custom * {@link HttpClient} can be optionally configured in the {@link KeyVaultAccessControlClientBuilder}.

- *

- * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.withhttpclient.instantiation} * *

Alternatively, a custom {@link HttpPipeline} with custom {@link HttpPipelinePolicy} policies and {@link String * vaultUrl} can be specified. It provides finer control over the construction of * {@link KeyVaultAccessControlAsyncClient} and {@link KeyVaultAccessControlClient} instances.

- *

- * {@codesnippet com.azure.security.keyvault.keys.async.accesscontrolclient.pipeline.instantiation} * *

The minimal configuration options required by {@link KeyVaultAccessControlClientBuilder} to build an * {@link KeyVaultAccessControlClient} are {@link String vaultUrl} and {@link TokenCredential credential}.

- *

- * {@codesnippet com.azure.security.keyvault.keys.accesscontrolclient.instantiation} * * @see KeyVaultAccessControlAsyncClient * @see KeyVaultAccessControlClient diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java index 2bf23f09d933..d987cbb04072 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultPermission.java @@ -17,13 +17,12 @@ public final class KeyVaultPermission { /** * Creates a new {@link KeyVaultPermission} with the specified allowed and denied actions and data actions. * - * @param actions The actions this {@link KeyVaultPermission permission} allows. - * @param deniedActions The actions this {@link KeyVaultPermission permission} denies. - * @param dataActions The data actions this {@link KeyVaultPermission permission} allows. + * @param actions The actions this {@link KeyVaultPermission permission} allows. + * @param deniedActions The actions this {@link KeyVaultPermission permission} denies. + * @param dataActions The data actions this {@link KeyVaultPermission permission} allows. * @param deniedDataActions The data actions this {@link KeyVaultPermission permission} denies. */ - public KeyVaultPermission(List actions, List deniedActions, List dataActions, - List deniedDataActions) { + public KeyVaultPermission(List actions, List deniedActions, List dataActions, List deniedDataActions) { this.actions = actions; this.deniedActions = deniedActions; this.dataActions = dataActions; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java index 68fb7c6c6b27..ef085aea877b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleAssignment.java @@ -16,16 +16,15 @@ public final class KeyVaultRoleAssignment { /** * Creates a new {@link KeyVaultRoleAssignment role assignment} with the specified details. * - * @param id The ID for this {@link KeyVaultRoleAssignment role assignment}. - * @param name The name of this {@link KeyVaultRoleAssignment role assignment}. - * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. + * @param id The ID for this {@link KeyVaultRoleAssignment role assignment}. + * @param name The name of this {@link KeyVaultRoleAssignment role assignment}. + * @param type The type of this {@link KeyVaultRoleAssignment role assignment}. * @param properties {@link KeyVaultRoleAssignmentProperties properties} of this {@link KeyVaultRoleAssignment - * role assignment}. - * @param roleScope The {@link KeyVaultRoleAssignmentScope scope} of this {@link KeyVaultRoleAssignment role + * role assignment}. + * @param roleScope The {@link KeyVaultRoleAssignmentScope scope} of this {@link KeyVaultRoleAssignment role * assignment}. */ - public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, - KeyVaultRoleAssignmentScope roleScope) { + public KeyVaultRoleAssignment(String id, String name, String type, KeyVaultRoleAssignmentProperties properties, KeyVaultRoleAssignmentScope roleScope) { this.id = id; this.name = name; this.type = type; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java index 9433fc9873c7..9d4a7465ffc5 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinition.java @@ -18,11 +18,11 @@ public final class KeyVaultRoleDefinition { /** * Creates a new {@link KeyVaultRoleDefinition role definition} with the specified details. * - * @param id The ID for this {@link KeyVaultRoleDefinition role definition}. - * @param name The name for this {@link KeyVaultRoleDefinition role definition}. - * @param type The type for this {@link KeyVaultRoleDefinition role definition}. + * @param id The ID for this {@link KeyVaultRoleDefinition role definition}. + * @param name The name for this {@link KeyVaultRoleDefinition role definition}. + * @param type The type for this {@link KeyVaultRoleDefinition role definition}. * @param properties {@link KeyVaultRoleDefinitionProperties properties} of this {@link KeyVaultRoleDefinition - * role assignment}. + * role assignment}. */ public KeyVaultRoleDefinition(String id, String name, String type, KeyVaultRoleDefinitionProperties properties) { this.id = id; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java index 430f4e766fe8..599a6ceae1f0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleDefinitionProperties.java @@ -19,16 +19,14 @@ public final class KeyVaultRoleDefinitionProperties { * Creates a new {@link KeyVaultRoleDefinitionProperties role definition properties} object with the specified * details. * - * @param roleName The name of the role. - * @param roleDescription The description of the role. - * @param roleType The type of the role. - * @param permissions The {@link KeyVaultPermission permissions} the {@link KeyVaultRoleDefinition role - * definition} has. + * @param roleName The name of the role. + * @param roleDescription The description of the role. + * @param roleType The type of the role. + * @param permissions The {@link KeyVaultPermission permissions} the {@link KeyVaultRoleDefinition role + * definition} has. * @param assignableScopes The assignable scopes of the {@link KeyVaultRoleDefinition role definition}. */ - public KeyVaultRoleDefinitionProperties(String roleName, String roleDescription, String roleType, - List permissions, - List assignableScopes) { + public KeyVaultRoleDefinitionProperties(String roleName, String roleDescription, String roleType, List permissions, List assignableScopes) { this.roleName = roleName; this.description = roleDescription; this.roleType = roleType; From 0907fcb7121377ba9fbb49b688063a0a70ec4f57 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 3 Sep 2020 13:46:52 -0700 Subject: [PATCH 35/40] Added samples to README.md --- .../README.md | 200 +++++++++++++++++- 1 file changed, 193 insertions(+), 7 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index ee1e5f901557..8ba004580cc0 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -24,7 +24,7 @@ Maven dependency for the Azure Key Vault Administration library. Add it to your ``` ### Authenticate the client -In order to interact with the Azure Key Vault service, you'll need to create an instance of the [KeyClient](#create-key-client) class. You would need a **vault url** and **client secret credentials (client id, client secret, tenant id)** to instantiate a client object using the default `DefaultAzureCredential` examples shown in this document. +In order to interact with the Azure Key Vault service, you'll need to create an instance of the [KeyVaultAccessControlClient](#create-access-control-client) class. You would need a **vault url** and **client secret credentials (client id, client secret, tenant id)** to instantiate a client object using the default `DefaultAzureCredential` examples shown in this document. The `DefaultAzureCredential` way of authentication by providing client secret credentials is being used in this getting started section but you can find more ways to authenticate with [azure-identity][azure_identity]. @@ -59,6 +59,16 @@ Here is an [Azure Cloud Shell](https://shell.azure.com/bash) snippet below to export AZURE_TENANT_ID="tenant-ID" ``` +* Take note of the service principal objectId + ```Bash + az ad sp show --id --query objectId + ``` + + Output: + ``` + "" + ``` + * Use the aforementioned Key Vault name to retrieve details of your Key Vault, which also contain your Key Vault URL: ```Bash @@ -66,23 +76,199 @@ Here is an [Azure Cloud Shell](https://shell.azure.com/bash) snippet below to ``` #### Create Access Control client +Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET**, and **AZURE_TENANT_ID** environment variables and replaced **your-key-vault-url** with the URI returned above, you can create the KeyVaultAccessControlClient: + +```Java +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.administration.KeyVaultAccessControlClient; +import com.azure.security.keyvault.administration.KeyVaultAccessControlClientBuilder; + +KeyVaultAccessControlClient accessControlClient = new KeyVaultAccessControlClientBuilder() + .vaultUrl("") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); +``` + +> NOTE: For using an asynchronous client use KeyVaultAccessControlAsyncClient instead of KeyVaultAccessControlClient and call `buildAsyncClient()` ## Key concepts -To be added. +### Role Definition +A role definition is a collection of permissions. It defines the operations that can be performed, such as read, write, and delete. It can also define the operations that are excluded from allowed operations. + +Role definitions can be listed and specified as part of a role assignment. + +### Role Assignment +A role assignment is the association of a role definition to a service principal. They can be created, listed, fetched individually, and deleted. + +### Key Vault Access Control client: +The Key Vault Access Control client performs the interactions with the Azure Key Vault service for getting, setting, deleting, and listing role assignments, as well as listing role definitions. Asynchronous (KeyVaultAccessControlAsyncClient) and synchronous (KeyVaultAccessControlClient) clients exist in the SDK allowing for the selection of a client based on an application's use case. Once you've initialized a role assignment, you can interact with the primary resource types in Key Vault. ## Examples ### Sync API -To be added. +The following sections provide several code snippets covering some of the most common Azure Key Vault Access Control service tasks, including: +- [List role definitions](#list-role-definitions) +- [List role assignments](#list-role-assignments) +- [Create a role assignment](#create-a-role-assignment) +- [Retrieve a role assignment](#retrieve-a-role-assignment) +- [Delete a role assignment](#delete-a-role-assignment) + +### List role definitions +List the role definitions in the key vault by calling `listRoleDefinitions`. + +```java +KeyVaultRoleAssignmentScope roleAssignmentScope = KeyVaultRoleAssignmentScope.GLOBAL; + +for (KeyVaultRoleDefinition roleDefinition : accessControlClient.listRoleDefinitions(roleAssignmentScope)) { + System.out.printf("Retrieved role definition with name \"%s\" and type \"%s\"%n", roleDefinition.getName(), + roleDefinition.getType()); +} +``` + +### List role assignments +List the role assignments in the key vault by calling `listRoleAssignments`. + +```java +KeyVaultRoleAssignmentScope roleAssignmentScope = KeyVaultRoleAssignmentScope.GLOBAL; + +for (KeyVaultRoleAssignment roleAssignment : accessControlClient.listRoleAssignments(roleAssignmentScope)) { + System.out.printf("Retrieved role assignment with name \"%s\" and type \"%s\"%n", roleAssignment.getName(), + roleAssignment.getType()); +} +``` + +### Create a role assignment +Create a role assignment to in the Azure Key Vault. To do this a role definition ID and a service principal object ID are required. + +A role definition ID can be obtained from the 'id' property of one of the role definitions returned from `listRoleDefinitions`. + +See the [Create/Get Credentials section](#createget-credentials) for links and instructions on how to generate a new service principal and obtain it's object ID. You can also get the object ID for your currently signed in account by running the following Azure CLI command: + +```Bash +az ad signed-in-user show --query objectId +``` + +```java +String roleDefinitionIdToAssign = ""; +String servicePrincipalObjectId = ""; + +KeyVaultRoleAssignmentProperties properties = + new KeyVaultRoleAssignmentProperties(roleDefinitionIdToAssign, servicePrincipalObjectId); +KeyVaultRoleAssignment createdAssignment = + accessControlClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, properties); + +System.out.printf("Created role assignment with name \"%s\" and type \"%s\"%n", createdAssignment.getName(), + createdAssignment.getType()); +``` + +### Retrieve a role assignment +Get an existing role assignment. To do this, the 'name' property from an existing role assignment is required. Let's use the `createdAssignment` from the previous example. + +```java +KeyVaultRoleAssignment retrievedAssignment = + accessControlClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdAssignment.getName()); + +System.out.printf("Retrieved role assignment with name \"%s\" and type \"%s\"%n", retrievedAssignment.getName(), + retrievedAssignment.getType()); +``` +### Delete a role assignment +To remove a role assignment from a service principal, the role assignment must be deleted. Let's delete the `createdAssignment` from the previous example. + +```java +KeyVaultRoleAssignment deletedAssignment = + accessControlClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdAssignment.getName()); + +System.out.printf("Deleted role assignment with name \"%s\" and type \"%s\"%n", deletedAssignment.getName(), + deletedAssignment.getType()); +``` ### Async API -To be added. +The following sections provide several code snippets covering some of the most common asynchronous Azure Key Vault Access Control service tasks, including: +- [List role definitions asynchronously](#list-role-definitions-asynchronously) +- [List role assignments asynchronously](#list-role-assignments-asynchronously) +- [Create a role assignment asynchronously](#create-a-role-assignment-asynchronously) +- [Retrieve a role assignment asynchronously](#retrieve-a-role-assignment-asynchronously) +- [Delete a role assignment asynchronously](#delete-a-role-assignment-asynchronously) -## Key concepts -To be added. +> Note : You should add `System.in.read()` or `Thread.sleep()` after the function calls in the main class/thread to allow async functions/operations to execute and finish before the main application/thread exits. + +### List role definitions asynchronously +List the role definitions in the key vault by calling `listRoleDefinitions`. + +```java +KeyVaultRoleAssignmentScope roleAssignmentScope = KeyVaultRoleAssignmentScope.GLOBAL; + +accessControlAsyncClient.listRoleDefinitions(roleAssignmentScope)) + .subscribe(roleDefinition -> + System.out.printf("Retrieved role definition with name \"%s\" and type \"%s\"%n", roleDefinition.getName(), + roleDefinition.getType())); +``` + +### List role assignments asynchronously +List the role assignments in the key vault by calling `listRoleAssignments`. + +```java +KeyVaultRoleAssignmentScope roleAssignmentScope = KeyVaultRoleAssignmentScope.GLOBAL; + +accessControlAsyncClient.listRoleAssignments(roleAssignmentScope)) + .subscribe(roleAssignment -> + System.out.printf("Retrieved role assignment with name \"%s\" and type \"%s\"%n", roleAssignment.getName(), + roleAssignment.getType())); +``` + +### Create a role assignment asynchronously +Create a role assignment to in the Azure Key Vault. To do this a role definition ID and a service principal object ID are required. + +A role definition ID can be obtained from the 'id' property of one of the role definitions returned from `listRoleDefinitions`. + +See the [Create/Get Credentials section](#createget-credentials) for links and instructions on how to generate a new service principal and obtain it's object ID. You can also get the object ID for your currently signed in account by running the following Azure CLI command: + +```Bash +az ad signed-in-user show --query objectId +``` + +```java +String roleDefinitionIdToAssign = ""; +String servicePrincipalObjectId = ""; + +KeyVaultRoleAssignmentProperties properties = + new KeyVaultRoleAssignmentProperties(roleDefinitionIdToAssign, servicePrincipalObjectId); + +accessControlAsyncClient.createRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, properties) + .subscribe(createdAssignment -> + System.out.printf("Created role assignment with name \"%s\" and type \"%s\"%n", createdAssignment.getName(), + createdAssignment.getType())); +``` + +### Retrieve a role assignment asynchronously +Get an existing role assignment. To do this, the 'name' property from an existing role assignment is required. Let's use the `createdAssignment` from the previous example. + +```java +accessControlAsyncClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdAssignment.getName()) + .subscribe(retrievedAssignment -> + System.out.printf("Retrieved role assignment with name \"%s\" and type \"%s\"%n", retrievedAssignment.getName(), + retrievedAssignment.getType())); +``` +### Delete a role assignment asynchronously +To remove a role assignment from a service principal, the role assignment must be deleted. Let's delete the `createdAssignment` from the previous example. + +```java +accessControlAsyncClient.deleteRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, createdAssignment.getName()) + .subscribe(deletedAssignment -> + System.out.printf("Deleted role assignment with name \"%s\" and type \"%s\"%n", deletedAssignment.getName(), + deletedAssignment.getType())); +``` ## Troubleshooting ### General -To be added. +Azure Key Vault Access Control clients raise exceptions. For example, if you try to retrieve a role assignment after it is deleted a `404` error is returned, indicating the resource was not found. In the following snippet, the error is handled gracefully by catching the exception and displaying additional information about the error. + +```java +try { + accessControlClient.getRoleAssignment(KeyVaultRoleAssignmentScope.GLOBAL, "") +} catch (HttpResponseException e) { + System.out.println(e.getMessage()); +} +``` ### Default HTTP client All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the [HTTP clients wiki](https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients). From 5a208bfbcbce629d7d0a0d1517fe1bf537c77210 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 3 Sep 2020 15:07:19 -0700 Subject: [PATCH 36/40] Fixed build analysis issues with the module's POM. --- sdk/keyvault/azure-security-keyvault-administration/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml index 6b6f627bd4e2..3a340d75ee46 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -11,6 +11,7 @@ 4.0.0 + com.azure azure-security-keyvault-administration 4.0.0-beta.1 From 016964397330777487187204dc4b032c6eaf59aa Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Thu, 3 Sep 2020 21:03:32 -0700 Subject: [PATCH 37/40] Fixed Build analysis issue related to README. --- eng/.docsettings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml index cc07234ec979..708b726e87cf 100644 --- a/eng/.docsettings.yml +++ b/eng/.docsettings.yml @@ -135,6 +135,7 @@ known_content_issues: - ['sdk/eventhubs/README.md', '#3113'] - ['sdk/formrecognizer/azure-ai-formrecognizer/swagger/README.md', '#3113'] - ['sdk/keyvault/README.md', '#3113'] + - ['sdk/keyvault/azure-security-keyvault-administration/README.md', '#3113'] - ['sdk/loganalytics/microsoft-azure-loganalytics/README.md', '#3113'] - ['sdk/parents/azure-client-sdk-parent/README.md', '#3113'] - ['sdk/search/azure-search-documents/swagger/readme.md', '#3113'] From a47601088f1bea5ef104ac4c181bf5281a1f292c Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 4 Sep 2020 00:03:44 -0700 Subject: [PATCH 38/40] Fixed broken links in autorest.md and README.md --- .../azure-security-keyvault-administration/README.md | 5 ----- .../swagger/autorest.md | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/README.md b/sdk/keyvault/azure-security-keyvault-administration/README.md index 8ba004580cc0..ad6226a67d83 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/README.md +++ b/sdk/keyvault/azure-security-keyvault-administration/README.md @@ -279,9 +279,6 @@ All client libraries, by default, use the Tomcat-native Boring SSL library to en ## Next steps Several Key Vault Java SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Azure Key Vault. -## Next steps samples -Samples are explained in detail [here][samples_readme]. - ### Additional documentation For more extensive documentation on Azure Key Vault, see the [API reference documentation][azkeyvault_rest]. @@ -306,8 +303,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope [azure_create_application_in_portal]: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal [azure_keyvault_cli]: https://docs.microsoft.com/azure/key-vault/quick-create-cli [azure_keyvault_cli_full]: https://docs.microsoft.com/cli/azure/keyvault?view=azure-cli-latest -[administration_samples]: src/samples/java/com/azure/security/keyvault/administration -[samples_readme]: src/samples/README.md [performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fkeyvault%2Fazure-security-keyvault-administration%2FREADME.png) diff --git a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md index 70a2f4efdd0a..3c96b1a3de64 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md +++ b/sdk/keyvault/azure-security-keyvault-administration/swagger/autorest.md @@ -7,7 +7,7 @@ Increase max memory if you're using Autorest older than 3. Set the environment v This is the AutoRest configuration file for KeyVaultAccessControlClient. --- ## Getting Started -To build the SDK for KeyVaultAccessControlClient, simply [Install AutoRest](https://aka.ms/autorest/install) and in this folder, run: +To build the SDK for KeyVaultAccessControlClient, simply [Install AutoRest](https://github.com/Azure/autorest/blob/master/docs/installing-autorest.md) and in this folder, run: > `autorest` From 43a5fee092eea1aae382da47a8bdbc313b30a73b Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 4 Sep 2020 01:45:04 -0700 Subject: [PATCH 39/40] Fixed a bug in `KeyVaultAccessControlAsyncClient.createRoleAssignmentWithResponse()`. Made fixes for tests cases. --- .../pom.xml | 35 +++++++++++++------ .../KeyVaultAccessControlAsyncClient.java | 2 +- .../src/main/java/module-info.java | 2 ++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml index 3a340d75ee46..5774cc7143d7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -32,16 +32,6 @@ HEAD - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M3 - - - - com.azure @@ -103,4 +93,29 @@ test + + + + java-lts + + [11,) + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M3 + + + --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED + + --add-opens com.azure.security.keyvault.administration/com.azure.security.keyvault.administration=ALL-UNNAMED + + + + + + + diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 1ae65b512915..ba8ccdb048ea 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -353,7 +353,7 @@ Mono> createRoleAssignmentWithResponse(KeyVault RoleAssignmentProperties roleAssignmentProperties = new RoleAssignmentProperties() .setRoleDefinitionId(properties.getRoleDefinitionId()) - .setPrincipalId(properties.getRoleDefinitionId()); + .setPrincipalId(properties.getPrincipalId()); RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters() .setProperties(roleAssignmentProperties); diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java index af1b771413c4..8bd509800fd7 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/module-info.java @@ -6,6 +6,8 @@ exports com.azure.security.keyvault.administration; exports com.azure.security.keyvault.administration.models; + exports com.azure.security.keyvault.administration.implementation; + exports com.azure.security.keyvault.administration.implementation.models; opens com.azure.security.keyvault.administration to com.fasterxml.jackson.databind; opens com.azure.security.keyvault.administration.models to com.fasterxml.jackson.databind; From 43caa664065f32b9d79852f06ba965439014c7dc Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Fri, 4 Sep 2020 01:52:31 -0700 Subject: [PATCH 40/40] Updated azure-core versions. --- .../azure-security-keyvault-administration/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-administration/pom.xml b/sdk/keyvault/azure-security-keyvault-administration/pom.xml index 5774cc7143d7..08da987d5cab 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-administration/pom.xml @@ -36,12 +36,12 @@ com.azure azure-core - 1.7.0 + 1.8.0 com.azure azure-core-http-netty - 1.5.4 + 1.6.0 @@ -77,13 +77,13 @@ com.azure azure-core-test - 1.4.0 + 1.4.1 test com.azure azure-core-http-okhttp - 1.2.5 + 1.3.0 test