mirror of https://github.com/apache/jclouds.git
Merge branch 'issue-830' of https://github.com/grkvlt/jclouds
* 'issue-830' of https://github.com/grkvlt/jclouds: (26 commits) Make JAXB XML marshaller pretty-print Updated Catalog expect tests Updating domain objects Updates to CatalogClient Deleted extraneous patching leftover Updated Metadata and associated domain objects Added IsEnabled property to Org Initial commit for CatalogClient with all operations defined and the client bound Added CatalogClient domain objects mergewithnext Updating ISO8601 time zone parsing and tests Tidyup Formatting Changed namespace identifier to VCLOUD_1_5_NS Remove client methods which rely on parsing URIs and add new function for tasksList operation Fix search and replace over-zealousness No enum for media types, after all... Completed TaskClient and tidied up OrgClient. Tidy Tidy up domain objects, using media type enum ...
This commit is contained in:
commit
64a1593c0c
|
@ -65,21 +65,21 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
|
|
||||||
Set<Host> actual = requestSendsResponse(request, response).listHosts();
|
Set<Host> actual = requestSendsResponse(request, response).listHosts();
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
|
||||||
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00");
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "GMT+02:00");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00");
|
||||||
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "GMT+02:00");
|
||||||
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "GMT+02:00");
|
||||||
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4);
|
Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4);
|
||||||
|
@ -111,8 +111,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.payload(payloadFromResource("/addhostresponse.json"))
|
.payload(payloadFromResource("/addhostresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
|
||||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).addHost(1, "http://example.com", "XenServer", "fred", "sekrit",
|
Host actual = requestSendsResponse(request, response).addHost(1, "http://example.com", "XenServer", "fred", "sekrit",
|
||||||
|
@ -132,8 +132,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.payload(payloadFromResource("/updatehostresponse.json"))
|
.payload(payloadFromResource("/updatehostresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
|
||||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
||||||
|
@ -223,9 +223,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.payload(payloadFromResource("/addsecondarystorageresponse.json"))
|
.payload(payloadFromResource("/addsecondarystorageresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00");
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "GMT+02:00");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00");
|
||||||
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId(1));
|
Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId(1));
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ListAlertsResponseTest extends BaseSetParserTest<Alert> {
|
||||||
@Override
|
@Override
|
||||||
@SelectJson("alert")
|
@SelectJson("alert")
|
||||||
public Set<Alert> expected() {
|
public Set<Alert> expected() {
|
||||||
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+02:00"));
|
||||||
c.set(Calendar.YEAR, 2011);
|
c.set(Calendar.YEAR, 2011);
|
||||||
c.set(Calendar.MONTH, Calendar.DECEMBER);
|
c.set(Calendar.MONTH, Calendar.DECEMBER);
|
||||||
c.set(Calendar.DAY_OF_MONTH, 4);
|
c.set(Calendar.DAY_OF_MONTH, 4);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ListStoragePoolsResponseTest extends BaseItemParserTest<Set<Storage
|
||||||
@Override
|
@Override
|
||||||
@SelectJson("storagepool")
|
@SelectJson("storagepool")
|
||||||
public Set<StoragePool> expected() {
|
public Set<StoragePool> expected() {
|
||||||
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+02:00"));
|
||||||
c.set(Calendar.YEAR, 2011);
|
c.set(Calendar.YEAR, 2011);
|
||||||
c.set(Calendar.MONTH, Calendar.NOVEMBER);
|
c.set(Calendar.MONTH, Calendar.NOVEMBER);
|
||||||
c.set(Calendar.DAY_OF_MONTH, 26);
|
c.set(Calendar.DAY_OF_MONTH, 26);
|
||||||
|
|
|
@ -27,14 +27,19 @@ import java.util.regex.Pattern;
|
||||||
*/
|
*/
|
||||||
public class DateUtils {
|
public class DateUtils {
|
||||||
|
|
||||||
public static final Pattern MILLIS_PATTERN = Pattern.compile("(.*\\.[0-9][0-9][0-9])[0-9]*Z?");
|
public static final String TZ_REGEX = "([+-][0-9][0-9](:?[0-9][0-9])?|Z)";
|
||||||
|
|
||||||
public static final Pattern TZ_PATTERN = Pattern.compile("(.*)[+-][0-9][0-9]:?[0-9][0-9]Z?");
|
public static final Pattern MILLIS_PATTERN = Pattern.compile("(.*\\.[0-9][0-9][0-9])[0-9]*" + TZ_REGEX + "?");
|
||||||
|
|
||||||
|
// This regexp will match all TZ forms that are valid is ISO 8601
|
||||||
|
public static final Pattern TZ_PATTERN = Pattern.compile("(.*)" + TZ_REGEX + "$");
|
||||||
|
|
||||||
public static String trimToMillis(String toParse) {
|
public static String trimToMillis(String toParse) {
|
||||||
Matcher matcher = MILLIS_PATTERN.matcher(toParse);
|
Matcher matcher = MILLIS_PATTERN.matcher(toParse);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
toParse = matcher.group(1) + 'Z';
|
toParse = matcher.group(1);
|
||||||
|
if (matcher.group(2) != null)
|
||||||
|
toParse += matcher.group(2);
|
||||||
}
|
}
|
||||||
return toParse;
|
return toParse;
|
||||||
}
|
}
|
||||||
|
@ -44,11 +49,28 @@ public class DateUtils {
|
||||||
public static String trimTZ(String toParse) {
|
public static String trimTZ(String toParse) {
|
||||||
Matcher matcher = TZ_PATTERN.matcher(toParse);
|
Matcher matcher = TZ_PATTERN.matcher(toParse);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
toParse = matcher.group(1) + 'Z';
|
toParse = matcher.group(1);
|
||||||
}
|
}
|
||||||
|
// TODO explain why this check is here
|
||||||
if (toParse.length() == 25 && SECOND_PATTERN.matcher(toParse).matches())
|
if (toParse.length() == 25 && SECOND_PATTERN.matcher(toParse).matches())
|
||||||
toParse = toParse.substring(0, toParse.length() - 6) + 'Z';
|
toParse = toParse.substring(0, toParse.length() - 6);
|
||||||
return toParse;
|
return toParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String findTZ(String toParse) {
|
||||||
|
Matcher matcher = TZ_PATTERN.matcher(toParse);
|
||||||
|
if (matcher.find()) {
|
||||||
|
// Remove ':' from the TZ string, as SimpleDateFormat can't handle it
|
||||||
|
String tz = matcher.group(2).replace(":", "");
|
||||||
|
// Append '00; if we only have a two digit TZ, as SimpleDateFormat
|
||||||
|
if (tz.length() == 2) tz += "00";
|
||||||
|
// Replace Z with +0000
|
||||||
|
if (tz.equals("Z")) return "+0000";
|
||||||
|
return tz;
|
||||||
|
} else {
|
||||||
|
// Return +0000 if no time zone
|
||||||
|
return "+0000";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,8 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.date.internal;
|
package org.jclouds.date.internal;
|
||||||
import static org.jclouds.date.internal.DateUtils.trimToMillis;
|
import static org.jclouds.date.internal.DateUtils.*;
|
||||||
import static org.jclouds.date.internal.DateUtils.trimTZ;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -42,20 +41,16 @@ public class SimpleDateFormatDateService implements DateService {
|
||||||
* guard against the lack of thread safety.
|
* guard against the lack of thread safety.
|
||||||
*/
|
*/
|
||||||
// @GuardedBy("this")
|
// @GuardedBy("this")
|
||||||
private static final SimpleDateFormat iso8601SecondsSimpleDateFormat = new SimpleDateFormat(
|
private static final SimpleDateFormat iso8601SecondsSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
|
||||||
"yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
|
||||||
|
|
||||||
// @GuardedBy("this")
|
// @GuardedBy("this")
|
||||||
private static final SimpleDateFormat iso8601SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
private static final SimpleDateFormat iso8601SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
|
||||||
Locale.US);
|
|
||||||
|
|
||||||
// @GuardedBy("this")
|
// @GuardedBy("this")
|
||||||
private static final SimpleDateFormat rfc822SimpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
|
private static final SimpleDateFormat rfc822SimpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||||
Locale.US);
|
|
||||||
|
|
||||||
// @GuardedBy("this")
|
// @GuardedBy("this")
|
||||||
private static final SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss '+0000' yyyy",
|
private static final SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.US);
|
||||||
Locale.US);
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
iso8601SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
|
iso8601SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
|
||||||
|
@ -64,83 +59,105 @@ public class SimpleDateFormatDateService implements DateService {
|
||||||
cSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
|
cSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Date fromSeconds(long seconds) {
|
public final Date fromSeconds(long seconds) {
|
||||||
return new Date(seconds * 1000);
|
return new Date(seconds * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String cDateFormat(Date date) {
|
public final String cDateFormat(Date date) {
|
||||||
synchronized (cSimpleDateFormat) {
|
synchronized (cSimpleDateFormat) {
|
||||||
return cSimpleDateFormat.format(date);
|
return cSimpleDateFormat.format(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String cDateFormat() {
|
public final String cDateFormat() {
|
||||||
return cDateFormat(new Date());
|
return cDateFormat(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Date cDateParse(String toParse) {
|
public final Date cDateParse(String toParse) {
|
||||||
synchronized (cSimpleDateFormat) {
|
synchronized (cSimpleDateFormat) {
|
||||||
try {
|
try {
|
||||||
return cSimpleDateFormat.parse(toParse);
|
return cSimpleDateFormat.parse(toParse);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException pe) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException("Error parsing data at " + pe.getErrorOffset(), pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String rfc822DateFormat(Date date) {
|
public final String rfc822DateFormat(Date date) {
|
||||||
synchronized (rfc822SimpleDateFormat) {
|
synchronized (rfc822SimpleDateFormat) {
|
||||||
return rfc822SimpleDateFormat.format(date);
|
return rfc822SimpleDateFormat.format(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String rfc822DateFormat() {
|
public final String rfc822DateFormat() {
|
||||||
return rfc822DateFormat(new Date());
|
return rfc822DateFormat(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Date rfc822DateParse(String toParse) {
|
public final Date rfc822DateParse(String toParse) {
|
||||||
synchronized (rfc822SimpleDateFormat) {
|
synchronized (rfc822SimpleDateFormat) {
|
||||||
try {
|
try {
|
||||||
return rfc822SimpleDateFormat.parse(toParse);
|
return rfc822SimpleDateFormat.parse(toParse);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException pe) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException("Error parsing data at " + pe.getErrorOffset(), pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String iso8601SecondsDateFormat() {
|
public final String iso8601SecondsDateFormat() {
|
||||||
return iso8601SecondsDateFormat(new Date());
|
return iso8601SecondsDateFormat(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String iso8601DateFormat(Date date) {
|
public final String iso8601DateFormat(Date date) {
|
||||||
synchronized (iso8601SimpleDateFormat) {
|
synchronized (iso8601SimpleDateFormat) {
|
||||||
return iso8601SimpleDateFormat.format(date);
|
String parsed = iso8601SimpleDateFormat.format(date);
|
||||||
|
String tz = findTZ(parsed);
|
||||||
|
if (tz.equals("+0000")) {
|
||||||
|
parsed = trimTZ(parsed) + "Z";
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String iso8601DateFormat() {
|
public final String iso8601DateFormat() {
|
||||||
return iso8601DateFormat(new Date());
|
return iso8601DateFormat(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Date iso8601DateParse(String toParse) {
|
public final Date iso8601DateParse(String toParse) {
|
||||||
toParse = trimTZ(toParse);
|
String tz = findTZ(toParse);
|
||||||
toParse = trimToMillis(toParse);
|
toParse = trimToMillis(toParse);
|
||||||
|
toParse = trimTZ(toParse);
|
||||||
|
toParse += tz;
|
||||||
synchronized (iso8601SimpleDateFormat) {
|
synchronized (iso8601SimpleDateFormat) {
|
||||||
try {
|
try {
|
||||||
return iso8601SimpleDateFormat.parse(toParse);
|
return iso8601SimpleDateFormat.parse(toParse);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException pe) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException("Error parsing data at " + pe.getErrorOffset(), pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Date iso8601SecondsDateParse(String toParse) {
|
public final Date iso8601SecondsDateParse(String toParse) {
|
||||||
|
String tz = findTZ(toParse);
|
||||||
|
toParse = trimToMillis(toParse);
|
||||||
toParse = trimTZ(toParse);
|
toParse = trimTZ(toParse);
|
||||||
|
toParse += tz;
|
||||||
synchronized (iso8601SecondsSimpleDateFormat) {
|
synchronized (iso8601SecondsSimpleDateFormat) {
|
||||||
try {
|
try {
|
||||||
return iso8601SecondsSimpleDateFormat.parse(toParse);
|
return iso8601SecondsSimpleDateFormat.parse(toParse);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException pe) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException("Error parsing data at " + pe.getErrorOffset(), pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +165,12 @@ public class SimpleDateFormatDateService implements DateService {
|
||||||
@Override
|
@Override
|
||||||
public String iso8601SecondsDateFormat(Date date) {
|
public String iso8601SecondsDateFormat(Date date) {
|
||||||
synchronized (iso8601SecondsSimpleDateFormat) {
|
synchronized (iso8601SecondsSimpleDateFormat) {
|
||||||
return iso8601SecondsSimpleDateFormat.format(date);
|
String parsed = iso8601SecondsSimpleDateFormat.format(date);
|
||||||
|
String tz = findTZ(parsed);
|
||||||
|
if (tz.equals("+0000")) {
|
||||||
|
parsed = trimTZ(parsed) + "Z";
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class ExceptionToValueOrPropagate<E extends Exception, T> implements Func
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public T apply(Exception from) {
|
public T apply(Exception from) {
|
||||||
checkNotNull(from, "exception");
|
checkNotNull(from, "exception");
|
||||||
|
|
|
@ -28,7 +28,6 @@ import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
|
||||||
import org.jclouds.xml.XMLParser;
|
import org.jclouds.xml.XMLParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +48,7 @@ public class JAXBParser implements XMLParser {
|
||||||
try {
|
try {
|
||||||
JAXBContext context = JAXBContext.newInstance(type);
|
JAXBContext context = JAXBContext.newInstance(type);
|
||||||
Marshaller marshaller = context.createMarshaller();
|
Marshaller marshaller = context.createMarshaller();
|
||||||
|
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
marshaller.marshal(src, writer);
|
marshaller.marshal(src, writer);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
|
@ -57,7 +57,6 @@ public class JAXBParser implements XMLParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T fromXML(final String xml, final Class<T> type) throws IOException {
|
public <T> T fromXML(final String xml, final Class<T> type) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -82,17 +82,17 @@ public class DateServiceTest extends PerformanceTest {
|
||||||
// Constant time test values, each TestData item must contain matching
|
// Constant time test values, each TestData item must contain matching
|
||||||
// times!
|
// times!
|
||||||
testData = new TestData[] {
|
testData = new TestData[] {
|
||||||
new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T02:00:07-04:00", "2009-03-12T02:00:07Z",
|
new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T06:00:07+0400", "2009-03-12T02:00:07Z",
|
||||||
"Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", new Date(1236823207000l)),
|
"Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", new Date(1236823207000l)),
|
||||||
new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T02:00:07+04:00", "2009-03-12T02:00:07Z",
|
new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T06:00:07+0400", "2009-03-12T02:00:07Z",
|
||||||
"Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", new Date(1236823207000l)),
|
"Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", new Date(1236823207000l)),
|
||||||
new TestData("2009-03-14T04:00:07.000Z", "2009-03-14T04:00:07Z+04:00", "2009-03-14T04:00:07Z",
|
new TestData("2009-03-14T04:00:07.000Z", "2009-03-14T08:00:07+0400", "2009-03-14T04:00:07Z",
|
||||||
"Sat, 14 Mar 2009 04:00:07 GMT", "Thu Mar 14 04:00:07 +0000 2009", new Date(1237003207000l)),
|
"Sat, 14 Mar 2009 04:00:07 GMT", "Thu Mar 14 04:00:07 +0000 2009", new Date(1237003207000l)),
|
||||||
new TestData("2009-03-16T06:00:07.000Z", "2009-03-16T06:00:07Z+04:00", "2009-03-16T06:00:07Z",
|
new TestData("2009-03-16T06:00:07.000Z", "2009-03-16T10:00:07+0400", "2009-03-16T06:00:07Z",
|
||||||
"Mon, 16 Mar 2009 06:00:07 GMT", "Thu Mar 16 06:00:07 +0000 2009", new Date(1237183207000l)),
|
"Mon, 16 Mar 2009 06:00:07 GMT", "Thu Mar 16 06:00:07 +0000 2009", new Date(1237183207000l)),
|
||||||
new TestData("2009-03-18T08:00:07.000Z", "2009-03-18T08:00:07Z+04:00", "2009-03-18T08:00:07Z",
|
new TestData("2009-03-18T08:00:07.000Z", "2009-03-18T12:00:07+0400", "2009-03-18T08:00:07Z",
|
||||||
"Wed, 18 Mar 2009 08:00:07 GMT", "Thu Mar 18 08:00:07 +0000 2009", new Date(1237363207000l)),
|
"Wed, 18 Mar 2009 08:00:07 GMT", "Thu Mar 18 08:00:07 +0000 2009", new Date(1237363207000l)),
|
||||||
new TestData("2009-03-20T10:00:07.000Z", "2009-03-20T10:00:07Z+04:00", "2009-03-20T10:00:07Z",
|
new TestData("2009-03-20T10:00:07.000Z", "2009-03-20T14:00:07+0400", "2009-03-20T10:00:07Z",
|
||||||
"Fri, 20 Mar 2009 10:00:07 GMT", "Thu Mar 20 10:00:07 +0000 2009", new Date(1237543207000l)) };
|
"Fri, 20 Mar 2009 10:00:07 GMT", "Thu Mar 20 10:00:07 +0000 2009", new Date(1237543207000l)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,13 +160,12 @@ public class DateServiceTest extends PerformanceTest {
|
||||||
void testFromSeconds() throws ExecutionException, InterruptedException {
|
void testFromSeconds() throws ExecutionException, InterruptedException {
|
||||||
long seconds = 1254008225;
|
long seconds = 1254008225;
|
||||||
Date date = dateService.fromSeconds(seconds);
|
Date date = dateService.fromSeconds(seconds);
|
||||||
assertEquals(dateService.rfc822DateFormat(date), "Sat, 26 Sep 2009 23:37:05 GMT");
|
assertEquals(dateService.iso8601SecondsDateFormat(date), "2009-09-26T23:37:05Z");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTzWithExtraZ() throws ExecutionException, InterruptedException {
|
void testTz() throws ExecutionException, InterruptedException {
|
||||||
assertEquals(dateService.iso8601SecondsDateParse("2011-05-26T06:14:13-04:00").getTime(), 1306390453000l);
|
assertEquals(dateService.iso8601SecondsDateParse("2011-05-26T02:14:13-04:00").getTime(), 1306390453000l);
|
||||||
assertEquals(dateService.iso8601SecondsDateParse("2011-05-26T06:14:13-04:00Z").getTime(), 1306390453000l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class DateUtilsTest {
|
||||||
// TODO: this test is failing on my jvm which is in IST
|
// TODO: this test is failing on my jvm which is in IST
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testTrimsToMillisNoTimezone() {
|
public void testTrimsToMillisNoTimezone() {
|
||||||
assertEquals("NO_MILLIS", DateUtils.trimToMillis("NO_MILLISZ"));
|
assertEquals("NO_MILLIS", DateUtils.trimToMillis("NO_MILLIS"));
|
||||||
assertEquals("NO_MILLIS.1", DateUtils.trimToMillis("NO_MILLIS.1"));
|
assertEquals("NO_MILLIS.1", DateUtils.trimToMillis("NO_MILLIS.1"));
|
||||||
assertEquals("NO_MILLIS.12", DateUtils.trimToMillis("NO_MILLIS.12"));
|
assertEquals("NO_MILLIS.12", DateUtils.trimToMillis("NO_MILLIS.12"));
|
||||||
assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123"));
|
assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123"));
|
||||||
|
|
|
@ -418,7 +418,6 @@ public abstract class BaseRestClientExpectTest<S> {
|
||||||
protected String identity = "identity";
|
protected String identity = "identity";
|
||||||
protected String credential = "credential";
|
protected String credential = "credential";
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private RestContextSpec<S, ?> makeContextSpec() {
|
private RestContextSpec<S, ?> makeContextSpec() {
|
||||||
if (getClass().isAnnotationPresent(RegisterContext.class))
|
if (getClass().isAnnotationPresent(RegisterContext.class))
|
||||||
return (RestContextSpec<S, ?>) contextSpec(provider, "http://mock", "1", "", "", "userfoo", null, getClass()
|
return (RestContextSpec<S, ?>) contextSpec(provider, "http://mock", "1", "", "", "userfoo", null, getClass()
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.binders;
|
package org.jclouds.rest.binders;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ public class BindToXMLPayloadTest {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
||||||
request = binder.bindToRequest(request, obj);
|
request = binder.bindToRequest(request, obj);
|
||||||
assertEquals(request.getPayload().getRawContent(), XMLParser.DEFAULT_XML_HEADER
|
assertEquals(request.getPayload().getRawContent(), XMLParser.DEFAULT_XML_HEADER + "\n<test>\n <elem>Hello World</elem>\n</test>\n");
|
||||||
+ "<test><elem>Hello World</elem></test>");
|
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ public class BindToXMLPayloadTest {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
request = binder.bindToRequest(request, obj);
|
request = binder.bindToRequest(request, obj);
|
||||||
assertEquals(request.getPayload().getRawContent(), XMLParser.DEFAULT_XML_HEADER
|
assertEquals(request.getPayload().getRawContent(), XMLParser.DEFAULT_XML_HEADER + "\n<test>\n <elem>Hello World</elem>\n</test>\n");
|
||||||
+ "<test><elem>Hello World</elem></test>");
|
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.date.joda;
|
package org.jclouds.date.joda;
|
||||||
|
|
||||||
|
import static org.jclouds.date.internal.DateUtils.*;
|
||||||
import static org.jclouds.date.internal.DateUtils.trimToMillis;
|
import static org.jclouds.date.internal.DateUtils.trimToMillis;
|
||||||
import static org.jclouds.date.internal.DateUtils.trimTZ;
|
import static org.jclouds.date.internal.DateUtils.trimTZ;
|
||||||
|
|
||||||
|
@ -41,16 +42,16 @@ import org.joda.time.format.DateTimeFormatter;
|
||||||
public class JodaDateService implements DateService {
|
public class JodaDateService implements DateService {
|
||||||
|
|
||||||
private static final DateTimeFormatter rfc822DateFormatter = DateTimeFormat.forPattern(
|
private static final DateTimeFormatter rfc822DateFormatter = DateTimeFormat.forPattern(
|
||||||
"EEE, dd MMM yyyy HH:mm:ss 'GMT'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
"EEE, dd MMM yyyy HH:mm:ss z").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
||||||
|
|
||||||
private static final DateTimeFormatter cDateFormatter = DateTimeFormat
|
private static final DateTimeFormatter cDateFormatter = DateTimeFormat
|
||||||
.forPattern("EEE MMM dd HH:mm:ss '+0000' yyyy").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
.forPattern("EEE MMM dd HH:mm:ss Z yyyy").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
||||||
|
|
||||||
private static final DateTimeFormatter iso8601SecondsDateFormatter = DateTimeFormat.forPattern(
|
private static final DateTimeFormatter iso8601SecondsDateFormatter = DateTimeFormat.forPattern(
|
||||||
"yyyy-MM-dd'T'HH:mm:ss'Z'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
"yyyy-MM-dd'T'HH:mm:ssZ").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
||||||
|
|
||||||
private static final DateTimeFormatter iso8601DateFormatter = DateTimeFormat.forPattern(
|
private static final DateTimeFormatter iso8601DateFormatter = DateTimeFormat.forPattern(
|
||||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
"yyyy-MM-dd'T'HH:mm:ss.SSSZ").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
|
||||||
|
|
||||||
public final Date fromSeconds(long seconds) {
|
public final Date fromSeconds(long seconds) {
|
||||||
return new Date(seconds * 1000);
|
return new Date(seconds * 1000);
|
||||||
|
@ -81,7 +82,12 @@ public class JodaDateService implements DateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String iso8601SecondsDateFormat(Date dateTime) {
|
public final String iso8601SecondsDateFormat(Date dateTime) {
|
||||||
return iso8601SecondsDateFormatter.print(new DateTime(dateTime));
|
String parsed = iso8601SecondsDateFormatter.print(new DateTime(dateTime));
|
||||||
|
String tz = findTZ(parsed);
|
||||||
|
if (tz.equals("+0000")) {
|
||||||
|
parsed = trimTZ(parsed) + "Z";
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String iso8601SecondsDateFormat() {
|
public final String iso8601SecondsDateFormat() {
|
||||||
|
@ -89,7 +95,12 @@ public class JodaDateService implements DateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String iso8601DateFormat(Date date) {
|
public final String iso8601DateFormat(Date date) {
|
||||||
return iso8601DateFormatter.print(new DateTime(date));
|
String parsed = iso8601DateFormatter.print(new DateTime(date));
|
||||||
|
String tz = findTZ(parsed);
|
||||||
|
if (tz.equals("+0000")) {
|
||||||
|
parsed = trimTZ(parsed) + "Z";
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String iso8601DateFormat() {
|
public final String iso8601DateFormat() {
|
||||||
|
@ -97,13 +108,18 @@ public class JodaDateService implements DateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Date iso8601DateParse(String toParse) {
|
public final Date iso8601DateParse(String toParse) {
|
||||||
toParse = trimTZ(toParse);
|
String tz = findTZ(toParse);
|
||||||
toParse = trimToMillis(toParse);
|
toParse = trimToMillis(toParse);
|
||||||
|
toParse = trimTZ(toParse);
|
||||||
|
toParse += tz;
|
||||||
return iso8601DateFormatter.parseDateTime(toParse).toDate();
|
return iso8601DateFormatter.parseDateTime(toParse).toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Date iso8601SecondsDateParse(String toParse) {
|
public final Date iso8601SecondsDateParse(String toParse) {
|
||||||
|
String tz = findTZ(toParse);
|
||||||
|
toParse = trimToMillis(toParse);
|
||||||
toParse = trimTZ(toParse);
|
toParse = trimTZ(toParse);
|
||||||
|
toParse += tz;
|
||||||
return iso8601SecondsDateFormatter.parseDateTime(toParse).toDate();
|
return iso8601SecondsDateFormatter.parseDateTime(toParse).toDate();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.date.joda;
|
package org.jclouds.date.joda;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.DateServiceTest;
|
import org.jclouds.date.DateServiceTest;
|
||||||
import org.jclouds.date.joda.config.JodaDateServiceModule;
|
import org.jclouds.date.joda.config.JodaDateServiceModule;
|
||||||
|
@ -49,4 +54,19 @@ public class JodaDateServiceTest extends DateServiceTest {
|
||||||
assert dateService instanceof JodaDateService;
|
assert dateService instanceof JodaDateService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME Joda routines cannot parse or correctly format the 'z' format specifier, e.g. 'GMT' used in RFC822 pattern. */
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
|
public void testRfc822DateFormat() throws ExecutionException, InterruptedException {
|
||||||
|
String dsString = dateService.rfc822DateFormat(testData[0].date);
|
||||||
|
assertEquals(dsString, testData[0].rfc822DateString.replace("GMT", "+00:00"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test(enabled = false)
|
||||||
|
public void testRfc822DateParse() throws ExecutionException, InterruptedException {
|
||||||
|
Date dsDate = dateService.rfc822DateParse(testData[0].rfc822DateString);
|
||||||
|
assertEquals(dsDate, testData[0].date);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -20,15 +20,16 @@ package org.jclouds.vcloud.director.v1_5;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to VCloudDirector via their REST API.
|
* Provides asynchronous access to VCloudDirector via their REST API.
|
||||||
* <p/>
|
|
||||||
*
|
*
|
||||||
* @see VCloudDirectorClient
|
* @see VCloudDirectorClient
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -47,9 +48,21 @@ public interface VCloudDirectorAsyncClient {
|
||||||
@Delegate
|
@Delegate
|
||||||
OrgAsyncClient getOrgClient();
|
OrgAsyncClient getOrgClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return asynchronous access to Task features
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
TaskAsyncClient getTaskClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return asynchronous access to Network features
|
* @return asynchronous access to Network features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
NetworkAsyncClient getNetworkClient();
|
NetworkAsyncClient getNetworkClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return asynchronous access to Catalog features
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
CatalogAsyncClient getCatalogClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
|
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.TaskClient;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
@ -45,14 +47,27 @@ public interface VCloudDirectorClient {
|
||||||
Session getCurrentSession();
|
Session getCurrentSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return synchronous access to Org features
|
* @return synchronous access to {@link Org} features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
OrgClient getOrgClient();
|
OrgClient getOrgClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return synchronous access to {@link Task} features
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
TaskClient getTaskClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return synchronous access to Network features
|
* @return synchronous access to Network features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
NetworkClient getNetworkClient();
|
NetworkClient getNetworkClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return synchronous access to {@link Catalog} features
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
CatalogClient getCatalogClient();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants used by VCloudDirector clients
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
public class VCloudDirectorConstants {
|
||||||
|
|
||||||
|
/** The XML namespace used by the clients. */
|
||||||
|
public static final String VCLOUD_1_5_NS = "http://www.vmware.com/vcloud/v1.5";
|
||||||
|
|
||||||
|
}
|
|
@ -27,7 +27,6 @@ import org.jclouds.rest.RestContextBuilder;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudDirectorContextBuilder extends RestContextBuilder<VCloudDirectorClient, VCloudDirectorAsyncClient> {
|
public class VCloudDirectorContextBuilder extends RestContextBuilder<VCloudDirectorClient, VCloudDirectorAsyncClient> {
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
public class VCloudDirectorException extends RuntimeException {
|
||||||
|
|
||||||
|
/** The serialVersionUID. */
|
||||||
|
private static final long serialVersionUID = -3200853408568729058L;
|
||||||
|
|
||||||
|
private final Error error;
|
||||||
|
|
||||||
|
public VCloudDirectorException(Error error) {
|
||||||
|
super("Error: " + error.getMessage());
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VCloudDirectorException(Task task) {
|
||||||
|
super("Task error: " + task.getError().getMessage());
|
||||||
|
this.error = task.getError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Error getError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,30 +18,46 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5;
|
package org.jclouds.vcloud.director.v1_5;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource Types used in VCloud
|
* Resource Types used in VCloud.
|
||||||
*
|
*
|
||||||
* <br/>
|
|
||||||
* The object type, specified as a MIME content type, of the object that the link references. This
|
* The object type, specified as a MIME content type, of the object that the link references. This
|
||||||
* attribute is present only for links to objects. It is not present for links to actions.
|
* attribute is present only for links to objects. It is not present for links to actions.
|
||||||
*
|
*
|
||||||
* @see MediaType
|
* @see javax.ws.rs.core.MediaType;
|
||||||
*/
|
*/
|
||||||
public interface VCloudDirectorMediaType {
|
public class VCloudDirectorMediaType {
|
||||||
public final static String NS = "http://www.vmware.com/vcloud/v1.5";
|
|
||||||
|
|
||||||
public final static String SESSION_XML = "application/vnd.vmware.vcloud.session+xml";
|
public static final String ANY = "*/*";
|
||||||
|
|
||||||
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml";
|
public static final String SESSION = "application/vnd.vmware.vcloud.session+xml";
|
||||||
|
|
||||||
public final static String METADATA_XML = "application/vnd.vmware.vcloud.metadata+xml";
|
|
||||||
|
|
||||||
public static final String METADATAENTRY_XML = "TODO"; // TODO
|
|
||||||
|
|
||||||
public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
|
|
||||||
|
|
||||||
public static final String ORG_NETWORK_XML = "application/vnd.vmware.vcloud.orgNetwork+xml";
|
public static final String ERROR = "application/vnd.vmware.vcloud.error+xml";
|
||||||
|
|
||||||
|
public static final String ORG_LIST = "application/vnd.vmware.vcloud.orgList+xml";
|
||||||
|
|
||||||
|
public static final String METADATA = "application/vnd.vmware.vcloud.metadata+xml";
|
||||||
|
|
||||||
|
public static final String METADATA_ENTRY = "*/*"; // No media type (?)
|
||||||
|
|
||||||
|
public static final String METADATA_VALUE = "application/vnd.vmware.vcloud.metadata.value+xml";;
|
||||||
|
|
||||||
|
public static final String ORG = "application/vnd.vmware.vcloud.org+xml";
|
||||||
|
|
||||||
|
public static final String TASKS_LIST = "application/vnd.vmware.vcloud.tasksList+xml";
|
||||||
|
|
||||||
|
public static final String TASK = "application/vnd.vmware.vcloud.task+xml";
|
||||||
|
|
||||||
|
public static final String ORG_NETWORK = "application/vnd.vmware.vcloud.orgNetwork+xml";
|
||||||
|
|
||||||
|
public static final String CATALOG = "application/vnd.vmware.vcloud.catalog+xml";
|
||||||
|
|
||||||
|
public static final String CATALOG_ITEM = "application/vnd.vmware.vcloud.catalogItem+xml";
|
||||||
|
|
||||||
|
public static final String CATALOG_ITEMS = "application/vnd.vmware.vcloud.catalogItems+xml";
|
||||||
|
|
||||||
|
public static final String CATALOGS_LIST = "application/vnd.vmware.vcloud.catalogsList+xml";
|
||||||
|
|
||||||
|
public static final String PROPERTY = "application/vnd.vmware.vcloud.property+xml";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,16 @@ import java.util.Properties;
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in VCloudDirector Clients
|
* Builds properties used in VCloudDirector clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudDirectorPropertiesBuilder extends PropertiesBuilder {
|
public class VCloudDirectorPropertiesBuilder extends PropertiesBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "http://localhost/api");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://vcloudbeta.bluelock.com/api");
|
||||||
properties.setProperty(PROPERTY_SESSION_INTERVAL, 30*60 + "");
|
properties.setProperty(PROPERTY_SESSION_INTERVAL, 30*60 + "");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1.5");
|
properties.setProperty(PROPERTY_API_VERSION, "1.5");
|
||||||
return properties;
|
return properties;
|
||||||
|
|
|
@ -42,10 +42,14 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.annotations.Login;
|
import org.jclouds.vcloud.director.v1_5.annotations.Login;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
|
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.TaskClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
|
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
|
||||||
import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
|
import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
|
||||||
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
|
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
|
||||||
|
@ -73,8 +77,10 @@ import com.google.inject.name.Named;
|
||||||
public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirectorClient, VCloudDirectorAsyncClient> {
|
public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirectorClient, VCloudDirectorAsyncClient> {
|
||||||
|
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||||
.put(OrgClient.class, OrgAsyncClient.class)
|
.put(CatalogClient.class, CatalogAsyncClient.class)
|
||||||
.put(NetworkClient.class, NetworkAsyncClient.class)
|
.put(NetworkClient.class, NetworkAsyncClient.class)
|
||||||
|
.put(OrgClient.class, OrgAsyncClient.class)
|
||||||
|
.put(TaskClient.class, TaskAsyncClient.class)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public VCloudDirectorRestClientModule() {
|
public VCloudDirectorRestClientModule() {
|
||||||
|
@ -85,8 +91,8 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
// session client is used directly for filters and retry handlers, so let's bind it explicitly
|
// session client is used directly for filters and retry handlers, so let's bind it explicitly
|
||||||
bindClientAndAsyncClient(binder(), SessionClient.class, SessionAsyncClient.class);
|
bindClientAndAsyncClient(binder(), SessionClient.class, SessionAsyncClient.class);
|
||||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
bindClientAndAsyncClient(binder(), OrgClient.class, OrgAsyncClient.class);
|
||||||
InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
|
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,239 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for references to VappTemplate and Media objects.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="CatalogType" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Catalog")
|
||||||
|
public class Catalog extends EntityType<Catalog> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromCatalog(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends EntityType.Builder<Catalog> {
|
||||||
|
|
||||||
|
private Entity owner;
|
||||||
|
private CatalogItems catalogItems;
|
||||||
|
private Boolean isPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Catalog#getOwner()
|
||||||
|
*/
|
||||||
|
public Builder owner(Entity owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Catalog#getCatalogItems()
|
||||||
|
*/
|
||||||
|
public Builder catalogItems(CatalogItems catalogItems) {
|
||||||
|
this.catalogItems = catalogItems;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Catalog#isPublished()
|
||||||
|
*/
|
||||||
|
public Builder isPublished(Boolean isPublished) {
|
||||||
|
this.isPublished = isPublished;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Catalog#isPublished()
|
||||||
|
*/
|
||||||
|
public Builder published() {
|
||||||
|
this.isPublished = Boolean.TRUE;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Catalog build() {
|
||||||
|
Catalog catalog = new Catalog(href, name);
|
||||||
|
catalog.setOwner(owner);
|
||||||
|
catalog.setCatalogItems(catalogItems);
|
||||||
|
catalog.setIsPublished(isPublished);
|
||||||
|
catalog.setDescription(description);
|
||||||
|
catalog.setId(id);
|
||||||
|
catalog.setType(type);
|
||||||
|
catalog.setLinks(links);
|
||||||
|
catalog.setTasksInProgress(tasksInProgress);
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getDescription()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder links(Set<Link> links) {
|
||||||
|
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder link(Link link) {
|
||||||
|
this.links.add(checkNotNull(link, "link"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder fromEntityType(EntityType<Catalog> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromCatalog(Catalog in) {
|
||||||
|
return fromEntityType(in).owner(in.getOwner()).catalogItems(in.getCatalogItems()).isPublished(in.isPublished());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Catalog() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private Catalog(URI href, String name) {
|
||||||
|
super(href, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Owner")
|
||||||
|
private Entity owner;
|
||||||
|
@XmlElement(name = "CatalogItems")
|
||||||
|
private CatalogItems catalogItems;
|
||||||
|
@XmlElement(name = "IsPublished")
|
||||||
|
private Boolean isPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the owner property.
|
||||||
|
*/
|
||||||
|
public Entity getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(Entity value) {
|
||||||
|
this.owner = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the catalogItems property.
|
||||||
|
*/
|
||||||
|
public CatalogItems getCatalogItems() {
|
||||||
|
return catalogItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCatalogItems(CatalogItems value) {
|
||||||
|
this.catalogItems = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the isPublished property.
|
||||||
|
*/
|
||||||
|
public Boolean isPublished() {
|
||||||
|
return isPublished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublished(Boolean value) {
|
||||||
|
this.isPublished = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,222 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Contains a reference to a VappTemplate or Media object and related metadata.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="CatalogItemType" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogItem")
|
||||||
|
public class CatalogItem extends EntityType<CatalogItem> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromCatalogItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends EntityType.Builder<CatalogItem> {
|
||||||
|
|
||||||
|
private Reference entity;
|
||||||
|
private List<Property> properties = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogItem#getEntity()
|
||||||
|
*/
|
||||||
|
public Builder entity(Reference entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogItem#getProperties()
|
||||||
|
*/
|
||||||
|
public Builder properties(List<Property> properties) {
|
||||||
|
this.properties = Lists.newArrayList(checkNotNull(properties, "properties"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogItem#getProperties()
|
||||||
|
*/
|
||||||
|
public Builder property(Property property) {
|
||||||
|
this.properties.add(checkNotNull(property, "property"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatalogItem build() {
|
||||||
|
CatalogItem catalog = new CatalogItem(href, name, entity);
|
||||||
|
catalog.setProperties(properties);
|
||||||
|
catalog.setDescription(description);
|
||||||
|
catalog.setId(id);
|
||||||
|
catalog.setType(type);
|
||||||
|
catalog.setLinks(links);
|
||||||
|
catalog.setTasksInProgress(tasksInProgress);
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getDescription()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder links(Set<Link> links) {
|
||||||
|
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder link(Link link) {
|
||||||
|
this.links.add(checkNotNull(link, "link"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder fromEntityType(EntityType<CatalogItem> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromCatalogItem(CatalogItem in) {
|
||||||
|
return fromEntityType(in).entity(in.getEntity()).properties(in.getProperties());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogItem() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogItem(URI href, String name, Reference entity) {
|
||||||
|
super(href, name);
|
||||||
|
this.entity = entity;
|
||||||
|
this.setProperties(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Entity", required = true)
|
||||||
|
private Reference entity;
|
||||||
|
@XmlElement(name = "Property")
|
||||||
|
private List<Property> properties = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to a VappTemplate or Media object.
|
||||||
|
*/
|
||||||
|
public Reference getEntity() {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User-specified key/value pair.
|
||||||
|
*
|
||||||
|
* This element has been superseded by the {@link Metadata} element, which is the preferred way to specify key/value pairs for objects.
|
||||||
|
*/
|
||||||
|
public List<Property> getProperties() {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(List<Property> properties) {
|
||||||
|
this.properties = Lists.newArrayList(checkNotNull(properties, "properties"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProperty(Property property) {
|
||||||
|
this.properties.add(checkNotNull(property, "property"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a list of catalog item references.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="CatalogItemsType" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogItems")
|
||||||
|
public class CatalogItems {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS;
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private List<Reference> catalogItems = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogItems#getCatalogItems()
|
||||||
|
*/
|
||||||
|
public Builder items(List<Reference> catalogItems) {
|
||||||
|
this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogItems#getCatalogItems()
|
||||||
|
*/
|
||||||
|
public Builder item(Reference catalogItem) {
|
||||||
|
this.catalogItems.add(checkNotNull(catalogItem, "catalogItem"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CatalogItems build() {
|
||||||
|
return new CatalogItems(catalogItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromCatalogItems(CatalogItems in) {
|
||||||
|
return items(in.getCatalogItems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogItems() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogItems(Collection<Reference> tasks) {
|
||||||
|
this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "CatalogItem")
|
||||||
|
private List<Reference> catalogItems = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the catalogItems property.
|
||||||
|
*/
|
||||||
|
public List<Reference> getCatalogItems() {
|
||||||
|
return this.catalogItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCatalogItems(List<Reference> catalogItems) {
|
||||||
|
this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCatalogItem(Reference catalogItem) {
|
||||||
|
this.catalogItems.add(checkNotNull(catalogItem, "catalogItem"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for ReferenceType elements that reference catalogs.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="CatalogsListType" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogsList")
|
||||||
|
public class CatalogsList {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS;
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private List<Reference> catalogReferences = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogsList#getCatalogItems()
|
||||||
|
*/
|
||||||
|
public Builder catalogs(List<Reference> catalogReferences) {
|
||||||
|
this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogsList#getCatalogItems()
|
||||||
|
*/
|
||||||
|
public Builder catalog(Reference catalog) {
|
||||||
|
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CatalogsList build() {
|
||||||
|
return new CatalogsList(catalogReferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromCatalogsList(CatalogsList in) {
|
||||||
|
return catalogs(in.getCatalogsList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogsList() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatalogsList(Collection<Reference> tasks) {
|
||||||
|
this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "CatalogReference")
|
||||||
|
private List<Reference> catalogReferences = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the catalogReferences property.
|
||||||
|
*/
|
||||||
|
public List<Reference> getCatalogsList() {
|
||||||
|
return this.catalogReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCatalogsList(List<Reference> catalogReferences) {
|
||||||
|
this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCatalog(Reference catalog) {
|
||||||
|
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -147,7 +147,9 @@ public class Entity extends EntityType<Entity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Entity that = Entity.class.cast(o);
|
Entity that = Entity.class.cast(o);
|
||||||
return super.equals(that);
|
return super.equals(that);
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -143,7 +143,6 @@ public class EntityType<T extends EntityType<T>> extends ResourceType<T> {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Builder<T> fromResourceType(ResourceType<T> in) {
|
public Builder<T> fromResourceType(ResourceType<T> in) {
|
||||||
return Builder.class.cast(super.fromResourceType(in));
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
|
@ -156,9 +155,9 @@ public class EntityType<T extends EntityType<T>> extends ResourceType<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Description")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Description")
|
||||||
private String description;
|
private String description;
|
||||||
@XmlElement(namespace = NS, name = "TasksInProgress")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "TasksInProgress")
|
||||||
private TasksInProgress tasksInProgress;
|
private TasksInProgress tasksInProgress;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -212,11 +211,6 @@ public class EntityType<T extends EntityType<T>> extends ResourceType<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the name of the the entity.
|
* Contains the name of the the entity.
|
||||||
*
|
|
||||||
* The object type, specified as a MIME content type, of the object that the link references.
|
|
||||||
* This attribute is present only for links to objects. It is not present for links to actions.
|
|
||||||
*
|
|
||||||
* @return type definition, type, expressed as an HTTP Content-Type
|
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -224,12 +218,14 @@ public class EntityType<T extends EntityType<T>> extends ResourceType<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
EntityType<?> that = EntityType.class.cast(o);
|
EntityType<?> that = EntityType.class.cast(o);
|
||||||
return super.equals(that) &&
|
return super.equals(that) &&
|
||||||
equal(this.id, that.id) && equal(this.description, that.description) &&
|
equal(this.id, that.id) && equal(this.description, that.description) &&
|
||||||
equal(this.tasksInProgress, that.tasksInProgress);
|
equal(this.tasksInProgress, that.tasksInProgress) && equal(this.name, that.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,15 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,9 +40,11 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Error")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Error")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Error {
|
public class Error {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.ERROR;
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -107,17 +111,17 @@ public class Error {
|
||||||
|
|
||||||
public Builder fromError(Error in) {
|
public Builder fromError(Error in) {
|
||||||
return message(in.getMessage())
|
return message(in.getMessage())
|
||||||
.majorErrorCode(in.getMajorErrorCode())
|
.majorErrorCode(in.getMajorErrorCode())
|
||||||
.minorErrorCode(in.getMinorErrorCode())
|
.minorErrorCode(in.getMinorErrorCode())
|
||||||
.vendorSpecificErrorCode(in.getVendorSpecificErrorCode())
|
.vendorSpecificErrorCode(in.getVendorSpecificErrorCode())
|
||||||
.stackTrace(in.getStackTrace());
|
.stackTrace(in.getStackTrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String message;
|
private String message;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private int majorErrorCode;
|
private Integer majorErrorCode;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String minorErrorCode;
|
private String minorErrorCode;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
|
@ -125,9 +129,9 @@ public class Error {
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String stackTrace;
|
private String stackTrace;
|
||||||
|
|
||||||
private Error(String message, int majorErrorCode, String minorErrorCode) {
|
private Error(String message, Integer majorErrorCode, String minorErrorCode) {
|
||||||
this.message = checkNotNull(message, "message");
|
this.message = checkNotNull(message, "message");
|
||||||
this.majorErrorCode = majorErrorCode;
|
this.majorErrorCode = checkNotNull(majorErrorCode, "majorErrorCode");
|
||||||
this.minorErrorCode = checkNotNull(minorErrorCode, "minorErrorCode");
|
this.minorErrorCode = checkNotNull(minorErrorCode, "minorErrorCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +149,7 @@ public class Error {
|
||||||
/**
|
/**
|
||||||
* The class of the error. Matches the HTTP status code.
|
* The class of the error. Matches the HTTP status code.
|
||||||
*/
|
*/
|
||||||
public int getMajorErrorCode() {
|
public Integer getMajorErrorCode() {
|
||||||
return majorErrorCode;
|
return majorErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,10 +186,11 @@ public class Error {
|
||||||
this.stackTrace = stackTrace;
|
this.stackTrace = stackTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Error that = (Error) o;
|
Error that = (Error) o;
|
||||||
return equal(this.message, that.message) &&
|
return equal(this.message, that.message) &&
|
||||||
|
@ -197,15 +202,14 @@ public class Error {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.hashCode() + Objects.hashCode(message, majorErrorCode, minorErrorCode, vendorSpecificErrorCode, stackTrace);
|
return Objects.hashCode(message, majorErrorCode, minorErrorCode, vendorSpecificErrorCode, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper("")
|
||||||
.add("message", message)
|
.add("message", message).add("majorErrorCode", majorErrorCode).add("minorErrorCode", minorErrorCode)
|
||||||
.add("majorErrorCode", majorErrorCode)
|
.add("vendorSpecificErrorCode", vendorSpecificErrorCode).add("stackTrace", stackTrace)
|
||||||
.add("minorErrorCode", minorErrorCode)
|
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "IpAddresses")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpAddresses")
|
||||||
public class IpAddresses {
|
public class IpAddresses {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -83,7 +83,7 @@ public class IpAddresses {
|
||||||
this.ipAddresses = ImmutableSet.copyOf(orgs);
|
this.ipAddresses = ImmutableSet.copyOf(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "IpAddress")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IpAddress")
|
||||||
private Set<String> ipAddresses = Sets.newLinkedHashSet();
|
private Set<String> ipAddresses = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<String> getIpAddresses() {
|
public Set<String> getIpAddresses() {
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
@ -31,7 +31,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "IpRange")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpRange")
|
||||||
public class IpRange {
|
public class IpRange {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -82,9 +82,9 @@ public class IpRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "StartAddress")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "StartAddress")
|
||||||
private String startAddress;
|
private String startAddress;
|
||||||
@XmlElement(namespace = NS, name = "EndAddress")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "EndAddress")
|
||||||
private String endAddress;
|
private String endAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "IpRanges")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpRanges")
|
||||||
public class IpRanges {
|
public class IpRanges {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -83,7 +83,7 @@ public class IpRanges {
|
||||||
this.ipRanges = ImmutableSet.copyOf(ipRanges);
|
this.ipRanges = ImmutableSet.copyOf(ipRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "IpRange")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IpRange")
|
||||||
private Set<IpRange> ipRanges = Sets.newLinkedHashSet();
|
private Set<IpRange> ipRanges = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<IpRange> getIpRanges() {
|
public Set<IpRange> getIpRanges() {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
@ -33,7 +33,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "IpScope")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpScope")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class IpScope {
|
public class IpScope {
|
||||||
|
|
||||||
|
@ -151,21 +151,21 @@ public class IpScope {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "IsInherited")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IsInherited")
|
||||||
private boolean isInherited;
|
private boolean isInherited;
|
||||||
@XmlElement(namespace = NS, name = "Gateway")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Gateway")
|
||||||
private String gateway;
|
private String gateway;
|
||||||
@XmlElement(namespace = NS, name = "Netmask")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Netmask")
|
||||||
private String netmask;
|
private String netmask;
|
||||||
@XmlElement(namespace = NS, name = "Dns1")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Dns1")
|
||||||
private String dns1;
|
private String dns1;
|
||||||
@XmlElement(namespace = NS, name = "Dns2")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Dns2")
|
||||||
private String dns2;
|
private String dns2;
|
||||||
@XmlElement(namespace = NS, name = "DnsSuffix")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "DnsSuffix")
|
||||||
private String dnsSuffix;
|
private String dnsSuffix;
|
||||||
@XmlElement(namespace = NS, name = "IpRanges")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IpRanges")
|
||||||
private IpRanges ipRanges;
|
private IpRanges ipRanges;
|
||||||
@XmlElement(namespace = NS, name = "AllocatedIpAddresses")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "AllocatedIpAddresses")
|
||||||
private IpAddresses allocatedIpAddresses;
|
private IpAddresses allocatedIpAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -159,7 +159,9 @@ public class Link extends ReferenceType<Link> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Link that = (Link) o;
|
Link that = (Link) o;
|
||||||
return super.equals(that) && equal(this.rel, that.rel);
|
return super.equals(that) && equal(this.rel, that.rel);
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,6 +28,9 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry.Builder;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -42,16 +45,19 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Metadata")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Metadata")
|
||||||
public class Metadata extends ResourceType<Metadata>{
|
public class Metadata extends ResourceType<Metadata> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Builder toBuilder() {
|
public Builder toBuilder() {
|
||||||
return new Builder().fromMetadataList(this);
|
return new Builder().fromMetadata(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends ResourceType.Builder<Metadata> {
|
public static class Builder extends ResourceType.Builder<Metadata> {
|
||||||
|
@ -74,6 +80,7 @@ public class Metadata extends ResourceType<Metadata>{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Metadata build() {
|
public Metadata build() {
|
||||||
Metadata metadata = new Metadata(href, metadataEntries);
|
Metadata metadata = new Metadata(href, metadataEntries);
|
||||||
metadata.setType(type);
|
metadata.setType(type);
|
||||||
|
@ -117,8 +124,16 @@ public class Metadata extends ResourceType<Metadata>{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromMetadataList(Metadata in) {
|
public Builder fromMetadata(Metadata in) {
|
||||||
return metadata(in.getMetadata());
|
return fromResourceType(in).metadata(in.getMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromResourceType(ResourceType<Metadata> in) {
|
||||||
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,32 +143,34 @@ public class Metadata extends ResourceType<Metadata>{
|
||||||
|
|
||||||
private Metadata(URI href, Set<MetadataEntry> metadataEntries) {
|
private Metadata(URI href, Set<MetadataEntry> metadataEntries) {
|
||||||
super(href);
|
super(href);
|
||||||
this.metadata = ImmutableSet.copyOf(metadataEntries);
|
this.metadataEntries = ImmutableSet.copyOf(metadataEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "MetadataEntry")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "MetadataEntry")
|
||||||
private Set<MetadataEntry> metadata = Sets.newLinkedHashSet();
|
private Set<MetadataEntry> metadataEntries = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<MetadataEntry> getMetadata() {
|
public Set<MetadataEntry> getMetadata() {
|
||||||
return ImmutableSet.copyOf(metadata);
|
return ImmutableSet.copyOf(metadataEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Metadata that = Metadata.class.cast(o);
|
Metadata that = Metadata.class.cast(o);
|
||||||
return super.equals(that) && equal(metadata, that.metadata);
|
return super.equals(that) && equal(this.metadataEntries, that.metadataEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.hashCode() + Objects.hashCode(metadata);
|
return super.hashCode() + Objects.hashCode(metadataEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToStringHelper string() {
|
public ToStringHelper string() {
|
||||||
return super.string().add("metadata", metadata);
|
return super.string().add("metadataEntries", metadataEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,6 +28,8 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -41,16 +43,19 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "TODO")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "MetadataEntry")
|
||||||
public class MetadataEntry extends ResourceType<MetadataEntry> {
|
public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Builder toBuilder() {
|
public Builder toBuilder() {
|
||||||
return new Builder().fromMetadata(this);
|
return new Builder().fromMetadataEntry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends ResourceType.Builder<MetadataEntry> {
|
public static class Builder extends ResourceType.Builder<MetadataEntry> {
|
||||||
|
@ -58,7 +63,7 @@ public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see MetadataEntry#getKey
|
* @see MetadataEntry#getKey()
|
||||||
*/
|
*/
|
||||||
public Builder key(String key) {
|
public Builder key(String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -66,13 +71,24 @@ public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see MetadataEntry#getValue
|
* @see MetadataEntry#getValue()
|
||||||
*/
|
*/
|
||||||
public Builder value(String value) {
|
public Builder value(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see MetadataEntry#getKey()
|
||||||
|
* @see MetadataEntry#getValue()
|
||||||
|
*/
|
||||||
|
public Builder entry(String key, String value) {
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MetadataEntry build() {
|
public MetadataEntry build() {
|
||||||
MetadataEntry metadataEntry = new MetadataEntry(href, key, value);
|
MetadataEntry metadataEntry = new MetadataEntry(href, key, value);
|
||||||
metadataEntry.setType(type);
|
metadataEntry.setType(type);
|
||||||
|
@ -116,10 +132,17 @@ public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromMetadata(MetadataEntry in) {
|
public Builder fromMetadataEntry(MetadataEntry in) {
|
||||||
return key(in.getKey()).value(in.getValue());
|
return fromResourceType(in).entry(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromResourceType(ResourceType<MetadataEntry> in) {
|
||||||
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MetadataEntry() {
|
private MetadataEntry() {
|
||||||
|
@ -132,13 +155,12 @@ public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
this.value = checkNotNull(value, "value");
|
this.value = checkNotNull(value, "value");
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "K")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Key")
|
||||||
private String key;
|
private String key;
|
||||||
@XmlElement(namespace = NS, name = "Value")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Value")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return key of the entry
|
* @return key of the entry
|
||||||
*/
|
*/
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
|
@ -146,25 +168,25 @@ public class MetadataEntry extends ResourceType<MetadataEntry> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return value of the entry
|
* @return value of the entry
|
||||||
*/
|
*/
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
MetadataEntry that = MetadataEntry.class.cast(o);
|
MetadataEntry that = MetadataEntry.class.cast(o);
|
||||||
return super.equals(that) && equal(key, that.key);
|
return super.equals(that) && equal(key, that.key) && equal(this.value, that.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.hashCode() + Objects.hashCode(key);
|
return super.hashCode() + Objects.hashCode(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,167 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.*;
|
||||||
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a metadata entry
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <xs:complexType name="MetadataType">
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "MetadataValue")
|
||||||
|
public class MetadataValue extends ResourceType<MetadataValue> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromMetadataValue(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends ResourceType.Builder<MetadataValue> {
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see MetadataValue#getValue
|
||||||
|
*/
|
||||||
|
public Builder value(String value) {
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetadataValue build() {
|
||||||
|
MetadataValue metadataValue = new MetadataValue(href, value);
|
||||||
|
metadataValue.setType(type);
|
||||||
|
metadataValue.setLinks(links);
|
||||||
|
return metadataValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getHref()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
super.href(href);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
super.type(type);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder links(Set<Link> links) {
|
||||||
|
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder link(Link link) {
|
||||||
|
super.link(link);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromMetadataValue(MetadataValue in) {
|
||||||
|
return fromResourceType(in).value(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromResourceType(ResourceType<MetadataValue> in) {
|
||||||
|
return Builder.class.cast(super.fromResourceType(in));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataValue() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataValue(URI href, String value) {
|
||||||
|
super(href);
|
||||||
|
this.value = checkNotNull(value, "value");
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Value", required = true)
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value.
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
MetadataValue that = MetadataValue.class.cast(o);
|
||||||
|
return super.equals(that) && equal(this.value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() + Objects.hashCode(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToStringHelper string() {
|
||||||
|
return super.string().add("value", value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
@ -33,7 +33,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "NetworkConfiguration")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkConfiguration")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class NetworkConfiguration{
|
public class NetworkConfiguration{
|
||||||
|
|
||||||
|
@ -138,19 +138,19 @@ public class NetworkConfiguration{
|
||||||
this.fenceMode = fenceMode;
|
this.fenceMode = fenceMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "IpScope")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IpScope")
|
||||||
private IpScope ipScope;
|
private IpScope ipScope;
|
||||||
@XmlElement(namespace = NS, name = "ParentNetwork")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "ParentNetwork")
|
||||||
private ReferenceType<?> parentNetwork;
|
private ReferenceType<?> parentNetwork;
|
||||||
@XmlElement(namespace = NS, name = "FenceMode")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "FenceMode")
|
||||||
private String fenceMode;
|
private String fenceMode;
|
||||||
@XmlElement(namespace = NS, name = "RetainNetInfoAcrossDeployments")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "RetainNetInfoAcrossDeployments")
|
||||||
private boolean retainNetInfoAcrossDeployments = false;
|
private boolean retainNetInfoAcrossDeployments = false;
|
||||||
@XmlElement(namespace = NS, name = "Features")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Features")
|
||||||
private NetworkFeatures features;
|
private NetworkFeatures features;
|
||||||
@XmlElement(namespace = NS, name = "SyslogServerSettings")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerSettings")
|
||||||
private SyslogServerSettings syslogServerSettings;
|
private SyslogServerSettings syslogServerSettings;
|
||||||
@XmlElement(namespace = NS, name = "RouterInfo")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "RouterInfo")
|
||||||
private RouterInfo routerInfo;
|
private RouterInfo routerInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Features")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Features")
|
||||||
public class NetworkFeatures {
|
public class NetworkFeatures {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -82,7 +82,7 @@ public class NetworkFeatures {
|
||||||
// For JAXB and builder use
|
// For JAXB and builder use
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "NetworkService")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "NetworkService")
|
||||||
private Set<NetworkService> services = Sets.newLinkedHashSet();
|
private Set<NetworkService> services = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
@ -31,7 +31,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "NetworkService")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkService")
|
||||||
public class NetworkService {
|
public class NetworkService {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -69,7 +69,7 @@ public class NetworkService {
|
||||||
// For JAXB and builder use
|
// For JAXB and builder use
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "IsEnabled")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IsEnabled")
|
||||||
private boolean isEnabled;
|
private boolean isEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,6 +28,8 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -43,8 +45,10 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Org")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Org")
|
||||||
public class Org extends EntityType<Org> {
|
public class Org extends EntityType<Org> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -59,6 +63,7 @@ public class Org extends EntityType<Org> {
|
||||||
public static class Builder extends EntityType.Builder<Org> {
|
public static class Builder extends EntityType.Builder<Org> {
|
||||||
|
|
||||||
private String fullName;
|
private String fullName;
|
||||||
|
private Boolean isEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Org#getFullName()
|
* @see Org#getFullName()
|
||||||
|
@ -68,6 +73,30 @@ public class Org extends EntityType<Org> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Org#isEnabled()
|
||||||
|
*/
|
||||||
|
public Builder isEnabled(Boolean isEnabled) {
|
||||||
|
this.isEnabled = isEnabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Org#isEnabled()
|
||||||
|
*/
|
||||||
|
public Builder enabled() {
|
||||||
|
this.isEnabled = Boolean.TRUE;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Org#isEnabled()
|
||||||
|
*/
|
||||||
|
public Builder disabled() {
|
||||||
|
this.isEnabled = Boolean.FALSE;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Org build() {
|
public Org build() {
|
||||||
Org org = new Org(href, name, fullName);
|
Org org = new Org(href, name, fullName);
|
||||||
|
@ -76,6 +105,7 @@ public class Org extends EntityType<Org> {
|
||||||
org.setType(type);
|
org.setType(type);
|
||||||
org.setLinks(links);
|
org.setLinks(links);
|
||||||
org.setTasksInProgress(tasksInProgress);
|
org.setTasksInProgress(tasksInProgress);
|
||||||
|
org.setIsEnabled(isEnabled);
|
||||||
return org;
|
return org;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,32 +200,46 @@ public class Org extends EntityType<Org> {
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "FullName")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "FullName", required = true)
|
||||||
private String fullName;
|
private String fullName;
|
||||||
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "IsEnabled")
|
||||||
|
private Boolean isEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Full name of the organization.
|
||||||
* @return fullName of the org
|
|
||||||
*/
|
*/
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
return fullName;
|
return fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full name of the organization.
|
||||||
|
*/
|
||||||
|
public Boolean isEnabled() {
|
||||||
|
return isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsEnabled(Boolean isEnabled) {
|
||||||
|
this.isEnabled = isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Org that = Org.class.cast(o);
|
Org that = Org.class.cast(o);
|
||||||
return super.equals(that) && equal(fullName, that.fullName);
|
return super.equals(that) && equal(fullName, that.fullName) && equal(this.isEnabled, that.isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.hashCode() + Objects.hashCode(fullName);
|
return super.hashCode() + Objects.hashCode(fullName, isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToStringHelper string() {
|
public ToStringHelper string() {
|
||||||
return super.string().add("fullName", fullName);
|
return super.string().add("fullName", fullName).add("isEnabled", isEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -36,8 +38,10 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "OrgList")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "OrgList")
|
||||||
public class OrgList {
|
public class OrgList {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG_LIST;
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -84,7 +88,7 @@ public class OrgList {
|
||||||
this.orgs = ImmutableSet.copyOf(orgs);
|
this.orgs = ImmutableSet.copyOf(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Org")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Org")
|
||||||
private Set<Reference> orgs = Sets.newLinkedHashSet();
|
private Set<Reference> orgs = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<Reference> getOrgs() {
|
public Set<Reference> getOrgs() {
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,13 +28,11 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.jclouds.ovf.Network;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
@XmlRootElement(namespace = NS, name = "OrgNetwork")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "OrgNetwork")
|
||||||
public class OrgNetwork extends EntityType<OrgNetwork> {
|
public class OrgNetwork extends EntityType<OrgNetwork> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -54,7 +52,7 @@ public class OrgNetwork extends EntityType<OrgNetwork> {
|
||||||
private IpAddresses allowedExternalIpAddresses;
|
private IpAddresses allowedExternalIpAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Network#getConfiguration()
|
* @see OrgNetwork#getConfiguration()
|
||||||
*/
|
*/
|
||||||
public Builder configuration(NetworkConfiguration networkConfiguration) {
|
public Builder configuration(NetworkConfiguration networkConfiguration) {
|
||||||
this.networkConfiguration = networkConfiguration;
|
this.networkConfiguration = networkConfiguration;
|
||||||
|
@ -62,7 +60,7 @@ public class OrgNetwork extends EntityType<OrgNetwork> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Network#getNetworkPool()
|
* @see OrgNetwork#getNetworkPool()
|
||||||
*/
|
*/
|
||||||
public Builder networkPool(ReferenceType<?> networkPool) {
|
public Builder networkPool(ReferenceType<?> networkPool) {
|
||||||
this.networkPool = networkPool;
|
this.networkPool = networkPool;
|
||||||
|
@ -70,7 +68,7 @@ public class OrgNetwork extends EntityType<OrgNetwork> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Network#getAllowedExternalIpAddresses()
|
* @see OrgNetwork#getAllowedExternalIpAddresses()
|
||||||
*/
|
*/
|
||||||
public Builder allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
|
public Builder allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
|
||||||
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
|
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
|
||||||
|
@ -183,11 +181,11 @@ public class OrgNetwork extends EntityType<OrgNetwork> {
|
||||||
super(href, name);
|
super(href, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Configuration")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Configuration")
|
||||||
private NetworkConfiguration networkConfiguration;
|
private NetworkConfiguration networkConfiguration;
|
||||||
@XmlElement(namespace = NS, name = "NetworkPool")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "NetworkPool")
|
||||||
private ReferenceType<?> networkPool;
|
private ReferenceType<?> networkPool;
|
||||||
@XmlElement(namespace = NS, name = "AllowedExternalIpAddresses")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "AllowedExternalIpAddresses")
|
||||||
private IpAddresses allowedExternalIpAddresses;
|
private IpAddresses allowedExternalIpAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains key/value pair as property.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="PropertyType" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Property")
|
||||||
|
public class Property {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.PROPERTY;
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Property#getKey()
|
||||||
|
*/
|
||||||
|
public Builder key(String key) {
|
||||||
|
this.key = key;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Property#getValue()
|
||||||
|
*/
|
||||||
|
public Builder value(String value) {
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Property#getKey()
|
||||||
|
* @see Property#getValue()
|
||||||
|
*/
|
||||||
|
public Builder property(String key, String value) {
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Property build() {
|
||||||
|
Property property = new Property(key);
|
||||||
|
property.setValue(value);
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromProperty(Property in) {
|
||||||
|
return property(in.getKey(), in.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Property() {
|
||||||
|
// For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private Property(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlValue
|
||||||
|
private String value;
|
||||||
|
@XmlAttribute(required = true)
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the value property.
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the key property.
|
||||||
|
*/
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,7 +42,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ReferenceType<T extends ReferenceType<T>> {
|
public class ReferenceType<T extends ReferenceType<T>> implements URISupplier {
|
||||||
|
|
||||||
public static <T extends ReferenceType<T>> Builder<T> builder() {
|
public static <T extends ReferenceType<T>> Builder<T> builder() {
|
||||||
return new Builder<T>();
|
return new Builder<T>();
|
||||||
|
@ -189,8 +189,9 @@ public class ReferenceType<T extends ReferenceType<T>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getHref()
|
* @see URISupplier#getURI()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public URI getURI() {
|
public URI getURI() {
|
||||||
return getHref();
|
return getHref();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +47,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ResourceType<T extends ResourceType<T>> {
|
public class ResourceType<T extends ResourceType<T>> implements URISupplier {
|
||||||
|
|
||||||
public static <T extends ResourceType<T>> Builder<T> builder() {
|
public static <T extends ResourceType<T>> Builder<T> builder() {
|
||||||
return new Builder<T>();
|
return new Builder<T>();
|
||||||
|
@ -110,7 +111,7 @@ public class ResourceType<T extends ResourceType<T>> {
|
||||||
private URI href;
|
private URI href;
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String type;
|
private String type;
|
||||||
@XmlElement(namespace = NS, name = "Link")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Link")
|
||||||
private Set<Link> links = Sets.newLinkedHashSet();
|
private Set<Link> links = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
protected ResourceType(URI href) {
|
protected ResourceType(URI href) {
|
||||||
|
@ -138,6 +139,14 @@ public class ResourceType<T extends ResourceType<T>> {
|
||||||
return href;
|
return href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see URISupplier#getURI()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public URI getURI() {
|
||||||
|
return getHref();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the type of the the entity.
|
* Contains the type of the the entity.
|
||||||
*
|
*
|
||||||
|
@ -157,7 +166,7 @@ public class ResourceType<T extends ResourceType<T>> {
|
||||||
/**
|
/**
|
||||||
* Set of optional links to an entity or operation associated with this object.
|
* Set of optional links to an entity or operation associated with this object.
|
||||||
*/
|
*/
|
||||||
public Set<Link>getLinks() {
|
public Set<Link> getLinks() {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,13 +178,6 @@ public class ResourceType<T extends ResourceType<T>> {
|
||||||
this.links.add(checkNotNull(link, "link"));
|
this.links.add(checkNotNull(link, "link"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #getHref()
|
|
||||||
*/
|
|
||||||
public URI getURI() {
|
|
||||||
return getHref();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
@ -199,4 +201,4 @@ public class ResourceType<T extends ResourceType<T>> {
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type);
|
return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
@ -31,7 +31,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "RouterInfo")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "RouterInfo")
|
||||||
public class RouterInfo {
|
public class RouterInfo {
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -71,7 +71,7 @@ public class RouterInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "ExternalIp")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "ExternalIp")
|
||||||
private String externalIp;
|
private String externalIp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -42,9 +44,11 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Session")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Session")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Session {
|
public class Session {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.SESSION;
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -120,7 +124,7 @@ public class Session {
|
||||||
this.links = ImmutableSet.copyOf(links);
|
this.links = ImmutableSet.copyOf(links);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Link")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Link")
|
||||||
private Set<Link> links = Sets.newLinkedHashSet();
|
private Set<Link> links = Sets.newLinkedHashSet();
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String user;
|
private String user;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SessionWithToken {
|
||||||
protected String token;
|
protected String token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see SessionWithToken#getType
|
* @see SessionWithToken#getSession()
|
||||||
*/
|
*/
|
||||||
public Builder session(Session session) {
|
public Builder session(Session session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
@ -51,7 +51,7 @@ public class SessionWithToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see SessionWithToken#getHref
|
* @see SessionWithToken#getToken()
|
||||||
*/
|
*/
|
||||||
public Builder token(String token) {
|
public Builder token(String token) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
@ -34,7 +34,7 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "SyslogServerSettings")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerSettings")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class SyslogServerSettings {
|
public class SyslogServerSettings {
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ public class SyslogServerSettings {
|
||||||
// For JAXB and builder use
|
// For JAXB and builder use
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "SyslogServerIp1")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerIp1")
|
||||||
private String syslogServerIp1;
|
private String syslogServerIp1;
|
||||||
@XmlElement(namespace = NS, name = "SyslogServerIp2")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerIp2")
|
||||||
private String syslogServerIp2;
|
private String syslogServerIp2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIOXMLNS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.domain;
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -43,8 +45,10 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "Task")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Task")
|
||||||
public class Task extends EntityType<Task> {
|
public class Task extends EntityType<Task> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -59,7 +63,10 @@ public class Task extends EntityType<Task> {
|
||||||
public static class Builder extends EntityType.Builder<Task> {
|
public static class Builder extends EntityType.Builder<Task> {
|
||||||
|
|
||||||
private Error error;
|
private Error error;
|
||||||
private Org org;
|
private Reference org;
|
||||||
|
private Reference owner;
|
||||||
|
private Reference user;
|
||||||
|
private Object params;
|
||||||
private Integer progress;
|
private Integer progress;
|
||||||
private String status;
|
private String status;
|
||||||
private String operation;
|
private String operation;
|
||||||
|
@ -79,11 +86,35 @@ public class Task extends EntityType<Task> {
|
||||||
/**
|
/**
|
||||||
* @see Task#getOrg()
|
* @see Task#getOrg()
|
||||||
*/
|
*/
|
||||||
public Builder org(Org org) {
|
public Builder org(Reference org) {
|
||||||
this.org = org;
|
this.org = org;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Task#getOwner()
|
||||||
|
*/
|
||||||
|
public Builder owner(Reference owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Task#getUser()
|
||||||
|
*/
|
||||||
|
public Builder user(Reference user) {
|
||||||
|
this.user = user;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Task#getParams()
|
||||||
|
*/
|
||||||
|
public Builder params(Object params) {
|
||||||
|
this.params = params;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Task#getProgress()
|
* @see Task#getProgress()
|
||||||
*/
|
*/
|
||||||
|
@ -143,8 +174,16 @@ public class Task extends EntityType<Task> {
|
||||||
@Override
|
@Override
|
||||||
public Task build() {
|
public Task build() {
|
||||||
Task task = new Task(href, name);
|
Task task = new Task(href, name);
|
||||||
|
task.setDescription(description);
|
||||||
|
task.setTasksInProgress(tasksInProgress);
|
||||||
|
task.setId(id);
|
||||||
|
task.setType(type);
|
||||||
|
task.setLinks(links);
|
||||||
task.setError(error);
|
task.setError(error);
|
||||||
task.setOrg(org);
|
task.setOrg(org);
|
||||||
|
task.setOwner(owner);
|
||||||
|
task.setUser(user);
|
||||||
|
task.setParams(params);
|
||||||
task.setProgress(progress);
|
task.setProgress(progress);
|
||||||
task.setStatus(status);
|
task.setStatus(status);
|
||||||
task.setOperation(operation);
|
task.setOperation(operation);
|
||||||
|
@ -247,31 +286,34 @@ public class Task extends EntityType<Task> {
|
||||||
super(href, name);
|
super(href, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Error")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Error")
|
||||||
private Error error;
|
private Error error;
|
||||||
@XmlElement(namespace = NS, name = "Organization")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Organization")
|
||||||
private Org org;
|
private Reference org;
|
||||||
@XmlElement(namespace = NS, name = "Progress")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Progress")
|
||||||
private Integer progress;
|
private Integer progress;
|
||||||
@XmlElement(namespace = NS, name = "Owner")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Owner")
|
||||||
private Entity owner;
|
private Reference owner;
|
||||||
@XmlElement(namespace = NS, name = "User")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "User")
|
||||||
private Entity user;
|
private Reference user;
|
||||||
@XmlElement(namespace = NS, name = "Params")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Params")
|
||||||
private Object params;
|
private Object params;
|
||||||
@XmlAttribute(namespace = NS, name = "status")
|
@XmlAttribute
|
||||||
private String status;
|
private String status;
|
||||||
@XmlAttribute(namespace = NS, name = "operation")
|
@XmlAttribute
|
||||||
private String operation;
|
private String operation;
|
||||||
@XmlAttribute(namespace = NS, name = "operationName")
|
@XmlAttribute
|
||||||
private String operationName;
|
private String operationName;
|
||||||
@XmlAttribute(namespace = NS, name = "startTime")
|
@XmlAttribute
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
@XmlAttribute(namespace = NS, name = "endTime")
|
@XmlAttribute
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
@XmlAttribute(namespace = NS, name = "expiryTime")
|
@XmlAttribute
|
||||||
private Date expiryTime;
|
private Date expiryTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an error information if the task failed.
|
||||||
|
*/
|
||||||
public Error getError() {
|
public Error getError() {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -280,14 +322,56 @@ public class Task extends EntityType<Task> {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Org getOrg() {
|
/**
|
||||||
|
* The organization that started the task.
|
||||||
|
*/
|
||||||
|
public Reference getOrg() {
|
||||||
return org;
|
return org;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrg(Org org) {
|
public void setOrg(Reference org) {
|
||||||
this.org = org;
|
this.org = org;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the owner of the task.
|
||||||
|
*/
|
||||||
|
public Reference getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(Reference owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user who started the task.
|
||||||
|
*/
|
||||||
|
public Reference getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(Reference user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters with which this task has been run.
|
||||||
|
*/
|
||||||
|
public Object getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Object params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The progress of a long running asynchronous task.
|
||||||
|
*
|
||||||
|
* The value is between 0 - 100. Not all tasks have progress, the value is not
|
||||||
|
* present for task which progress is not available.
|
||||||
|
*/
|
||||||
public Integer getProgress() {
|
public Integer getProgress() {
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
@ -296,6 +380,20 @@ public class Task extends EntityType<Task> {
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The execution status of the task.
|
||||||
|
*
|
||||||
|
* One of:
|
||||||
|
* <ul>
|
||||||
|
* <li>queued - The task has been queued for execution.
|
||||||
|
* <li>preRunning - The task is awaiting preprocessing or, if it is a blocking task, administrative action.
|
||||||
|
* <li>running - The task is runnning.
|
||||||
|
* <li>success - The task completed with a status of success.
|
||||||
|
* <li>error - The task encountered an error while running.
|
||||||
|
* <li>canceled - The task was canceled by the owner or an administrator.
|
||||||
|
* <li>aborted - The task was aborted by an administrative action.
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -304,6 +402,9 @@ public class Task extends EntityType<Task> {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The display name of the operation that is tracked by this task.
|
||||||
|
*/
|
||||||
public String getOperation() {
|
public String getOperation() {
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -312,6 +413,9 @@ public class Task extends EntityType<Task> {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the operation that is tracked by this task.
|
||||||
|
*/
|
||||||
public String getOperationName() {
|
public String getOperationName() {
|
||||||
return operationName;
|
return operationName;
|
||||||
}
|
}
|
||||||
|
@ -320,6 +424,11 @@ public class Task extends EntityType<Task> {
|
||||||
this.operationName = operationName;
|
this.operationName = operationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date and time the system started executing the task.
|
||||||
|
*
|
||||||
|
* May not be present if the task hasn't been executed yet.
|
||||||
|
*/
|
||||||
public Date getStartTime() {
|
public Date getStartTime() {
|
||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
@ -328,6 +437,11 @@ public class Task extends EntityType<Task> {
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date and time that processing of the task was completed.
|
||||||
|
*
|
||||||
|
* May not be present if the task is still being executed.
|
||||||
|
*/
|
||||||
public Date getEndTime() {
|
public Date getEndTime() {
|
||||||
return endTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
@ -336,6 +450,11 @@ public class Task extends EntityType<Task> {
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date and time at which the task resource will be destroyed and no longer available for retrieval.
|
||||||
|
*
|
||||||
|
* May not be present if the task has not been executed or is still being executed.
|
||||||
|
*/
|
||||||
public Date getExpiryTime() {
|
public Date getExpiryTime() {
|
||||||
return expiryTime;
|
return expiryTime;
|
||||||
}
|
}
|
||||||
|
@ -346,10 +465,13 @@ public class Task extends EntityType<Task> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o))
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
Task that = Task.class.cast(o);
|
Task that = Task.class.cast(o);
|
||||||
return super.equals(that) && equal(this.error, that.error) && equal(this.org, that.org) &&
|
return super.equals(that) &&
|
||||||
|
equal(this.error, that.error) && equal(this.org, that.org) &&
|
||||||
equal(this.progress, that.progress) && equal(this.status, that.status) &&
|
equal(this.progress, that.progress) && equal(this.status, that.status) &&
|
||||||
equal(this.operation, that.operation) && equal(this.operationName, that.operationName) &&
|
equal(this.operation, that.operation) && equal(this.operationName, that.operationName) &&
|
||||||
equal(this.startTime, that.startTime) && equal(this.endTime, that.endTime) &&
|
equal(this.startTime, that.startTime) && equal(this.endTime, that.endTime) &&
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIOXMLNS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -37,7 +37,7 @@ import com.google.common.collect.Sets;
|
||||||
/**
|
/**
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "TasksInProgress")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "TasksInProgress")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class TasksInProgress {
|
public class TasksInProgress {
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class TasksInProgress {
|
||||||
this.tasks = ImmutableSet.copyOf(tasks);
|
this.tasks = ImmutableSet.copyOf(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Task")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Task")
|
||||||
private Set<Task> tasks = Sets.newLinkedHashSet();
|
private Set<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<Task> getTasks() {
|
public Set<Task> getTasks() {
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.*;
|
import static com.google.common.base.Objects.*;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,7 +28,10 @@ import java.util.Set;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
@ -37,8 +40,10 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(namespace = NS, name = "TasksList")
|
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "TasksList")
|
||||||
public class TasksList extends EntityType<TasksList> {
|
public class TasksList extends EntityType<TasksList> {
|
||||||
|
|
||||||
|
public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASKS_LIST;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
@ -81,8 +86,85 @@ public class TasksList extends EntityType<TasksList> {
|
||||||
return taskslist;
|
return taskslist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getDescription()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EntityType#getTasksInProgress()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||||
|
this.tasksInProgress = tasksInProgress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder links(Set<Link> links) {
|
||||||
|
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ReferenceType#getLinks()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder link(Link link) {
|
||||||
|
this.links.add(checkNotNull(link, "link"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder fromEntityType(EntityType<TasksList> in) {
|
||||||
|
return Builder.class.cast(super.fromEntityType(in));
|
||||||
|
}
|
||||||
|
|
||||||
public Builder fromTasksList(TasksList in) {
|
public Builder fromTasksList(TasksList in) {
|
||||||
return tasks(in.getTasks());
|
return fromEntityType(in).tasks(in.getTasks());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +177,7 @@ public class TasksList extends EntityType<TasksList> {
|
||||||
this.tasks = ImmutableSet.copyOf(tasks);
|
this.tasks = ImmutableSet.copyOf(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(namespace = NS, name = "Task")
|
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Task")
|
||||||
private Set<Task> tasks = Sets.newLinkedHashSet();
|
private Set<Task> tasks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public Set<Task> getTasks() {
|
public Set<Task> getTasks() {
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
public interface URISupplier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link URI} for a particular {@link ReferenceType} or {@link ResourceType} object.
|
||||||
|
*
|
||||||
|
* @see ResourceType#getHref()
|
||||||
|
* @see ReferenceType#getHref()
|
||||||
|
*/
|
||||||
|
public URI getURI();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
@XmlSchema(namespace = VCLOUD_1_5_NS, elementFormDefault = XmlNsForm.QUALIFIED)
|
||||||
|
package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlNsForm;
|
||||||
|
import javax.xml.bind.annotation.XmlSchema;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
|
@ -0,0 +1,183 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.binders.BindToXMLPayload;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CatalogClient
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||||
|
public interface CatalogAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a catalog.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Catalog> getCatalog(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a catalog item in a catalog.
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/catalogItems")
|
||||||
|
@Consumes(VCloudDirectorMediaType.CATALOG_ITEM)
|
||||||
|
@Produces(VCloudDirectorMediaType.CATALOG_ITEM)
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<CatalogItem> addCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
|
||||||
|
@BinderParam(BindToXMLPayload.class) CatalogItem catalogItem);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/metadata")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Metadata> getCatalogMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog for the specified key.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/metadata/{key}")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<MetadataEntry> getCatalogMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
|
||||||
|
@PathParam("key") String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a catalog item.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifies a catalog item.
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Consumes(VCloudDirectorMediaType.CATALOG_ITEM)
|
||||||
|
@Produces(VCloudDirectorMediaType.CATALOG_ITEM)
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<CatalogItem> updateCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||||
|
@BinderParam(BindToXMLPayload.class) CatalogItem catalogItem);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a catalog item.
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Void> deleteCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog item.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/metadata")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Metadata> getCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges the metadata for a catalog item with the information provided.
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/metadata")
|
||||||
|
@Consumes(VCloudDirectorMediaType.METADATA)
|
||||||
|
@Produces(VCloudDirectorMediaType.TASK)
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Task> mergeCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||||
|
@BinderParam(BindToXMLPayload.class) Metadata catalogItemMetadata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog item for the specified key.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/metadata/{key}")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<MetadataEntry> getCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||||
|
@PathParam("key") String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the metadata for the particular key for the catalog item to the value provided.
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Path("/metadata/{key}")
|
||||||
|
@Consumes(VCloudDirectorMediaType.METADATA_VALUE)
|
||||||
|
@Produces(VCloudDirectorMediaType.TASK)
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Task> setCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||||
|
@PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the metadata for the particular key for the catalog item.
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Path("/metadata/{key}")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Task> deleteCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||||
|
@PathParam("key") String key);
|
||||||
|
}
|
|
@ -0,0 +1,191 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to {@link Catalog} objects.
|
||||||
|
*
|
||||||
|
* @see CatalogAsyncClient
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface CatalogClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a catalog.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalog/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogRef the reference for the catalog
|
||||||
|
* @return a catalog
|
||||||
|
*/
|
||||||
|
Catalog getCatalog(ReferenceType<?> catalogRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a catalog item in a catalog.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* POST /catalog/{id}/catalogItems
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogRef the reference for the catalog
|
||||||
|
* @param item the catalog item to create
|
||||||
|
* @return the created catalog item
|
||||||
|
*/
|
||||||
|
CatalogItem addCatalogItem(ReferenceType<?> catalogRef, CatalogItem item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalog/{id}/metadata
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogRef the reference for the catalog
|
||||||
|
* @return the catalog metadata
|
||||||
|
*/
|
||||||
|
Metadata getCatalogMetadata(ReferenceType<?> catalogRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog for the specified key.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalog/{id}/metadata/{key}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogRef the reference for the catalog
|
||||||
|
* @param key the metadata entry key
|
||||||
|
* @return the catalog metadata entry
|
||||||
|
*/
|
||||||
|
MetadataEntry getCatalogMetadataEntry(ReferenceType<?> catalogRef, String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a catalog item.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalogItem/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @return the catalog item
|
||||||
|
*/
|
||||||
|
CatalogItem getCatalogItem(ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifies a catalog item.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* PUT /catalogItem/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @param catalogItem the catalog item
|
||||||
|
* @return the updated catalog item
|
||||||
|
*/
|
||||||
|
CatalogItem updateCatalogItem(ReferenceType<?> catalogItemRef, CatalogItem catalogItem);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a catalog item.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* DELETE /catalogItem/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
*/
|
||||||
|
void deleteCatalogItem(ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog item.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalogItem/{id}/metadata
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @return the catalog item metadata
|
||||||
|
*/
|
||||||
|
Metadata getCatalogItemMetadata(ReferenceType<?> catalogItemRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges the metadata for a catalog item with the information provided.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* POST /catalogItem/{id}/metadata
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @param catalogItemMetadata the metadata for the catalog item
|
||||||
|
* @return a task for the merge operation
|
||||||
|
*/
|
||||||
|
Task mergeCatalogItemMetadata(ReferenceType<?> catalogItemRef, Metadata catalogItemMetadata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata associated with the catalog item for the specified key.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /catalog/{id}/metadata/{key}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @param key the metadata entry key
|
||||||
|
* @return the catalog item metadata entry
|
||||||
|
*/
|
||||||
|
MetadataEntry getCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the metadata for the particular key for the catalog item to the value provided.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* PUT /catalog/{id}/metadata/{key}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @param key the metadata entry key
|
||||||
|
* @param value the metadata value
|
||||||
|
* @return a task for the set operation
|
||||||
|
*/
|
||||||
|
Task setCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key, MetadataValue value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the metadata for the particular key for the catalog item.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* DELETE /catalog/{id}/metadata/{key}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param catalogItemRef the reference for the catalog item
|
||||||
|
* @param key the metadata entry key
|
||||||
|
* @return a task for the delete operation
|
||||||
|
*/
|
||||||
|
Task deleteCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key);
|
||||||
|
}
|
|
@ -18,27 +18,27 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
* @see OrgClient
|
* @see OrgClient
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -46,39 +46,41 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
public interface OrgAsyncClient {
|
public interface OrgAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgClient#getOrgList
|
* @see OrgClient#getOrgList()
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/org/")
|
@Path("/org")
|
||||||
@Consumes
|
@Consumes
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
ListenableFuture<OrgList> getOrgList();
|
ListenableFuture<OrgList> getOrgList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgClient#getOrg
|
* @see OrgClient#getOrg(ReferenceType)
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Consumes
|
@Consumes
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
ListenableFuture<Org> getOrg(@EndpointParam URI uri);
|
ListenableFuture<Org> getOrg(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgClient#getMetadata
|
* @see OrgClient#getMetadata(ReferenceType)
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/metadata/")
|
@Path("/metadata")
|
||||||
@Consumes
|
@Consumes
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
ListenableFuture<Metadata> getMetadata(@EndpointParam URI orgRef);
|
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgClient#getMetadataEntry
|
* @see OrgClient#getMetadataEntry(ReferenceType, String)
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
|
@Path("/metadata/{key}")
|
||||||
@Consumes
|
@Consumes
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam URI metaDataRef);
|
ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef,
|
||||||
|
@PathParam("key") String key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -26,13 +25,13 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Org.
|
* Provides synchronous access to Org.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see OrgAsyncClient
|
* @see OrgAsyncClient
|
||||||
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
|
@ -40,6 +39,10 @@ public interface OrgClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a list of organizations.
|
* Retrieves a list of organizations.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /org
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return a list of organizations
|
* @return a list of organizations
|
||||||
*/
|
*/
|
||||||
|
@ -47,22 +50,36 @@ public interface OrgClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an organization.
|
* Retrieves an organization.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /org/{id}
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return the org or null if not found
|
* @return the org or null if not found
|
||||||
*/
|
*/
|
||||||
Org getOrg(URI orgHref);
|
Org getOrg(ReferenceType<?> orgRef);
|
||||||
|
// FIXME throws exception on not found currently
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an list of the organization's metadata
|
* Retrieves an list of the organization's metadata
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /org/{id}/metadata
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return a list of metadata
|
* @return a list of metadata
|
||||||
*/
|
*/
|
||||||
Metadata getMetadata(URI orgRef);
|
Metadata getMetadata(ReferenceType<?> orgRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a metadata
|
* Retrieves a metadata entry.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /org/{id}/metadata{key}
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return the metadata or null if not found
|
* @return the metadata entry or null if not found
|
||||||
*/
|
*/
|
||||||
MetadataEntry getMetadataEntry(URI metaDataRef);
|
MetadataEntry getMetadataEntry(ReferenceType<?> orgRef, String key);
|
||||||
|
// FIXME throws exception on not found currently
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.OrgReferenceToTaskListEndpoint;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TaskClient
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||||
|
public interface TaskAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TaskClient#getTaskList(ReferenceType<?>)
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) ReferenceType<?> orgRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TaskClient#getTask(ReferenceType<?>)
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Task> getTask(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> taskRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TaskClient#cancelTask(URI)
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/action/cancel")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Void> cancelTask(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> taskRef);
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to {@link Task} objects.
|
||||||
|
*
|
||||||
|
* @see TaskAsyncClient
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface TaskClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of tasks.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /tasksList/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param orgId the unique id for the organization
|
||||||
|
* @return a list of tasks
|
||||||
|
*/
|
||||||
|
TasksList getTaskList(ReferenceType<?> orgRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a task.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /task/{id}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return the task or null if not found
|
||||||
|
*/
|
||||||
|
Task getTask(ReferenceType<?> taskRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels a task.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* POST /task/{id}/action/cancel
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
void cancelTask(ReferenceType<?> taskRef);
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class OrgReferenceToTaskListEndpoint implements Function<Object, URI> {
|
||||||
|
private final OrgClient client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OrgReferenceToTaskListEndpoint(OrgClient client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URI apply(Object input) {
|
||||||
|
Preconditions.checkNotNull(input);
|
||||||
|
Preconditions.checkArgument(input instanceof ReferenceType<?>);
|
||||||
|
ReferenceType<?> reference = (ReferenceType<?>) input;
|
||||||
|
Org org = client.getOrg(reference);
|
||||||
|
for (Link link : org.getLinks()) {
|
||||||
|
if (link.getType().equals(VCloudDirectorMediaType.TASKS_LIST)) {
|
||||||
|
return link.getHref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException(String.format("Could not find a link of type %s", VCloudDirectorMediaType.TASKS_LIST));
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
public class ReferenceToEndpoint implements Function<Object, URI> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URI apply(Object input) {
|
||||||
|
Preconditions.checkNotNull(input);
|
||||||
|
Preconditions.checkArgument(input instanceof ReferenceType<?>);
|
||||||
|
ReferenceType<?> reference = (ReferenceType<?>) input;
|
||||||
|
return reference.getURI();
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.functions;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import javax.xml.bind.JAXB;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
import org.jclouds.io.InputSuppliers;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ThrowVCloudErrorOn4xx implements Function<Exception, Object> {
|
||||||
|
@Inject
|
||||||
|
private ThrowVCloudErrorOn4xx() { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object apply(Exception from) {
|
||||||
|
Iterable<HttpResponseException> throwables = Iterables.filter(Throwables.getCausalChain(from), HttpResponseException.class);
|
||||||
|
HttpResponseException exception = Iterables.getFirst(throwables, null);
|
||||||
|
if (exception != null && exception.getResponse().getStatusCode() >= 400 && exception.getResponse().getStatusCode() < 500) {
|
||||||
|
try {
|
||||||
|
Error error = JAXB.unmarshal(InputSuppliers.of(exception.getContent()).getInput(), Error.class);
|
||||||
|
throw new VCloudDirectorException(error);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw Throwables.propagate(from);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,218 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
*(Link.builder().regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless(Link.builder().required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItems;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the {@link CatalogClient} by observing its side effects.
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||||
|
public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCatalog() {
|
||||||
|
HttpRequest catalogRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse catalogResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/catalog.xml", VCloudDirectorMediaType.CATALOG + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||||
|
|
||||||
|
Catalog expected = Catalog.builder()
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.id("urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("add")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("down")
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
|
.build())
|
||||||
|
.catalogItems(CatalogItems.builder()
|
||||||
|
.item(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.name("ubuntu10")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.item(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.name("imageTesting")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.description("Testing")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference catalogRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().getCatalog(catalogRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddCatalogItem() {
|
||||||
|
HttpRequest catalogItemRequest = HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/newCatalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse catalogItemResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/catalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||||
|
|
||||||
|
Reference catalogRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference ubuntu = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.vAppTemplate+xml")
|
||||||
|
.name("ubuntu10")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
CatalogItem newItem = CatalogItem.builder()
|
||||||
|
.name("newCatalogItem")
|
||||||
|
.description("New Catalog Item")
|
||||||
|
.entity(ubuntu)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
CatalogItem expected = CatalogItem.builder()
|
||||||
|
.name("newCatalogItem")
|
||||||
|
.id("urn:vcloud:catalogitem:a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("down")
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("edit")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("remove")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.description("New Catalog Item")
|
||||||
|
.entity(ubuntu)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().addCatalogItem(catalogRef, newItem), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCatalogMetadata() {
|
||||||
|
HttpRequest catalogItemRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse catalogItemResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadata.xml", VCloudDirectorMediaType.METADATA + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||||
|
|
||||||
|
Reference catalogRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Metadata expected = Metadata.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api//catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.metadata(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().getCatalogMetadata(catalogRef), expected);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
|
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
|
import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -51,13 +52,13 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", networkRef),
|
getStandardRequest("GET", networkRef),
|
||||||
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML));
|
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK));
|
||||||
|
|
||||||
OrgNetwork expected = OrgNetwork
|
OrgNetwork expected = OrgNetwork
|
||||||
.builder()
|
.builder()
|
||||||
.name("internet01-Jclouds")
|
.name("internet01-Jclouds")
|
||||||
.id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c")
|
.id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c")
|
||||||
.type(VCloudDirectorMediaType.ORG_NETWORK_XML)
|
.type(VCloudDirectorMediaType.ORG_NETWORK)
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
|
||||||
.link(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("up")
|
.rel("up")
|
||||||
|
@ -96,12 +97,12 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
||||||
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
|
URI orgUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c");
|
||||||
URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/");
|
URI metaUri = URI.create(orgUri.toASCIIString() + "/metadata/");
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", metaRef),
|
getStandardRequest("GET", metaUri),
|
||||||
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
|
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA));
|
||||||
|
|
||||||
Metadata expected = Metadata.builder()
|
Metadata expected = Metadata.builder()
|
||||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
@ -113,21 +114,25 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getMetadata(orgRef), expected);
|
// TODO change network client to use ReferenceType<?> params
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getNetworkClient().getMetadata(orgUri), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled=false) // No metadata in exemplar xml...
|
@Test(enabled=false) // No metadata in exemplar xml...
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() {
|
public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() {
|
||||||
URI metadataRef = URI.create(
|
URI metadataUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY");
|
||||||
"https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", metadataRef),
|
getStandardRequest("GET", metadataUri),
|
||||||
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
|
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
||||||
|
|
||||||
MetadataEntry expected = MetadataEntry.builder()
|
MetadataEntry expected = MetadataEntry.builder().build();
|
||||||
.build();
|
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected);
|
// TODO change network client to use ReferenceType<?> params
|
||||||
|
Reference orgRef = Reference.builder().href(metadataUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getNetworkClient().getMetadataEntry(metadataUri), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
@ -33,6 +35,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows us to test a client via its side effects.
|
* Allows us to test a client via its side effects.
|
||||||
*
|
*
|
||||||
|
@ -40,12 +44,12 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", singleThreaded = true, testName = "OrgClientExpectTest")
|
@Test(groups = "unit", singleThreaded = true, testName = "OrgClientExpectTest")
|
||||||
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
|
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", URI.create("http://localhost/api/org/")),
|
getStandardRequest("GET", "/org"),
|
||||||
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML+";version=1.5"));
|
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORG_LIST));
|
||||||
|
|
||||||
OrgList expected = OrgList.builder()
|
OrgList expected = OrgList.builder()
|
||||||
.org(Reference.builder()
|
.org(Reference.builder()
|
||||||
|
@ -58,21 +62,162 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
assertEquals(client.getOrgClient().getOrgList(), expected);
|
assertEquals(client.getOrgClient().getOrgList(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhenResponseIs2xxLoginReturnsValidOrgFromListByReference() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org"),
|
||||||
|
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORG_LIST));
|
||||||
|
|
||||||
|
Reference org = Iterables.getOnlyElement(client.getOrgClient().getOrgList().getOrgs());
|
||||||
|
|
||||||
|
client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", org.getHref()),
|
||||||
|
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG));
|
||||||
|
|
||||||
|
Org expected = org();
|
||||||
|
|
||||||
|
assertEquals(client.getOrgClient().getOrg(org), expected);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
|
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
|
||||||
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
URI orgUri = URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", orgRef),
|
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"),
|
||||||
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML+";version=1.5"));
|
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG));
|
||||||
|
|
||||||
Org expected = Org
|
Org expected = org();
|
||||||
.builder()
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getOrgClient().getOrg(orgRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhenResponseIs400ForInvalidOrgId() {
|
||||||
|
URI orgUri = URI.create(endpoint + "/org/NOTAUUID");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org/NOTAUUID"),
|
||||||
|
getStandardPayloadResponse(400, "/org/error400.xml", VCloudDirectorMediaType.ERROR));
|
||||||
|
|
||||||
|
Error expected = Error.builder()
|
||||||
|
.message("validation error on field 'id': String value has invalid format or length")
|
||||||
|
.majorErrorCode(400)
|
||||||
|
.minorErrorCode("BAD_REQUEST")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
try {
|
||||||
|
client.getOrgClient().getOrg(orgRef);
|
||||||
|
fail("Should give HTTP 400 error");
|
||||||
|
} catch (VCloudDirectorException vde) {
|
||||||
|
assertEquals(vde.getError(), expected);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Should have thrown a VCloudDirectorException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhenResponseIs403ForCatalogIdUsedAsOrgId() {
|
||||||
|
URI orgUri = URI.create(endpoint + "/org/9e08c2f6-077a-42ce-bece-d5332e2ebb5c");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"),
|
||||||
|
getStandardPayloadResponse(403, "/org/error403-catalog.xml", VCloudDirectorMediaType.ERROR));
|
||||||
|
|
||||||
|
Error expected = Error.builder()
|
||||||
|
.message("No access to entity \"com.vmware.vcloud.entity.org:9e08c2f6-077a-42ce-bece-d5332e2ebb5c\".")
|
||||||
|
.majorErrorCode(403)
|
||||||
|
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.getOrgClient().getOrg(orgRef);
|
||||||
|
fail("Should give HTTP 403 error");
|
||||||
|
} catch (VCloudDirectorException vde) {
|
||||||
|
assertEquals(vde.getError(), expected);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Should have thrown a VCloudDirectorException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhenResponseIs403ForFakeOrgId() {
|
||||||
|
URI orgUri = URI.create(endpoint + "/org/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"),
|
||||||
|
getStandardPayloadResponse(403, "/org/error403-fake.xml", VCloudDirectorMediaType.ERROR));
|
||||||
|
|
||||||
|
Error expected = Error.builder()
|
||||||
|
.message("No access to entity \"com.vmware.vcloud.entity.org:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".")
|
||||||
|
.majorErrorCode(403)
|
||||||
|
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.getOrgClient().getOrg(orgRef);
|
||||||
|
fail("Should give HTTP 403 error");
|
||||||
|
} catch (VCloudDirectorException vde) {
|
||||||
|
assertEquals(vde.getError(), expected);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Should have thrown a VCloudDirectorException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() {
|
||||||
|
URI orgUri = URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"),
|
||||||
|
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA));
|
||||||
|
|
||||||
|
Metadata expected = Metadata.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getOrgClient().getMetadata(orgRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled=false) // No metadata in exemplar xml...
|
||||||
|
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
||||||
|
URI orgUri = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"),
|
||||||
|
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
||||||
|
|
||||||
|
MetadataEntry expected = MetadataEntry.builder()
|
||||||
|
.key("KEY")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||||
|
|
||||||
|
assertEquals(client.getOrgClient().getMetadataEntry(orgRef, "KEY"), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Org org() {
|
||||||
|
return Org.builder()
|
||||||
.name("JClouds")
|
.name("JClouds")
|
||||||
.description("")
|
.description("")
|
||||||
.fullName("JClouds")
|
.fullName("JClouds")
|
||||||
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
|
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
|
||||||
.type(VCloudDirectorMediaType.ORG_XML)
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
.link(Link.builder()
|
.link(Link.builder()
|
||||||
.rel("down")
|
.rel("down")
|
||||||
|
@ -114,43 +259,5 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getOrg(orgRef), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() {
|
|
||||||
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
|
||||||
URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
|
||||||
getStandardRequest("GET", metaRef),
|
|
||||||
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML+";version=1.5"));
|
|
||||||
|
|
||||||
Metadata expected = Metadata.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
|
||||||
.link(Link.builder()
|
|
||||||
.rel("up")
|
|
||||||
.type("application/vnd.vmware.vcloud.org+xml")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getMetadata(orgRef), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled=false) // No metadata in exemplar xml...
|
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
|
||||||
URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
|
||||||
getStandardRequest("GET", metadataRef),
|
|
||||||
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML+";version=1.5"));
|
|
||||||
|
|
||||||
MetadataEntry expected = MetadataEntry.builder()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,313 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
*(Link.builder().regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless(Link.builder().required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the {@link TaskClient} by observing its side effects.
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", singleThreaded = true, testName = "TaskClientExpectTest")
|
||||||
|
public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaskListForValidOrg() {
|
||||||
|
HttpRequest taskRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse taskResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/task/taskslist.xml", VCloudDirectorMediaType.TASKS_LIST + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpRequest orgRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse orgResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/org/org.xml", VCloudDirectorMediaType.TASKS_LIST + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse, orgRequest, orgResponse);
|
||||||
|
|
||||||
|
TasksList expected = TasksList.builder()
|
||||||
|
.name("Tasks Lists")
|
||||||
|
.type("application/vnd.vmware.vcloud.tasksList+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.task(Task.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.name("task")
|
||||||
|
.id("urn:vcloud:task:5fcd2af3-d0ec-45ce-9451-8c585a2c766b")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
||||||
|
.status("success")
|
||||||
|
.operation("Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)")
|
||||||
|
.operationName("catalogCreateCatalog")
|
||||||
|
.startTime(dateService.iso8601DateParse("2012-02-07T00:16:28.450-05:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2012-02-07T00:16:28.867-05:00"))
|
||||||
|
.expiryTime(dateService.iso8601DateParse("2012-05-07T00:16:28.450-04:00"))
|
||||||
|
.owner(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.user(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.admin.user+xml")
|
||||||
|
.name("JClouds")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.org(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.name("JClouds")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.task(Task.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.name("task")
|
||||||
|
.id("urn:vcloud:task:bd22e745-9c2a-4f82-a954-0e35b6f76ba5")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/bd22e745-9c2a-4f82-a954-0e35b6f76ba5"))
|
||||||
|
.status("success")
|
||||||
|
.operation("Enabled User (967d317c-4273-4a95-b8a4-bf63b78e9c69)")
|
||||||
|
.operationName("jobEnable")
|
||||||
|
.startTime(dateService.iso8601DateParse("2012-02-06T17:30:38.507-05:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2012-02-06T17:30:38.507-05:00"))
|
||||||
|
.expiryTime(dateService.iso8601DateParse("2012-05-06T17:30:38.507-04:00"))
|
||||||
|
.user(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.admin.user+xml")
|
||||||
|
.name("adrian@jclouds.org")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93"))
|
||||||
|
.build())
|
||||||
|
.org(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.name("JClouds")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")).build();
|
||||||
|
|
||||||
|
assertEquals(client.getTaskClient().getTaskList(orgRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaskListForInvalidOrgId() {
|
||||||
|
HttpRequest taskRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/tasksList/NOTAUUID"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse taskResponse = HttpResponse.builder().build();
|
||||||
|
|
||||||
|
HttpRequest orgRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/org/NOTAUUID"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse orgResponse = HttpResponse.builder()
|
||||||
|
.statusCode(400)
|
||||||
|
.payload(payloadFromResourceWithContentType("/org/error400.xml", VCloudDirectorMediaType.ERROR + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse, orgRequest, orgResponse);
|
||||||
|
|
||||||
|
Error expected = Error.builder()
|
||||||
|
.message("validation error on field 'id': String value has invalid format or length")
|
||||||
|
.majorErrorCode(400)
|
||||||
|
.minorErrorCode("BAD_REQUEST")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/NOTAUUID")).build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.getTaskClient().getTaskList(orgRef);
|
||||||
|
fail("Should give HTTP 400 error");
|
||||||
|
} catch (VCloudDirectorException vde) {
|
||||||
|
assertEquals(vde.getError(), expected);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Should have thrown a VCloudDirectorException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaskListForNotFoundOrgId() {
|
||||||
|
HttpRequest taskRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/tasksList/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse taskResponse = HttpResponse.builder().build();
|
||||||
|
|
||||||
|
HttpRequest orgRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/org/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse orgResponse = HttpResponse.builder()
|
||||||
|
.statusCode(403)
|
||||||
|
.payload(payloadFromResourceWithContentType("/org/error403-fake.xml", VCloudDirectorMediaType.ERROR + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse, orgRequest, orgResponse);
|
||||||
|
|
||||||
|
Error expected = Error.builder()
|
||||||
|
.message("No access to entity \"com.vmware.vcloud.entity.org:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".")
|
||||||
|
.majorErrorCode(403)
|
||||||
|
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")).build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.getTaskClient().getTaskList(orgRef);
|
||||||
|
fail("Should give HTTP 403 error");
|
||||||
|
} catch (VCloudDirectorException vde) {
|
||||||
|
assertEquals(vde.getError(), expected);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Should have thrown a VCloudDirectorException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTaskForTaskRef() {
|
||||||
|
HttpRequest taskRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse taskResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/task/task.xml", VCloudDirectorMediaType.TASK + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse);
|
||||||
|
|
||||||
|
Reference taskRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.name("task")
|
||||||
|
.href(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Task expected = Task.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.name("task")
|
||||||
|
.id("urn:vcloud:task:5fcd2af3-d0ec-45ce-9451-8c585a2c766b")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
||||||
|
.status("success")
|
||||||
|
.operation("Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)")
|
||||||
|
.operationName("catalogCreateCatalog")
|
||||||
|
.startTime(dateService.iso8601DateParse("2012-02-07T00:16:28.450-05:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2012-02-07T00:16:28.867-05:00"))
|
||||||
|
.expiryTime(dateService.iso8601DateParse("2012-05-07T00:16:28.450-04:00"))
|
||||||
|
.owner(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.user(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.admin.user+xml")
|
||||||
|
.name("JClouds")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.org(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.name("JClouds")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getTaskClient().getTask(taskRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCancelTaskByTaskRef() {
|
||||||
|
HttpRequest taskRequest = HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b/action/cancel"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse taskResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse);
|
||||||
|
|
||||||
|
Reference taskRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.name("task")
|
||||||
|
.href(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
client.getTaskClient().cancelTask(taskRef);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,13 +20,20 @@ package org.jclouds.vcloud.director.v1_5.internal;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for writing KeyStone Rest Client Expect tests
|
* Base class for writing KeyStone Rest Client Expect tests
|
||||||
|
@ -39,17 +46,33 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
||||||
public static final String org = "JClouds";
|
public static final String org = "JClouds";
|
||||||
public static final String password = "password";
|
public static final String password = "password";
|
||||||
public static final String token = "mIaR3/6Lna8DWImd7/JPR5rK8FcUHabt+G/UCJV5pJQ=";
|
public static final String token = "mIaR3/6Lna8DWImd7/JPR5rK8FcUHabt+G/UCJV5pJQ=";
|
||||||
|
public static final String endpoint = "https://vcloudbeta.bluelock.com/api";
|
||||||
|
|
||||||
protected HttpRequest loginRequest = HttpRequest.builder().method("POST").endpoint(
|
protected DateService dateService;
|
||||||
URI.create("http://localhost/api/sessions")).headers(
|
|
||||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("Authorization",
|
|
||||||
"Basic YWRyaWFuQGpjbG91ZHMub3JnQEpDbG91ZHM6cGFzc3dvcmQ=").build()).build();
|
|
||||||
|
|
||||||
protected HttpResponse sessionResponse = HttpResponse.builder().statusCode(200).headers(
|
@BeforeClass
|
||||||
ImmutableMultimap.<String, String> builder().put("x-vcloud-authorization", token).put("Set-Cookie",
|
protected void setUpInjector() {
|
||||||
String.format("vcloud-token=%s; Secure; Path=/", token)).build()).payload(
|
dateService = Guice.createInjector().getInstance(DateService.class);
|
||||||
payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION_XML + ";version=1.5"))
|
assert dateService != null;
|
||||||
.build();
|
}
|
||||||
|
|
||||||
|
protected HttpRequest loginRequest = HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint(URI.create(endpoint + "/sessions"))
|
||||||
|
.headers(ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.put("Authorization", "Basic YWRyaWFuQGpjbG91ZHMub3JnQEpDbG91ZHM6cGFzc3dvcmQ=")
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
protected HttpResponse sessionResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.put("Set-Cookie", String.format("vcloud-token=%s; Secure; Path=/", token))
|
||||||
|
.build())
|
||||||
|
.payload(payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
public BaseVCloudDirectorRestClientExpectTest() {
|
public BaseVCloudDirectorRestClientExpectTest() {
|
||||||
provider = "vcloud-director";
|
provider = "vcloud-director";
|
||||||
|
@ -57,17 +80,32 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
||||||
credential = password;
|
credential = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HttpRequest getStandardRequest(String method, String command) {
|
||||||
|
return getStandardRequest(method, URI.create(endpoint + command));
|
||||||
|
}
|
||||||
|
|
||||||
protected HttpRequest getStandardRequest(String method, URI uri) {
|
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||||
return HttpRequest.builder().method(method).endpoint(uri).headers(
|
return getStandardRequest(method, uri, VCloudDirectorMediaType.ANY);
|
||||||
ImmutableMultimap.<String, String> builder()
|
}
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization",token)
|
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
|
||||||
.build()).build();
|
return HttpRequest.builder()
|
||||||
|
.method(method)
|
||||||
|
.endpoint(uri)
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", mediaType)
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||||
return HttpResponse.builder().statusCode(200)
|
return getStandardPayloadResponse(200, relativeFilePath, mediaType);
|
||||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType+";version=1.5")).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HttpResponse getStandardPayloadResponse(int statusCode, String relativeFilePath, String mediaType) {
|
||||||
|
return HttpResponse.builder()
|
||||||
|
.statusCode(statusCode)
|
||||||
|
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType + ";version=1.5")).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,7 @@ public class SessionClientExpectTest extends BaseRestClientExpectTest<SessionCli
|
||||||
ImmutableMultimap.<String, String> builder().put("x-vcloud-authorization", token).put("Set-Cookie",
|
ImmutableMultimap.<String, String> builder().put("x-vcloud-authorization", token).put("Set-Cookie",
|
||||||
String.format("vcloud-token=%s; Secure; Path=/", token)).build())
|
String.format("vcloud-token=%s; Secure; Path=/", token)).build())
|
||||||
.payload(
|
.payload(
|
||||||
payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION_XML
|
payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5")).build()
|
||||||
+ ";version=1.5")).build()
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -97,8 +96,7 @@ public class SessionClientExpectTest extends BaseRestClientExpectTest<SessionCli
|
||||||
|
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(
|
.payload(
|
||||||
payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION_XML
|
payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5")).build()
|
||||||
+ ";version=1.5")).build()
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Catalog xmlns="http://www.vmware.com/vcloud/v1.5" name="QunyingTestCatalog" id="urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||||
|
<Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"/>
|
||||||
|
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"/>
|
||||||
|
<Description>Testing</Description>
|
||||||
|
<CatalogItems>
|
||||||
|
<CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="imageTesting" href="https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"/>
|
||||||
|
</CatalogItems>
|
||||||
|
<IsPublished>false</IsPublished>
|
||||||
|
</Catalog>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CatalogItem xmlns="http://www.vmware.com/vcloud/v1.5" name="newCatalogItem" id="urn:vcloud:catalogitem:a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
|
||||||
|
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"/>
|
||||||
|
<Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<Link rel="remove" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<Description>New Catalog Item</Description>
|
||||||
|
<Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"/>
|
||||||
|
</CatalogItem>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Metadata xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api//catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
|
||||||
|
<MetadataEntry>
|
||||||
|
<Key>key</Key>
|
||||||
|
<Value>value</Value>
|
||||||
|
</MetadataEntry>
|
||||||
|
</Metadata>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<CatalogItem name="newCatalogItem" xmlns="http://www.vmware.com/vcloud/v1.5">
|
||||||
|
<Description>New Catalog Item</Description>
|
||||||
|
<Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"/>
|
||||||
|
</CatalogItem>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="validation error on field 'id': String value has invalid format or length" majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN" message="No access to entity "com.vmware.vcloud.entity.org:9e08c2f6-077a-42ce-bece-d5332e2ebb5c"." majorErrorCode="403" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN" message="No access to entity "com.vmware.vcloud.entity.org:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"." majorErrorCode="403" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="validation error on field 'id': String value has invalid format or length" majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN" message="No access to entity "com.vmware.vcloud.entity.org:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"." majorErrorCode="403" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="success" startTime="2012-02-07T00:16:28.450-05:00" operationName="catalogCreateCatalog" operation="Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)" expiryTime="2012-05-07T00:16:28.450-04:00" endTime="2012-02-07T00:16:28.867-05:00" name="task" id="urn:vcloud:task:5fcd2af3-d0ec-45ce-9451-8c585a2c766b" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Owner type="application/vnd.vmware.vcloud.catalog+xml" name="QunyingTestCatalog" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
|
||||||
|
<User type="application/vnd.vmware.admin.user+xml" name="qunying.huang@enstratus.com" href="https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69"/>
|
||||||
|
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||||
|
</Task>
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TasksList xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"
|
||||||
|
name="Tasks Lists"
|
||||||
|
type="application/vnd.vmware.vcloud.tasksList+xml"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0">
|
||||||
|
<Task
|
||||||
|
status="success"
|
||||||
|
startTime="2012-02-07T00:16:28.450-05:00"
|
||||||
|
operationName="catalogCreateCatalog"
|
||||||
|
operation="Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)"
|
||||||
|
expiryTime="2012-05-07T00:16:28.450-04:00"
|
||||||
|
endTime="2012-02-07T00:16:28.867-05:00"
|
||||||
|
name="task"
|
||||||
|
id="urn:vcloud:task:5fcd2af3-d0ec-45ce-9451-8c585a2c766b"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b">
|
||||||
|
<Owner
|
||||||
|
type="application/vnd.vmware.vcloud.catalog+xml"
|
||||||
|
name="QunyingTestCatalog"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4" />
|
||||||
|
<User
|
||||||
|
type="application/vnd.vmware.admin.user+xml"
|
||||||
|
name="qunying.huang@enstratus.com"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69" />
|
||||||
|
<Organization
|
||||||
|
type="application/vnd.vmware.vcloud.org+xml"
|
||||||
|
name="JClouds"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0" />
|
||||||
|
</Task>
|
||||||
|
<Task
|
||||||
|
status="success"
|
||||||
|
startTime="2012-02-06T17:30:38.507-05:00"
|
||||||
|
operationName="jobEnable"
|
||||||
|
operation="Enabled User (967d317c-4273-4a95-b8a4-bf63b78e9c69)"
|
||||||
|
expiryTime="2012-05-06T17:30:38.507-04:00"
|
||||||
|
endTime="2012-02-06T17:30:38.507-05:00"
|
||||||
|
name="task"
|
||||||
|
id="urn:vcloud:task:bd22e745-9c2a-4f82-a954-0e35b6f76ba5"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/task/bd22e745-9c2a-4f82-a954-0e35b6f76ba5">
|
||||||
|
<User
|
||||||
|
type="application/vnd.vmware.admin.user+xml"
|
||||||
|
name="adrian@jclouds.org"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93" />
|
||||||
|
<Organization
|
||||||
|
type="application/vnd.vmware.vcloud.org+xml"
|
||||||
|
name="JClouds"
|
||||||
|
href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0" />
|
||||||
|
</Task>
|
||||||
|
</TasksList>
|
Loading…
Reference in New Issue