Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8581ea
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 15, 2016
54323e1
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 15, 2016
e313fd6
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 15, 2016
eac650d
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 16, 2016
723e8a3
making Manager generic to start exposing common method implementation…
Jun 16, 2016
f435291
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 17, 2016
fa3f50a
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 17, 2016
e2cf0f9
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 17, 2016
c975f34
renaming SupportsGettingByName#get() as getByName(); adding SupportsG…
Jun 17, 2016
59c8be5
base class for collection classes for shared functionality
Jun 17, 2016
e19cafa
adding getById() support to AvailabilitySets
Jun 17, 2016
0b5952e
adding getById() support to VirtualMachines
Jun 17, 2016
2dfb06a
adding getById() support to NICs
Jun 17, 2016
305fe20
adding getById() support to Networks
Jun 17, 2016
d582aaf
adding getById() support to network security groups
Jun 17, 2016
975115d
adding support for getById() to public IP addresses
Jun 17, 2016
282d380
adding getById support to Deployments
Jun 17, 2016
2bee4f9
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 17, 2016
2137f27
adding getById() support to storage accounts
Jun 17, 2016
5283996
making getById final in th ebase class since there is no need to over…
Jun 17, 2016
092380e
adding getById test to TestTemplate
Jun 17, 2016
d9d76ca
enforcing the presence of a consistent createFluentModel(name) across…
Jun 17, 2016
78c0210
renaming ResourcesImpl as GroupableResourcesImpl;
Jun 17, 2016
b7c2afc
factoring ResourceManager reference logic out of concrete collection …
Jun 17, 2016
546c7dd
factoring client (inner collection) out of concrete collection impls …
Jun 17, 2016
8745d3b
minor javadoc violation
Jun 18, 2016
5a75693
enhancing GenericResources
Jun 18, 2016
938e221
pushing converter logic from concrete collection classes into the bas…
Jun 18, 2016
e0f3d97
Merge remote-tracking branch 'upstream/master' into martin-internals
Jun 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -13,6 +14,7 @@
public interface AvailabilitySets extends
SupportsListingByGroup<AvailabilitySet>,
SupportsGettingByGroup<AvailabilitySet>,
SupportsGettingById<AvailabilitySet>,
SupportsListing<AvailabilitySet>,
SupportsCreating<AvailabilitySet.DefinitionBlank>,
SupportsDeleting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -19,6 +20,7 @@ public interface VirtualMachines extends
SupportsListing<VirtualMachine>,
SupportsListingByGroup<VirtualMachine>,
SupportsGettingByGroup<VirtualMachine>,
SupportsGettingById<VirtualMachine>,
SupportsCreating<VirtualMachine.DefinitionBlank>,
SupportsDeleting,
SupportsDeletingByGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetInner;
import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetsInner;
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList;
import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter;
import com.microsoft.azure.management.resources.implementation.ResourceManager;
import com.microsoft.azure.management.resources.implementation.api.PageImpl;
import com.microsoft.rest.RestException;
Expand All @@ -26,21 +26,13 @@
/**
* The implementation for {@link AvailabilitySets}.
*/
class AvailabilitySetsImpl implements AvailabilitySets {
private final AvailabilitySetsInner client;
private final ResourceManager resourceManager;
private final PagedListConverter<AvailabilitySetInner, AvailabilitySet> converter;
class AvailabilitySetsImpl
extends GroupableResourcesImpl<AvailabilitySet, AvailabilitySetImpl, AvailabilitySetInner, AvailabilitySetsInner>
implements AvailabilitySets {
AvailabilitySetsImpl(
final AvailabilitySetsInner client,
final ResourceManager resourceManager) {
this.client = client;
this.resourceManager = resourceManager;
this.converter = new PagedListConverter<AvailabilitySetInner, AvailabilitySet>() {
@Override
public AvailabilitySet typeConvert(AvailabilitySetInner inner) {
return createFluentModel(inner);
}
};
super(resourceManager, client);
}

@Override
Expand All @@ -49,7 +41,7 @@ public PagedList<AvailabilitySet> list() throws CloudException, IOException {
@Override
public List<AvailabilitySet> listNextGroup(String resourceGroupName) throws RestException, IOException {
PageImpl<AvailabilitySetInner> page = new PageImpl<>();
page.setItems(client.list(resourceGroupName).getBody());
page.setItems(innerCollection.list(resourceGroupName).getBody());
page.setNextPageLink(null);
return converter.convert(new PagedList<AvailabilitySetInner>(page) {
@Override
Expand All @@ -64,7 +56,7 @@ public Page<AvailabilitySetInner> nextPage(String nextPageLink) throws RestExcep
@Override
public PagedList<AvailabilitySet> listByGroup(String groupName) throws CloudException, IOException {
PageImpl<AvailabilitySetInner> page = new PageImpl<>();
page.setItems(client.list(groupName).getBody());
page.setItems(this.innerCollection.list(groupName).getBody());
page.setNextPageLink(null);
return this.converter.convert(new PagedList<AvailabilitySetInner>(page) {
@Override
Expand All @@ -76,7 +68,7 @@ public Page<AvailabilitySetInner> nextPage(String nextPageLink) throws RestExcep

@Override
public AvailabilitySetImpl getByGroup(String groupName, String name) throws CloudException, IOException {
ServiceResponse<AvailabilitySetInner> response = this.client.get(groupName, name);
ServiceResponse<AvailabilitySetInner> response = this.innerCollection.get(groupName, name);
return createFluentModel(response.getBody());
}

Expand All @@ -92,25 +84,26 @@ public void delete(String id) throws Exception {

@Override
public void delete(String groupName, String name) throws Exception {
this.client.delete(groupName, name);
this.innerCollection.delete(groupName, name);
}

/**************************************************************
* Fluent model helpers.
**************************************************************/

private AvailabilitySetImpl createFluentModel(String name) {
AvailabilitySetInner availabilitySetInner = new AvailabilitySetInner();
@Override
protected AvailabilitySetImpl createFluentModel(String name) {
return new AvailabilitySetImpl(name,
availabilitySetInner,
this.client,
new AvailabilitySetInner(),
this.innerCollection,
this.resourceManager);
}

private AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilitySetInner) {
@Override
protected AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilitySetInner) {
return new AvailabilitySetImpl(availabilitySetInner.name(),
availabilitySetInner,
this.client,
this.innerCollection,
this.resourceManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Entry point to Azure compute resource management.
*/
public final class ComputeManager extends Manager {
public final class ComputeManager extends Manager<ComputeManager> {
// The service managers
private StorageManager storageManager;
private NetworkManager networkManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.microsoft.azure.management.network.implementation.NetworkManager;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl;
import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter;
import com.microsoft.azure.management.resources.implementation.ResourceManager;
import com.microsoft.azure.management.resources.implementation.api.PageImpl;
Expand All @@ -38,53 +39,44 @@
* The implementation for {@link VirtualMachines}.
*/
class VirtualMachinesImpl
extends GroupableResourcesImpl<VirtualMachine, VirtualMachineImpl, VirtualMachineInner, VirtualMachinesInner>
implements VirtualMachines {
private final VirtualMachinesInner client;
private final VirtualMachineSizesInner virtualMachineSizesClient;
private final ComputeManager computeManager;
private final ResourceManager resourceManager;
private final StorageManager storageManager;
private final NetworkManager networkManager;
private final PagedListConverter<VirtualMachineInner, VirtualMachine> converter;

VirtualMachinesImpl(VirtualMachinesInner client,
VirtualMachineSizesInner virtualMachineSizesClient,
ComputeManager computeManager,
ResourceManager resourceManager,
StorageManager storageManager,
NetworkManager networkManager) {
this.client = client;
super(resourceManager, client);
this.virtualMachineSizesClient = virtualMachineSizesClient;
this.computeManager = computeManager;
this.resourceManager = resourceManager;
this.storageManager = storageManager;
this.networkManager = networkManager;
this.converter = new PagedListConverter<VirtualMachineInner, VirtualMachine>() {
@Override
public VirtualMachine typeConvert(VirtualMachineInner inner) {
return createFluentModel(inner);
}
};
}

// Actions
//

@Override
public PagedList<VirtualMachine> list() throws CloudException, IOException {
ServiceResponse<PagedList<VirtualMachineInner>> response = client.listAll();
return converter.convert(response.getBody());
ServiceResponse<PagedList<VirtualMachineInner>> response = this.innerCollection.listAll();
return this.converter.convert(response.getBody());
}

@Override
public PagedList<VirtualMachine> listByGroup(String groupName) throws CloudException, IOException {
ServiceResponse<List<VirtualMachineInner>> response = client.list(groupName);
return converter.convert(toPagedList(response.getBody()));
ServiceResponse<List<VirtualMachineInner>> response = this.innerCollection.list(groupName);
return this.converter.convert(toPagedList(response.getBody()));
}

@Override
public VirtualMachine getByGroup(String groupName, String name) throws CloudException, IOException {
ServiceResponse<VirtualMachineInner> response = this.client.get(groupName, name);
ServiceResponse<VirtualMachineInner> response = this.innerCollection.get(groupName, name);
return createFluentModel(response.getBody());
}

Expand All @@ -95,7 +87,7 @@ public void delete(String id) throws Exception {

@Override
public void delete(String groupName, String name) throws Exception {
this.client.delete(groupName, name);
this.innerCollection.delete(groupName, name);
}

@Override
Expand Down Expand Up @@ -131,32 +123,32 @@ public PagedList<VirtualMachineSize> availableSizesByRegion(Region region) throw

@Override
public void deallocate(String groupName, String name) throws CloudException, IOException, InterruptedException {
this.client.deallocate(groupName, name);
this.innerCollection.deallocate(groupName, name);
}

@Override
public void generalize(String groupName, String name) throws CloudException, IOException {
this.client.generalize(groupName, name);
this.innerCollection.generalize(groupName, name);
}

@Override
public void powerOff(String groupName, String name) throws CloudException, IOException, InterruptedException {
this.client.powerOff(groupName, name);
this.innerCollection.powerOff(groupName, name);
}

@Override
public void restart(String groupName, String name) throws CloudException, IOException, InterruptedException {
this.client.restart(groupName, name);
this.innerCollection.restart(groupName, name);
}

@Override
public void start(String groupName, String name) throws CloudException, IOException, InterruptedException {
this.client.start(groupName, name);
this.innerCollection.start(groupName, name);
}

@Override
public void redeploy(String groupName, String name) throws CloudException, IOException, InterruptedException {
this.client.redeploy(groupName, name);
this.innerCollection.redeploy(groupName, name);
}

@Override
Expand All @@ -166,7 +158,7 @@ public String capture(String groupName, String name,
VirtualMachineCaptureParametersInner parameters = new VirtualMachineCaptureParametersInner();
parameters.withDestinationContainerName(containerName);
parameters.withOverwriteVhds(overwriteVhd);
ServiceResponse<VirtualMachineCaptureResultInner> captureResult = this.client.capture(groupName, name, parameters);
ServiceResponse<VirtualMachineCaptureResultInner> captureResult = this.innerCollection.capture(groupName, name, parameters);
ObjectMapper mapper = new ObjectMapper();
//Object to JSON string
return mapper.writeValueAsString(captureResult.getBody().output());
Expand All @@ -175,7 +167,8 @@ public String capture(String groupName, String name,
// Helper methods
//

private VirtualMachineImpl createFluentModel(String name) {
@Override
protected VirtualMachineImpl createFluentModel(String name) {
VirtualMachineInner inner = new VirtualMachineInner();
inner.withStorageProfile(new StorageProfile()
.withOsDisk(new OSDisk())
Expand All @@ -186,17 +179,18 @@ private VirtualMachineImpl createFluentModel(String name) {
.withNetworkInterfaces(new ArrayList<NetworkInterfaceReference>()));
return new VirtualMachineImpl(name,
inner,
this.client,
this.innerCollection,
this.computeManager,
this.resourceManager,
this.storageManager,
this.networkManager);
}

private VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachineInner) {
@Override
protected VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachineInner) {
return new VirtualMachineImpl(virtualMachineInner.name(),
virtualMachineInner,
this.client,
this.innerCollection,
this.computeManager,
this.resourceManager,
this.storageManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -15,6 +16,7 @@ public interface NetworkInterfaces extends
SupportsListing<NetworkInterface>,
SupportsListingByGroup<NetworkInterface>,
SupportsGettingByGroup<NetworkInterface>,
SupportsGettingById<NetworkInterface>,
SupportsDeleting,
SupportsDeletingByGroup {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -21,6 +22,7 @@ public interface NetworkSecurityGroups extends
SupportsListing<NetworkSecurityGroup>,
SupportsListingByGroup<NetworkSecurityGroup>,
SupportsGettingByGroup<NetworkSecurityGroup>,
SupportsGettingById<NetworkSecurityGroup>,
SupportsDeleting,
SupportsDeletingByGroup {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -21,6 +22,7 @@ public interface Networks extends
SupportsListing<Network>,
SupportsListingByGroup<Network>,
SupportsGettingByGroup<Network>,
SupportsGettingById<Network>,
SupportsDeleting,
SupportsDeletingByGroup {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
Expand All @@ -22,5 +23,6 @@ public interface PublicIpAddresses extends
SupportsDeleting,
SupportsListingByGroup<PublicIpAddress>,
SupportsGettingByGroup<PublicIpAddress>,
SupportsGettingById<PublicIpAddress>,
SupportsDeletingByGroup {
}
Loading