-
Notifications
You must be signed in to change notification settings - Fork 0
Cluster, SVM and Aggr Feign Client #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
951d8ea
85da607
c35ebc8
4a42f58
287a8b0
5802f44
0363ab5
a74c021
8de7034
9ceeb10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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.apache.cloudstack.storage.feign.client; | ||
|
|
||
| import org.apache.cloudstack.storage.feign.model.Aggregate; | ||
| import org.apache.cloudstack.storage.feign.FeignConfiguration; | ||
| import org.apache.cloudstack.storage.feign.model.response.OntapResponse; | ||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.context.annotation.Lazy; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestMethod; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| @Lazy | ||
| @FeignClient(name="AggregateClient", url="https://{clusterIP}/api/storage/aggregates", configuration = FeignConfiguration.class) | ||
| public interface AggregateFeignClient { | ||
|
|
||
| //this method to get all aggregates and also filtered aggregates based on query params as a part of URL | ||
| @RequestMapping(method=RequestMethod.GET) | ||
| OntapResponse<Aggregate> getAggregateResponse(URI baseURL, @RequestHeader("Authorization") String header); | ||
|
|
||
| @RequestMapping(method=RequestMethod.GET, value="/{uuid}") | ||
| Aggregate getAggregateByUUID(URI baseURL,@RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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.apache.cloudstack.storage.feign.client; | ||
|
|
||
| import org.apache.cloudstack.storage.feign.FeignConfiguration; | ||
| import org.apache.cloudstack.storage.feign.model.Cluster; | ||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestMethod; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| @FeignClient(name="ClusterClient", url="https://{clusterIP}/api/cluster", configuration = FeignConfiguration.class) | ||
| public interface ClusterFeignClient { | ||
|
|
||
| @RequestMapping(method= RequestMethod.GET) | ||
| Cluster getCluster(URI baseURL, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value); | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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.apache.cloudstack.storage.feign.client; | ||
|
|
||
| import org.apache.cloudstack.storage.feign.FeignConfiguration; | ||
| import org.apache.cloudstack.storage.feign.model.Svm; | ||
| import org.apache.cloudstack.storage.feign.model.response.OntapResponse; | ||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestMethod; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| @FeignClient(name = "SvmClient", url = "https://{clusterIP}/api/svm/svms", configuration = FeignConfiguration.class) | ||
| public interface SvmFeignClient { | ||
|
|
||
| //this method to get all svms and also filtered svms based on query params as a part of URL | ||
| @RequestMapping(method = RequestMethod.GET) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A general comment which can be taken later. I see somewhere RequestMapping and somewhere GetMapping,PostMapping.We can have same aross all feign client |
||
| OntapResponse<Svm> getSvmResponse(URI baseURL, @RequestHeader("Authorization") String header); | ||
|
|
||
| @RequestMapping(method = RequestMethod.GET, value = "/{uuid}") | ||
| Svm getSvmByUUID(URI baseURL, @RequestHeader("Authorization") String header); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,9 @@ | |
|
|
||
|
|
||
| import org.apache.cloudstack.storage.feign.FeignConfiguration; | ||
| import org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO; | ||
| import org.apache.cloudstack.storage.feign.model.response.JobResponseDTO; | ||
| import org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO; | ||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
|
|
@@ -34,27 +37,20 @@ | |
| public interface VolumeFeignClient { | ||
|
|
||
| @DeleteMapping("/storage/volumes/{id}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /api is missing |
||
| void deleteVolume(@RequestHeader("Authorization") String authHeader, | ||
| @PathVariable("id") String volumeId); | ||
| void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId); | ||
|
|
||
| @PostMapping("/api/storage/volumes") | ||
| org.apache.cloudstack.storage.feign.model.response.JobResponseDTO createVolumeWithJob( | ||
| @RequestHeader("Authorization") String authHeader, | ||
| @RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request | ||
| JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request | ||
| ); | ||
|
|
||
| @GetMapping("/api/storage/volumes/{uuid}") | ||
| org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO getVolumeDetails( | ||
| @RequestHeader("Authorization") String authHeader, | ||
| @PathVariable("uuid") String uuid | ||
| VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid | ||
| ); | ||
|
|
||
| @PatchMapping("/api/storage/volumes/{uuid}") | ||
| org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing( | ||
| @RequestHeader("accept") String acceptHeader, | ||
| org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader, | ||
| @PathVariable("uuid") String uuid, | ||
| @RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request | ||
| ); | ||
|
|
||
|
|
||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we reuse this in VolumeRequestDTO, instead of AggregateDTO?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, will remove the request DTOs and use the same ontap model with null annotation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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.apache.cloudstack.storage.feign.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Complete cluster information | ||
| */ | ||
| @SuppressWarnings("checkstyle:RegexpSingleline") | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class Cluster { | ||
|
|
||
| @JsonProperty("name") | ||
| private String name = null; | ||
| @JsonProperty("uuid") | ||
| private String uuid = null; | ||
| @JsonProperty("version") | ||
| private Version version = null; | ||
| @JsonProperty("health") | ||
| private String health = null; | ||
|
|
||
| @JsonProperty("san_optimized") | ||
| private Boolean sanOptimized = null; | ||
|
|
||
| @JsonProperty("disaggregated") | ||
| private Boolean disaggregated = null; | ||
|
|
||
|
|
||
| public String getHealth() { | ||
| return health; | ||
| } | ||
|
|
||
| public void setHealth(String health) { | ||
| this.health = health; | ||
| } | ||
|
|
||
| public Cluster name(String name) { | ||
| this.name = name; | ||
| return this; | ||
| } | ||
|
|
||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
|
|
||
| public String getUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public Cluster version(Version version) { | ||
| this.version = version; | ||
| return this; | ||
| } | ||
|
|
||
| public Version getVersion() { | ||
| return version; | ||
| } | ||
|
|
||
| public void setVersion(Version version) { | ||
| this.version = version; | ||
| } | ||
|
|
||
| public Boolean getSanOptimized() { | ||
| return sanOptimized; | ||
| } | ||
|
|
||
| public void setSanOptimized(Boolean sanOptimized) { | ||
| this.sanOptimized = sanOptimized; | ||
| } | ||
|
|
||
| public Boolean getDisaggregated() { | ||
| return disaggregated; | ||
| } | ||
| public void setDisaggregated(Boolean disaggregated) { | ||
| this.disaggregated = disaggregated; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(getName(), getUuid()); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(java.lang.Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| Cluster cluster = (Cluster) o; | ||
| return Objects.equals(this.name, cluster.name) && | ||
| Objects.equals(this.uuid, cluster.uuid); | ||
| } | ||
| @Override | ||
| public String toString() { | ||
| return "Cluster{" + | ||
| "name='" + name + '\'' + | ||
| ", uuid='" + uuid + '\'' + | ||
| ", version=" + version + | ||
| ", sanOptimized=" + sanOptimized + | ||
| ", disaggregated=" + disaggregated + | ||
| '}'; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To instantiate only when required, we can use this across all the feign clients?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some feign client we need upfront like Cluster, SVM for others we will use @lazy