From 58cbafbc4dccafcdb838777397833e540c1d5730 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 23 Aug 2021 06:09:50 +0000 Subject: [PATCH] CodeGen from PR 15745 in Azure/azure-rest-api-specs Merge 08be25055797e3f2449384ac32d63f8e82e0d3a9 into 15d6343c7cdbad3015583859ea872f8c6bb97d52 --- .../azure-resourcemanager-relay/CHANGELOG.md | 3 +- .../azure-resourcemanager-relay/README.md | 20 ++- sdk/relay/azure-resourcemanager-relay/pom.xml | 136 ++++++++++------- .../resourcemanager/relay/RelayManager.java | 51 +++++-- .../relay/implementation/AccessKeysImpl.java | 7 +- .../implementation/AuthorizationRuleImpl.java | 35 ++++- .../CheckNameAvailabilityResultImpl.java | 8 +- .../implementation/HybridConnectionImpl.java | 10 +- .../HybridConnectionsClientImpl.java | 24 +-- .../implementation/HybridConnectionsImpl.java | 16 +- .../implementation/NamespacesClientImpl.java | 32 ++-- .../relay/implementation/NamespacesImpl.java | 19 ++- .../relay/implementation/OperationImpl.java | 7 +- .../implementation/OperationsClientImpl.java | 4 +- .../relay/implementation/OperationsImpl.java | 11 +- .../relay/implementation/RelayApiImpl.java | 4 +- .../implementation/RelayNamespaceImpl.java | 9 +- .../relay/implementation/Utils.java | 137 ++++++++++++++++++ .../relay/implementation/WcfRelayImpl.java | 9 +- .../implementation/WcfRelaysClientImpl.java | 24 +-- .../relay/implementation/WcfRelaysImpl.java | 15 +- .../relay/models/AuthorizationRule.java | 44 ++++++ .../relay/models/ResourceNamespacePatch.java | 2 + 23 files changed, 449 insertions(+), 178 deletions(-) diff --git a/sdk/relay/azure-resourcemanager-relay/CHANGELOG.md b/sdk/relay/azure-resourcemanager-relay/CHANGELOG.md index 147f7a13a21ab..42e73147368eb 100644 --- a/sdk/relay/azure-resourcemanager-relay/CHANGELOG.md +++ b/sdk/relay/azure-resourcemanager-relay/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.1 (2021-08-23) +- Azure Resource Manager Relay client library for Java. This package contains Microsoft Azure SDK for Relay Management SDK. Use these API to manage Azure Relay resources through Azure Resource Manager. Package tag package-2017-04. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## 1.0.0-beta.1 (2020-12-18) diff --git a/sdk/relay/azure-resourcemanager-relay/README.md b/sdk/relay/azure-resourcemanager-relay/README.md index 065e213e9d43b..98a2c12ed443e 100644 --- a/sdk/relay/azure-resourcemanager-relay/README.md +++ b/sdk/relay/azure-resourcemanager-relay/README.md @@ -4,6 +4,20 @@ Azure Resource Manager Relay client library for Java. This package contains Microsoft Azure SDK for Relay Management SDK. Use these API to manage Azure Relay resources through Azure Resource Manager. Package tag package-2017-04. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + ## Getting started ### Prerequisites @@ -18,7 +32,7 @@ This package contains Microsoft Azure SDK for Relay Management SDK. Use these AP com.azure.resourcemanager azure-resourcemanager-relay - 1.0.0-beta.1 + 1.0.0-beta.2 ``` [//]: # ({x-version-update-end}) @@ -60,6 +74,8 @@ See [API design][design] for general introduction on design and key concepts on ## Examples + + ## Troubleshooting ## Next steps @@ -75,6 +91,8 @@ For details on contributing to this repository, see the [contributing guide](htt 1. Create new Pull Request +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ [jdk]: https://docs.microsoft.com/java/azure/jdk/ [azure_subscription]: https://azure.microsoft.com/free/ [azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/relay/azure-resourcemanager-relay/pom.xml b/sdk/relay/azure-resourcemanager-relay/pom.xml index d3532779e77e9..d2aeb35932fcd 100644 --- a/sdk/relay/azure-resourcemanager-relay/pom.xml +++ b/sdk/relay/azure-resourcemanager-relay/pom.xml @@ -1,62 +1,86 @@ - 4.0.0 - - com.azure - azure-client-sdk-parent - 1.7.0 - ../../parents/azure-client-sdk-parent - + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + - com.azure.resourcemanager - azure-resourcemanager-relay - 1.0.0-beta.2 - jar + com.azure.resourcemanager + azure-resourcemanager-relay + 1.0.0-beta.2 + jar - Microsoft Azure SDK for Relay Management - This package contains Microsoft Azure SDK for Relay Management SDK. Use these API to manage Azure Relay resources through Azure Resource Manager. Package tag package-2017-04. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt - https://github.com/Azure/azure-sdk-for-java + Microsoft Azure SDK for Relay Management + This package contains Microsoft Azure SDK for Relay Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Use these API to manage Azure Relay resources through Azure Resource Manager. Package tag package-2017-04. + https://github.com/Azure/azure-sdk-for-java - - - The MIT License (MIT) - http://opensource.org/licenses/MIT - repo - - + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + - - https://github.com/Azure/azure-sdk-for-java - scm:git:git@github.com:Azure/azure-sdk-for-java.git - scm:git:git@github.com:Azure/azure-sdk-for-java.git - HEAD - - - - microsoft - Microsoft - - - - UTF-8 - - - - - com.azure - azure-core-management - 1.4.0 - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.5 - - true - - - - + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.19.0 + + + com.azure + azure-core-management + 1.4.0 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/RelayManager.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/RelayManager.java index 5e40fa85401f5..f4042a9e8f666 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/RelayManager.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/RelayManager.java @@ -9,7 +9,6 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -17,6 +16,7 @@ import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; import com.azure.core.management.profile.AzureProfile; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; @@ -89,6 +89,7 @@ public static final class Configurable { private HttpClient httpClient; private HttpLogOptions httpLogOptions; private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); private RetryPolicy retryPolicy; private Duration defaultPollInterval; @@ -128,6 +129,17 @@ public Configurable withPolicy(HttpPipelinePolicy policy) { return this; } + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + /** * Sets the retry policy to the HTTP pipeline. * @@ -164,25 +176,40 @@ public RelayManager authenticate(TokenCredential credential, AzureProfile profil Objects.requireNonNull(credential, "'credential' cannot be null."); Objects.requireNonNull(profile, "'profile' cannot be null."); + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder + .append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.relay") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder + .append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } if (retryPolicy == null) { retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); } List policies = new ArrayList<>(); - policies - .add( - new UserAgentPolicy( - null, - "com.azure.resourcemanager.relay", - "1.0.0-beta.1", - Configuration.getGlobalConfiguration())); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); policies.add(new RequestIdPolicy()); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new AddDatePolicy()); - policies - .add( - new BearerTokenAuthenticationPolicy( - credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); HttpPipeline httpPipeline = diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AccessKeysImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AccessKeysImpl.java index 4bd253cb06286..d28735428fe6d 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AccessKeysImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AccessKeysImpl.java @@ -4,16 +4,15 @@ package com.azure.resourcemanager.relay.implementation; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.AccessKeysInner; import com.azure.resourcemanager.relay.models.AccessKeys; public final class AccessKeysImpl implements AccessKeys { private AccessKeysInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - AccessKeysImpl(AccessKeysInner innerObject, RelayManager serviceManager) { + AccessKeysImpl(AccessKeysInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; } @@ -42,7 +41,7 @@ public AccessKeysInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AuthorizationRuleImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AuthorizationRuleImpl.java index 7b97159490c44..ba7fdbb10081b 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AuthorizationRuleImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/AuthorizationRuleImpl.java @@ -4,11 +4,13 @@ package com.azure.resourcemanager.relay.implementation; +import com.azure.core.http.rest.Response; import com.azure.core.util.Context; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner; +import com.azure.resourcemanager.relay.models.AccessKeys; import com.azure.resourcemanager.relay.models.AccessRights; import com.azure.resourcemanager.relay.models.AuthorizationRule; +import com.azure.resourcemanager.relay.models.RegenerateAccessKeyParameters; import java.util.Collections; import java.util.List; @@ -16,7 +18,7 @@ public final class AuthorizationRuleImpl implements AuthorizationRule, AuthorizationRule.Definition, AuthorizationRule.Update { private AuthorizationRuleInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; public String id() { return this.innerModel().id(); @@ -43,7 +45,7 @@ public AuthorizationRuleInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } @@ -81,7 +83,7 @@ public AuthorizationRule create(Context context) { return this; } - AuthorizationRuleImpl(String name, RelayManager serviceManager) { + AuthorizationRuleImpl(String name, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = new AuthorizationRuleInner(); this.serviceManager = serviceManager; this.authorizationRuleName = name; @@ -113,7 +115,8 @@ public AuthorizationRule apply(Context context) { return this; } - AuthorizationRuleImpl(AuthorizationRuleInner innerObject, RelayManager serviceManager) { + AuthorizationRuleImpl( + AuthorizationRuleInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); @@ -141,6 +144,28 @@ public AuthorizationRule refresh(Context context) { return this; } + public AccessKeys listKeys() { + return serviceManager.namespaces().listKeys(resourceGroupName, namespaceName, authorizationRuleName); + } + + public Response listKeysWithResponse(Context context) { + return serviceManager + .namespaces() + .listKeysWithResponse(resourceGroupName, namespaceName, authorizationRuleName, context); + } + + public AccessKeys regenerateKeys(RegenerateAccessKeyParameters parameters) { + return serviceManager + .namespaces() + .regenerateKeys(resourceGroupName, namespaceName, authorizationRuleName, parameters); + } + + public Response regenerateKeysWithResponse(RegenerateAccessKeyParameters parameters, Context context) { + return serviceManager + .namespaces() + .regenerateKeysWithResponse(resourceGroupName, namespaceName, authorizationRuleName, parameters, context); + } + public AuthorizationRuleImpl withRights(List rights) { this.innerModel().withRights(rights); return this; diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/CheckNameAvailabilityResultImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/CheckNameAvailabilityResultImpl.java index 1e57e3783550c..2f26b9b2484ed 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/CheckNameAvailabilityResultImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/CheckNameAvailabilityResultImpl.java @@ -4,7 +4,6 @@ package com.azure.resourcemanager.relay.implementation; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.CheckNameAvailabilityResultInner; import com.azure.resourcemanager.relay.models.CheckNameAvailabilityResult; import com.azure.resourcemanager.relay.models.UnavailableReason; @@ -12,9 +11,10 @@ public final class CheckNameAvailabilityResultImpl implements CheckNameAvailabilityResult { private CheckNameAvailabilityResultInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - CheckNameAvailabilityResultImpl(CheckNameAvailabilityResultInner innerObject, RelayManager serviceManager) { + CheckNameAvailabilityResultImpl( + CheckNameAvailabilityResultInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; } @@ -35,7 +35,7 @@ public CheckNameAvailabilityResultInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionImpl.java index eddd11524d600..078e44acfa358 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionImpl.java @@ -5,7 +5,6 @@ package com.azure.resourcemanager.relay.implementation; import com.azure.core.util.Context; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.HybridConnectionInner; import com.azure.resourcemanager.relay.models.HybridConnection; import java.time.OffsetDateTime; @@ -14,7 +13,7 @@ public final class HybridConnectionImpl implements HybridConnection, HybridConnection.Definition, HybridConnection.Update { private HybridConnectionInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; public String id() { return this.innerModel().id(); @@ -52,7 +51,7 @@ public HybridConnectionInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } @@ -90,7 +89,7 @@ public HybridConnection create(Context context) { return this; } - HybridConnectionImpl(String name, RelayManager serviceManager) { + HybridConnectionImpl(String name, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = new HybridConnectionInner(); this.serviceManager = serviceManager; this.hybridConnectionName = name; @@ -122,7 +121,8 @@ public HybridConnection apply(Context context) { return this; } - HybridConnectionImpl(HybridConnectionInner innerObject, RelayManager serviceManager) { + HybridConnectionImpl( + HybridConnectionInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsClientImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsClientImpl.java index 63d9a4f147271..410ac0b4d2cfb 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsClientImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsClientImpl.java @@ -314,7 +314,7 @@ private Mono> listByNamespaceSinglePageAsyn res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -498,7 +498,7 @@ private Mono> createOrUpdateWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -684,7 +684,7 @@ private Mono> deleteWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -840,7 +840,7 @@ private Mono> getWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1014,7 +1014,7 @@ private Mono> listAuthorizationRulesSingle res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1222,7 +1222,7 @@ private Mono> createOrUpdateAuthorizationRuleWi parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1436,7 +1436,7 @@ private Mono> deleteAuthorizationRuleWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1621,7 +1621,7 @@ private Mono> getAuthorizationRuleWithResponseA this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1814,7 +1814,7 @@ private Mono> listKeysWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2016,7 +2016,7 @@ private Mono> regenerateKeysWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2205,7 +2205,7 @@ private Mono> listByNamespaceNextSinglePage res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2278,7 +2278,7 @@ private Mono> listAuthorizationRulesNextSi res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsImpl.java index 673552041d268..02cd1fc27cf80 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/HybridConnectionsImpl.java @@ -9,7 +9,6 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.HybridConnectionsClient; import com.azure.resourcemanager.relay.fluent.models.AccessKeysInner; import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner; @@ -26,9 +25,10 @@ public final class HybridConnectionsImpl implements HybridConnections { private final HybridConnectionsClient innerClient; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - public HybridConnectionsImpl(HybridConnectionsClient innerClient, RelayManager serviceManager) { + public HybridConnectionsImpl( + HybridConnectionsClient innerClient, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } @@ -36,14 +36,14 @@ public HybridConnectionsImpl(HybridConnectionsClient innerClient, RelayManager s public PagedIterable listByNamespace(String resourceGroupName, String namespaceName) { PagedIterable inner = this.serviceClient().listByNamespace(resourceGroupName, namespaceName); - return inner.mapPage(inner1 -> new HybridConnectionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new HybridConnectionImpl(inner1, this.manager())); } public PagedIterable listByNamespace( String resourceGroupName, String namespaceName, Context context) { PagedIterable inner = this.serviceClient().listByNamespace(resourceGroupName, namespaceName, context); - return inner.mapPage(inner1 -> new HybridConnectionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new HybridConnectionImpl(inner1, this.manager())); } public void delete(String resourceGroupName, String namespaceName, String hybridConnectionName) { @@ -83,7 +83,7 @@ public PagedIterable listAuthorizationRules( String resourceGroupName, String namespaceName, String hybridConnectionName) { PagedIterable inner = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName, hybridConnectionName); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public PagedIterable listAuthorizationRules( @@ -92,7 +92,7 @@ public PagedIterable listAuthorizationRules( this .serviceClient() .listAuthorizationRules(resourceGroupName, namespaceName, hybridConnectionName, context); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public AuthorizationRule createOrUpdateAuthorizationRule( @@ -382,7 +382,7 @@ private HybridConnectionsClient serviceClient() { return this.innerClient; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesClientImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesClientImpl.java index 7ca2d69efcedf..55a02f49c2d57 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesClientImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesClientImpl.java @@ -342,7 +342,7 @@ private Mono> checkNameAvailabilityWi parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -480,7 +480,7 @@ private Mono> listSinglePageAsync() { res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -627,7 +627,7 @@ private Mono> listByResourceGroupSinglePageAs res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -794,7 +794,7 @@ private Mono>> createOrUpdateWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1053,7 +1053,7 @@ private Mono>> deleteWithResponseAsync(String resource this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1280,7 +1280,7 @@ private Mono> getByResourceGroupWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1437,7 +1437,7 @@ private Mono> updateWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1611,7 +1611,7 @@ private Mono> listAuthorizationRulesSingle res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1800,7 +1800,7 @@ private Mono> createOrUpdateAuthorizationRuleWi parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1994,7 +1994,7 @@ private Mono> deleteAuthorizationRuleWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2153,7 +2153,7 @@ private Mono> getAuthorizationRuleWithResponseA this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2320,7 +2320,7 @@ private Mono> listKeysWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2495,7 +2495,7 @@ private Mono> regenerateKeysWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2668,7 +2668,7 @@ private Mono> listNextSinglePageAsync(String res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2740,7 +2740,7 @@ private Mono> listByResourceGroupNextSinglePa res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2813,7 +2813,7 @@ private Mono> listAuthorizationRulesNextSi res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesImpl.java index 550485aabb0e4..b1a73b9b0a1e4 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/NamespacesImpl.java @@ -9,7 +9,6 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.NamespacesClient; import com.azure.resourcemanager.relay.fluent.models.AccessKeysInner; import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner; @@ -29,9 +28,9 @@ public final class NamespacesImpl implements Namespaces { private final NamespacesClient innerClient; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - public NamespacesImpl(NamespacesClient innerClient, RelayManager serviceManager) { + public NamespacesImpl(NamespacesClient innerClient, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } @@ -62,22 +61,22 @@ public Response checkNameAvailabilityWithResponse( public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return inner.mapPage(inner1 -> new RelayNamespaceImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new RelayNamespaceImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return inner.mapPage(inner1 -> new RelayNamespaceImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new RelayNamespaceImpl(inner1, this.manager())); } public PagedIterable listByResourceGroup(String resourceGroupName) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); - return inner.mapPage(inner1 -> new RelayNamespaceImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new RelayNamespaceImpl(inner1, this.manager())); } public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); - return inner.mapPage(inner1 -> new RelayNamespaceImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new RelayNamespaceImpl(inner1, this.manager())); } public void deleteByResourceGroup(String resourceGroupName, String namespaceName) { @@ -115,14 +114,14 @@ public Response getByResourceGroupWithResponse( public PagedIterable listAuthorizationRules(String resourceGroupName, String namespaceName) { PagedIterable inner = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public PagedIterable listAuthorizationRules( String resourceGroupName, String namespaceName, Context context) { PagedIterable inner = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName, context); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public void deleteAuthorizationRule(String resourceGroupName, String namespaceName, String authorizationRuleName) { @@ -421,7 +420,7 @@ private NamespacesClient serviceClient() { return this.innerClient; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationImpl.java index f260b0a30dfd7..b7835ab36aacf 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationImpl.java @@ -4,7 +4,6 @@ package com.azure.resourcemanager.relay.implementation; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.OperationInner; import com.azure.resourcemanager.relay.models.Operation; import com.azure.resourcemanager.relay.models.OperationDisplay; @@ -12,9 +11,9 @@ public final class OperationImpl implements Operation { private OperationInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - OperationImpl(OperationInner innerObject, RelayManager serviceManager) { + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; } @@ -31,7 +30,7 @@ public OperationInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsClientImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsClientImpl.java index 715cbc58d0dfb..300bc5598c311 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsClientImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsClientImpl.java @@ -108,7 +108,7 @@ private Mono> listSinglePageAsync() { res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -228,7 +228,7 @@ private Mono> listNextSinglePageAsync(String nextL res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsImpl.java index fe3a7522371bd..7f403552abba6 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/OperationsImpl.java @@ -7,7 +7,6 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.OperationsClient; import com.azure.resourcemanager.relay.fluent.models.OperationInner; import com.azure.resourcemanager.relay.models.Operation; @@ -19,28 +18,28 @@ public final class OperationsImpl implements Operations { private final OperationsClient innerClient; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - public OperationsImpl(OperationsClient innerClient, RelayManager serviceManager) { + public OperationsImpl(OperationsClient innerClient, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); } private OperationsClient serviceClient() { return this.innerClient; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayApiImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayApiImpl.java index 1c640a3de165d..fa4f85d3aa979 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayApiImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayApiImpl.java @@ -277,7 +277,7 @@ public Mono getLroFinalResultOrError(AsyncPollResponse, if (managementError.getCode() == null || managementError.getMessage() == null) { managementError = null; } - } catch (IOException ioe) { + } catch (IOException | RuntimeException ioe) { logger.logThrowableAsWarning(ioe); } } @@ -306,7 +306,7 @@ private static final class HttpResponseImpl extends HttpResponse { super(null); this.statusCode = statusCode; this.httpHeaders = httpHeaders; - this.responseBody = responseBody.getBytes(StandardCharsets.UTF_8); + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); } public int getStatusCode() { diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayNamespaceImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayNamespaceImpl.java index ec139b588e394..2b48b9be1e04b 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayNamespaceImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/RelayNamespaceImpl.java @@ -6,7 +6,6 @@ import com.azure.core.management.Region; import com.azure.core.util.Context; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.RelayNamespaceInner; import com.azure.resourcemanager.relay.models.ProvisioningStateEnum; import com.azure.resourcemanager.relay.models.RelayNamespace; @@ -19,7 +18,7 @@ public final class RelayNamespaceImpl implements RelayNamespace, RelayNamespace.Definition, RelayNamespace.Update { private RelayNamespaceInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; public String id() { return this.innerModel().id(); @@ -82,7 +81,7 @@ public RelayNamespaceInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } @@ -115,7 +114,7 @@ public RelayNamespace create(Context context) { return this; } - RelayNamespaceImpl(String name, RelayManager serviceManager) { + RelayNamespaceImpl(String name, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = new RelayNamespaceInner(); this.serviceManager = serviceManager; this.namespaceName = name; @@ -146,7 +145,7 @@ public RelayNamespace apply(Context context) { return this; } - RelayNamespaceImpl(RelayNamespaceInner innerObject, RelayManager serviceManager) { + RelayNamespaceImpl(RelayNamespaceInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/Utils.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/Utils.java index 7393cca62663e..9004f41e59d10 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/Utils.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/Utils.java @@ -4,12 +4,20 @@ package com.azure.resourcemanager.relay.implementation; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; import com.azure.core.util.CoreUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; final class Utils { static String getValueFromIdByName(String id, String name) { @@ -64,4 +72,133 @@ static String getValueFromIdByParameterName(String id, String pathTemplate, Stri } return null; } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super( + PagedFlux + .create( + () -> + (continuationToken, pageSize) -> + Flux.fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> + new PagedResponseBase( + page.getRequest(), + page.getStatusCode(), + page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), + page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl(iterable.iterator(), mapper); + } + } } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelayImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelayImpl.java index ec16f03e2147b..b3f300629089e 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelayImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelayImpl.java @@ -5,7 +5,6 @@ package com.azure.resourcemanager.relay.implementation; import com.azure.core.util.Context; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.models.WcfRelayInner; import com.azure.resourcemanager.relay.models.Relaytype; import com.azure.resourcemanager.relay.models.WcfRelay; @@ -14,7 +13,7 @@ public final class WcfRelayImpl implements WcfRelay, WcfRelay.Definition, WcfRelay.Update { private WcfRelayInner innerObject; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; public String id() { return this.innerModel().id(); @@ -64,7 +63,7 @@ public WcfRelayInner innerModel() { return this.innerObject; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } @@ -101,7 +100,7 @@ public WcfRelay create(Context context) { return this; } - WcfRelayImpl(String name, RelayManager serviceManager) { + WcfRelayImpl(String name, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = new WcfRelayInner(); this.serviceManager = serviceManager; this.relayName = name; @@ -132,7 +131,7 @@ public WcfRelay apply(Context context) { return this; } - WcfRelayImpl(WcfRelayInner innerObject, RelayManager serviceManager) { + WcfRelayImpl(WcfRelayInner innerObject, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerObject = innerObject; this.serviceManager = serviceManager; this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysClientImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysClientImpl.java index 49e55d6320a52..b2f7bbcec016f 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysClientImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysClientImpl.java @@ -309,7 +309,7 @@ private Mono> listByNamespaceSinglePageAsync( res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -492,7 +492,7 @@ private Mono> createOrUpdateWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -667,7 +667,7 @@ private Mono> deleteWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -821,7 +821,7 @@ private Mono> getWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -992,7 +992,7 @@ private Mono> listAuthorizationRulesSingle res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1196,7 +1196,7 @@ private Mono> createOrUpdateAuthorizationRuleWi parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1408,7 +1408,7 @@ private Mono> deleteAuthorizationRuleWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1590,7 +1590,7 @@ private Mono> getAuthorizationRuleWithResponseA this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1779,7 +1779,7 @@ private Mono> listKeysWithResponseAsync( this.client.getSubscriptionId(), accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -1978,7 +1978,7 @@ private Mono> regenerateKeysWithResponseAsync( parameters, accept, context)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2165,7 +2165,7 @@ private Mono> listByNamespaceNextSinglePageAsync(St res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** @@ -2237,7 +2237,7 @@ private Mono> listAuthorizationRulesNextSi res.getValue().value(), res.getValue().nextLink(), null)) - .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysImpl.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysImpl.java index a08c9f0808e83..e134e674ba733 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysImpl.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/implementation/WcfRelaysImpl.java @@ -9,7 +9,6 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.resourcemanager.relay.RelayManager; import com.azure.resourcemanager.relay.fluent.WcfRelaysClient; import com.azure.resourcemanager.relay.fluent.models.AccessKeysInner; import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner; @@ -26,22 +25,22 @@ public final class WcfRelaysImpl implements WcfRelays { private final WcfRelaysClient innerClient; - private final RelayManager serviceManager; + private final com.azure.resourcemanager.relay.RelayManager serviceManager; - public WcfRelaysImpl(WcfRelaysClient innerClient, RelayManager serviceManager) { + public WcfRelaysImpl(WcfRelaysClient innerClient, com.azure.resourcemanager.relay.RelayManager serviceManager) { this.innerClient = innerClient; this.serviceManager = serviceManager; } public PagedIterable listByNamespace(String resourceGroupName, String namespaceName) { PagedIterable inner = this.serviceClient().listByNamespace(resourceGroupName, namespaceName); - return inner.mapPage(inner1 -> new WcfRelayImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new WcfRelayImpl(inner1, this.manager())); } public PagedIterable listByNamespace(String resourceGroupName, String namespaceName, Context context) { PagedIterable inner = this.serviceClient().listByNamespace(resourceGroupName, namespaceName, context); - return inner.mapPage(inner1 -> new WcfRelayImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new WcfRelayImpl(inner1, this.manager())); } public void delete(String resourceGroupName, String namespaceName, String relayName) { @@ -81,14 +80,14 @@ public PagedIterable listAuthorizationRules( String resourceGroupName, String namespaceName, String relayName) { PagedIterable inner = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName, relayName); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public PagedIterable listAuthorizationRules( String resourceGroupName, String namespaceName, String relayName, Context context) { PagedIterable inner = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName, relayName, context); - return inner.mapPage(inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager())); } public AuthorizationRule createOrUpdateAuthorizationRule( @@ -366,7 +365,7 @@ private WcfRelaysClient serviceClient() { return this.innerClient; } - private RelayManager manager() { + private com.azure.resourcemanager.relay.RelayManager manager() { return this.serviceManager; } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/AuthorizationRule.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/AuthorizationRule.java index 5c50ee82cb9ff..9b97f64f4b250 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/AuthorizationRule.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/AuthorizationRule.java @@ -4,6 +4,7 @@ package com.azure.resourcemanager.relay.models; +import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner; import java.util.List; @@ -150,4 +151,47 @@ interface WithRights { * @return the refreshed resource. */ AuthorizationRule refresh(Context context); + + /** + * Primary and secondary connection strings to the namespace. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return namespace/Relay Connection String. + */ + AccessKeys listKeys(); + + /** + * Primary and secondary connection strings to the namespace. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return namespace/Relay Connection String. + */ + Response listKeysWithResponse(Context context); + + /** + * Regenerates the primary or secondary connection strings to the namespace. + * + * @param parameters Parameters supplied to regenerate authorization rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return namespace/Relay Connection String. + */ + AccessKeys regenerateKeys(RegenerateAccessKeyParameters parameters); + + /** + * Regenerates the primary or secondary connection strings to the namespace. + * + * @param parameters Parameters supplied to regenerate authorization rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return namespace/Relay Connection String. + */ + Response regenerateKeysWithResponse(RegenerateAccessKeyParameters parameters, Context context); } diff --git a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/ResourceNamespacePatch.java b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/ResourceNamespacePatch.java index d2ef9b107da6f..9c53655499c47 100644 --- a/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/ResourceNamespacePatch.java +++ b/sdk/relay/azure-resourcemanager-relay/src/main/java/com/azure/resourcemanager/relay/models/ResourceNamespacePatch.java @@ -8,6 +8,7 @@ import com.azure.core.management.ProxyResource; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; @@ -20,6 +21,7 @@ public class ResourceNamespacePatch extends ProxyResource { * Resource tags. */ @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) private Map tags; /**