Skip to content

Commit

Permalink
Mgmt: merge ManagerBase to Manager (Azure#15441)
Browse files Browse the repository at this point in the history
* move manager base to manager

* refactor usage of manager base

* update all manager

* fix compile error

* remove extends

* fix checkstyle
  • Loading branch information
ChenTanyi authored Sep 22, 2020
1 parent 495bce2 commit ad9d5a4
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure App Platform management. */
public final class AppPlatformManager extends Manager<AppPlatformManager, AppPlatformManagementClient> {
public final class AppPlatformManager extends Manager<AppPlatformManagementClient> {
// Collections
private SpringServices springServices;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.azure.resourcemanager.storage.StorageManager;

/** Entry point to Azure storage resource management. */
public final class AppServiceManager extends Manager<AppServiceManager, WebSiteManagementClient> {
public final class AppServiceManager extends Manager<WebSiteManagementClient> {
// Managers
private final AuthorizationManager authorizationManager;
private final KeyVaultManager keyVaultManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Entry point to Azure CDN management.
*/
public final class CdnManager extends Manager<CdnManager, CdnManagementClient> {
public final class CdnManager extends Manager<CdnManagementClient> {
// Collections
private CdnProfiles profiles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.azure.resourcemanager.storage.StorageManager;

/** Entry point to Azure compute resource management. */
public final class ComputeManager extends Manager<ComputeManager, ComputeManagementClient> {
public final class ComputeManager extends Manager<ComputeManagementClient> {
// The service managers
private final StorageManager storageManager;
private final NetworkManager networkManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/** Entry point to Azure container instance management. */
public final class ContainerInstanceManager
extends Manager<ContainerInstanceManager, ContainerInstanceManagementClient> {
extends Manager<ContainerInstanceManagementClient> {

// The service managers
private ContainerGroupsImpl containerGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/** Entry point to Azure container registry management. */
public final class ContainerRegistryManager
extends Manager<ContainerRegistryManager, ContainerRegistryManagementClient> {
extends Manager<ContainerRegistryManagementClient> {
// The service managers
private RegistriesImpl registries;
private final StorageManager storageManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** Entry point to Azure Container Service management. */
public final class ContainerServiceManager
extends Manager<ContainerServiceManager, ContainerServiceManagementClient> {
extends Manager<ContainerServiceManagementClient> {
// The service managers
private KubernetesClustersImpl kubernetesClusters;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure compute resource management. */
public final class CosmosManager extends Manager<CosmosManager, CosmosDBManagementClient> {
public final class CosmosManager extends Manager<CosmosDBManagementClient> {
private CosmosDBAccountsImpl databaseAccounts;
/**
* Get a Configurable instance that can be used to create ComputeManager with optional configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure DNS zone management. */
public final class DnsZoneManager extends Manager<DnsZoneManager, DnsManagementClient> {
public final class DnsZoneManager extends Manager<DnsManagementClient> {
// Collections
private DnsZones zones;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Entry point to Azure EventHub resource management.
*/
public final class EventHubsManager extends Manager<EventHubsManager, EventHubManagementClient> {
public final class EventHubsManager extends Manager<EventHubManagementClient> {
private EventHubNamespaces namespaces;
private EventHubs eventHubs;
private EventHubConsumerGroups consumerGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure KeyVault resource management. */
public final class KeyVaultManager extends Manager<KeyVaultManager, KeyVaultManagementClient> {
public final class KeyVaultManager extends Manager<KeyVaultManagementClient> {
// Service managers
private final AuthorizationManager authorizationManager;
// Collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure Monitor. */
public final class MonitorManager extends Manager<MonitorManager, MonitorClient> {
public final class MonitorManager extends Manager<MonitorClient> {
// Collections
private ActivityLogs activityLogs;
private MetricDefinitions metricDefinitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Entry point to Azure Managed Service Identity (MSI) resource management.
*/
public final class MSIManager extends Manager<MSIManager, ManagedServiceIdentityClient> {
public final class MSIManager extends Manager<ManagedServiceIdentityClient> {
private final AuthorizationManager authorizationManager;

private Identities identities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

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

// Collections
private PublicIpAddresses publicIPAddresses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.azure.resourcemanager.network.models.AppliableWithTags;
import com.azure.resourcemanager.network.models.UpdatableWithTags;
import com.azure.resourcemanager.resources.fluentcore.arm.ManagerBase;
import com.azure.resourcemanager.resources.fluentcore.arm.Manager;
import com.azure.resourcemanager.resources.fluentcore.arm.models.GroupableResource;
import com.azure.resourcemanager.resources.fluentcore.arm.models.Resource;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl;
Expand All @@ -23,7 +23,7 @@ public abstract class GroupableParentResourceWithTagsImpl<
InnerModelT extends com.azure.core.management.Resource,
FluentModelImplT extends
GroupableParentResourceWithTagsImpl<FluentModelT, InnerModelT, FluentModelImplT, ManagerT>,
ManagerT extends ManagerBase>
ManagerT extends Manager<?>>
extends GroupableParentResourceImpl<FluentModelT, InnerModelT, FluentModelImplT, ManagerT>
implements UpdatableWithTags<FluentModelT>, AppliableWithTags<FluentModelT> {
protected GroupableParentResourceWithTagsImpl(String name, InnerModelT innerObject, ManagerT manager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure private DNS zone management. */
public final class PrivateDnsZoneManager extends Manager<PrivateDnsZoneManager, PrivateDnsManagementClient> {
public final class PrivateDnsZoneManager extends Manager<PrivateDnsManagementClient> {

private PrivateDnsZones privateZones;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/** Entry point to Azure redis resource management. */
public final class RedisManager extends Manager<RedisManager, RedisManagementClient> {
public final class RedisManager extends Manager<RedisManagementClient> {
// Collections
private RedisCaches redisCaches;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.azure.resourcemanager.resources.fluent.ResourceManagementClientBuilder;
import com.azure.resourcemanager.resources.fluent.SubscriptionClient;
import com.azure.resourcemanager.resources.fluent.SubscriptionClientBuilder;
import com.azure.resourcemanager.resources.fluentcore.arm.Manager;
import com.azure.resourcemanager.resources.implementation.DeploymentsImpl;
import com.azure.resourcemanager.resources.implementation.FeaturesImpl;
import com.azure.resourcemanager.resources.implementation.GenericResourcesImpl;
Expand All @@ -33,8 +34,6 @@
import com.azure.resourcemanager.resources.models.Tenants;
import com.azure.resourcemanager.resources.fluentcore.arm.AzureConfigurable;
import com.azure.resourcemanager.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
import com.azure.resourcemanager.resources.fluentcore.arm.ManagerBase;
import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider;
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
Expand All @@ -45,9 +44,8 @@
/**
* Entry point to Azure resource management.
*/
public final class ResourceManager extends ManagerBase implements HasInner<ResourceManagementClient> {
public final class ResourceManager extends Manager<ResourceManagementClient> {
// The sdk clients
private final ResourceManagementClient resourceManagementClient;
private final FeatureClient featureClient;
private final SubscriptionClient subscriptionClient;
private final PolicyClient policyClient;
Expand Down Expand Up @@ -216,13 +214,16 @@ public ResourceManager withDefaultSubscription() {
}

private ResourceManager(HttpPipeline httpPipeline, AzureProfile profile, SdkContext sdkContext) {
super(null, profile, sdkContext);
super.withResourceManager(this);
this.resourceManagementClient = new ResourceManagementClientBuilder()
super(
null,
profile,
new ResourceManagementClientBuilder()
.pipeline(httpPipeline)
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient();
.buildClient(),
sdkContext);
super.withResourceManager(this);

this.featureClient = new FeatureClientBuilder()
.pipeline(httpPipeline)
Expand Down Expand Up @@ -287,7 +288,7 @@ public Features features() {
*/
public Providers providers() {
if (providers == null) {
providers = new ProvidersImpl(resourceManagementClient.getProviders());
providers = new ProvidersImpl(inner().getProviders());
}
return providers;
}
Expand Down Expand Up @@ -331,9 +332,4 @@ public Tenants tenants() {
}
return tenants;
}

@Override
public ResourceManagementClient inner() {
return this.resourceManagementClient;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,81 @@
package com.azure.resourcemanager.resources.fluentcore.arm;

import com.azure.core.http.HttpPipeline;
import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.ResourceManager;
import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;

/**
* Generic base class for Azure resource managers.
*
* @param <T> specific manager type
* @param <InnerT> inner management client implementation type
*/
public abstract class Manager<T, InnerT> extends ManagerBase implements HasInner<InnerT> {
public abstract class Manager<InnerT> implements HasInner<InnerT> {
private ResourceManager resourceManager;
private final String subscriptionId;
private final AzureEnvironment environment;
private final HttpPipeline httpPipeline;
private final SdkContext sdkContext;

protected final InnerT innerManagementClient;

protected Manager(HttpPipeline httpPipeline, AzureProfile profile,
InnerT innerManagementClient, SdkContext sdkContext) {
super(httpPipeline, profile, sdkContext);
this.httpPipeline = httpPipeline;
if (httpPipeline != null) {
this.resourceManager = ResourceManager.authenticate(httpPipeline, profile)
.withSdkContext(sdkContext)
.withDefaultSubscription();
}
this.subscriptionId = profile.getSubscriptionId();
this.environment = profile.getEnvironment();
this.sdkContext = sdkContext;
this.innerManagementClient = innerManagementClient;
}

@Override
public InnerT inner() {
return this.innerManagementClient;
}

/**
* @return the ID of the subscription the manager is working with
*/
public String subscriptionId() {
return this.subscriptionId;
}

/**
* @return the Azure environment the manager is working with
*/
public AzureEnvironment environment() {
return this.environment;
}

protected final void withResourceManager(ResourceManager resourceManager) {
this.resourceManager = resourceManager;
}

/**
* @return the {@link ResourceManager} associated with this manager
*/
public ResourceManager resourceManager() {
return this.resourceManager;
}

/**
* @return the {@link HttpPipeline} associated with this manager
*/
public HttpPipeline httpPipeline() {
return this.httpPipeline;
}

/**
* @return the {@link SdkContext} associated with this manager
*/
public SdkContext sdkContext() {
return this.sdkContext;
}
}

This file was deleted.

Loading

0 comments on commit ad9d5a4

Please sign in to comment.