-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #679 from anuchandy/master
Applying fluent model design patterns in existing models and collections.
- Loading branch information
Showing
59 changed files
with
882 additions
and
796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...e/src/main/java/com/microsoft/azure/management/compute/implementation/ComputeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.microsoft.azure.management.compute.implementation; | ||
|
||
import com.microsoft.azure.management.compute.AvailabilitySets; | ||
import com.microsoft.azure.management.compute.VirtualMachines; | ||
import com.microsoft.azure.management.compute.implementation.api.ComputeManagementClientImpl; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; | ||
import com.microsoft.azure.management.resources.implementation.ResourceManager; | ||
import com.microsoft.rest.RestClient; | ||
import com.microsoft.rest.credentials.ServiceClientCredentials; | ||
|
||
public final class ComputeManager { | ||
private RestClient restClient; | ||
private String subscriptionId; | ||
// The service managers | ||
private ResourceManager resourceClient; | ||
// The sdk clients | ||
private ComputeManagementClientImpl computeManagementClient; | ||
// The collections | ||
private AvailabilitySets availabilitySets; | ||
private VirtualMachines virtualMachines; | ||
|
||
public static Configurable configurable() { | ||
return new ComputeManager().new ConfigurableImpl(); | ||
} | ||
|
||
public static ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) { | ||
return new ComputeManager(credentials, subscriptionId); | ||
} | ||
|
||
public static ComputeManager authenticate(RestClient restClient, String subscriptionId) { | ||
return new ComputeManager(restClient, subscriptionId); | ||
} | ||
|
||
public interface Configurable extends AzureConfigurable<Configurable> { | ||
ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId); | ||
} | ||
|
||
final class ConfigurableImpl extends AzureConfigurableImpl<Configurable> implements Configurable { | ||
public ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) { | ||
buildRestClient(credentials); | ||
return ComputeManager.authenticate(restClient, subscriptionId); | ||
} | ||
} | ||
|
||
private ComputeManager(ServiceClientCredentials credentials, String subscriptionId) { | ||
this.restClient = new RestClient | ||
.Builder("https://management.azure.com") | ||
.withCredentials(credentials) | ||
.build(); | ||
this.subscriptionId = subscriptionId; | ||
} | ||
|
||
private ComputeManager(RestClient restClient, String subscriptionId) { | ||
this.restClient = restClient; | ||
this.subscriptionId = subscriptionId; | ||
} | ||
|
||
private ComputeManager() {} | ||
|
||
public AvailabilitySets availabilitySets() { | ||
if (availabilitySets == null) { | ||
availabilitySets = new AvailabilitySetsImpl(computeManagementClient().availabilitySets(), | ||
resourceClient().resourceGroups(), virtualMachines()); | ||
} | ||
return availabilitySets; | ||
} | ||
|
||
public VirtualMachines virtualMachines() { | ||
virtualMachines = null; | ||
return virtualMachines; | ||
} | ||
|
||
private ComputeManagementClientImpl computeManagementClient() { | ||
if (computeManagementClient == null) { | ||
computeManagementClient = new ComputeManagementClientImpl(restClient); | ||
computeManagementClient.setSubscriptionId(subscriptionId); | ||
} | ||
return computeManagementClient; | ||
} | ||
|
||
private ResourceManager resourceClient() { | ||
if (restClient == null) { | ||
resourceClient = ResourceManager | ||
.authenticate(restClient) | ||
.useSubscription(subscriptionId); | ||
} | ||
return resourceClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIP.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.microsoft.azure.management.network; | ||
|
||
|
||
public interface PublicIP { | ||
} |
8 changes: 6 additions & 2 deletions
8
...esources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...t-resources/src/main/java/com/microsoft/azure/management/resources/ResourceConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.microsoft.azure.management.resources; | ||
|
||
import com.microsoft.rest.credentials.ServiceClientCredentials; | ||
import com.microsoft.rest.RestClient; | ||
|
||
public interface ResourceConnector<T extends ResourceConnector> { | ||
interface Builder<T> { | ||
T create(ServiceClientCredentials credentials, String subscriptionId, ResourceGroup resourceGroup); | ||
T create(RestClient restClient, String subscriptionId, ResourceGroup resourceGroup); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.