Skip to content

Commit

Permalink
mgmt hybrid, port latest Manager API (Azure#28378)
Browse files Browse the repository at this point in the history
* port of bug fix

* port Azure#27873
  • Loading branch information
weidongxu-microsoft authored Apr 19, 2022
1 parent 5aced37 commit ac25422
Show file tree
Hide file tree
Showing 21 changed files with 235 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.storage.StorageManager;

import java.util.Objects;

/** Entry point to Azure storage resource management. */
public final class AppServiceManager extends Manager<WebSiteManagementClient> {
// Managers
Expand Down Expand Up @@ -61,6 +63,8 @@ public static Configurable configure() {
* @return the StorageManager
*/
public static AppServiceManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -71,7 +75,9 @@ public static AppServiceManager authenticate(TokenCredential credential, AzurePr
* @param profile the profile to use
* @return the StorageManager
*/
private static AppServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static AppServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new AppServiceManager(httpPipeline, profile);
}

Expand Down Expand Up @@ -103,15 +109,10 @@ private AppServiceManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
keyVaultManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, KeyVaultManager.configure())
.authenticate(null, profile);
storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
.authenticate(null, profile);
authorizationManager = AzureConfigurableImpl
.configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
.authenticate(null, profile);
dnsZoneManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, DnsZoneManager.configure())
.authenticate(null, profile);
keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
storageManager = StorageManager.authenticate(httpPipeline, profile);
authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile);
}

/** @return the authorization manager instance. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;

import java.util.Objects;

/** Entry point to Azure Authorization and Graph RBAC management. */
public final class AuthorizationManager implements HasServiceClient<GraphRbacManagementClient> {
private final String tenantId;
Expand All @@ -52,6 +54,8 @@ public final class AuthorizationManager implements HasServiceClient<GraphRbacMan
* @return the AuthorizationManager instance
*/
public static AuthorizationManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -63,7 +67,9 @@ public static AuthorizationManager authenticate(TokenCredential credential, Azur
* @param profile the profile used in Active Directory
* @return the AuthorizationManager instance
*/
private static AuthorizationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static AuthorizationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new AuthorizationManager(httpPipeline, profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.storage.StorageManager;

import java.util.Objects;

/** Entry point to Azure compute resource management. */
public final class ComputeManager extends Manager<ComputeManagementClient> {
// The service managers
Expand Down Expand Up @@ -97,6 +99,8 @@ public static Configurable configure() {
* @return the ComputeManager
*/
public static ComputeManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -107,7 +111,9 @@ public static ComputeManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the ComputeManager
*/
private static ComputeManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static ComputeManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new ComputeManager(httpPipeline, profile);
}

Expand Down Expand Up @@ -140,13 +146,9 @@ private ComputeManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
.authenticate(null, profile);
networkManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, NetworkManager.configure())
.authenticate(null, profile);
authorizationManager = AzureConfigurableImpl
.configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
.authenticate(null, profile);
storageManager = StorageManager.authenticate(httpPipeline, profile);
networkManager = NetworkManager.authenticate(httpPipeline, profile);
authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
}

/** @return the availability set resource management API entry point */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.storage.StorageManager;

import java.util.Objects;

/** Entry point to Azure container registry management. */
public final class ContainerRegistryManager
extends Manager<ContainerRegistryManagementClient> {
Expand All @@ -46,6 +48,8 @@ public static Configurable configure() {
* @return the ContainerRegistryManager
*/
public static ContainerRegistryManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -56,7 +60,9 @@ public static ContainerRegistryManager authenticate(TokenCredential credential,
* @param profile the profile to use
* @return the ContainerRegistryManager
*/
private static ContainerRegistryManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static ContainerRegistryManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new ContainerRegistryManager(httpPipeline, profile);
}

Expand Down Expand Up @@ -95,8 +101,7 @@ private ContainerRegistryManager(HttpPipeline httpPipeline, AzureProfile profile
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
this.storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
.authenticate(null, profile);
storageManager = StorageManager.authenticate(httpPipeline, profile);
}

/** @return the availability set resource management API entry point */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;

import java.util.Objects;

/** Entry point to Azure Container Service management. */
public final class ContainerServiceManager
extends Manager<ContainerServiceManagementClient> {
Expand All @@ -39,6 +41,8 @@ public static Configurable configure() {
* @return the ContainerServiceManager
*/
public static ContainerServiceManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -49,7 +53,9 @@ public static ContainerServiceManager authenticate(TokenCredential credential, A
* @param profile the profile to use
* @return the ContainerServiceManager
*/
private static ContainerServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static ContainerServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new ContainerServiceManager(httpPipeline, profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;

import java.util.Objects;

/** Entry point to Azure DNS zone management. */
public final class DnsZoneManager extends Manager<DnsManagementClient> {
// Collections
Expand All @@ -37,6 +39,8 @@ public static Configurable configure() {
* @return the DnsZoneManager
*/
public static DnsZoneManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -47,7 +51,9 @@ public static DnsZoneManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the DnsZoneManager
*/
private static DnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static DnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new DnsZoneManager(httpPipeline, profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.storage.StorageManager;

import java.util.Objects;

/**
* Entry point to Azure EventHub resource management.
*/
Expand Down Expand Up @@ -59,6 +61,8 @@ public static Configurable configure() {
* @return the EventHubsManager
*/
public static EventHubsManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -69,7 +73,9 @@ public static EventHubsManager authenticate(TokenCredential credential, AzurePro
* @param profile the profile to use
* @return the EventHubsManager
*/
private static EventHubsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static EventHubsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new EventHubsManager(httpPipeline, profile);
}

Expand Down Expand Up @@ -103,8 +109,7 @@ private EventHubsManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
.authenticate(null, profile);
storageManager = StorageManager.authenticate(httpPipeline, profile);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;

import java.util.Objects;

/** Entry point to Azure KeyVault resource management. */
public final class KeyVaultManager extends Manager<KeyVaultManagementClient> {
// Service managers
Expand All @@ -42,6 +44,8 @@ public static Configurable configure() {
* @return the KeyVaultManager
*/
public static KeyVaultManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(
HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}
Expand All @@ -53,7 +57,9 @@ public static KeyVaultManager authenticate(TokenCredential credential, AzureProf
* @param profile the profile to use
* @return the KeyVaultManager
*/
private static KeyVaultManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static KeyVaultManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new KeyVaultManager(httpPipeline, profile);
}

Expand Down Expand Up @@ -88,9 +94,7 @@ private KeyVaultManager(
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
authorizationManager = AzureConfigurableImpl
.configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
.authenticate(null, profile);
authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
this.tenantId = profile.getTenantId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;

import java.util.Objects;

/** Entry point to Azure Monitor. */
public final class MonitorManager extends Manager<MonitorClient> {
// Collections
Expand Down Expand Up @@ -61,7 +63,9 @@ public static MonitorManager authenticate(
* @param profile the profile to use
* @return the MonitorManager
*/
private static MonitorManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static MonitorManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new MonitorManager(httpPipeline, profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;

import java.util.Objects;

/** Entry point to Azure network management. */
public final class NetworkManager extends Manager<NetworkManagementClient> {

Expand Down Expand Up @@ -88,6 +90,8 @@ public static Configurable configure() {
* @return the NetworkManager
*/
public static NetworkManager authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -98,7 +102,9 @@ public static NetworkManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the NetworkManager
*/
private static NetworkManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static NetworkManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new NetworkManager(httpPipeline, profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.0.0-hybrid (2022-01-12)

- Fixed a bug that `ResourceManager.pipeline()` be `null`.

- Azure Resource Manager resources client library for Java (Hybrid) using API Profiles to allow building hybrid cloud solutions
that target both Azure and Azure Stack Hub.
- Supports api versions in the 2020-09-01-hybrid api profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public final class ResourceManager extends Manager<ResourceManagementClient> {
* @return the ResourceManager instance
*/
public static ResourceManager.Authenticated authenticate(TokenCredential credential, AzureProfile profile) {
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new AuthenticatedImpl(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
}

Expand All @@ -89,7 +91,9 @@ public static ResourceManager.Authenticated authenticate(TokenCredential credent
* @param profile the profile used in resource management
* @return the interface exposing resource management API entry points that work across subscriptions
*/
private static ResourceManager.Authenticated authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
public static ResourceManager.Authenticated authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new AuthenticatedImpl(httpPipeline, profile);
}

Expand Down
Loading

0 comments on commit ac25422

Please sign in to comment.