Skip to content

Commit 951d8ea

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-29 Cluster, SVM and Aggr Feign Client
1 parent 2822946 commit 951d8ea

File tree

10 files changed

+579
-21
lines changed

10 files changed

+579
-21
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.apache.cloudstack.storage.feign.client;
2+
3+
import org.apache.cloudstack.storage.feign.model.AggregateResponse;
4+
import org.apache.cloudstack.storage.feign.model.Aggregate;
5+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
6+
import org.springframework.cloud.openfeign.FeignClient;
7+
import org.springframework.context.annotation.Lazy;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestHeader;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RequestMethod;
12+
13+
import java.net.URI;
14+
15+
@Lazy
16+
@FeignClient(name="AggregateClient", url="https://{clusterIP}/api/storage/aggregates", configuration = FeignConfiguration.class)
17+
public interface AggregateFeignClient {
18+
@RequestMapping(method=RequestMethod.GET)
19+
AggregateResponse getAllAggregates(URI baseURL,@RequestHeader("Authorization") String header);
20+
21+
@RequestMapping(method=RequestMethod.GET, value="/{uuid}")
22+
Aggregate getAggregateByUUID(URI baseURL,@RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
23+
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.apache.cloudstack.storage.feign.client;
2+
3+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
4+
import org.apache.cloudstack.storage.feign.model.Cluster;
5+
import org.springframework.cloud.openfeign.FeignClient;
6+
import org.springframework.web.bind.annotation.RequestHeader;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RequestMethod;
9+
10+
import java.net.URI;
11+
12+
@FeignClient(name="ClusterClient", url="https://{clusterIP}/api/cluster", configuration = FeignConfiguration.class)
13+
public interface ClusterFeignClient {
14+
@RequestMapping(method= RequestMethod.GET)
15+
Cluster getCluster(URI baseURL, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value);
16+
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.apache.cloudstack.storage.feign.client;
2+
3+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
4+
import org.apache.cloudstack.storage.feign.model.SvmResponse;
5+
import org.apache.cloudstack.storage.feign.model.Svm;
6+
import org.springframework.cloud.openfeign.FeignClient;
7+
import org.springframework.web.bind.annotation.RequestHeader;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RequestMethod;
10+
11+
import java.net.URI;
12+
13+
@FeignClient(name = "SvmClient", url = "https://{clusterIP}/api/svm/svms", configuration = FeignConfiguration.class)
14+
public interface SvmFeignClient {
15+
@RequestMapping(method = RequestMethod.GET)
16+
SvmResponse getAllSvms(URI baseURL, @RequestHeader("Authorization") String header);
17+
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
18+
Svm getSvmByUUID(URI baseURL, @RequestHeader("Authorization") String header);
19+
20+
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121

2222
import org.apache.cloudstack.storage.feign.FeignConfiguration;
23+
import org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO;
24+
import org.apache.cloudstack.storage.feign.model.response.JobResponseDTO;
25+
import org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO;
2326
import org.springframework.cloud.openfeign.FeignClient;
2427
import org.springframework.web.bind.annotation.DeleteMapping;
2528
import org.springframework.web.bind.annotation.GetMapping;
@@ -34,27 +37,20 @@
3437
public interface VolumeFeignClient {
3538

3639
@DeleteMapping("/storage/volumes/{id}")
37-
void deleteVolume(@RequestHeader("Authorization") String authHeader,
38-
@PathVariable("id") String volumeId);
40+
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId);
3941

4042
@PostMapping("/api/storage/volumes")
41-
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO createVolumeWithJob(
42-
@RequestHeader("Authorization") String authHeader,
43-
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
43+
JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request
4444
);
4545

4646
@GetMapping("/api/storage/volumes/{uuid}")
47-
org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO getVolumeDetails(
48-
@RequestHeader("Authorization") String authHeader,
49-
@PathVariable("uuid") String uuid
47+
VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid
5048
);
5149

5250
@PatchMapping("/api/storage/volumes/{uuid}")
53-
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(
54-
@RequestHeader("accept") String acceptHeader,
51+
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader,
5552
@PathVariable("uuid") String uuid,
5653
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
5754
);
5855

59-
6056
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Aggregate.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@
2020
package org.apache.cloudstack.storage.feign.model;
2121

2222
import com.fasterxml.jackson.annotation.JsonInclude;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2324
import com.google.gson.annotations.SerializedName;
25+
import io.swagger.annotations.ApiModelProperty;
2426

2527
import java.util.Objects;
2628

2729
@JsonInclude(JsonInclude.Include.NON_NULL)
2830
public class Aggregate {
2931

30-
@SerializedName("name")
32+
@JsonProperty("name")
3133
private String name = null;
3234

3335
@Override
3436
public int hashCode() {
3537
return Objects.hash(getName(), getUuid());
3638
}
3739

38-
@SerializedName("uuid")
40+
@JsonProperty("uuid")
3941
private String uuid = null;
4042

4143
public Aggregate name(String name) {
@@ -48,6 +50,7 @@ public Aggregate name(String name) {
4850
*
4951
* @return name
5052
**/
53+
@ApiModelProperty(value = "Name of aggregate")
5154
public String getName() {
5255
return name;
5356
}
@@ -66,6 +69,7 @@ public Aggregate uuid(String uuid) {
6669
*
6770
* @return uuid
6871
**/
72+
@ApiModelProperty(value = "UUID of aggregate")
6973
public String getUuid() {
7074
return uuid;
7175
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*
2+
* ONTAP REST API
3+
* ONTAP adds support for an expansive RESTful API. The documentation below provides information about the types of API calls available to you, as well as details about using each API endpoint. You can learn more about the ONTAP REST API and ONTAP in the ONTAP 9 Documentation Center: http://docs.netapp.com/ontap-9/topic/com.netapp.doc.dot-rest-api/home.html. NetApp welcomes your comments and suggestions about the ONTAP REST API and the documentation for its use.</br> **Using the ONTAP REST API online documentation** Each API method includes usage examples, as well as a model that displays all the required and optional properties supported by the method. Click the _Model_ link, available with each API method, to see all the required and optional properties supported by each method.
4+
*
5+
* OpenAPI spec version: v1
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package org.apache.cloudstack.storage.feign.model;
15+
16+
import com.fasterxml.jackson.annotation.JsonInclude;
17+
import com.fasterxml.jackson.annotation.JsonProperty;
18+
import com.google.gson.annotations.SerializedName;
19+
import io.swagger.annotations.ApiModelProperty;
20+
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
import java.util.Objects;
24+
25+
/**
26+
* AggregateResponse
27+
*/
28+
@JsonInclude(JsonInclude.Include.NON_NULL)
29+
public class AggregateResponse {
30+
@JsonProperty("error")
31+
private Error error = null;
32+
@JsonProperty("num_records")
33+
private Integer numRecords = null;
34+
@JsonProperty("records")
35+
private List<Aggregate> records = null;
36+
37+
public AggregateResponse error(Error error) {
38+
this.error = error;
39+
return this;
40+
}
41+
42+
/**
43+
* Get error
44+
* @return error
45+
**/
46+
@ApiModelProperty(value = "")
47+
public Error getError() {
48+
return error;
49+
}
50+
51+
public void setError(Error error) {
52+
this.error = error;
53+
}
54+
55+
public AggregateResponse numRecords(Integer numRecords) {
56+
this.numRecords = numRecords;
57+
return this;
58+
}
59+
60+
/**
61+
* Number of records
62+
* @return numRecords
63+
**/
64+
@ApiModelProperty(value = "Number of records")
65+
public Integer getNumRecords() {
66+
return numRecords;
67+
}
68+
69+
public void setNumRecords(Integer numRecords) {
70+
this.numRecords = numRecords;
71+
}
72+
73+
public AggregateResponse records(List<Aggregate> records) {
74+
this.records = records;
75+
return this;
76+
}
77+
78+
public AggregateResponse addRecordsItem(Aggregate recordsItem) {
79+
if (this.records == null) {
80+
this.records = new ArrayList<Aggregate>();
81+
}
82+
this.records.add(recordsItem);
83+
return this;
84+
}
85+
86+
/**
87+
* Get records
88+
* @return records
89+
**/
90+
@ApiModelProperty(value = "")
91+
public List<Aggregate> getRecords() {
92+
return records;
93+
}
94+
95+
public void setRecords(List<Aggregate> records) {
96+
this.records = records;
97+
}
98+
99+
100+
@Override
101+
public boolean equals(Object o) {
102+
if (this == o) {
103+
return true;
104+
}
105+
if (o == null || getClass() != o.getClass()) {
106+
return false;
107+
}
108+
AggregateResponse aggregateResponse = (AggregateResponse) o;
109+
return
110+
Objects.equals(this.error, aggregateResponse.error) &&
111+
Objects.equals(this.numRecords, aggregateResponse.numRecords) &&
112+
Objects.equals(this.records, aggregateResponse.records);
113+
}
114+
115+
@Override
116+
public int hashCode() {
117+
return Objects.hash(error, numRecords, records);
118+
}
119+
120+
121+
@Override
122+
public String toString() {
123+
StringBuilder sb = new StringBuilder();
124+
sb.append("class AggregateResponse {\n");
125+
126+
sb.append(" error: ").append(toIndentedString(error)).append("\n");
127+
sb.append(" numRecords: ").append(toIndentedString(numRecords)).append("\n");
128+
sb.append(" records: ").append(toIndentedString(records)).append("\n");
129+
sb.append("}");
130+
return sb.toString();
131+
}
132+
133+
/**
134+
* Convert the given object to string with each line indented by 4 spaces
135+
* (except the first line).
136+
*/
137+
private String toIndentedString(Object o) {
138+
if (o == null) {
139+
return "null";
140+
}
141+
return o.toString().replace("\n", "\n ");
142+
}
143+
144+
}
145+

0 commit comments

Comments
 (0)