mirror of https://github.com/apache/jclouds.git
get/put generalSettings
This commit is contained in:
parent
709c7bff63
commit
8e5ec325ae
|
@ -143,6 +143,8 @@ public class VCloudDirectorMediaType {
|
|||
|
||||
public static final String ORG_LDAP_SETTINGS = "application/vnd.vmware.admin.organizationLdapSettings+xml";
|
||||
|
||||
public static final String ORG_GENERAL_SETTINGS = "application/vnd.vmware.admin.organizationGeneralSettings+xml";
|
||||
|
||||
/**
|
||||
*
|
||||
* All acceptable media types.
|
||||
|
@ -162,6 +164,7 @@ public class VCloudDirectorMediaType {
|
|||
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_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
|
||||
ORG_GENERAL_SETTINGS
|
||||
);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "OrgGeneralSettings")
|
||||
@XmlRootElement(name = "GeneralOrgSettings")
|
||||
@XmlType(propOrder = {
|
||||
"canPublishCatalogs",
|
||||
"deployedVMQuota",
|
||||
|
|
|
@ -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.OrgGeneralSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||
|
@ -63,9 +64,29 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
|
|||
|
||||
// PUT /admin/org/{id}/settings/email
|
||||
|
||||
// GET /admin/org/{id}/settings/general
|
||||
|
||||
// PUT /admin/org/{id}/settings/general
|
||||
/**
|
||||
* @see AdminOrgClient#getGeneralSettings(URI)
|
||||
*/
|
||||
@GET
|
||||
@Path("/settings/general")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<OrgGeneralSettings> getGeneralSettings(
|
||||
@EndpointParam URI orgRef);
|
||||
|
||||
/**
|
||||
* @see AdminOrgClient#updateGeneralSettings(URI, OrgGeneralSettings)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/settings/general")
|
||||
@Consumes(VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
@Produces(VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<OrgGeneralSettings> updateGeneralSettings(
|
||||
@EndpointParam URI orgRef,
|
||||
@BinderParam(BindToXMLPayload.class) OrgGeneralSettings settings);
|
||||
|
||||
/**
|
||||
* @see AdminOrgClient#getPasswordPolicy(URI)
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||
|
@ -51,11 +52,30 @@ public interface AdminOrgClient extends OrgClient {
|
|||
|
||||
// PUT /admin/org/{id}/settings/email
|
||||
|
||||
// GET /admin/org/{id}/settings/general
|
||||
/**
|
||||
* Gets general organization settings.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/org/{id}/settings/general
|
||||
* </pre>
|
||||
*
|
||||
* @param orgRef the reference for the admin org
|
||||
* @return the lease settings
|
||||
*/
|
||||
OrgGeneralSettings getGeneralSettings(URI orgRef);
|
||||
|
||||
// PUT /admin/org/{id}/settings/general
|
||||
|
||||
// GET /admin/org/{id}/settings/ldap
|
||||
/**
|
||||
* Updates general organization settings.
|
||||
*
|
||||
* <pre>
|
||||
* PUT /admin/org/{id}/settings/general
|
||||
* </pre>
|
||||
* @param orgRef the reference for the admin org
|
||||
* @param newSettings the requested updated settings
|
||||
* @return the resultant settings
|
||||
*/
|
||||
OrgGeneralSettings updateGeneralSettings(URI orgRef,
|
||||
OrgGeneralSettings newSettings);
|
||||
|
||||
/**
|
||||
* Retrieves LDAP settings for an organization.
|
||||
|
|
|
@ -531,7 +531,7 @@ public class Checks {
|
|||
public static void checkOrgSetting(OrgSettings settings) {
|
||||
// Check optional fields
|
||||
if (settings.getOrgGeneralSettings() != null) {
|
||||
checkOrgGeneralSettings(settings.getOrgGeneralSettings());
|
||||
checkGeneralSettings(settings.getOrgGeneralSettings());
|
||||
}
|
||||
if (settings.getVAppLeaseSettings() != null) {
|
||||
checkVAppLeaseSettings(settings.getVAppLeaseSettings());
|
||||
|
@ -574,7 +574,7 @@ public class Checks {
|
|||
// TODO: validate email addresses
|
||||
}
|
||||
|
||||
public static void checkOrgGeneralSettings(OrgGeneralSettings settings) {
|
||||
public static void checkGeneralSettings(OrgGeneralSettings settings) {
|
||||
// Check optional fields
|
||||
// NOTE canPublishCatalogs cannot be checked
|
||||
// NOTE useServerBootSequence cannot be checked
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.Link;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||
|
@ -61,9 +62,53 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
|
||||
// PUT /admin/org/{id}/settings/email
|
||||
|
||||
// GET /admin/org/{id}/settings/general
|
||||
|
||||
// PUT /admin/org/{id}/settings/general
|
||||
@Test(enabled = false)
|
||||
public void testGetGeneralSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/org/admin/generalSettings.xml",
|
||||
VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
OrgGeneralSettings expected = generalSettings();
|
||||
|
||||
assertEquals(client.getAdminOrgClient().getGeneralSettings(orgRef.getURI()), expected);
|
||||
}
|
||||
|
||||
public static final OrgGeneralSettings generalSettings() {
|
||||
return OrgGeneralSettings.builder()
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testUpdateGeneralSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("PUT", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general")
|
||||
.xmlFilePayload("/org/admin/updateGeneralSettingsSource.xml",
|
||||
VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
.acceptMedia(VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/org/admin/updateGeneralSettings.xml",
|
||||
VCloudDirectorMediaType.ORG_GENERAL_SETTINGS)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
OrgGeneralSettings expected = updateGeneralSettings();
|
||||
|
||||
assertEquals(client.getAdminOrgClient().updateGeneralSettings(orgRef.getURI(), expected), expected);
|
||||
}
|
||||
|
||||
public static final OrgGeneralSettings updateGeneralSettings() {
|
||||
return generalSettings().toBuilder()
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLdapSettings() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||
|
@ -59,6 +60,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
OrgPasswordPolicySettings passwordPolicy;
|
||||
OrgLeaseSettings vAppLeaseSettings;
|
||||
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
OrgGeneralSettings generalSettings;
|
||||
|
||||
@Override
|
||||
@BeforeClass(inheritGroups = true)
|
||||
|
@ -82,9 +84,66 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// PUT /admin/org/{id}/settings/email
|
||||
|
||||
// GET /admin/org/{id}/settings/general
|
||||
|
||||
// PUT /admin/org/{id}/settings/general
|
||||
@Test(testName = "GET /admin/org/{id}/settings/generalSettings")
|
||||
public void testGetGeneralSettings() {
|
||||
generalSettings = orgClient.getGeneralSettings(orgRef.getURI());
|
||||
|
||||
Checks.checkGeneralSettings(generalSettings);
|
||||
}
|
||||
|
||||
@Test(testName = "PUT /admin/org/{id}/settings/generalSettings",
|
||||
dependsOnMethods = { "testGetGeneralSettings" }, enabled = false )
|
||||
public void testUpdateGeneralSettings() {
|
||||
// boolean canPublishCatalogs = generalSettings.canPublishCatalogs(); // FIXME: did not update
|
||||
Integer deployedVMQuota = generalSettings.getDeployedVMQuota();
|
||||
Integer storedVmQuota = generalSettings.getStoredVmQuota();
|
||||
boolean useServerBootSequence = generalSettings.useServerBootSequence();
|
||||
Integer delayAfterPowerOnSeconds = generalSettings.getDelayAfterPowerOnSeconds();
|
||||
|
||||
try {
|
||||
generalSettings = generalSettings.toBuilder()
|
||||
// .canPublishCatalogs(!canPublishCatalogs)
|
||||
.deployedVMQuota(deployedVMQuota+1)
|
||||
.storedVmQuota(storedVmQuota+1)
|
||||
.useServerBootSequence(!useServerBootSequence)
|
||||
.delayAfterPowerOnSeconds(delayAfterPowerOnSeconds+1)
|
||||
.build();
|
||||
|
||||
generalSettings = orgClient.updateGeneralSettings(
|
||||
orgRef.getURI(), generalSettings);
|
||||
|
||||
// assertTrue(equal(generalSettings.canPublishCatalogs(), !canPublishCatalogs),
|
||||
// String.format(OBJ_FIELD_UPDATABLE,
|
||||
// "generalSettings", "canPublishCatalogs"));
|
||||
assertTrue(equal(generalSettings.getDeployedVMQuota(), deployedVMQuota+1),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"generalSettings", "deployedVMQuota"));
|
||||
assertTrue(equal(generalSettings.getStoredVmQuota(), storedVmQuota+1),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"generalSettings", "storedVmQuota"));
|
||||
assertTrue(equal(generalSettings.useServerBootSequence(), !useServerBootSequence),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"generalSettings", "useServerBootSequence"));
|
||||
assertTrue(equal(generalSettings.getDelayAfterPowerOnSeconds(), delayAfterPowerOnSeconds+1),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"generalSettings", "delayAfterPowerOnSeconds"));
|
||||
|
||||
//TODO negative tests?
|
||||
|
||||
Checks.checkGeneralSettings(generalSettings);
|
||||
} finally {
|
||||
generalSettings = generalSettings.toBuilder()
|
||||
// .canPublishCatalogs(canPublishCatalogs)
|
||||
.deployedVMQuota(deployedVMQuota)
|
||||
.storedVmQuota(storedVmQuota)
|
||||
.useServerBootSequence(useServerBootSequence)
|
||||
.delayAfterPowerOnSeconds(delayAfterPowerOnSeconds)
|
||||
.build();
|
||||
|
||||
generalSettings = orgClient.updateGeneralSettings(
|
||||
orgRef.getURI(), generalSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/org/{id}/settings/ldap")
|
||||
public void getLdapSettings() {
|
||||
|
|
Loading…
Reference in New Issue