mirror of https://github.com/apache/jclouds.git
in cloudstack operations that affect resources, account and domainid must be paired
This commit is contained in:
parent
3b752ea955
commit
3c0cffc54f
|
@ -34,21 +34,15 @@ public class AssociateIPAddressOptions extends BaseHttpRequestOptions {
|
||||||
public static final AssociateIPAddressOptions NONE = new AssociateIPAddressOptions();
|
public static final AssociateIPAddressOptions NONE = new AssociateIPAddressOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param domainId
|
*
|
||||||
* the ID of the domain to associate with this IP address
|
|
||||||
*/
|
|
||||||
public AssociateIPAddressOptions domainId(long domainId) {
|
|
||||||
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
|
||||||
return this;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param account
|
* @param account
|
||||||
* the account to associate with this IP address
|
* an optional account for the ip address
|
||||||
|
* @param domain
|
||||||
|
* domain id
|
||||||
*/
|
*/
|
||||||
public AssociateIPAddressOptions account(String account) {
|
public AssociateIPAddressOptions accountInDomain(String account, long domain) {
|
||||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||||
|
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domain + ""));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,21 +57,12 @@ public class AssociateIPAddressOptions extends BaseHttpRequestOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AssociateIPAddressOptions#account
|
* @see AssociateIPAddressOptions#accountInDomain
|
||||||
*/
|
*/
|
||||||
public static AssociateIPAddressOptions account(String account) {
|
public static AssociateIPAddressOptions accountInDomain(String account, long domain) {
|
||||||
AssociateIPAddressOptions options = new AssociateIPAddressOptions();
|
AssociateIPAddressOptions options = new AssociateIPAddressOptions();
|
||||||
return options.account(account);
|
return options.accountInDomain(account, domain);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see AssociateIPAddressOptions#domainId
|
|
||||||
*/
|
|
||||||
public static AssociateIPAddressOptions domainId(long id) {
|
|
||||||
AssociateIPAddressOptions options = new AssociateIPAddressOptions();
|
|
||||||
return options.domainId(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,8 +46,9 @@ public class DeployVirtualMachineOptions extends BaseHttpRequestOptions {
|
||||||
* domain id
|
* domain id
|
||||||
*/
|
*/
|
||||||
public DeployVirtualMachineOptions accountInDomain(String account, long domain) {
|
public DeployVirtualMachineOptions accountInDomain(String account, long domain) {
|
||||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||||
return domainId(domain);
|
this.queryParameters.replaceValues("domain", ImmutableSet.of(domain + ""));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,15 +76,6 @@ public class DeployVirtualMachineOptions extends BaseHttpRequestOptions {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param domainId
|
|
||||||
* an optional domainId for the virtual machine
|
|
||||||
*/
|
|
||||||
public DeployVirtualMachineOptions domainId(long domainId) {
|
|
||||||
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param group
|
* @param group
|
||||||
* an optional group for the virtual machine
|
* an optional group for the virtual machine
|
||||||
|
@ -208,14 +200,6 @@ public class DeployVirtualMachineOptions extends BaseHttpRequestOptions {
|
||||||
return options.displayName(displayName);
|
return options.displayName(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see DeployVirtualMachineOptions#domainId
|
|
||||||
*/
|
|
||||||
public static DeployVirtualMachineOptions domainId(long id) {
|
|
||||||
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
|
||||||
return options.domainId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DeployVirtualMachineOptions#group
|
* @see DeployVirtualMachineOptions#group
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import static org.jclouds.cloudstack.options.AssociateIPAddressOptions.Builder.account;
|
import static org.jclouds.cloudstack.options.AssociateIPAddressOptions.Builder.accountInDomain;
|
||||||
import static org.jclouds.cloudstack.options.AssociateIPAddressOptions.Builder.domainId;
|
|
||||||
import static org.jclouds.cloudstack.options.AssociateIPAddressOptions.Builder.networkId;
|
import static org.jclouds.cloudstack.options.AssociateIPAddressOptions.Builder.networkId;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -36,23 +35,15 @@ import com.google.common.collect.ImmutableList;
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class AssociateIPAddressOptionsTest {
|
public class AssociateIPAddressOptionsTest {
|
||||||
|
|
||||||
public void testAccount() {
|
public void testAccountInDomainId() {
|
||||||
AssociateIPAddressOptions options = new AssociateIPAddressOptions().account("account");
|
AssociateIPAddressOptions options = new AssociateIPAddressOptions().accountInDomain("adrian", 6);
|
||||||
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
}
|
|
||||||
|
|
||||||
public void testAccountStatic() {
|
|
||||||
AssociateIPAddressOptions options = account("account");
|
|
||||||
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDomainId() {
|
|
||||||
AssociateIPAddressOptions options = new AssociateIPAddressOptions().domainId(6);
|
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDomainIdStatic() {
|
public void testAccountInDomainIdStatic() {
|
||||||
AssociateIPAddressOptions options = domainId(6);
|
AssociateIPAddressOptions options = accountInDomain("adrian", 6);
|
||||||
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue