Skip to content

Commit 9a9bfb7

Browse files
committed
Merge pull request woorea#178 from danielerez/cinder_v3.1.x
cinder: introduce client and model
2 parents 367a08d + 5ca5101 commit 9a9bfb7

25 files changed

+1818
-0
lines changed

cinder-client/pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>com.woorea</groupId>
5+
<artifactId>openstack-java-sdk</artifactId>
6+
<version>3.1.0-SNAPSHOT</version>
7+
</parent>
8+
<artifactId>cinder-client</artifactId>
9+
<name>OpenStack Cinder Client</name>
10+
<description>OpenStack Cinder Client</description>
11+
<dependencies>
12+
<dependency>
13+
<groupId>com.woorea</groupId>
14+
<artifactId>openstack-client</artifactId>
15+
<version>3.1.0-SNAPSHOT</version>
16+
</dependency>
17+
18+
<dependency>
19+
<groupId>com.woorea</groupId>
20+
<artifactId>cinder-model</artifactId>
21+
<version>3.1.0-SNAPSHOT</version>
22+
</dependency>
23+
</dependencies>
24+
</project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.woorea.openstack.cinder;
2+
3+
import com.woorea.openstack.base.client.OpenStackClient;
4+
import com.woorea.openstack.base.client.OpenStackClientConnector;
5+
6+
public class Cinder extends OpenStackClient {
7+
8+
private final VolumesExtension VOLUMES;
9+
10+
private final SnapshotsExtension SNAPSHOTS;
11+
12+
private final VolumeTypesExtension VOLUME_TYPES;
13+
14+
private final LimitsExtension LIMITS;
15+
16+
public Cinder(String endpoint, OpenStackClientConnector connector) {
17+
super(endpoint, connector);
18+
VOLUMES = new VolumesExtension(this);
19+
SNAPSHOTS = new SnapshotsExtension(this);
20+
VOLUME_TYPES = new VolumeTypesExtension(this);
21+
LIMITS = new LimitsExtension(this);
22+
}
23+
24+
public Cinder(String endpoint) {
25+
this(endpoint, null);
26+
}
27+
28+
public final VolumesExtension volumes() {
29+
return VOLUMES;
30+
}
31+
32+
public final SnapshotsExtension snapshots() {
33+
return SNAPSHOTS;
34+
}
35+
36+
public final VolumeTypesExtension volumeTypes() {
37+
return VOLUME_TYPES;
38+
}
39+
40+
public final LimitsExtension limits() {
41+
return LIMITS;
42+
}
43+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.woorea.openstack.cinder;
2+
3+
import com.woorea.openstack.base.client.HttpMethod;
4+
import com.woorea.openstack.base.client.OpenStackClient;
5+
import com.woorea.openstack.base.client.OpenStackRequest;
6+
import com.woorea.openstack.cinder.model.Limits;
7+
8+
public class LimitsExtension {
9+
10+
private final OpenStackClient CLIENT;
11+
12+
public LimitsExtension(OpenStackClient client) {
13+
CLIENT = client;
14+
}
15+
16+
public List list() {
17+
return new List();
18+
}
19+
20+
public class List extends OpenStackRequest<Limits> {
21+
22+
public List() {
23+
super(CLIENT, HttpMethod.GET, "/limits", null, Limits.class);
24+
}
25+
26+
}
27+
28+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package com.woorea.openstack.cinder;
2+
3+
import com.woorea.openstack.base.client.Entity;
4+
import com.woorea.openstack.base.client.HttpMethod;
5+
import com.woorea.openstack.base.client.OpenStackClient;
6+
import com.woorea.openstack.base.client.OpenStackRequest;
7+
import com.woorea.openstack.cinder.model.Metadata;
8+
import com.woorea.openstack.cinder.model.Snapshot;
9+
import com.woorea.openstack.cinder.model.SnapshotForCreate;
10+
import com.woorea.openstack.cinder.model.SnapshotForUpdate;
11+
import com.woorea.openstack.cinder.model.Snapshots;
12+
13+
public class SnapshotsExtension {
14+
15+
private final OpenStackClient CLIENT;
16+
17+
public SnapshotsExtension(OpenStackClient client) {
18+
CLIENT = client;
19+
}
20+
21+
public List list(boolean detail) {
22+
return new List(detail);
23+
}
24+
25+
public Create create(SnapshotForCreate snapshotForCreate) {
26+
return new Create(snapshotForCreate);
27+
}
28+
29+
public Show show(String id) {
30+
return new Show(id);
31+
}
32+
33+
public ShowMetadata showMetadata(String snapshotId) {
34+
return new ShowMetadata(snapshotId);
35+
}
36+
37+
public UpdateMetadata updateMetadata(String snapshotId, Metadata metadata) {
38+
return new UpdateMetadata(snapshotId, metadata);
39+
}
40+
41+
public Delete delete(String id) {
42+
return new Delete(id);
43+
}
44+
45+
public Update update(String id, SnapshotForUpdate snapshot) {
46+
return new Update(id, snapshot);
47+
}
48+
49+
public class List extends OpenStackRequest<Snapshots> {
50+
51+
public List(boolean detail) {
52+
super(CLIENT, HttpMethod.GET, detail ? "/snapshots/detail" : "/snapshots", null, Snapshots.class);
53+
}
54+
55+
}
56+
57+
public class Create extends OpenStackRequest<Snapshot> {
58+
59+
public Create(SnapshotForCreate snapshotForCreate) {
60+
super(CLIENT, HttpMethod.POST, "/snapshots", Entity.json(snapshotForCreate), Snapshot.class);
61+
}
62+
63+
}
64+
65+
public class Show extends OpenStackRequest<Snapshot> {
66+
67+
public Show(String id) {
68+
super(CLIENT, HttpMethod.GET, new StringBuilder("/snapshots/").append(id).toString(), null, Snapshot.class);
69+
}
70+
71+
}
72+
73+
public class Delete extends OpenStackRequest<Void> {
74+
75+
public Delete(String id) {
76+
super(CLIENT, HttpMethod.DELETE, new StringBuilder("/snapshots/").append(id).toString(), null, Void.class);
77+
}
78+
79+
}
80+
81+
public class Update extends OpenStackRequest<Void> {
82+
83+
public Update(String id, SnapshotForUpdate snapshot) {
84+
super(CLIENT, HttpMethod.PUT, new StringBuilder("/snapshots/").append(id).toString(),
85+
Entity.json(snapshot), Void.class);
86+
}
87+
88+
}
89+
90+
public class ShowMetadata extends OpenStackRequest<Metadata> {
91+
92+
public ShowMetadata(String id) {
93+
super(CLIENT,
94+
HttpMethod.GET,
95+
new StringBuilder("/snapshots/").append(id).append("/metadata").toString(),
96+
null,
97+
Metadata.class);
98+
}
99+
100+
}
101+
102+
public class UpdateMetadata extends OpenStackRequest<Void> {
103+
104+
public UpdateMetadata(String snapshotId, Metadata metadata) {
105+
super(CLIENT, HttpMethod.PUT, new StringBuilder("/snapshots/").append(snapshotId)
106+
.append("/metadata")
107+
.toString(), Entity.json(metadata), Void.class);
108+
}
109+
110+
}
111+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.woorea.openstack.cinder;
2+
3+
import com.woorea.openstack.base.client.Entity;
4+
import com.woorea.openstack.base.client.HttpMethod;
5+
import com.woorea.openstack.base.client.OpenStackClient;
6+
import com.woorea.openstack.base.client.OpenStackRequest;
7+
import com.woorea.openstack.cinder.model.VolumeType;
8+
import com.woorea.openstack.cinder.model.VolumeTypeForCreate;
9+
import com.woorea.openstack.cinder.model.VolumeTypes;
10+
11+
public class VolumeTypesExtension {
12+
13+
private final OpenStackClient CLIENT;
14+
15+
public VolumeTypesExtension(OpenStackClient client) {
16+
CLIENT = client;
17+
}
18+
19+
public List list() {
20+
return new List();
21+
}
22+
23+
public Create create(VolumeTypeForCreate volumeTypeForCreate) {
24+
return new Create(volumeTypeForCreate);
25+
}
26+
27+
public Show show(String id) {
28+
return new Show(id);
29+
}
30+
31+
public Delete delete(String id) {
32+
return new Delete(id);
33+
}
34+
35+
public class List extends OpenStackRequest<VolumeTypes> {
36+
37+
public List() {
38+
super(CLIENT, HttpMethod.GET, "/types", null, VolumeTypes.class);
39+
}
40+
41+
}
42+
43+
public class Create extends OpenStackRequest<VolumeType> {
44+
45+
private VolumeTypeForCreate volumeTypeForCreate;
46+
47+
public Create(VolumeTypeForCreate volumeTypeForCreate) {
48+
super(CLIENT, HttpMethod.POST, "/types", Entity.json(volumeTypeForCreate), VolumeType.class);
49+
this.volumeTypeForCreate = volumeTypeForCreate;
50+
}
51+
52+
}
53+
54+
public class Show extends OpenStackRequest<VolumeType> {
55+
56+
public Show(String id) {
57+
super(CLIENT, HttpMethod.GET, new StringBuilder("/types/").append(id).toString(), null, VolumeType.class);
58+
}
59+
60+
}
61+
62+
public class Delete extends OpenStackRequest<Void> {
63+
64+
public Delete(String id) {
65+
super(CLIENT, HttpMethod.DELETE, new StringBuilder("/types/").append(id).toString(), null, Void.class);
66+
}
67+
68+
}
69+
70+
}

0 commit comments

Comments
 (0)