Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some VM image code #688

Merged
merged 3 commits into from
May 9, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
@@ -1,12 +1,107 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetInner;
import com.microsoft.azure.SubResource;
import com.microsoft.azure.management.compute.implementation.KnownVirtualMachineImage;
import com.microsoft.azure.management.compute.implementation.api.*;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

import java.util.List;

public interface VirtualMachine extends
GroupableResource,
Refreshable<AvailabilitySet>,
Wrapper<AvailabilitySetInner> {
Refreshable<VirtualMachine>,
Wrapper<VirtualMachineInner> {
/**
* Get the plan value.
*
* @return the plan value
*/
Plan plan();

/**
* Get the hardwareProfile value.
*
* @return the hardwareProfile value
*/
HardwareProfile hardwareProfile();

/**
* Get the storageProfile value.
*
* @return the storageProfile value
*/
StorageProfile storageProfile();

/**
* Get the osProfile value.
*
* @return the osProfile value
*/
OSProfile osProfile();

/**
* Get the networkProfile value.
*
* @return the networkProfile value
*/
NetworkProfile networkProfile();

/**
* Get the diagnosticsProfile value.
*
* @return the diagnosticsProfile value
*/
DiagnosticsProfile diagnosticsProfile();

/**
* Get the availabilitySet value.
*
* @return the availabilitySet value
*/
SubResource availabilitySet();

/**
* Get the provisioningState value.
*
* @return the provisioningState value
*/
String provisioningState();

/**
* Get the instanceView value.
*
* @return the instanceView value
*/
VirtualMachineInstanceView instanceView();

/**
* Get the licenseType value.
*
* @return the licenseType value
*/
String licenseType();

/**
* Get the resources value.
*
* @return the resources value
*/
List<VirtualMachineExtensionInner> resources();

interface DefinitionBlank extends GroupableResource.DefinitionWithRegion<DefinitionWithRegion> {
}

interface DefinitionWithRegion extends GroupableResource.DefinitionWithGroup<DefinitionWithGroup> {
}

interface DefinitionWithGroup {
DefinitionWithImage withImage(String publisher, String offer, String sku, String version);
DefinitionWithImage withLatestImage(String publisher, String offer, String sku);
DefinitionWithImage withKnownImage(KnownVirtualMachineImage image);
}

interface DefinitionWithImage {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.compute.implementation.api.DataDiskImage;
import com.microsoft.azure.management.compute.implementation.api.OSDiskImage;
import com.microsoft.azure.management.compute.implementation.api.PurchasePlan;
import com.microsoft.azure.management.compute.implementation.api.VirtualMachineImageInner;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

import java.util.List;

public interface VirtualMachineImage extends
Wrapper<VirtualMachineImageInner> {
String location();
String publisher();
String offer();
String sku();
String version();
PurchasePlan plan();
OSDiskImage osDiskImage();
List<DataDiskImage> dataDiskImages();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.microsoft.azure.management.compute;

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.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing;

public interface VirtualMachineImages extends
SupportsListing<VirtualMachine>,
SupportsListingByGroup<VirtualMachine>,
SupportsGettingByGroup<VirtualMachine>,
SupportsCreating<VirtualMachine>,
SupportsDeleting,
SupportsDeletingByGroup {
interface InGroup extends
SupportsListing<VirtualMachine>,
SupportsCreating<VirtualMachine>,
SupportsDeleting {}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template parameter type should be "VirtualMachineImage" instead of "VirtualMachine"

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.management.compute.VirtualMachineImage;

public enum KnownVirtualMachineImage {
UBUNTU_14_04_LTS(new VirtualMachineImageImpl(
"Canonical", "UbuntuServer", "14.04.4-LTS", "14.04.201604060"
)),
UBUNTU_16_04_LTS(new VirtualMachineImageImpl(
"Canonical", "UbuntuServer", "16.04.0-LTS", "16.04.201604203"
)),
WINDOWS_SERVER_2008_R2_SP1(new VirtualMachineImageImpl(
"MicrosoftWindowsServer", "WindowsServer", "2008-R2-SP1", "2.0.20160430"
)),
WINDOWS_SERVER_2012_DATACENTER(new VirtualMachineImageImpl(
"MicrosoftWindowsServer", "WindowsServer", "2012-Datacenter", "3.0.20160430"
)),
WINDOWS_SERVER_2012_R2_DATACENTER(new VirtualMachineImageImpl(
"MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", "4.0.20160430"
)),
WINDOWS_SERVER_2016_TECHNICAL_PREVIEW_WITH_CONTAINIERS(new VirtualMachineImageImpl(
"MicrosoftWindowsServer", "WindowsServer", "2016-Technical-Preview-with-Containers", "2016.0.20151118"
)),
WINDOWS_SERVER_TECHNICAL_PREVIEW(new VirtualMachineImageImpl(
"MicrosoftWindowsServer", "WindowsServer", "Windows-Server-Technical-Preview", "5.0.20160420"
));

private final VirtualMachineImage image;

KnownVirtualMachineImage(VirtualMachineImage image) {
this.image = image;
}

public VirtualMachineImage image() {
return this.image;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.management.compute.VirtualMachineImage;
import com.microsoft.azure.management.compute.implementation.api.DataDiskImage;
import com.microsoft.azure.management.compute.implementation.api.OSDiskImage;
import com.microsoft.azure.management.compute.implementation.api.PurchasePlan;
import com.microsoft.azure.management.compute.implementation.api.VirtualMachineImageInner;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableWrapperImpl;

import java.util.List;

class VirtualMachineImageImpl
extends IndexableWrapperImpl<VirtualMachineImageInner>
implements VirtualMachineImage {
VirtualMachineImageImpl(String publisher, String offer, String sku, String version) {
super(null, null);
this.publisher = publisher;
this.offer = offer;
this.sku = sku;
this.version = version;
}

VirtualMachineImageImpl(String publisher, String offer, String sku, String version, VirtualMachineImageInner innerObject) {
Copy link
Member

@anuchandy anuchandy May 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the name of the inner parameter in fluent models is "innerModel".

super(innerObject.id(), innerObject);
this.publisher = publisher;
this.offer = offer;
this.sku = sku;
this.version = version;
}

private String publisher;
private String offer;
private String sku;
private String version;

@Override
public String location() {
return inner().location();
}

@Override
public String publisher() {
return publisher;
}

@Override
public String offer() {
return offer;
}

@Override
public String sku() {
return sku;
}

@Override
public String version() {
return version;
}

@Override
public PurchasePlan plan() {
return inner().plan();
}

@Override
public OSDiskImage osDiskImage() {
return inner().osDiskImage();
}

@Override
public List<DataDiskImage> dataDiskImages() {
return inner().dataDiskImages();
}
}