From 8e46d9e9ecabb6b4fa8241bcbab46c1c3d3c3f54 Mon Sep 17 00:00:00 2001 From: danikov Date: Sun, 11 Mar 2012 20:34:22 +0000 Subject: [PATCH] get adminOrg --- .../v1_5/VCloudDirectorMediaType.java | 12 +- .../vcloud/director/v1_5/domain/AdminOrg.java | 11 +- .../director/v1_5/domain/CatalogsList.java | 10 +- .../director/v1_5/domain/GroupsList.java | 2 +- .../vcloud/director/v1_5/domain/Networks.java | 6 +- .../vcloud/director/v1_5/domain/Org.java | 10 +- .../director/v1_5/domain/OrgSettings.java | 12 +- .../director/v1_5/domain/UsersList.java | 6 +- .../vcloud/director/v1_5/domain/Vdcs.java | 4 +- .../v1_5/features/AdminOrgAsyncClient.java | 15 +- .../v1_5/features/AdminOrgClient.java | 19 +- .../v1_5/features/OrgAsyncClient.java | 2 +- .../vcloud/director/v1_5/domain/Checks.java | 40 +++ .../features/AdminOrgClientExpectTest.java | 263 ++++++++++++++++-- .../v1_5/features/AdminOrgClientLiveTest.java | 26 +- .../src/test/resources/org/admin/org.xml | 86 ++++++ 16 files changed, 448 insertions(+), 76 deletions(-) create mode 100644 labs/vcloud-director/src/test/resources/org/admin/org.xml diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index 354bf95e15..be26e4b8c0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -129,7 +129,7 @@ public class VCloudDirectorMediaType { public static final String ADMIN_CATALOG = "application/vnd.vmware.admin.catalog+xml"; - public static final String ADMIN_ORGANIZATION = "application/vnd.vmware.admin.organization+xml"; + public static final String ADMIN_ORG = "application/vnd.vmware.admin.organization+xml"; public static final String PUBLISH_CATALOG_PARAMS = "application/vnd.vmware.admin.publishCatalogParams+xml"; @@ -149,8 +149,11 @@ public class VCloudDirectorMediaType { public static final String ORG_SETTINGS = "application/vnd.vmware.admin.orgSettings+xml"; + public static final String ADMIN_NETWORK = "application/vnd.vmware.admin.network+xml"; + + public static final String ADMIN_ORG_NETWORK = "application/vnd.vmware.admin.orgNetwork+xml"; + /** - * * All acceptable media types. * * This list must be updated whenever a new media type constant is added. @@ -162,13 +165,14 @@ public class VCloudDirectorMediaType { MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE, CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS, COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, - UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORGANIZATION, + UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORG, QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE, PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS, ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS, - ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS + ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK, + ADMIN_ORG_NETWORK ); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java index a940c0cfca..3caf989887 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java @@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import java.net.URI; +import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -145,7 +148,8 @@ public class AdminOrg extends Org { } public AdminOrg build() { - return new AdminOrg(settings, users, groups, catalogs, vdcs, networks); + return new AdminOrg(href, type, links, description, tasksInProgress, id, + name, fullName, isEnabled, settings, users, groups, catalogs, vdcs, networks); } public T fromAdminOrg(AdminOrg in) { @@ -175,8 +179,11 @@ public class AdminOrg extends Org { // For JAXB } - protected AdminOrg(OrgSettings settings, UsersList users, GroupsList groups, + protected AdminOrg(URI href, String type, Set links, String description, + TasksInProgress tasksInProgress, String id, String name, String fullName, + Boolean enabled, OrgSettings settings, UsersList users, GroupsList groups, CatalogsList catalogs, Vdcs vdcs, Networks networks) { + super(href, type, links, description, tasksInProgress, id, name, fullName, enabled); this.settings = settings; this.users = users; this.groups = groups; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java index 36ff6d9d65..ee0b2af588 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java @@ -67,6 +67,14 @@ public class CatalogsList { this.catalogReferences = 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); @@ -81,7 +89,7 @@ public class CatalogsList { // for JAXB } - private CatalogsList(Set tasks) { + private CatalogsList(Set catalogReferences) { this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences")); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java index f74d9c6d77..7d2bb4ee40 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GroupsList.java @@ -62,7 +62,7 @@ import com.google.common.collect.ImmutableList; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "GroupsList") @XmlType(propOrder = { - "groupReference" + "groups" }) public class GroupsList { public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java index 01323bf708..a5558238b2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Networks.java @@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableList; @@ -62,7 +64,7 @@ import com.google.common.collect.ImmutableList; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Networks", propOrder = { - "network" + "networks" }) public class Networks { public static Builder builder() { @@ -75,7 +77,7 @@ public class Networks { public static class Builder { - private List networks; + private List networks = Lists.newArrayList(); /** * @see Networks#getNetwork() diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java index 464208023c..06e54d5852 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java @@ -59,8 +59,8 @@ public class Org extends EntityType { public static abstract class NewBuilder> extends EntityType.NewBuilder { - private String fullName; - private Boolean isEnabled; + protected String fullName; + protected Boolean isEnabled; /** * @see Org#getFullName() @@ -232,8 +232,10 @@ public class Org extends EntityType { // for JAXB } - public Org(URI href, String type, Set links, String description, Set tasks, String id, String name, String fullName, Boolean enabled) { - super(href, type, links, description, tasks, id, name); + public Org(URI href, String type, Set links, String description, + TasksInProgress tasksInProgress, String id, String name, + String fullName, Boolean enabled) { + super(href, type, links, description, tasksInProgress, id, name); this.fullName = fullName; isEnabled = enabled; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java index f4de180a68..7bcc9451fa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java @@ -97,7 +97,7 @@ public class OrgSettings extends ResourceType { /** * @see OrgSettings#getGeneralSettings() */ - public Builder orgGeneralSettings(OrgGeneralSettings generalSettings) { + public Builder generalSettings(OrgGeneralSettings generalSettings) { this.generalSettings = generalSettings; return this; } @@ -121,7 +121,7 @@ public class OrgSettings extends ResourceType { /** * @see OrgSettings#getLdapSettings() */ - public Builder orgLdapSettings(OrgLdapSettings ldapSettings) { + public Builder ldapSettings(OrgLdapSettings ldapSettings) { this.ldapSettings = ldapSettings; return this; } @@ -129,7 +129,7 @@ public class OrgSettings extends ResourceType { /** * @see OrgSettings#getEmailSettings() */ - public Builder orgEmailSettings(OrgEmailSettings emailSettings) { + public Builder emailSettings(OrgEmailSettings emailSettings) { this.emailSettings = emailSettings; return this; } @@ -191,11 +191,11 @@ public class OrgSettings extends ResourceType { } public Builder fromOrgSettings(OrgSettings in) { return fromResourceType(in) - .orgGeneralSettings(in.getGeneralSettings()) + .generalSettings(in.getGeneralSettings()) .vAppLeaseSettings(in.getVAppLeaseSettings()) .vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings()) - .orgLdapSettings(in.getLdapSettings()) - .orgEmailSettings(in.getEmailSettings()) + .ldapSettings(in.getLdapSettings()) + .emailSettings(in.getEmailSettings()) .passwordPolicy(in.getPasswordPolicy()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java index 1e949d30fe..3e57b99809 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UsersList.java @@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; @@ -62,7 +64,7 @@ import com.google.common.collect.ImmutableList; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "UsersList") @XmlType(propOrder = { - "userReference" + "users" }) public class UsersList { public static Builder builder() { @@ -74,7 +76,7 @@ public class UsersList { } public static class Builder { - private List users; + private List users = Lists.newArrayList(); /** * @see UsersList#getUsers() diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java index 7d2467abf2..a55af00488 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdcs.java @@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableList; @@ -76,7 +78,7 @@ public class Vdcs { public static class Builder { - private List vdcs; + private List vdcs = Lists.newArrayList(); /** * @see Vdcs#getVdc() diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgAsyncClient.java index eda625bd03..fea0a6d155 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgAsyncClient.java @@ -33,6 +33,7 @@ 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.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; @@ -52,11 +53,15 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(AddVCloudAuthorizationToRequest.class) public interface AdminOrgAsyncClient extends OrgAsyncClient { -// GET /admin/org/{id} - -// POST /admin/org/{id}/catalogs - -// POST /admin/org/{id}/groups + /** + * @see AdminOrgClient#getOrg(URI) + */ + @GET + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getOrg( + @EndpointParam URI orgRef); /** * @see AdminOrgClient#getSettings(URI) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClient.java index af752307ce..471572b512 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClient.java @@ -22,6 +22,7 @@ import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; @@ -40,11 +41,19 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface AdminOrgClient extends OrgClient { -// GET /admin/org/{id} - -// POST /admin/org/{id}/catalogs - -// POST /admin/org/{id}/groups + /** + * Retrieves an admin view of an organization. + * The organization might be enabled or disabled. + * If enabled, the organization allows login and all other operations. + * + *
+    * GET /admin/org/{id}
+    * 
+ * + * @param orgRef the reference for the admin org + * @return the admin org + */ + AdminOrg getOrg(URI orgRef); /** * Gets organizational settings for this organization. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index fa1e7cda69..98dc3bb731 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -60,7 +60,7 @@ public interface OrgAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrg(@EndpointParam URI orgUri); + ListenableFuture getOrg(@EndpointParam URI orgUri); /** * @return asynchronous access to {@link Metadata.Readable} features diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 13c1ba76bc..d6f966d534 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -232,6 +232,46 @@ public class Checks { checkEntityType(org); } + public static void checkAdminOrg(AdminOrg org) { + // required + assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJECT_FMT, "settings", "AdminOrg")); + + // optional + if (org.getGroups() != null) { + checkGroupsList(org.getGroups()); + } + if (org.getCatalogs() != null) { + checkCatalogsList(org.getCatalogs()); + } + if (org.getVdcs() != null) { + checkVdcs(org.getVdcs()); + } + if (org.getNetworks() != null) { + checkNetworks(org.getNetworks()); + } + + // Check parent type + checkOrg(org); + } + + public static void checkCatalogsList(CatalogsList catalogList) { + for (Reference catalogItem : catalogList.getCatalogItems()) { + checkReferenceType(catalogItem); + } + } + + public static void checkVdcs(Vdcs vdcs) { + for (Reference vdc : vdcs.getVdcs()) { + checkReferenceType(vdc); + } + } + + public static void checkNetworks(Networks networks) { + for (Reference network : networks.getNetwork()) { + checkReferenceType(network); + } + } + public static void checkAdminCatalog(AdminCatalog catalog) { // Check parent type checkCatalogType(catalog); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java index ddd092a076..0ec249dfce 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientExpectTest.java @@ -24,7 +24,11 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.CatalogsList; +import org.jclouds.vcloud.director.v1_5.domain.GroupsList; import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Networks; import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; @@ -34,6 +38,8 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.UsersList; +import org.jclouds.vcloud.director.v1_5.domain.Vdcs; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -49,13 +55,151 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect .href(URI.create(endpoint + "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .build(); -// GET /admin/org/{id} - -// POST /admin/org/{id}/catalogs - -// POST /admin/org/{id}/groups - @Test + public void testGetOrg() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/org/admin/org.xml", + VCloudDirectorMediaType.ADMIN_ORG) + .httpResponseBuilder().build()); + + AdminOrg expected = adminOrg(); + + assertEquals(client.getAdminOrgClient().getOrg(orgRef.getURI()), expected); + } + + public static final AdminOrg adminOrg() { + return AdminOrg.builder() + .name("JClouds") + .id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0") + .type("application/vnd.vmware.admin.organization+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.tasksList+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.admin.catalog+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.admin.user+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/users")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.admin.group+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/groups")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.admin.orgNetwork+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/networks")) + .build()) + .link(Link.builder() + .rel("edit") + .type("application/vnd.vmware.admin.organization+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("remove") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("alternate") + .type("application/vnd.vmware.vcloud.org+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .description("") + .fullName("JClouds") + .isEnabled(true) + .settings(settings()) + .users(UsersList.builder() + .user(Reference.builder() + .type("application/vnd.vmware.admin.user+xml") + .name("adam.lowe@cloudsoftcorp.com") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/672ebb67-d8ff-4201-9c1b-c1be869e526c")) + .build()) + .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()) + .user(Reference.builder() + .type("application/vnd.vmware.admin.user+xml") + .name("qunying.huang@enstratus.com") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69")) + .build()) + .user(Reference.builder() + .type("application/vnd.vmware.admin.user+xml") + .name("dan@cloudsoftcorp.com") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/ae75edd2-12de-414c-8e85-e6ea10442c08")) + .build()) + .user(Reference.builder() + .type("application/vnd.vmware.admin.user+xml") + .name("adk@cloudsoftcorp.com") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9")) + .build()) + .build()) + .groups(GroupsList.builder() + .build()) + .catalogs(CatalogsList.builder() + .catalog(Reference.builder() + .type("application/vnd.vmware.admin.catalog+xml") + .name("QunyingTestCatalog") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4")) + .build()) + .catalog(Reference.builder() + .type("application/vnd.vmware.admin.catalog+xml") + .name("Public") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")) + .build()) + .catalog(Reference.builder() + .type("application/vnd.vmware.admin.catalog+xml") + .name("dantest") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b542aff4-9f97-4f51-a126-4330fbf62f02")) + .build()) + .catalog(Reference.builder() + .type("application/vnd.vmware.admin.catalog+xml") + .name("test") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da")) + .build()) + .build()) + .vdcs(Vdcs.builder() + .vdc(Reference.builder() + .type("application/vnd.vmware.vcloud.vdc+xml") + .name("Cluster01-JClouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) + .build()) + .build()) + .networks(Networks.builder() + .network(Reference.builder() + .type("application/vnd.vmware.admin.network+xml") + .name("ilsolation01-Jclouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38")) + .build()) + .network(Reference.builder() + .type("application/vnd.vmware.admin.network+xml") + .name("internet01-Jclouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c")) + .build()) + .build()) + .build(); + } + + @Test(enabled = false) public void testGetSettings() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -74,18 +218,53 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect public static final OrgSettings settings() { return OrgSettings.builder() - .type("application/vnd.vmware.admin.organizationSettings+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/")) + .type("application/vnd.vmware.admin.orgSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings")) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.organizationEmailSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.vAppLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.organizationGeneralSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.admin.organizationLdapSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap")) + .build()) .link(Link.builder() .rel("edit") - .type("application/vnd.vmware.admin.organizationSettings+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/")) + .type("application/vnd.vmware.admin.orgSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings")) .build()) - + .generalSettings(generalSettings()) + .vAppLeaseSettings(vAppLeaseSettings()) + .vAppTemplateLeaseSettings(vAppTemplateLeaseSettings()) + .ldapSettings(ldapSettings()) + .emailSettings(emailSettings()) + .passwordPolicy(passwordPolicy()) .build(); } - @Test + @Test(enabled = false) public void testUpdateSettings() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -204,7 +383,18 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect public static final OrgGeneralSettings generalSettings() { return OrgGeneralSettings.builder() - + .type("application/vnd.vmware.admin.organizationGeneralSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")) + .link(Link.builder() + .rel("edit") + .type("application/vnd.vmware.admin.organizationGeneralSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")) + .build()) + .canPublishCatalogs(false) + .deployedVMQuota(0) + .storedVmQuota(0) + .useServerBootSequence(false) + .delayAfterPowerOnSeconds(0) .build(); } @@ -270,12 +460,12 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS) .httpResponseBuilder().build()); - OrgPasswordPolicySettings expected = orgPasswordPolicy(); + OrgPasswordPolicySettings expected = passwordPolicy(); assertEquals(client.getAdminOrgClient().getPasswordPolicy(orgRef.getURI()), expected); } - public static final OrgPasswordPolicySettings orgPasswordPolicy() { + public static final OrgPasswordPolicySettings passwordPolicy() { return OrgPasswordPolicySettings.builder() .type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml") .link(Link.builder() @@ -310,7 +500,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect } public static final OrgPasswordPolicySettings updateOrgPasswordPolicy() { - return orgPasswordPolicy().toBuilder() + return passwordPolicy().toBuilder() .accountLockoutEnabled(true) .invalidLoginsBeforeLockout(6) .accountLockoutIntervalMinutes(11) @@ -329,14 +519,23 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect VCloudDirectorMediaType.ORG_LEASE_SETTINGS) .httpResponseBuilder().build()); - OrgLeaseSettings expected = orgVAppLeaseSettings(); + OrgLeaseSettings expected = vAppLeaseSettings(); assertEquals(client.getAdminOrgClient().getVAppLeaseSettings(orgRef.getURI()), expected); } - public static final OrgLeaseSettings orgVAppLeaseSettings() { + public static final OrgLeaseSettings vAppLeaseSettings() { return OrgLeaseSettings.builder() - + .type("application/vnd.vmware.admin.vAppLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")) + .link(Link.builder() + .rel("edit") + .type("application/vnd.vmware.admin.vAppLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings")) + .build()) + .deleteOnStorageLeaseExpiration(false) + .deploymentLeaseSeconds(0) + .storageLeaseSeconds(0) .build(); } @@ -354,13 +553,13 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect VCloudDirectorMediaType.ORG_LEASE_SETTINGS) .httpResponseBuilder().build()); - OrgLeaseSettings expected = updateOrgVAppLeaseSettings(); + OrgLeaseSettings expected = updateVAppLeaseSettings(); assertEquals(client.getAdminOrgClient().updateVAppLeaseSettings(orgRef.getURI(), expected), expected); } - public static final OrgLeaseSettings updateOrgVAppLeaseSettings() { - return orgVAppLeaseSettings().toBuilder() + public static final OrgLeaseSettings updateVAppLeaseSettings() { + return vAppLeaseSettings().toBuilder() .build(); } @@ -377,14 +576,22 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS) .httpResponseBuilder().build()); - OrgVAppTemplateLeaseSettings expected = orgVAppTemplateLeaseSettings(); + OrgVAppTemplateLeaseSettings expected = vAppTemplateLeaseSettings(); assertEquals(client.getAdminOrgClient().getVAppTemplateLeaseSettings(orgRef.getURI()), expected); } - public static final OrgVAppTemplateLeaseSettings orgVAppTemplateLeaseSettings() { + public static final OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings() { return OrgVAppTemplateLeaseSettings.builder() - + .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")) + .link(Link.builder() + .rel("edit") + .type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings")) + .build()) + .deleteOnStorageLeaseExpiration(false) + .storageLeaseSeconds(0) .build(); } @@ -402,13 +609,13 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS) .httpResponseBuilder().build()); - OrgVAppTemplateLeaseSettings expected = updateOrgVAppTemplateLeaseSettings(); + OrgVAppTemplateLeaseSettings expected = updateVAppTemplateLeaseSettings(); assertEquals(client.getAdminOrgClient().updateVAppTemplateLeaseSettings(orgRef.getURI(), expected), expected); } - public static final OrgVAppTemplateLeaseSettings updateOrgVAppTemplateLeaseSettings() { - return orgVAppTemplateLeaseSettings().toBuilder() + public static final OrgVAppTemplateLeaseSettings updateVAppTemplateLeaseSettings() { + return vAppTemplateLeaseSettings().toBuilder() .build(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java index 17d2be7297..d174978356 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java @@ -59,7 +59,6 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { * Shared state between dependant tests. */ private ReferenceType orgRef; - private AdminOrg org; private OrgSettings settings, newSettings; private OrgEmailSettings emailSettings, newEmailSettings; private OrgGeneralSettings generalSettings, newGeneralSettings; @@ -76,14 +75,13 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertNotNull(orgRef, String.format(REF_REQ_LIVE, "admin org")); } -// GET /admin/org/{id} + @Test(testName = "GET /admin/org/{id}") + public void testGetAdminOrg() { + AdminOrg adminOrg = orgClient.getOrg(orgRef.getURI()); + + Checks.checkAdminOrg(adminOrg); + } -// POST /admin/org/{id}/catalogs - -// POST /admin/org/{id}/groups - - - @Test(testName = "GET /admin/org/{id}/settings/emailSettings") public void testGetEmailSettings() { emailSettings = orgClient.getEmailSettings(orgRef.getURI()); @@ -391,11 +389,11 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { public void testUpdateSettings() { try { newSettings = settings.toBuilder() - .orgGeneralSettings(newGeneralSettings) + .generalSettings(newGeneralSettings) .vAppLeaseSettings(newVAppLeaseSettings) .vAppTemplateLeaseSettings(newVAppTemplateLeaseSettings) - .orgLdapSettings(newLdapSettings) - .orgEmailSettings(newEmailSettings) + .ldapSettings(newLdapSettings) + .emailSettings(newEmailSettings) .passwordPolicy(newPasswordPolicy) .build(); @@ -426,11 +424,11 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkOrgSettings(settings); } finally { settings = settings.toBuilder() - .orgGeneralSettings(generalSettings) + .generalSettings(generalSettings) .vAppLeaseSettings(vAppLeaseSettings) .vAppTemplateLeaseSettings(vAppTemplateLeaseSettings) - .orgLdapSettings(ldapSettings) - .orgEmailSettings(emailSettings) + .ldapSettings(ldapSettings) + .emailSettings(emailSettings) .passwordPolicy(passwordPolicy) .build(); diff --git a/labs/vcloud-director/src/test/resources/org/admin/org.xml b/labs/vcloud-director/src/test/resources/org/admin/org.xml new file mode 100644 index 0000000000..5e0ee14a4f --- /dev/null +++ b/labs/vcloud-director/src/test/resources/org/admin/org.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + JClouds + true + + + + + + + + + + + false + 0 + 0 + false + 0 + + + + false + 0 + 0 + + + + false + 0 + + + NONE + + + + true + true + + + true + + false + + + + + + + false + 5 + 10 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file