mirror of https://github.com/apache/jclouds.git
example start on a vcloud director client
This commit is contained in:
parent
47ade5a429
commit
7d93887789
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5;
|
||||
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -38,4 +40,9 @@ public interface VCloudDirectorAsyncClient {
|
|||
@Provides
|
||||
Session getCurrentSession();
|
||||
|
||||
/**
|
||||
* @return synchronous access to Org features
|
||||
*/
|
||||
@Delegate
|
||||
OrgAsyncClient getOrgClient();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ package org.jclouds.vcloud.director.v1_5;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -41,4 +43,9 @@ public interface VCloudDirectorClient {
|
|||
@Provides
|
||||
Session getCurrentSession();
|
||||
|
||||
/**
|
||||
* @return synchronous access to Org features
|
||||
*/
|
||||
@Delegate
|
||||
OrgClient getOrgClient();
|
||||
}
|
||||
|
|
|
@ -34,4 +34,7 @@ public interface VCloudDirectorMediaType {
|
|||
|
||||
public final static String SESSION_XML = "application/vnd.vmware.vcloud.session+xml";
|
||||
|
||||
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml";
|
||||
|
||||
public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
|||
import org.jclouds.vcloud.director.v1_5.annotations.Login;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Session;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
||||
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
|
||||
import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
|
||||
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
|
||||
|
@ -69,7 +71,7 @@ import com.google.inject.name.Named;
|
|||
public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirectorClient, VCloudDirectorAsyncClient> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
// TODO
|
||||
.put(OrgClient.class, OrgAsyncClient.class)
|
||||
.build();
|
||||
|
||||
public VCloudDirectorRestClientModule() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Retrieves a list of organizations.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@XmlRootElement(namespace = NS, name = "Org")
|
||||
public class Org extends BaseNamedResource<Org> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromOrg(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<Org> {
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private String fullName;
|
||||
private Set<Link> links = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see Org#getId
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Org#getDescription
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Org#getFullName
|
||||
*/
|
||||
public Builder fullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Org#getOrgs
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Org#getOrgs
|
||||
*/
|
||||
public Builder addLink(Link org) {
|
||||
links.add(checkNotNull(org, "org"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Org build() {
|
||||
return new Org(href, type, name, id, description, fullName, links);
|
||||
}
|
||||
|
||||
public Builder fromOrg(Org in) {
|
||||
return id(in.getId()).description(in.getDescription()).fullName(in.getFullName()).links(in.getLinks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Org() {
|
||||
// For JAXB and builder use
|
||||
}
|
||||
|
||||
private Org(URI href, String type, String name, String id, String description, String fullName, Set<Link> links) {
|
||||
super(href, type, name);
|
||||
this.id = id;
|
||||
this.description = description;
|
||||
this.fullName = fullName;
|
||||
this.links = ImmutableSet.copyOf(links);
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String id;
|
||||
@XmlElement(namespace = NS, name = "Description")
|
||||
private String description;
|
||||
@XmlElement(namespace = NS, name = "FullName")
|
||||
private String fullName;
|
||||
@XmlElement(namespace = NS, name = "Link")
|
||||
private Set<Link> links = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return id of the org
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return description of the org
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return fullName of the org
|
||||
*/
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public Set<Link> getLinks() {
|
||||
return ImmutableSet.copyOf(links);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!super.equals(o))
|
||||
return false;
|
||||
Org that = Org.class.cast(o);
|
||||
return equal(id, that.id) && equal(description, that.description) && equal(fullName, that.fullName)
|
||||
&& equal(links, that.links);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + Objects.hashCode(id, description, fullName, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("id", id).add("description", description).add("fullName", fullName).add("links", links);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class OrgLink extends BaseNamedResource<OrgLink> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return Builder.class.cast(new Builder().fromNamedResource(this));
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<OrgLink> {
|
||||
|
||||
@Override
|
||||
public OrgLink build() {
|
||||
return new OrgLink(href, type, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OrgLink(URI href, String type, String name) {
|
||||
super(href, type, name);
|
||||
}
|
||||
|
||||
private OrgLink() {
|
||||
// for JAXB
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Retrieves a list of organizations.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@XmlRootElement(namespace = NS, name = "OrgList")
|
||||
public class OrgList {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromOrgList(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<OrgLink> orgs = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see OrgList#getOrgs
|
||||
*/
|
||||
public Builder orgs(Set<OrgLink> orgs) {
|
||||
this.orgs = Sets.newLinkedHashSet(checkNotNull(orgs, "orgs"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OrgList#getOrgs
|
||||
*/
|
||||
public Builder addOrg(OrgLink org) {
|
||||
orgs.add(checkNotNull(org, "org"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrgList build() {
|
||||
return new OrgList(orgs);
|
||||
}
|
||||
|
||||
public Builder fromOrgList(OrgList in) {
|
||||
return orgs(in.getOrgs());
|
||||
}
|
||||
}
|
||||
|
||||
private OrgList() {
|
||||
// For JAXB and builder use
|
||||
}
|
||||
|
||||
private OrgList(Set<OrgLink> orgs) {
|
||||
this.orgs = ImmutableSet.copyOf(orgs);
|
||||
}
|
||||
|
||||
@XmlElement(namespace = NS, name = "Org")
|
||||
private Set<OrgLink> orgs = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<OrgLink> getOrgs() {
|
||||
return ImmutableSet.copyOf(orgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
OrgList that = OrgList.class.cast(o);
|
||||
return equal(orgs, that.orgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(orgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("").add("orgs", orgs).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* 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.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
|
||||
* @see OrgClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
public interface OrgAsyncClient {
|
||||
|
||||
/**
|
||||
* @see OrgClient#getOrgList
|
||||
*/
|
||||
@GET
|
||||
@Path("/org/")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<OrgList> getOrgList();
|
||||
|
||||
/**
|
||||
* @see OrgClient#getOrg
|
||||
*/
|
||||
@GET
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<OrgList> getOrg(@EndpointParam URI uri);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* 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.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Org.
|
||||
* <p/>
|
||||
*
|
||||
* @see OrgAsyncClient
|
||||
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface OrgClient {
|
||||
|
||||
/**
|
||||
* Retrieves a list of organizations.
|
||||
*
|
||||
* @return a list of organizations
|
||||
*/
|
||||
OrgList getOrgList();
|
||||
|
||||
/**
|
||||
* Retrieves an organization.
|
||||
*
|
||||
* @return the org or null if not found
|
||||
*/
|
||||
Org getOrg(URI orgHref);
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
*(Link.builder().regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless(Link.builder().required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.testng.Assert.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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLink;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
*
|
||||
* Allows us to test a client via its side effects.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", singleThreaded = true, testName = "OrgClientExpectTest")
|
||||
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||
|
||||
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
|
||||
|
||||
HttpRequest orgListRequest = HttpRequest.builder().method("GET")
|
||||
.endpoint(URI.create("http://localhost/api/org/")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("x-vcloud-authorization",
|
||||
token).build()).build();
|
||||
|
||||
HttpResponse orgListResponse = HttpResponse.builder().statusCode(200)
|
||||
|
||||
.payload(
|
||||
payloadFromResourceWithContentType("/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML
|
||||
+ ";version=1.5")).build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest,
|
||||
orgListResponse);
|
||||
|
||||
assertEquals(client.getOrgClient().getOrgList(), OrgList.builder().addOrg(
|
||||
OrgLink.builder().type("application/vnd.vmware.vcloud.org+xml").name("JClouds").href(
|
||||
URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
.build()).build()
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// please help solve javax.xml.bind.UnmarshalException
|
||||
@Test(enabled = false)
|
||||
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
|
||||
|
||||
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||
|
||||
HttpRequest orgRequest = HttpRequest.builder().method("GET").endpoint(orgRef).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("x-vcloud-authorization", token)
|
||||
.build()).build();
|
||||
|
||||
HttpResponse orgResponse = HttpResponse.builder().statusCode(200)
|
||||
|
||||
.payload(payloadFromResourceWithContentType("/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse);
|
||||
|
||||
assertEquals(
|
||||
client.getOrgClient().getOrg(orgRef),
|
||||
Org
|
||||
.builder()
|
||||
.name("JClouds")
|
||||
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
|
||||
.type(VCloudDirectorMediaType.ORG_XML)
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||
.name("Cluster01-JClouds")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.tasksList+xml")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||
.name("Public")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.controlAccess+xml")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||
.name("ilsolation01-Jclouds")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||
.name("internet01-Jclouds")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
|
||||
.build())
|
||||
.addLink(
|
||||
Link
|
||||
.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(
|
||||
URI
|
||||
.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
||||
.build()).description("").fullName("JClouds").build()
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Org xmlns="http://www.vmware.com/vcloud/v1.5" name="JClouds" id="urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0" 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="down" type="application/vnd.vmware.vcloud.vdc+xml" name="Cluster01-JClouds" href="https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.tasksList+xml" href="https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.catalog+xml" name="Public" href="https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c/controlAccess/"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.orgNetwork+xml" name="ilsolation01-Jclouds" href="https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.orgNetwork+xml" name="internet01-Jclouds" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"/>
|
||||
<Description/>
|
||||
<FullName>JClouds</FullName>
|
||||
</Org>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OrgList xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.orgList+xml" href="https://vcloudbeta.bluelock.com/api/org/" 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">
|
||||
<Org type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||
</OrgList>
|
Loading…
Reference in New Issue