diff options
Diffstat (limited to 'nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java')
-rw-r--r-- | nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java | 140 |
1 files changed, 69 insertions, 71 deletions
diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java index c3e2256..0c8621d 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/FlavorsResource.java @@ -10,76 +10,74 @@ import com.woorea.openstack.nova.model.Flavors; import com.woorea.openstack.nova.model.Metadata; public class FlavorsResource { - - private final OpenStackClient CLIENT; - - public FlavorsResource(OpenStackClient client) { - CLIENT = client; - } - - public List list(boolean detail) { - return new List(detail); - } - - public Create create(Flavor flavor) { - return new Create(flavor); - } - - public Show show(String id) { - return new Show(id); - } - - public ShowMetadata showMetadata(String id) { - return new ShowMetadata(id); - } - - - public Delete delete(String id) { - return new Delete(id); - } - - public class List extends OpenStackRequest<Flavors> { - - public List(boolean detail) { - super(CLIENT, HttpMethod.GET, detail ? "/flavors/detail" : "/flavors", null, Flavors.class); - } - - } - - public class Create extends OpenStackRequest<Flavor> { - - private Flavor flavor; - - public Create(Flavor flavor) { - super(CLIENT, HttpMethod.POST, "/flavors", Entity.json(flavor), Flavor.class); - this.flavor = flavor; - } - - } - - public class Show extends OpenStackRequest<Flavor> { - - public Show(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/flavors/").append(id).toString(), null, Flavor.class); - } - - } - - public class ShowMetadata extends OpenStackRequest<Metadata> { - - public ShowMetadata(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/flavors/").append(id).append("/metadata").toString(), null, Metadata.class); - } - - } - - public class Delete extends OpenStackRequest<Void> { - - public Delete(String id) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/flavors/").append(id).toString(), null, Void.class); - } - - } - + + private final OpenStackClient client; + + public FlavorsResource(OpenStackClient client) { + this.client = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(Flavor flavor) { + return new Create(flavor); + } + + public Show show(String id) { + return new Show(id); + } + + public ShowMetadata showMetadata(String id) { + return new ShowMetadata(id); + } + + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest<Flavors> { + + public List(boolean detail) { + super(client, HttpMethod.GET, detail ? "/flavors/detail" : "/flavors", null, Flavors.class); + } + } + + public class Create extends OpenStackRequest<Flavor> { + + private Flavor flavor; + + public Create(Flavor flavor) { + super(client, HttpMethod.POST, "/flavors", Entity.json(flavor), Flavor.class); + this.flavor = flavor; + } + } + + public class Show extends OpenStackRequest<Flavor> { + + public Show(String id) { + super(client, HttpMethod.GET, getFlavorsString(id), null, Flavor.class); + } + } + + public class ShowMetadata extends OpenStackRequest<Metadata> { + + public ShowMetadata(String id) { + super(client, HttpMethod.GET, "/flavors/" + id + "/metadata", null, Metadata.class); + } + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, getFlavorsString(id), null, Void.class); + } + } + + private String getFlavorsString(String id) { + return "/flavors/" + id; + } } |