mirror of https://github.com/apache/jclouds.git
Issue 695: Added Templates client+classes+tests
This commit is contained in:
parent
81605f1258
commit
e0500af771
|
@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient;
|
import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.features.TemplateAsyncClient;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
|
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,4 +46,10 @@ public interface TerremarkEnterpriseCloudAsyncClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineAsyncClient getVirtualMachineClient();
|
VirtualMachineAsyncClient getVirtualMachineClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to Template features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
TemplateAsyncClient getTemplateClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.TaskClient;
|
import org.jclouds.tmrk.enterprisecloud.features.TaskClient;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.features.TemplateClient;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient;
|
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,4 +50,10 @@ public interface TerremarkEnterpriseCloudClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineClient getVirtualMachineClient();
|
VirtualMachineClient getVirtualMachineClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to Template features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
TemplateClient getTemplateClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudAsyncClient;
|
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudAsyncClient;
|
||||||
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudClient;
|
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudClient;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient;
|
import org.jclouds.tmrk.enterprisecloud.features.*;
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.TaskClient;
|
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
|
|
||||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient;
|
|
||||||
import org.jclouds.tmrk.enterprisecloud.handlers.TerremarkEnterpriseCloudErrorHandler;
|
import org.jclouds.tmrk.enterprisecloud.handlers.TerremarkEnterpriseCloudErrorHandler;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -52,6 +49,7 @@ public class TerremarkEnterpriseCloudRestClientModule extends
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||||
.put(TaskClient.class, TaskAsyncClient.class)
|
.put(TaskClient.class, TaskAsyncClient.class)
|
||||||
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)
|
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)
|
||||||
|
.put(TemplateClient.class, TemplateAsyncClient.class)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public TerremarkEnterpriseCloudRestClientModule() {
|
public TerremarkEnterpriseCloudRestClientModule() {
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps individual TemplateCategory elements.
|
||||||
|
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||||
|
* <xs:complexType name="TemplateCategories">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateCategories {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateCategories(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateCategories#getTemplateCategories()
|
||||||
|
*/
|
||||||
|
public Builder categories(Set<TemplateCategory> categories) {
|
||||||
|
this.categories = Sets.newLinkedHashSet(checkNotNull(categories, "categories"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addCategory(TemplateCategory category) {
|
||||||
|
categories.add(checkNotNull(category,"category"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateCategories build() {
|
||||||
|
return new TemplateCategories(categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateCategories(TemplateCategories in) {
|
||||||
|
return categories(in.getTemplateCategories());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateCategories() {
|
||||||
|
//For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateCategories(Set<TemplateCategory> categories) {
|
||||||
|
this.categories = Sets.newLinkedHashSet(categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Category")
|
||||||
|
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<TemplateCategory> getTemplateCategories() {
|
||||||
|
return Collections.unmodifiableSet(categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateCategories that = (TemplateCategories) o;
|
||||||
|
|
||||||
|
if (categories != null ? !categories.equals(that.categories) : that.categories != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return categories != null ? categories.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "["+ categories.toString()+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <xs:complexType name="TemplateCategory">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateCategory {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateCategory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateCategory#getTemplateOperatingSystems
|
||||||
|
*/
|
||||||
|
public Builder templateOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||||
|
this.operatingSystems = Sets.newLinkedHashSet(checkNotNull(operatingSystems, "operatingSystems"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateCategory#getName
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateCategory build() {
|
||||||
|
return new TemplateCategory(name,operatingSystems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateCategory(TemplateCategory in) {
|
||||||
|
return name(in.getName()).templateOperatingSystems(in.getTemplateOperatingSystems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Name", required = false)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@XmlElement(name = "OperatingSystems", required = false)
|
||||||
|
private TemplateOperatingSystems operatingSystems = TemplateOperatingSystems.builder().build();
|
||||||
|
|
||||||
|
private TemplateCategory(@Nullable String name, Set<TemplateOperatingSystem> operatingSystems) {
|
||||||
|
this.name = name;
|
||||||
|
this.operatingSystems = TemplateOperatingSystems.builder().operatingSystems(operatingSystems).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TemplateCategory() {
|
||||||
|
//For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<TemplateOperatingSystem> getTemplateOperatingSystems() {
|
||||||
|
return operatingSystems.getTemplateOperatingSystems();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateCategory that = (TemplateCategory) o;
|
||||||
|
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
if (operatingSystems != null ? !operatingSystems.equals(that.operatingSystems) : that.operatingSystems != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + (operatingSystems != null ? operatingSystems.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[name="+name+", +operatingSystems="+operatingSystems+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps individual TemplateFamily elements.
|
||||||
|
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||||
|
* <xs:complexType name="TemplateFamilies">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateFamilies {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateFamilies(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateFamilies#getTemplateFamilies()
|
||||||
|
*/
|
||||||
|
public Builder families(Set<TemplateFamily> families) {
|
||||||
|
this.families = Sets.newLinkedHashSet(checkNotNull(families, "families"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addFamily(TemplateFamily family) {
|
||||||
|
families.add(checkNotNull(family,"family"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateFamilies build() {
|
||||||
|
return new TemplateFamilies(families);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateFamilies(TemplateFamilies in) {
|
||||||
|
return families(in.getTemplateFamilies());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateFamilies() {
|
||||||
|
//For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateFamilies(Set<TemplateFamily> families) {
|
||||||
|
this.families = Sets.newLinkedHashSet(families);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Family")
|
||||||
|
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<TemplateFamily> getTemplateFamilies() {
|
||||||
|
return Collections.unmodifiableSet(families);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateFamilies that = (TemplateFamilies) o;
|
||||||
|
|
||||||
|
if (families != null ? !families.equals(that.families) : that.families != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return families != null ? families.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "["+ families.toString()+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <xs:complexType name="TemplateFamily">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateFamily {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateFamily(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateFamily#getTemplateCategories
|
||||||
|
*/
|
||||||
|
public Builder templateCategories(Set<TemplateCategory> categories) {
|
||||||
|
this.categories = Sets.newLinkedHashSet(checkNotNull(categories, "categories"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateFamily#getName
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateFamily build() {
|
||||||
|
return new TemplateFamily(name,categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateFamily(TemplateFamily in) {
|
||||||
|
return name(in.getName()).templateCategories(in.getTemplateCategories());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Name", required = false)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@XmlElement(name = "Categories", required = false)
|
||||||
|
private TemplateCategories categories = TemplateCategories.builder().build();
|
||||||
|
|
||||||
|
private TemplateFamily(@Nullable String name, Set<TemplateCategory> categories) {
|
||||||
|
this.name = name;
|
||||||
|
this.categories = TemplateCategories.builder().categories(categories).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TemplateFamily() {
|
||||||
|
//For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<TemplateCategory> getTemplateCategories() {
|
||||||
|
return categories.getTemplateCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateFamily that = (TemplateFamily) o;
|
||||||
|
|
||||||
|
if (categories != null ? !categories.equals(that.categories) : that.categories != null)
|
||||||
|
return false;
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + (categories != null ? categories.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[name="+name+", +categories="+categories+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <xs:complexType name="TemplateOperatingSystem">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateOperatingSystem {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateOperatingSystem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private Set<TemplateReference> templates = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateOperatingSystem#getTemplates
|
||||||
|
*/
|
||||||
|
public Builder templates(Set<TemplateReference> templates) {
|
||||||
|
this.templates = Sets.newLinkedHashSet(checkNotNull(templates, "templates"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateOperatingSystem#getName
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateOperatingSystem build() {
|
||||||
|
return new TemplateOperatingSystem(name,templates);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateOperatingSystem(TemplateOperatingSystem in) {
|
||||||
|
return name(in.getName()).templates(in.getTemplates());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Name", required = false)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@XmlElement(name = "Templates", required = false)
|
||||||
|
private TemplateReferences templates = TemplateReferences.builder().build();
|
||||||
|
|
||||||
|
private TemplateOperatingSystem(@Nullable String name, Set<TemplateReference> templates) {
|
||||||
|
this.name = name;
|
||||||
|
this.templates = TemplateReferences.builder().templateReferences(checkNotNull(templates,"templates")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateOperatingSystem() {
|
||||||
|
//For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<TemplateReference> getTemplates() {
|
||||||
|
return templates.getTemplateReferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateOperatingSystem that = (TemplateOperatingSystem) o;
|
||||||
|
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
if (templates != null ? !templates.equals(that.templates) : that.templates != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + (templates != null ? templates.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[name="+name+", +templates="+templates+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps individual TemplateOperatingSystem elements.
|
||||||
|
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||||
|
* <xs:complexType name="TemplateOperatingSystems">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateOperatingSystems {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateOperatingSystems(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TemplateOperatingSystems#getTemplateOperatingSystems()
|
||||||
|
*/
|
||||||
|
public Builder operatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||||
|
this.operatingSystems = Sets.newLinkedHashSet(checkNotNull(operatingSystems, "operatingSystems"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addOperatingSystem(TemplateOperatingSystem operatingSystem) {
|
||||||
|
operatingSystems.add(checkNotNull(operatingSystem,"operatingSystem"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateOperatingSystems build() {
|
||||||
|
return new TemplateOperatingSystems(operatingSystems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateOperatingSystems(TemplateOperatingSystems in) {
|
||||||
|
return operatingSystems(in.getTemplateOperatingSystems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateOperatingSystems() {
|
||||||
|
//For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||||
|
this.operatingSystems = Sets.newLinkedHashSet(operatingSystems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "OperatingSystem")
|
||||||
|
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<TemplateOperatingSystem> getTemplateOperatingSystems() {
|
||||||
|
return Collections.unmodifiableSet(operatingSystems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateOperatingSystems that = (TemplateOperatingSystems) o;
|
||||||
|
|
||||||
|
if (operatingSystems != null ? !operatingSystems.equals(that.operatingSystems) : that.operatingSystems != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return operatingSystems != null ? operatingSystems.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "["+ operatingSystems.toString()+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateReference extends BaseNamedResource<TemplateReference> {
|
||||||
|
public TemplateReference() {
|
||||||
|
//For JAXB
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps individual TemplateReference elements.
|
||||||
|
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||||
|
* <xs:complexType name="TemplateReferences">
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public class TemplateReferences {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromTemplateReferences(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private Set<TemplateReference> templateReferences = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.tmrk.enterprisecloud.domain.template.TemplateReferences#getTemplateReferences()
|
||||||
|
*/
|
||||||
|
public Builder templateReferences(Set<TemplateReference> templateReferences) {
|
||||||
|
this.templateReferences = Sets.newLinkedHashSet(checkNotNull(templateReferences, "templateReferences"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addTemplateReference(TemplateReference templateReference) {
|
||||||
|
templateReferences.add(checkNotNull(templateReference,"templateReference"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateReferences build() {
|
||||||
|
return new TemplateReferences(templateReferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromTemplateReferences(TemplateReferences in) {
|
||||||
|
return templateReferences(in.getTemplateReferences());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateReferences() {
|
||||||
|
//For JAXB and builder use
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateReferences(Set<TemplateReference> templateReferences) {
|
||||||
|
this.templateReferences = Sets.newLinkedHashSet(templateReferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Template")
|
||||||
|
private Set<TemplateReference> templateReferences = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Set<TemplateReference> getTemplateReferences() {
|
||||||
|
return Collections.unmodifiableSet(templateReferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TemplateReferences that = (TemplateReferences) o;
|
||||||
|
|
||||||
|
if (templateReferences != null ? !templateReferences.equals(that.templateReferences) : that.templateReferences != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return templateReferences != null ? templateReferences.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "["+ templateReferences.toString()+"]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||||
|
@ -32,6 +33,7 @@ import java.util.Set;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Templates is more than a simple wrapper as it extends BaseResource.
|
||||||
* <xs:complexType name="Templates">
|
* <xs:complexType name="Templates">
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
*
|
*
|
||||||
|
@ -54,7 +56,8 @@ public class Templates extends BaseResource<Templates> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends BaseResource.Builder<Templates> {
|
public static class Builder extends BaseResource.Builder<Templates> {
|
||||||
private Links links = Links.builder().build();
|
private Links links = Links.builder().build();
|
||||||
|
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Templates#getLinks
|
* @see Templates#getLinks
|
||||||
|
@ -64,13 +67,21 @@ public class Templates extends BaseResource<Templates> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Templates#getTemplateFamilies
|
||||||
|
*/
|
||||||
|
public Builder families(Set<TemplateFamily> families) {
|
||||||
|
this.families =(checkNotNull(families,"families"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Templates build() {
|
public Templates build() {
|
||||||
return new Templates(href, type, links);
|
return new Templates(href, type, links, families);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromTemplates(Templates in) {
|
public Builder fromTemplates(Templates in) {
|
||||||
return fromResource(in).links(in.getLinks());
|
return fromResource(in).links(in.getLinks()).families(in.getTemplateFamilies());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,15 +118,19 @@ public class Templates extends BaseResource<Templates> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "Links", required = true)
|
@XmlElement(name = "Links", required = false)
|
||||||
private Links links = Links.builder().build();
|
private Links links = Links.builder().build();
|
||||||
|
|
||||||
public Templates(URI href, String type, Links links ) {
|
@XmlElement(name = "Families", required = false)
|
||||||
|
private TemplateFamilies families;
|
||||||
|
|
||||||
|
private Templates(URI href, String type, Links links, Set<TemplateFamily> families) {
|
||||||
super(href, type);
|
super(href, type);
|
||||||
this.links = checkNotNull(links, "links");
|
this.links = checkNotNull(links, "links");
|
||||||
|
this.families = TemplateFamilies.builder().families(families).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Templates() {
|
private Templates() {
|
||||||
//For JAXB
|
//For JAXB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +138,36 @@ public class Templates extends BaseResource<Templates> {
|
||||||
return Collections.unmodifiableSet(links.getLinks());
|
return Collections.unmodifiableSet(links.getLinks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<TemplateFamily> getTemplateFamilies() {
|
||||||
|
return families.getTemplateFamilies();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
if (!super.equals(o)) return false;
|
||||||
|
|
||||||
|
Templates templates = (Templates) o;
|
||||||
|
|
||||||
|
if (families != null ? !families.equals(templates.families) : templates.families != null)
|
||||||
|
return false;
|
||||||
|
if (links != null ? !links.equals(templates.links) : templates.links != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||||
|
result = 31 * result + (families != null ? families.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String string() {
|
public String string() {
|
||||||
return super.string()+", links="+links;
|
return super.string()+", links="+links+", families="+families;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ public interface TemplateClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Get Templates call returns information regarding templates defined in a compute pool.
|
* The Get Templates call returns information regarding templates defined in a compute pool.
|
||||||
* Note that Templates are not a simple wrapper around template objects.
|
* Note that Templates are not a simple wrapper around template objects, so if not found returns null.
|
||||||
* Once the desired template is located getTemplate must be called to retrieve all the attached information
|
* Once the desired template is located getTemplate must be called to retrieve all the attached information
|
||||||
* @param uri compute pool identifier
|
* @param uri compute pool identifier
|
||||||
* @return the templates
|
* @return the templates
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.features;
|
||||||
|
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.template.*;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code TemplateClientLiveTest}
|
||||||
|
* TODO: don't hard-code uri's it should be possible to determine them but that means chaining the tests potentially.
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", testName = "TemplateClientLiveTest")
|
||||||
|
public class TemplateClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTest {
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
super.setupClient();
|
||||||
|
client = context.getApi().getTemplateClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TemplateClient client;
|
||||||
|
|
||||||
|
public void testGetTemplates() throws Exception {
|
||||||
|
Templates templates = client.getTemplates(new URI("/cloudapi/ecloud/templates/computepools/89"));
|
||||||
|
for(TemplateFamily family: templates.getTemplateFamilies()) {
|
||||||
|
for(TemplateCategory category: family.getTemplateCategories()) {
|
||||||
|
for(TemplateOperatingSystem os: category.getTemplateOperatingSystems()) {
|
||||||
|
for(TemplateReference templateReference: os.getTemplates()) {
|
||||||
|
testTemplate(templateReference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testTemplate(TemplateReference templateReference) {
|
||||||
|
Template template = client.getTemplate(templateReference.getHref());
|
||||||
|
assertNotNull(template);
|
||||||
|
assertNotNull(template.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTemplatesWhenMissing() throws Exception {
|
||||||
|
Templates templates = client.getTemplates(new URI("/cloudapi/ecloud/templates/computepools/-1"));
|
||||||
|
assertNull(templates);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTemplateWhenMissing() throws Exception {
|
||||||
|
Template template = client.getTemplate(new URI("/cloudapi/ecloud/templates/-1/computepools/89"));
|
||||||
|
assertNull(template);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
/**
|
||||||
|
* 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.tmrk.enterprisecloud.xml;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import org.jclouds.crypto.Crypto;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||||
|
import org.jclouds.logging.config.NullLoggingModule;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
import org.jclouds.rest.BaseRestClientTest;
|
||||||
|
import org.jclouds.rest.RestContextSpec;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.CustomizationOption;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.template.*;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.features.TemplateAsyncClient;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||||
|
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||||
|
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of JAXB parsing for Templates
|
||||||
|
*
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "TemplatesJAXBParsingTest")
|
||||||
|
public class TemplatesJAXBParsingTest extends BaseRestClientTest {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
void setupFactory() {
|
||||||
|
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||||
|
"credentialFoo", String.class, Integer.class,
|
||||||
|
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Provides
|
||||||
|
@Named("exception")
|
||||||
|
Set<String> exception() {
|
||||||
|
throw new AuthorizationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
injector = createContextBuilder(contextSpec).buildInjector();
|
||||||
|
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
crypto = injector.getInstance(Crypto.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParseTemplates() throws Exception {
|
||||||
|
|
||||||
|
Method method = TemplateAsyncClient.class.getMethod("getTemplates", URI.class);
|
||||||
|
HttpRequest request = factory(TemplateAsyncClient.class).createRequest(method,new URI("/1"));
|
||||||
|
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||||
|
|
||||||
|
Function<HttpResponse, Templates> parser = (Function<HttpResponse, Templates>) RestAnnotationProcessor
|
||||||
|
.createResponseParser(parserFactory, injector, method, request);
|
||||||
|
|
||||||
|
InputStream is = getClass().getResourceAsStream("/templates.xml");
|
||||||
|
Templates templates = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||||
|
|
||||||
|
assertLinks(templates.getLinks());
|
||||||
|
assertFamilies(templates.getTemplateFamilies());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertLinks(Set<Link> links) {
|
||||||
|
assertEquals(links.size(),1);
|
||||||
|
Link link = Iterables.getOnlyElement(links);
|
||||||
|
assertEquals(link.getName(),"Default Compute Pool");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertFamilies(Set<TemplateFamily> families) {
|
||||||
|
assertEquals(families.size(),1);
|
||||||
|
TemplateFamily family = Iterables.getOnlyElement(families);
|
||||||
|
assertEquals(family.getName(),"Standard Templates");
|
||||||
|
assertCategories(family.getTemplateCategories());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertCategories(Set<TemplateCategory> categories) {
|
||||||
|
assertEquals(categories.size(),1);
|
||||||
|
TemplateCategory category = Iterables.getOnlyElement(categories);
|
||||||
|
assertEquals(category.getName(),"OS Only");
|
||||||
|
assertOperatingSystems(category.getTemplateOperatingSystems());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||||
|
assertEquals(operatingSystems.size(),2);
|
||||||
|
TemplateOperatingSystem windows = Iterables.get(operatingSystems, 0);
|
||||||
|
assertEquals(windows.getName(),"Windows");
|
||||||
|
assertEquals(windows.getTemplates().size(),4);
|
||||||
|
|
||||||
|
TemplateOperatingSystem linux = Iterables.get(operatingSystems, 1);
|
||||||
|
assertEquals(linux.getName(),"Linux");
|
||||||
|
assertEquals(linux.getTemplates().size(),2);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue