mirror of https://github.com/apache/jclouds.git
Issue #830 vcloud-director: added admin-query client
This commit is contained in:
parent
ec8b428220
commit
eea5b261ba
|
@ -28,12 +28,15 @@ import org.jclouds.vcloud.director.v1_5.domain.Org;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminNetworkAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminQueryAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.GroupAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
|
||||
|
@ -68,6 +71,12 @@ public interface VCloudDirectorAsyncClient {
|
|||
@Delegate
|
||||
QueryAsyncClient getQueryClient();
|
||||
|
||||
/**
|
||||
* @return asynchronous access to admin query features
|
||||
*/
|
||||
@Delegate
|
||||
AdminQueryAsyncClient getAdminQueryClient();
|
||||
|
||||
/**
|
||||
* @return asynchronous access to {@link Org} features
|
||||
*/
|
||||
|
|
|
@ -31,12 +31,15 @@ import org.jclouds.vcloud.director.v1_5.domain.Org;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminNetworkClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminQueryClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.GroupClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.MediaClient;
|
||||
|
@ -72,6 +75,12 @@ public interface VCloudDirectorClient {
|
|||
@Delegate
|
||||
QueryClient getQueryClient();
|
||||
|
||||
/**
|
||||
* @return asynchronous access to admin query features
|
||||
*/
|
||||
@Delegate
|
||||
AdminQueryClient getAdminQueryClient();
|
||||
|
||||
/**
|
||||
* @return synchronous access to {@link Org} features
|
||||
*/
|
||||
|
|
|
@ -48,6 +48,8 @@ import org.jclouds.vcloud.director.v1_5.features.AdminNetworkAsyncClient;
|
|||
import org.jclouds.vcloud.director.v1_5.features.AdminNetworkClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminQueryAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminQueryClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
|
||||
|
@ -110,6 +112,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
|
|||
.put(NetworkClient.class, NetworkAsyncClient.class)
|
||||
.put(OrgClient.class, OrgAsyncClient.class)
|
||||
.put(QueryClient.class, QueryAsyncClient.class)
|
||||
.put(AdminQueryClient.class, AdminQueryAsyncClient.class)
|
||||
.put(MediaClient.class, MediaAsyncClient.class)
|
||||
.put(TaskClient.class, TaskAsyncClient.class)
|
||||
.put(VdcClient.class, VdcAsyncClient.class)
|
||||
|
|
|
@ -67,6 +67,9 @@ import com.google.common.collect.Lists;
|
|||
"vdcs"
|
||||
})
|
||||
public class Vdcs {
|
||||
|
||||
// FIXME Delete Vdcs, and use Set<Vdc>
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a AdminGroup vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@XmlRootElement(name = "GroupRecord")
|
||||
@XmlType(name = "QueryResultAdminGroupRecordType")
|
||||
public class QueryResultAdminGroupRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultAdminGroupRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private String org;
|
||||
private String roleName;
|
||||
private Boolean isReadOnly;
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminGroupRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminGroupRecord#getOrg()
|
||||
*/
|
||||
public B org(String val) {
|
||||
this.org = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminGroupRecord#getRoleName()
|
||||
*/
|
||||
public B roleName(String val) {
|
||||
this.roleName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminGroupRecord#isReadOnly()
|
||||
*/
|
||||
public B isReadOnly(Boolean val) {
|
||||
this.isReadOnly = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultAdminGroupRecord build() {
|
||||
return new QueryResultAdminGroupRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultAdminGroupRecord(QueryResultAdminGroupRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.org(in.getOrg())
|
||||
.roleName(in.getRoleName())
|
||||
.isReadOnly(in.isReadOnly());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private String org;
|
||||
@XmlAttribute
|
||||
private String roleName;
|
||||
@XmlAttribute
|
||||
private Boolean isReadOnly;
|
||||
|
||||
protected QueryResultAdminGroupRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.org = builder.org;
|
||||
this.roleName = builder.roleName;
|
||||
this.isReadOnly = builder.isReadOnly;
|
||||
}
|
||||
|
||||
protected QueryResultAdminGroupRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization reference or id
|
||||
*/
|
||||
public String getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
/**
|
||||
* Role name
|
||||
*/
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is read only
|
||||
*/
|
||||
public Boolean isReadOnly() {
|
||||
return isReadOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultAdminGroupRecord that = QueryResultAdminGroupRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(org, that.org) && equal(roleName, that.roleName) &&
|
||||
equal(isReadOnly, that.isReadOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, org, roleName, isReadOnly);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("org", org).add("roleName", roleName).add("isReadOnly", isReadOnly);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,321 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a AdminUser vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@XmlRootElement(name = "UserRecord")
|
||||
@XmlType(name = "QueryResultAdminUserRecordType")
|
||||
public class QueryResultAdminUserRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultAdminUserRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private String org;
|
||||
private String fullName;
|
||||
private Boolean isEnabled;
|
||||
private Integer numberOfDeployedVMs;
|
||||
private Integer deployedVMQuota;
|
||||
private Integer numberOfStoredVMs;
|
||||
private Integer storedVMQuota;
|
||||
private Boolean isLdapUser;
|
||||
private Integer deployedVMQuotaRank;
|
||||
private Integer storedVMQuotaRank;
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getOrg()
|
||||
*/
|
||||
public B org(String val) {
|
||||
this.org = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getFullName()
|
||||
*/
|
||||
public B fullName(String val) {
|
||||
this.fullName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#isEnabled()
|
||||
*/
|
||||
public B isEnabled(Boolean val) {
|
||||
this.isEnabled = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getNumberOfDeployedVMs()
|
||||
*/
|
||||
public B numberOfDeployedVMs(Integer val) {
|
||||
this.numberOfDeployedVMs = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getDeployedVMQuota()
|
||||
*/
|
||||
public B deployedVMQuota(Integer val) {
|
||||
this.deployedVMQuota = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getNumberOfStoredVMs()
|
||||
*/
|
||||
public B numberOfStoredVMs(Integer val) {
|
||||
this.numberOfStoredVMs = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getStoredVMQuota()
|
||||
*/
|
||||
public B storedVMQuota(Integer val) {
|
||||
this.storedVMQuota = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#isLdapUser()
|
||||
*/
|
||||
public B isLdapUser(Boolean val) {
|
||||
this.isLdapUser = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getDeployedVMQuotaRank()
|
||||
*/
|
||||
public B deployedVMQuotaRank(Integer val) {
|
||||
this.deployedVMQuotaRank = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminUserRecord#getStoredVMQuotaRank()
|
||||
*/
|
||||
public B storedVMQuotaRank(Integer val) {
|
||||
this.storedVMQuotaRank = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultAdminUserRecord build() {
|
||||
return new QueryResultAdminUserRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultAdminUserRecord(QueryResultAdminUserRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.org(in.getOrg())
|
||||
.fullName(in.getFullName())
|
||||
.isEnabled(in.isEnabled())
|
||||
.numberOfDeployedVMs(in.getNumberOfDeployedVMs())
|
||||
.deployedVMQuota(in.getDeployedVMQuota())
|
||||
.numberOfStoredVMs(in.getNumberOfStoredVMs())
|
||||
.storedVMQuota(in.getStoredVMQuota())
|
||||
.isLdapUser(in.isLdapUser())
|
||||
.deployedVMQuotaRank(in.getDeployedVMQuotaRank())
|
||||
.storedVMQuotaRank(in.getStoredVMQuotaRank());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private String org;
|
||||
@XmlAttribute
|
||||
private String fullName;
|
||||
@XmlAttribute
|
||||
private Boolean isEnabled;
|
||||
@XmlAttribute
|
||||
private Integer numberOfDeployedVMs;
|
||||
@XmlAttribute
|
||||
private Integer deployedVMQuota;
|
||||
@XmlAttribute
|
||||
private Integer numberOfStoredVMs;
|
||||
@XmlAttribute
|
||||
private Integer storedVMQuota;
|
||||
@XmlAttribute
|
||||
private Boolean isLdapUser;
|
||||
@XmlAttribute
|
||||
private Integer deployedVMQuotaRank;
|
||||
@XmlAttribute
|
||||
private Integer storedVMQuotaRank;
|
||||
|
||||
protected QueryResultAdminUserRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.org = builder.org;
|
||||
this.fullName = builder.fullName;
|
||||
this.isEnabled = builder.isEnabled;
|
||||
this.numberOfDeployedVMs = builder.numberOfDeployedVMs;
|
||||
this.deployedVMQuota = builder.deployedVMQuota;
|
||||
this.numberOfStoredVMs = builder.numberOfStoredVMs;
|
||||
this.storedVMQuota = builder.storedVMQuota;
|
||||
this.isLdapUser = builder.isLdapUser;
|
||||
this.deployedVMQuotaRank = builder.deployedVMQuotaRank;
|
||||
this.storedVMQuotaRank = builder.storedVMQuotaRank;
|
||||
}
|
||||
|
||||
protected QueryResultAdminUserRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization reference or id
|
||||
*/
|
||||
public String getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full name
|
||||
*/
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is enabled
|
||||
*/
|
||||
public Boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of deployed VMs
|
||||
*/
|
||||
public Integer getNumberOfDeployedVMs() {
|
||||
return numberOfDeployedVMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deployed VM quota
|
||||
*/
|
||||
public Integer getDeployedVMQuota() {
|
||||
return deployedVMQuota;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of stored VMs
|
||||
*/
|
||||
public Integer getNumberOfStoredVMs() {
|
||||
return numberOfStoredVMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored VM Quota
|
||||
*/
|
||||
public Integer getStoredVMQuota() {
|
||||
return storedVMQuota;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows if the user was imported from LDAP
|
||||
*/
|
||||
public Boolean isLdapUser() {
|
||||
return isLdapUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deployed VM quota rank
|
||||
*/
|
||||
public Integer getDeployedVMQuotaRank() {
|
||||
return deployedVMQuotaRank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored VM Quota rank
|
||||
*/
|
||||
public Integer getStoredVMQuotaRank() {
|
||||
return storedVMQuotaRank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultAdminUserRecord that = QueryResultAdminUserRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(org, that.org) && equal(fullName, that.fullName)
|
||||
&& equal(isEnabled, that.isEnabled) && equal(numberOfDeployedVMs, that.numberOfDeployedVMs)
|
||||
&& equal(deployedVMQuota, that.deployedVMQuota) && equal(numberOfStoredVMs, that.numberOfStoredVMs)
|
||||
&& equal(storedVMQuota, that.storedVMQuota) && equal(isLdapUser, that.isLdapUser)
|
||||
&& equal(deployedVMQuotaRank, that.deployedVMQuotaRank) && equal(storedVMQuotaRank, that.storedVMQuotaRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, org, fullName, isEnabled, numberOfDeployedVMs, deployedVMQuota, numberOfStoredVMs, storedVMQuota, isLdapUser, deployedVMQuotaRank, storedVMQuotaRank);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("org", org).add("fullName", fullName).add("isEnabled", isEnabled)
|
||||
.add("numberOfDeployedVMs", numberOfDeployedVMs).add("deployedVMQuota", deployedVMQuota)
|
||||
.add("numberOfStoredVMs", numberOfStoredVMs).add("storedVMQuota", storedVMQuota)
|
||||
.add("isLdapUser", isLdapUser).add("deployedVMQuotaRank", deployedVMQuotaRank)
|
||||
.add("storedVMQuotaRank", storedVMQuotaRank);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,552 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a AdminVdc vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@XmlRootElement(name = "VdcRecord")
|
||||
@XmlType(name = "QueryResultAdminVdcRecordType")
|
||||
public class QueryResultAdminVdcRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultAdminVdcRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private Boolean isEnabled;
|
||||
private Long cpuAllocationMhz;
|
||||
private Long cpuLimitMhz;
|
||||
private Long cpuUsedMhz;
|
||||
private Long memoryAllocationMB;
|
||||
private Long memoryLimitMB;
|
||||
private Long memoryUsedMB;
|
||||
private Long storageAllocationMB;
|
||||
private Long storageLimitMB;
|
||||
private Long storageUsedMB;
|
||||
private String providerVdcName;
|
||||
private String providerVdc;
|
||||
private String orgName;
|
||||
private String org;
|
||||
private Integer numberOfVApps;
|
||||
private Integer numberOfMedia;
|
||||
private Integer numberOfVAppTemplates;
|
||||
private Boolean isSystemVdc;
|
||||
private Boolean isBusy;
|
||||
private String status;
|
||||
private String networkPool;
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#isEnabled()
|
||||
*/
|
||||
public B isEnabled(Boolean val) {
|
||||
this.isEnabled = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getCpuAllocationMhz()
|
||||
*/
|
||||
public B cpuAllocationMhz(Long val) {
|
||||
this.cpuAllocationMhz = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getCpuLimitMhz()
|
||||
*/
|
||||
public B cpuLimitMhz(Long val) {
|
||||
this.cpuLimitMhz = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getCpuUsedMhz()
|
||||
*/
|
||||
public B cpuUsedMhz(Long val) {
|
||||
this.cpuUsedMhz = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getMemoryAllocationMB()
|
||||
*/
|
||||
public B memoryAllocationMB(Long val) {
|
||||
this.memoryAllocationMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getMemoryLimitMB()
|
||||
*/
|
||||
public B memoryLimitMB(Long val) {
|
||||
this.memoryLimitMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getMemoryUsedMB()
|
||||
*/
|
||||
public B memoryUsedMB(Long val) {
|
||||
this.memoryUsedMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getStorageAllocationMB()
|
||||
*/
|
||||
public B storageAllocationMB(Long val) {
|
||||
this.storageAllocationMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getStorageLimitMB()
|
||||
*/
|
||||
public B storageLimitMB(Long val) {
|
||||
this.storageLimitMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getStorageUsedMB()
|
||||
*/
|
||||
public B storageUsedMB(Long val) {
|
||||
this.storageUsedMB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getProviderVdcName()
|
||||
*/
|
||||
public B providerVdcName(String val) {
|
||||
this.providerVdcName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getProviderVdc()
|
||||
*/
|
||||
public B providerVdc(String val) {
|
||||
this.providerVdc = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getOrgName()
|
||||
*/
|
||||
public B orgName(String val) {
|
||||
this.orgName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getOrg()
|
||||
*/
|
||||
public B org(String val) {
|
||||
this.org = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getNumberOfVApps()
|
||||
*/
|
||||
public B numberOfVApps(Integer val) {
|
||||
this.numberOfVApps = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getNumberOfMedia()
|
||||
*/
|
||||
public B numberOfMedia(Integer val) {
|
||||
this.numberOfMedia = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getNumberOfVAppTemplates()
|
||||
*/
|
||||
public B numberOfVAppTemplates(Integer val) {
|
||||
this.numberOfVAppTemplates = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#isSystemVdc()
|
||||
*/
|
||||
public B isSystemVdc(Boolean val) {
|
||||
this.isSystemVdc = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#isBusy()
|
||||
*/
|
||||
public B isBusy(Boolean val) {
|
||||
this.isBusy = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getStatus()
|
||||
*/
|
||||
public B status(String val) {
|
||||
this.status = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultAdminVdcRecord#getNetworkPool()
|
||||
*/
|
||||
public B networkPool(String val) {
|
||||
this.networkPool = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultAdminVdcRecord build() {
|
||||
return new QueryResultAdminVdcRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultAdminVdcRecord(QueryResultAdminVdcRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.isEnabled(in.isEnabled())
|
||||
.cpuAllocationMhz(in.getCpuAllocationMhz())
|
||||
.cpuLimitMhz(in.getCpuLimitMhz())
|
||||
.cpuUsedMhz(in.getCpuUsedMhz())
|
||||
.memoryAllocationMB(in.getMemoryAllocationMB())
|
||||
.memoryLimitMB(in.getMemoryLimitMB())
|
||||
.memoryUsedMB(in.getMemoryUsedMB())
|
||||
.storageAllocationMB(in.getStorageAllocationMB())
|
||||
.storageLimitMB(in.getStorageLimitMB())
|
||||
.storageUsedMB(in.getStorageUsedMB())
|
||||
.providerVdcName(in.getProviderVdcName())
|
||||
.providerVdc(in.getProviderVdc())
|
||||
.orgName(in.getOrgName())
|
||||
.org(in.getOrg())
|
||||
.numberOfVApps(in.getNumberOfVApps())
|
||||
.numberOfMedia(in.getNumberOfMedia())
|
||||
.numberOfVAppTemplates(in.getNumberOfVAppTemplates())
|
||||
.isSystemVdc(in.isSystemVdc())
|
||||
.isBusy(in.isBusy())
|
||||
.status(in.getStatus())
|
||||
.networkPool(in.getNetworkPool());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private Boolean isEnabled;
|
||||
@XmlAttribute
|
||||
private Long cpuAllocationMhz;
|
||||
@XmlAttribute
|
||||
private Long cpuLimitMhz;
|
||||
@XmlAttribute
|
||||
private Long cpuUsedMhz;
|
||||
@XmlAttribute
|
||||
private Long memoryAllocationMB;
|
||||
@XmlAttribute
|
||||
private Long memoryLimitMB;
|
||||
@XmlAttribute
|
||||
private Long memoryUsedMB;
|
||||
@XmlAttribute
|
||||
private Long storageAllocationMB;
|
||||
@XmlAttribute
|
||||
private Long storageLimitMB;
|
||||
@XmlAttribute
|
||||
private Long storageUsedMB;
|
||||
@XmlAttribute
|
||||
private String providerVdcName;
|
||||
@XmlAttribute
|
||||
private String providerVdc;
|
||||
@XmlAttribute
|
||||
private String orgName;
|
||||
@XmlAttribute
|
||||
private String org;
|
||||
@XmlAttribute
|
||||
private Integer numberOfVApps;
|
||||
@XmlAttribute
|
||||
private Integer numberOfMedia;
|
||||
@XmlAttribute
|
||||
private Integer numberOfVAppTemplates;
|
||||
@XmlAttribute
|
||||
private Boolean isSystemVdc;
|
||||
@XmlAttribute
|
||||
private Boolean isBusy;
|
||||
@XmlAttribute
|
||||
private String status;
|
||||
@XmlAttribute
|
||||
private String networkPool;
|
||||
|
||||
protected QueryResultAdminVdcRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.isEnabled = builder.isEnabled;
|
||||
this.cpuAllocationMhz = builder.cpuAllocationMhz;
|
||||
this.cpuLimitMhz = builder.cpuLimitMhz;
|
||||
this.cpuUsedMhz = builder.cpuUsedMhz;
|
||||
this.memoryAllocationMB = builder.memoryAllocationMB;
|
||||
this.memoryLimitMB = builder.memoryLimitMB;
|
||||
this.memoryUsedMB = builder.memoryUsedMB;
|
||||
this.storageAllocationMB = builder.storageAllocationMB;
|
||||
this.storageLimitMB = builder.storageLimitMB;
|
||||
this.storageUsedMB = builder.storageUsedMB;
|
||||
this.providerVdcName = builder.providerVdcName;
|
||||
this.providerVdc = builder.providerVdc;
|
||||
this.orgName = builder.orgName;
|
||||
this.org = builder.org;
|
||||
this.numberOfVApps = builder.numberOfVApps;
|
||||
this.numberOfMedia = builder.numberOfMedia;
|
||||
this.numberOfVAppTemplates = builder.numberOfVAppTemplates;
|
||||
this.isSystemVdc = builder.isSystemVdc;
|
||||
this.isBusy = builder.isBusy;
|
||||
this.status = builder.status;
|
||||
this.networkPool = builder.networkPool;
|
||||
}
|
||||
|
||||
protected QueryResultAdminVdcRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is enabled
|
||||
*/
|
||||
public Boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cpu allocation in Mhz
|
||||
*/
|
||||
public Long getCpuAllocationMhz() {
|
||||
return cpuAllocationMhz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cpu limit in Mhz
|
||||
*/
|
||||
public Long getCpuLimitMhz() {
|
||||
return cpuLimitMhz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cpu used in Mhz
|
||||
*/
|
||||
public Long getCpuUsedMhz() {
|
||||
return cpuUsedMhz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory allocation in MB
|
||||
*/
|
||||
public Long getMemoryAllocationMB() {
|
||||
return memoryAllocationMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory limit in MB
|
||||
*/
|
||||
public Long getMemoryLimitMB() {
|
||||
return memoryLimitMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory used in MB
|
||||
*/
|
||||
public Long getMemoryUsedMB() {
|
||||
return memoryUsedMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage allocation in MB
|
||||
*/
|
||||
public Long getStorageAllocationMB() {
|
||||
return storageAllocationMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage limit in MB
|
||||
*/
|
||||
public Long getStorageLimitMB() {
|
||||
return storageLimitMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage used in MB
|
||||
*/
|
||||
public Long getStorageUsedMB() {
|
||||
return storageUsedMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* provider vDC name
|
||||
*/
|
||||
public String getProviderVdcName() {
|
||||
return providerVdcName;
|
||||
}
|
||||
|
||||
/**
|
||||
* vDC reference or id
|
||||
*/
|
||||
public String getProviderVdc() {
|
||||
return providerVdc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization name
|
||||
*/
|
||||
public String getOrgName() {
|
||||
return orgName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization reference or id
|
||||
*/
|
||||
public String getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of vApps
|
||||
*/
|
||||
public Integer getNumberOfVApps() {
|
||||
return numberOfVApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of media
|
||||
*/
|
||||
public Integer getNumberOfMedia() {
|
||||
return numberOfMedia;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of vApp templates
|
||||
*/
|
||||
public Integer getNumberOfVAppTemplates() {
|
||||
return numberOfVAppTemplates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows wheter it is a system vDC
|
||||
*/
|
||||
public Boolean isSystemVdc() {
|
||||
return isSystemVdc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is busy
|
||||
*/
|
||||
public Boolean isBusy() {
|
||||
return isBusy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network pool reference or id
|
||||
*/
|
||||
public String getNetworkPool() {
|
||||
return networkPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultAdminVdcRecord that = QueryResultAdminVdcRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(isEnabled, that.isEnabled)
|
||||
&& equal(cpuAllocationMhz, that.cpuAllocationMhz) && equal(cpuLimitMhz, that.cpuLimitMhz)
|
||||
&& equal(cpuUsedMhz, that.cpuUsedMhz) && equal(memoryAllocationMB, that.memoryAllocationMB)
|
||||
&& equal(memoryLimitMB, that.memoryLimitMB) && equal(memoryUsedMB, that.memoryUsedMB)
|
||||
&& equal(storageAllocationMB, that.storageAllocationMB) && equal(storageLimitMB, that.storageLimitMB)
|
||||
&& equal(storageUsedMB, that.storageUsedMB) && equal(providerVdcName, that.providerVdcName)
|
||||
&& equal(providerVdc, that.providerVdc) && equal(orgName, that.orgName) && equal(org, that.org)
|
||||
&& equal(numberOfVApps, that.numberOfVApps) && equal(numberOfMedia, that.numberOfMedia)
|
||||
&& equal(numberOfVAppTemplates, that.numberOfVAppTemplates) && equal(isSystemVdc, that.isSystemVdc)
|
||||
&& equal(isBusy, that.isBusy) && equal(status, that.status) && equal(networkPool, that.networkPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, isEnabled, cpuAllocationMhz, cpuLimitMhz, cpuUsedMhz,
|
||||
memoryAllocationMB, memoryLimitMB, memoryUsedMB, storageAllocationMB, storageLimitMB, storageUsedMB,
|
||||
providerVdcName, providerVdc, orgName, org, numberOfVApps, numberOfMedia, numberOfVAppTemplates,
|
||||
isSystemVdc, isBusy, status, networkPool);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("isEnabled", isEnabled).add("cpuAllocationMhz", cpuAllocationMhz)
|
||||
.add("cpuLimitMhz", cpuLimitMhz).add("cpuUsedMhz", cpuUsedMhz).add("memoryAllocationMB", memoryAllocationMB)
|
||||
.add("memoryLimitMB", memoryLimitMB).add("memoryUsedMB", memoryUsedMB)
|
||||
.add("storageAllocationMB", storageAllocationMB).add("storageLimitMB", storageLimitMB)
|
||||
.add("storageUsedMB", storageUsedMB).add("providerVdcName", providerVdcName).add("providerVdc", providerVdc)
|
||||
.add("orgName", orgName).add("org", org).add("numberOfVApps", numberOfVApps).add("numberOfMedia", numberOfMedia)
|
||||
.add("numberOfVAppTemplates", numberOfVAppTemplates).add("isSystemVdc", isSystemVdc).add("isBusy", isBusy)
|
||||
.add("status", status).add("networkPool", networkPool);
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@ import java.util.Set;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
|
@ -50,7 +49,12 @@ import com.google.common.collect.Sets;
|
|||
QueryResultVMRecord.class,
|
||||
QueryResultDatastoreRecord.class,
|
||||
QueryResultCatalogRecord.class,
|
||||
QueryResultNetworkRecord.class}
|
||||
QueryResultNetworkRecord.class,
|
||||
QueryResultRoleRecord.class,
|
||||
QueryResultAdminGroupRecord.class,
|
||||
QueryResultAdminVdcRecord.class,
|
||||
QueryResultAdminUserRecord.class,
|
||||
QueryResultStrandedUserRecord.class}
|
||||
)
|
||||
public class QueryResultRecordType {
|
||||
|
||||
|
|
|
@ -45,30 +45,30 @@ import com.google.common.collect.Sets;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlRootElement(name = "QueryResultRecords")
|
||||
public class QueryResultRecords extends ContainerType {
|
||||
public class QueryResultRecords<R extends QueryResultRecordType> extends ContainerType {
|
||||
|
||||
public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_RECORDS;
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
public static <R extends QueryResultRecordType> Builder<R, ?> builder() {
|
||||
return new ConcreteBuilder<R>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultRecords(this);
|
||||
public Builder<R, ?> toBuilder() {
|
||||
return QueryResultRecords.<R>builder().fromQueryResultRecords(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
private static class ConcreteBuilder<R extends QueryResultRecordType> extends Builder<R, ConcreteBuilder<R>> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends ContainerType.Builder<B> {
|
||||
public static class Builder<R extends QueryResultRecordType, B extends Builder<R, B>> extends ContainerType.Builder<B> {
|
||||
|
||||
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
|
||||
private Set<R> records = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see QueryResultRecords#getRecords()
|
||||
*/
|
||||
public B records(Set<? extends QueryResultRecordType> records) {
|
||||
public B records(Set<? extends R> records) {
|
||||
this.records = Sets.newLinkedHashSet(checkNotNull(records, "records"));
|
||||
return self();
|
||||
}
|
||||
|
@ -76,22 +76,22 @@ public class QueryResultRecords extends ContainerType {
|
|||
/**
|
||||
* @see QueryResultRecords#getRecords()
|
||||
*/
|
||||
public B record(QueryResultRecordType record) {
|
||||
public B record(R record) {
|
||||
this.records.add(record);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultRecords build() {
|
||||
return new QueryResultRecords(this);
|
||||
public QueryResultRecords<R> build() {
|
||||
return new QueryResultRecords<R>(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultRecords(QueryResultRecords in) {
|
||||
public B fromQueryResultRecords(QueryResultRecords<R> in) {
|
||||
return fromContainerType(in).records(in.getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
protected QueryResultRecords(Builder<?> builder) {
|
||||
protected QueryResultRecords(Builder<R,?> builder) {
|
||||
super(builder);
|
||||
this.records = ImmutableSet.copyOf(builder.records);
|
||||
}
|
||||
|
@ -101,12 +101,12 @@ public class QueryResultRecords extends ContainerType {
|
|||
}
|
||||
|
||||
@XmlElementRef
|
||||
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
|
||||
private Set<R> records = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Set of records representing query results.
|
||||
*/
|
||||
public Set<QueryResultRecordType> getRecords() {
|
||||
public Set<R> getRecords() {
|
||||
return Collections.unmodifiableSet(records);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class QueryResultRecords extends ContainerType {
|
|||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultRecords that = QueryResultRecords.class.cast(o);
|
||||
QueryResultRecords<?> that = QueryResultRecords.class.cast(o);
|
||||
return super.equals(that) && equal(this.records, that.records);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a Right vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
public class QueryResultRightRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultRightRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* @see QueryResultRightRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultRightRecord#getCategory()
|
||||
*/
|
||||
public B category(String val) {
|
||||
this.category = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultRightRecord build() {
|
||||
return new QueryResultRightRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultRightRecord(QueryResultRightRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.category(in.getCategory());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private String category;
|
||||
|
||||
protected QueryResultRightRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.category = builder.category;
|
||||
}
|
||||
|
||||
protected QueryResultRightRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultRightRecord that = QueryResultRightRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(category, that.category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, category);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("category", category);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a Role vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@XmlRootElement(name = "RoleRecord")
|
||||
@XmlType(name = "QueryResultRoleRecordType")
|
||||
public class QueryResultRoleRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultRoleRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private Boolean isReadOnly;
|
||||
|
||||
/**
|
||||
* @see QueryResultRoleRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultRoleRecord#isReadOnly()
|
||||
*/
|
||||
public B isReadOnly(Boolean val) {
|
||||
this.isReadOnly = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultRoleRecord build() {
|
||||
return new QueryResultRoleRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultRoleRecord(QueryResultRoleRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.isReadOnly(in.isReadOnly());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private Boolean isReadOnly;
|
||||
|
||||
protected QueryResultRoleRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.isReadOnly = builder.isReadOnly;
|
||||
}
|
||||
|
||||
protected QueryResultRoleRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is read only
|
||||
*/
|
||||
public Boolean isReadOnly() {
|
||||
return isReadOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultRoleRecord that = QueryResultRoleRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(isReadOnly, that.isReadOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, isReadOnly);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("isReadOnly", isReadOnly);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* 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.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a StrandedUser vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@XmlRootElement(name = "StrandedUserRecord")
|
||||
@XmlType(name = "QueryResultStrandedUserRecordType")
|
||||
public class QueryResultStrandedUserRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultStrandedUserRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String name;
|
||||
private String fullName;
|
||||
private Boolean isInSync;
|
||||
private Integer numberOfDeployedVMs;
|
||||
private Integer numberOfStoredVMs;
|
||||
|
||||
/**
|
||||
* @see QueryResultStrandedUserRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultStrandedUserRecord#getFullName()
|
||||
*/
|
||||
public B fullName(String val) {
|
||||
this.fullName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultStrandedUserRecord#isInSync()
|
||||
*/
|
||||
public B isInSync(Boolean val) {
|
||||
this.isInSync = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultStrandedUserRecord#getNumberOfDeployedVMs()
|
||||
*/
|
||||
public B numberOfDeployedVMs(Integer val) {
|
||||
this.numberOfDeployedVMs = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultStrandedUserRecord#getNumberOfStoredVMs()
|
||||
*/
|
||||
public B numberOfStoredVMs(Integer val) {
|
||||
this.numberOfStoredVMs = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultStrandedUserRecord build() {
|
||||
return new QueryResultStrandedUserRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultStrandedUserRecord(QueryResultStrandedUserRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.name(in.getName())
|
||||
.fullName(in.getFullName())
|
||||
.isInSync(in.isInSync())
|
||||
.numberOfDeployedVMs(in.getNumberOfDeployedVMs())
|
||||
.numberOfStoredVMs(in.getNumberOfStoredVMs());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private String fullName;
|
||||
@XmlAttribute
|
||||
private Boolean isInSync;
|
||||
@XmlAttribute
|
||||
private Integer numberOfDeployedVMs;
|
||||
@XmlAttribute
|
||||
private Integer numberOfStoredVMs;
|
||||
|
||||
protected QueryResultStrandedUserRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.name = builder.name;
|
||||
this.fullName = builder.fullName;
|
||||
this.isInSync = builder.isInSync;
|
||||
this.numberOfDeployedVMs = builder.numberOfDeployedVMs;
|
||||
this.numberOfStoredVMs = builder.numberOfStoredVMs;
|
||||
}
|
||||
|
||||
protected QueryResultStrandedUserRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full name
|
||||
*/
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is in sync
|
||||
*/
|
||||
public Boolean isInSync() {
|
||||
return isInSync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of deployed VMs
|
||||
*/
|
||||
public Integer getNumberOfDeployedVMs() {
|
||||
return numberOfDeployedVMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of stored VMs
|
||||
*/
|
||||
public Integer getNumberOfStoredVMs() {
|
||||
return numberOfStoredVMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultStrandedUserRecord that = QueryResultStrandedUserRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(name, that.name) && equal(fullName, that.fullName)
|
||||
&& equal(isInSync, that.isInSync) && equal(numberOfDeployedVMs, that.numberOfDeployedVMs)
|
||||
&& equal(numberOfStoredVMs, that.numberOfStoredVMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), name, fullName, isInSync, numberOfDeployedVMs, numberOfStoredVMs);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("name", name).add("fullName", fullName).add("isInSync", isInSync)
|
||||
.add("numberOfDeployedVMs", numberOfDeployedVMs).add("numberOfStoredVMs", numberOfStoredVMs);
|
||||
}
|
||||
}
|
|
@ -22,9 +22,11 @@ import java.net.URI;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to {@link AdminCatalog} objects.
|
||||
|
@ -32,6 +34,7 @@ import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
|||
* @see AdminCatalogAsyncClient
|
||||
* @author danikov
|
||||
*/
|
||||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface AdminCatalogClient extends CatalogClient {
|
||||
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* 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 javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
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.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to {@link AdminQuery} objects.
|
||||
*
|
||||
* @see AdminQueryClient
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface AdminQueryAsyncClient extends QueryAsyncClient {
|
||||
|
||||
@GET
|
||||
@Path("/admin/groups/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> groupsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/groups/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> groupsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/orgs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> orgsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/orgs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> orgsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/rights/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rightsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/rights/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rightsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/roles/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rolesQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/roles/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rolesQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/strandedUsers/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> strandedUsersQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/strandedUsers/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> strandedUsersQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/users/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> usersQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/users/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> usersQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/vdcs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> vdcsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/vdcs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> vdcsQuery(@QueryParam("filter") String filter);
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/**
|
||||
* 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 javax.management.relation.Role;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to {@link AdminQuery} objects.
|
||||
*
|
||||
* @see AdminQueryAsyncClient
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface AdminQueryClient extends QueryClient {
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Group}s for organization the org admin belongs to by using REST API general QueryHandler
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/groups/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> groupsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> groupsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Org}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/orgs/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> orgsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> orgsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Right}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/rights/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> rightsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> rightsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Role}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/roles/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> rolesQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> rolesQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/strandedUsers/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> strandedUsersQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> strandedUsersQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/users/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> usersQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> usersQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Vdc}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/vdcs/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> vdcsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vdcsQuery(String filter);
|
||||
}
|
|
@ -28,6 +28,7 @@ import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences;
|
||||
|
||||
|
@ -66,13 +67,13 @@ public interface QueryClient {
|
|||
* @see #query(String, String)
|
||||
* @see #query(Integer, Integer, String, String, String)
|
||||
*/
|
||||
QueryResultRecords queryAll(String type);
|
||||
QueryResultRecords<QueryResultRecordType> queryAll(String type);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords query(String type, String filter);
|
||||
QueryResultRecords<QueryResultRecordType> query(String type, String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter);
|
||||
QueryResultRecords<QueryResultRecordType> query(Integer page, Integer pageSize, String format, String type, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Catalog}s by using REST API general QueryHandler.
|
||||
|
@ -83,13 +84,13 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords catalogsQueryAll();
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords catalogsQuery(String filter);
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQuery(String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String filter);
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -118,10 +119,10 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords vAppTemplatesQueryAll();
|
||||
QueryResultRecords<QueryResultRecordType> vAppTemplatesQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords vAppTemplatesQuery(String filter);
|
||||
QueryResultRecords<QueryResultRecordType> vAppTemplatesQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link VApp}s by using REST API general QueryHandler.
|
||||
|
@ -132,13 +133,13 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords vAppsQueryAll();
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords vAppsQuery(String filter);
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQuery(String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords vAppsQuery(Integer page, Integer pageSize, String filter);
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Vm}s by using REST API general QueryHandler.
|
||||
|
@ -149,10 +150,10 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords vmsQueryAll();
|
||||
QueryResultRecords<QueryResultRecordType> vmsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords vmsQuery(String filter);
|
||||
QueryResultRecords<QueryResultRecordType> vmsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link VAppReference}s by using REST API general QueryHandler.
|
||||
|
|
|
@ -36,7 +36,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.R
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -65,6 +64,7 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualSystem;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.google.common.base.Splitter;
|
||||
|
@ -1457,4 +1457,16 @@ public class Checks {
|
|||
// parent type
|
||||
checkEntityType(vdc);
|
||||
}
|
||||
|
||||
public static void checkQueryResultRecord(QueryResultRecordType record) {
|
||||
checkHref(record.getHref());
|
||||
if (record.getLinks() != null) {
|
||||
for (Link link : record.getLinks()) {
|
||||
checkLink(link);
|
||||
}
|
||||
}
|
||||
if (record.getType() != null) {
|
||||
checkType(record.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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 static org.testng.Assert.assertEquals;
|
||||
|
||||
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.Link;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* Test the {@link AdminQueryClient} by observing its side effects.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
|
||||
public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||
|
||||
// TODO Write expect tests for all other admin-query operations
|
||||
|
||||
@Test
|
||||
public void testQueryAllGroups() {
|
||||
|
||||
// TODO Need an example /admin/groups/query that actually contains records!
|
||||
|
||||
HttpRequest queryRequest = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create(endpoint + "/admin/groups/query"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
HttpResponse queryResponse= HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/query/admin/allGroups.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("group")
|
||||
.page(1)
|
||||
.pageSize(25)
|
||||
.total(0L)
|
||||
.link(Link.builder()
|
||||
.rel("alternate")
|
||||
.type("application/vnd.vmware.vcloud.query.references+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=references"))
|
||||
.build())
|
||||
.link(Link.builder()
|
||||
.rel("alternate")
|
||||
.type("application/vnd.vmware.vcloud.query.idrecords+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=idrecords"))
|
||||
.build())
|
||||
.build();
|
||||
|
||||
assertEquals(client.getAdminQueryClient().groupsQueryAll(), expected);
|
||||
}
|
||||
|
||||
// <?xml version="1.0" encoding="UTF-8"?>
|
||||
// <QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="4" pageSize="25" page="1" name="role" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records" 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="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=references"/>
|
||||
// <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=idrecords"/>
|
||||
// <RoleRecord name="vApp Author" isReadOnly="false" href="https://vcloudbeta.bluelock.com/api/admin/role/1bf4457f-a253-3cf1-b163-f319f1a31802"/>
|
||||
// </QueryResultRecords>
|
||||
|
||||
@Test
|
||||
public void testQueryAllRoles() {
|
||||
|
||||
HttpRequest queryRequest = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create(endpoint + "/admin/roles/query"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
HttpResponse queryResponse= HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/query/admin/allRoles.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("role")
|
||||
.page(1)
|
||||
.pageSize(25)
|
||||
.total(1L)
|
||||
.link(Link.builder()
|
||||
.rel("alternate")
|
||||
.type("application/vnd.vmware.vcloud.query.references+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=references"))
|
||||
.build())
|
||||
.link(Link.builder()
|
||||
.rel("alternate")
|
||||
.type("application/vnd.vmware.vcloud.query.idrecords+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=idrecords"))
|
||||
.build())
|
||||
.record(QueryResultRoleRecord.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/role/1bf4457f-a253-3cf1-b163-f319f1a31802"))
|
||||
.name("vApp Author")
|
||||
.isReadOnly(false)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
assertEquals(client.getAdminQueryClient().rolesQueryAll(), expected);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* 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 static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultAdminUserRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultAdminVdcRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRightRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultStrandedUserRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests live behavior of {@link AdminQueryClient}.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest")
|
||||
public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||
|
||||
/*
|
||||
* Convenience references to API clients.
|
||||
*/
|
||||
|
||||
private AdminQueryClient queryClient;
|
||||
|
||||
@Override
|
||||
@BeforeClass(inheritGroups = true)
|
||||
public void setupRequiredClients() {
|
||||
queryClient = context.getApi().getAdminQueryClient();
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/groups/query")
|
||||
public void testQueryAllGroups() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.groupsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/orgs/query")
|
||||
public void testQueryAllOrgs() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.orgsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/rights/query")
|
||||
public void testQueryAllRights() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rightsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
assertEquals(record.getClass(), QueryResultRightRecord.class, "incorrect record type admin query");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/roles/query")
|
||||
public void testQueryAllRoles() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rolesQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
assertEquals(record.getClass(), QueryResultRoleRecord.class, "incorrect record type admin query");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/strandedUsers/query")
|
||||
public void testQueryAllStrandedUsers() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.strandedUsersQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
assertEquals(record.getClass(), QueryResultStrandedUserRecord.class, "incorrect record type admin query");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/users/query")
|
||||
public void testQueryAllUsers() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.usersQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
assertEquals(record.getClass(), QueryResultAdminUserRecord.class, "incorrect record type admin query");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/vdcs/query")
|
||||
public void testQueryAllVdc() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.vdcsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
assertEquals(record.getClass(), QueryResultAdminVdcRecord.class, "incorrect record type admin query");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,7 +66,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.build();
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/group/{id}", enabled = false)
|
||||
@Test(testName = "GET /admin/group/{id}")
|
||||
public void testGetGroup() {
|
||||
assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group"));
|
||||
group = groupClient.getGroup(groupRef.getHref());
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultCatalogRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -37,7 +38,7 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* Test the {@link TaskClient} by observing its side effects.
|
||||
* Test the {@link QueryClient} by observing its side effects.
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
|
@ -62,7 +63,7 @@ public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords expected = QueryResultRecords.builder()
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("catalog")
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_EMPTY_OBJECT_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -35,17 +32,19 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vm;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppTemplateRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVMRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
@ -114,7 +113,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@Test(testName = "GET /catalogs/query")
|
||||
public void testQueryAllCatalogs() {
|
||||
QueryResultRecords catalogRecords = queryClient.catalogsQueryAll();
|
||||
QueryResultRecords<?> catalogRecords = queryClient.catalogsQueryAll();
|
||||
assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords"));
|
||||
}
|
||||
|
||||
|
@ -126,20 +125,20 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@Test(testName = "GET /vAppTemplates/query")
|
||||
public void testQueryAllVAppTemplates() {
|
||||
QueryResultRecords queryResult = queryClient.vAppTemplatesQueryAll();
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
|
||||
assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should include vAppTemplate "+vAppTemplateURI+"; but only has "+hrefs);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /vAppTemplates/query?filter)")
|
||||
public void testQueryVAppTemplatesWithFilter() {
|
||||
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||
QueryResultRecords queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
|
||||
assertEquals(hrefs, Collections.singleton(vAppTemplateURI), "VAppTemplates query result should have found vAppTemplate "+vAppTemplateURI);
|
||||
}
|
||||
|
||||
|
@ -147,19 +146,19 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void testQueryAllVApps() {
|
||||
vApp = instantiateVApp();
|
||||
|
||||
QueryResultRecords queryResult = queryClient.vAppsQueryAll();
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppsQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
|
||||
assertTrue(hrefs.contains(vApp.getHref()), "VApp query result should include vapp "+vApp.getHref()+"; but only has "+hrefs);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" } )
|
||||
public void testQueryVAppsWithFilter() {
|
||||
QueryResultRecords queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
|
||||
assertEquals(hrefs, Collections.singleton(vApp.getHref()), "VApps query result should have found vApp "+vApp.getHref());
|
||||
}
|
||||
|
||||
|
@ -180,10 +179,10 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Set<URI> vmHrefs = toHrefs(vms);
|
||||
|
||||
// Method under test: do the query
|
||||
QueryResultRecords queryResult = queryClient.vmsQueryAll();
|
||||
QueryResultRecords<?> queryResult = queryClient.vmsQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
|
||||
assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms "+vmHrefs+"; but only has "+hrefs);
|
||||
}
|
||||
|
||||
|
@ -192,20 +191,21 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
List<Vm> vms = vApp.getChildren().getVms();
|
||||
Set<URI> vmHrefs = toHrefs(vms);
|
||||
|
||||
QueryResultRecords queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
|
||||
QueryResultRecords<?> queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null));
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
|
||||
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs);
|
||||
}
|
||||
|
||||
private void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes) {
|
||||
private static void assertRecordTypes(QueryResultRecords<?> queryResult, Collection<String> validTypes, Class<?> validClazz) {
|
||||
for (QueryResultRecordType record : queryResult.getRecords()) {
|
||||
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes);
|
||||
assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<URI> toHrefs(QueryResultRecords queryResult) {
|
||||
private Set<URI> toHrefs(QueryResultRecords<?> queryResult) {
|
||||
Set<URI> hrefs = new LinkedHashSet<URI>();
|
||||
for (QueryResultRecordType record : queryResult.getRecords()) {
|
||||
hrefs.add(record.getHref());
|
||||
|
|
|
@ -424,7 +424,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(enabled = false, testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" })
|
||||
public void testRelocate() {
|
||||
// Relocate to the last of the available datastores
|
||||
QueryResultRecords records = context.getApi().getQueryClient().queryAll("datastore");
|
||||
QueryResultRecords<?> records = context.getApi().getQueryClient().queryAll("datastore");
|
||||
QueryResultRecordType datastore = Iterables.getLast(records.getRecords());
|
||||
RelocateParams params = RelocateParams.builder().datastore(Reference.builder().href(datastore.getHref()).build()).build();
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="0" pageSize="25" page="1" name="group" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=records" 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="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=references"/>
|
||||
<Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=idrecords"/>
|
||||
</QueryResultRecords>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="1" pageSize="25" page="1" name="role" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records" 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="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=references"/>
|
||||
<Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=idrecords"/>
|
||||
<RoleRecord name="vApp Author" isReadOnly="false" href="https://vcloudbeta.bluelock.com/api/admin/role/1bf4457f-a253-3cf1-b163-f319f1a31802"/>
|
||||
</QueryResultRecords>
|
Loading…
Reference in New Issue