Skip to content

Commit c585299

Browse files
suryag1201Gupta, Surya
andauthored
NAS and Job Feign Client
* CSTACKEX-31 NAS and Job Feign Client and POJOs * CSTACKEX-31 Fixed Checks Issues * CSTACKEX-31 Resolve Review Comments * CSTACKEX-31 Resolve Review Comments * CSTACKEX-31 Resolve Review Comments * CSTACKEX-31 Added Aggr and size to volume model * CSTACKEX-31 Change the export policy endpoint path * CSTACKEX-31 Fixed check styles --------- Co-authored-by: Gupta, Surya <[email protected]>
1 parent f7b837a commit c585299

File tree

12 files changed

+821
-179
lines changed

12 files changed

+821
-179
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.storage.feign.client;
20+
21+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
22+
import org.apache.cloudstack.storage.feign.model.Job;
23+
import org.springframework.cloud.openfeign.FeignClient;
24+
import org.springframework.context.annotation.Lazy;
25+
import org.springframework.web.bind.annotation.PathVariable;
26+
import org.springframework.web.bind.annotation.RequestHeader;
27+
import org.springframework.web.bind.annotation.RequestMapping;
28+
import org.springframework.web.bind.annotation.RequestMethod;
29+
import java.net.URI;
30+
31+
/**
32+
* @author Administrator
33+
*
34+
*/
35+
@Lazy
36+
@FeignClient(name = "JobClient", url = "https://{clusterIP}/api/cluster/jobs" , configuration = FeignConfiguration.class)
37+
public interface JobFeignClient {
38+
39+
@RequestMapping(method = RequestMethod.GET, value="/{uuid}")
40+
Job getJobByUUID(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
41+
42+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.cloudstack.storage.feign.client;
21+
22+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
23+
import org.apache.cloudstack.storage.feign.model.ExportPolicy;
24+
import org.apache.cloudstack.storage.feign.model.FileInfo;
25+
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
26+
import org.springframework.cloud.openfeign.FeignClient;
27+
import org.springframework.context.annotation.Lazy;
28+
import org.springframework.web.bind.annotation.PathVariable;
29+
import org.springframework.web.bind.annotation.RequestHeader;
30+
import org.springframework.web.bind.annotation.RequestMapping;
31+
import org.springframework.web.bind.annotation.RequestBody;
32+
import org.springframework.web.bind.annotation.RequestMethod;
33+
import java.net.URI;
34+
35+
/**
36+
* @author Administrator
37+
*
38+
*/
39+
@Lazy
40+
@FeignClient(name = "NASClient", url = "" , configuration = FeignConfiguration.class)
41+
public interface NASFeignClient {
42+
43+
//File Operations
44+
45+
@RequestMapping(method = RequestMethod.GET, value="/{volume.uuid}/files/{path}")
46+
OntapResponse<FileInfo> getFileResponse(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID,
47+
@PathVariable(name = "path", required = true) String filePath);
48+
@RequestMapping(method = RequestMethod.DELETE, value="/{volume.uuid}/files/{path}")
49+
void deleteFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID,
50+
@PathVariable(name = "path", required = true) String filePath);
51+
@RequestMapping(method = RequestMethod.PATCH, value="/{volume.uuid}/files/{path}")
52+
void updateFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID,
53+
@PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo fileInfo);
54+
@RequestMapping(method = RequestMethod.POST, value="/{volume.uuid}/files/{path}")
55+
void createFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID,
56+
@PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo file);
57+
58+
59+
60+
//Export Policy Operations
61+
62+
@RequestMapping(method = RequestMethod.POST)
63+
ExportPolicy createExportPolicy(URI uri, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value,
64+
@RequestBody ExportPolicy exportPolicy);
65+
66+
//this method to get all export policies and also filtered export policy based on query params as a part of URL
67+
@RequestMapping(method = RequestMethod.GET)
68+
OntapResponse<ExportPolicy> getExportPolicyResponse(URI baseURL, @RequestHeader("Authorization") String header);
69+
70+
@RequestMapping(method = RequestMethod.GET, value="/{id}")
71+
OntapResponse<ExportPolicy> getExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id);
72+
73+
@RequestMapping(method = RequestMethod.DELETE, value="/{id}")
74+
void deleteExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id);
75+
76+
@RequestMapping(method = RequestMethod.PATCH, value="/{id}")
77+
OntapResponse<ExportPolicy> updateExportPolicy(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id,
78+
@RequestBody ExportPolicy request);
79+
}

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,31 @@
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;
23+
import org.apache.cloudstack.storage.feign.model.Volume;
24+
import org.apache.cloudstack.storage.feign.model.response.JobResponse;
2625
import org.springframework.cloud.openfeign.FeignClient;
27-
import org.springframework.web.bind.annotation.DeleteMapping;
28-
import org.springframework.web.bind.annotation.GetMapping;
29-
import org.springframework.web.bind.annotation.PatchMapping;
26+
import org.springframework.context.annotation.Lazy;
3027
import org.springframework.web.bind.annotation.PathVariable;
31-
import org.springframework.web.bind.annotation.PostMapping;
32-
import org.springframework.web.bind.annotation.RequestBody;
3328
import org.springframework.web.bind.annotation.RequestHeader;
29+
import org.springframework.web.bind.annotation.RequestMapping;
30+
import org.springframework.web.bind.annotation.RequestBody;
31+
import org.springframework.web.bind.annotation.RequestMethod;
3432

3533

34+
@Lazy
3635
@FeignClient(name = "VolumeClient", url = "https://{clusterIP}/api/storage/volumes", configuration = FeignConfiguration.class)
3736
public interface VolumeFeignClient {
3837

39-
@DeleteMapping("/storage/volumes/{id}")
40-
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId);
38+
@RequestMapping(method = RequestMethod.DELETE, value="/{uuid}")
39+
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid);
4140

42-
@PostMapping("/api/storage/volumes")
43-
JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request
44-
);
41+
@RequestMapping(method = RequestMethod.POST)
42+
JobResponse createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody Volume volumeRequest);
4543

46-
@GetMapping("/api/storage/volumes/{uuid}")
47-
VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid
48-
);
44+
@RequestMapping(method = RequestMethod.GET, value="/{uuid}")
45+
Volume getVolumeByUUID(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid);
4946

50-
@PatchMapping("/api/storage/volumes/{uuid}")
51-
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader,
52-
@PathVariable("uuid") String uuid,
53-
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
54-
);
47+
@RequestMapping(method = RequestMethod.PATCH)
48+
JobResponse updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader, @PathVariable("uuid") String uuid, @RequestBody Volume volumeRequest);
5549

5650
}

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

Lines changed: 91 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,105 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
package org.apache.cloudstack.storage.feign.model;
2021

2122
import com.fasterxml.jackson.annotation.JsonInclude;
22-
23+
import com.fasterxml.jackson.annotation.JsonProperty;
24+
import java.math.BigInteger;
25+
import java.util.List;
2326
import java.util.Objects;
2427

2528
@JsonInclude(JsonInclude.Include.NON_NULL)
2629
public class ExportPolicy {
27-
private String name;
28-
private long id;
29-
public String getName() { return name; }
30-
public void setName(String name) { this.name = name; }
31-
public long getId() { return id; }
32-
public void setId(long id) { this.id = id; }
33-
34-
@Override
35-
public boolean equals(Object o) {
36-
if (o == null || getClass() != o.getClass()) return false;
37-
ExportPolicy that = (ExportPolicy) o;
38-
return getId() == that.getId();
30+
31+
@JsonProperty("id")
32+
private BigInteger id = null;
33+
@JsonProperty("name")
34+
private String name = null;
35+
@JsonProperty("rules")
36+
private List<ExportRule> rules = null;
37+
@JsonProperty("svm")
38+
private Svm svm = null;
39+
40+
public BigInteger getId() {
41+
return id;
42+
}
43+
44+
public ExportPolicy name(String name) {
45+
this.name = name;
46+
return this;
47+
}
48+
49+
public String getName() {
50+
return name;
51+
}
52+
53+
public void setName(String name) {
54+
this.name = name;
55+
}
56+
57+
public ExportPolicy rules(List<ExportRule> rules) {
58+
this.rules = rules;
59+
return this;
60+
}
61+
62+
public List<ExportRule> getRules() {
63+
return rules;
64+
}
65+
66+
public void setRules(List<ExportRule> rules) {
67+
this.rules = rules;
68+
}
69+
70+
public ExportPolicy svm(Svm svm) {
71+
this.svm = svm;
72+
return this;
73+
}
74+
75+
public Svm getSvm() {
76+
return svm;
77+
}
78+
79+
public void setSvm(Svm svm) {
80+
this.svm = svm;
81+
}
82+
83+
84+
@Override
85+
public boolean equals(Object o) {
86+
if (this == o) {
87+
return true;
88+
}
89+
if (o == null || getClass() != o.getClass()) {
90+
return false;
3991
}
92+
ExportPolicy exportPolicy = (ExportPolicy) o;
93+
return Objects.equals(this.id, exportPolicy.id) &&
94+
Objects.equals(this.name, exportPolicy.name);
95+
}
96+
97+
@Override
98+
public int hashCode() {
99+
return Objects.hash( id, name, rules, svm);
100+
}
101+
40102

41-
@Override
42-
public int hashCode() {
43-
return Objects.hashCode(getId());
103+
@Override
104+
public String toString() {
105+
StringBuilder sb = new StringBuilder();
106+
sb.append("class ExportPolicy {\n");
107+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
108+
sb.append(" name: ").append(toIndentedString(name)).append("\n");
109+
sb.append(" rules: ").append(toIndentedString(rules)).append("\n");
110+
sb.append(" svm: ").append(toIndentedString(svm)).append("\n");
111+
sb.append("}");
112+
return sb.toString();
113+
}
114+
private String toIndentedString(Object o) {
115+
if (o == null) {
116+
return "null";
44117
}
118+
return o.toString().replace("\n", "\n ");
119+
}
45120
}

0 commit comments

Comments
 (0)