diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/JobFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/JobFeignClient.java new file mode 100644 index 000000000000..4becf7bb29c4 --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/JobFeignClient.java @@ -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.Job; +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; + +/** + * @author Administrator + * + */ +@Lazy +@FeignClient(name = "JobClient", url = "https://{clusterIP}/api/cluster/jobs" , configuration = FeignConfiguration.class) +public interface JobFeignClient { + + @RequestMapping(method = RequestMethod.GET, value="/{uuid}") + Job getJobByUUID(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid); + +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java new file mode 100644 index 000000000000..6e7b37d9378f --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java @@ -0,0 +1,79 @@ +/* + * 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.ExportPolicy; +import org.apache.cloudstack.storage.feign.model.FileInfo; +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.RequestBody; +import org.springframework.web.bind.annotation.RequestMethod; +import java.net.URI; + +/** + * @author Administrator + * + */ +@Lazy +@FeignClient(name = "NASClient", url = "" , configuration = FeignConfiguration.class) +public interface NASFeignClient { + + //File Operations + + @RequestMapping(method = RequestMethod.GET, value="/{volume.uuid}/files/{path}") + OntapResponse getFileResponse(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, + @PathVariable(name = "path", required = true) String filePath); + @RequestMapping(method = RequestMethod.DELETE, value="/{volume.uuid}/files/{path}") + void deleteFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, + @PathVariable(name = "path", required = true) String filePath); + @RequestMapping(method = RequestMethod.PATCH, value="/{volume.uuid}/files/{path}") + void updateFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, + @PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo fileInfo); + @RequestMapping(method = RequestMethod.POST, value="/{volume.uuid}/files/{path}") + void createFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, + @PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo file); + + + + //Export Policy Operations + + @RequestMapping(method = RequestMethod.POST) + ExportPolicy createExportPolicy(URI uri, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value, + @RequestBody ExportPolicy exportPolicy); + + //this method to get all export policies and also filtered export policy based on query params as a part of URL + @RequestMapping(method = RequestMethod.GET) + OntapResponse getExportPolicyResponse(URI baseURL, @RequestHeader("Authorization") String header); + + @RequestMapping(method = RequestMethod.GET, value="/{id}") + OntapResponse getExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id); + + @RequestMapping(method = RequestMethod.DELETE, value="/{id}") + void deleteExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id); + + @RequestMapping(method = RequestMethod.PATCH, value="/{id}") + OntapResponse updateExportPolicy(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id, + @RequestBody ExportPolicy request); +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java index 8218cffad6d6..fb3c9712d750 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java @@ -20,37 +20,31 @@ 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.apache.cloudstack.storage.feign.model.Volume; +import org.apache.cloudstack.storage.feign.model.response.JobResponse; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMethod; +@Lazy @FeignClient(name = "VolumeClient", url = "https://{clusterIP}/api/storage/volumes", configuration = FeignConfiguration.class) public interface VolumeFeignClient { - @DeleteMapping("/storage/volumes/{id}") - void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId); + @RequestMapping(method = RequestMethod.DELETE, value="/{uuid}") + void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid); - @PostMapping("/api/storage/volumes") - JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request - ); + @RequestMapping(method = RequestMethod.POST) + JobResponse createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody Volume volumeRequest); - @GetMapping("/api/storage/volumes/{uuid}") - VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid - ); + @RequestMapping(method = RequestMethod.GET, value="/{uuid}") + Volume getVolumeByUUID(@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, - @PathVariable("uuid") String uuid, - @RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request - ); + @RequestMapping(method = RequestMethod.PATCH) + JobResponse updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader, @PathVariable("uuid") String uuid, @RequestBody Volume volumeRequest); } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java index 489ecb3d4087..be78639844b3 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java @@ -16,30 +16,105 @@ * 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.math.BigInteger; +import java.util.List; import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_NULL) public class ExportPolicy { - private String name; - private long id; - public String getName() { return name; } - public void setName(String name) { this.name = name; } - public long getId() { return id; } - public void setId(long id) { this.id = id; } - - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - ExportPolicy that = (ExportPolicy) o; - return getId() == that.getId(); + + @JsonProperty("id") + private BigInteger id = null; + @JsonProperty("name") + private String name = null; + @JsonProperty("rules") + private List rules = null; + @JsonProperty("svm") + private Svm svm = null; + + public BigInteger getId() { + return id; + } + + public ExportPolicy name(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ExportPolicy rules(List rules) { + this.rules = rules; + return this; + } + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + public ExportPolicy svm(Svm svm) { + this.svm = svm; + return this; + } + + public Svm getSvm() { + return svm; + } + + public void setSvm(Svm svm) { + this.svm = svm; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; } + ExportPolicy exportPolicy = (ExportPolicy) o; + return Objects.equals(this.id, exportPolicy.id) && + Objects.equals(this.name, exportPolicy.name); + } + + @Override + public int hashCode() { + return Objects.hash( id, name, rules, svm); + } + - @Override - public int hashCode() { - return Objects.hashCode(getId()); + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExportPolicy {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" svm: ").append(toIndentedString(svm)).append("\n"); + sb.append("}"); + return sb.toString(); + } + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } + return o.toString().replace("\n", "\n "); + } } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportRule.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportRule.java new file mode 100644 index 000000000000..6d4798667075 --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportRule.java @@ -0,0 +1,159 @@ +/* + * 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.List; + +/** + * ExportRule + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExportRule { + @JsonProperty("anonymous_user") + private String anonymousUser ; + + @JsonProperty("clients") + private List clients = null; + + @JsonProperty("index") + private Integer index = null; + + public enum ProtocolsEnum { + any("any"), + + nfs("nfs"), + + nfs3("nfs3"), + + nfs4("nfs4"); + + private String value; + + ProtocolsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ProtocolsEnum fromValue(String text) { + for (ProtocolsEnum b : ProtocolsEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("protocols") + private List protocols = null; + + public ExportRule anonymousUser(String anonymousUser) { + this.anonymousUser = anonymousUser; + return this; + } + + public String getAnonymousUser() { + return anonymousUser; + } + + public void setAnonymousUser(String anonymousUser) { + this.anonymousUser = anonymousUser; + } + + public ExportRule clients(List clients) { + this.clients = clients; + return this; + } + + public List getClients() { + return clients; + } + + public void setClients(List clients) { + this.clients = clients; + } + + public Integer getIndex() { + return index; + } + public void setIndex(Integer index) + { + this.index=index; + } + + public ExportRule protocols(List protocols) { + this.protocols = protocols; + return this; + } + + public List getProtocols() { + return protocols; + } + + public void setProtocols(List protocols) { + this.protocols = protocols; + } + + public static class ExportClient { + @JsonProperty("match") + private String match = null; + + public ExportClient match (String match) { + this.match = match; + return this; + } + public String getMatch () { + return match; + } + + public void setMatch (String match) { + this.match = match; + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExportRule {\n"); + + sb.append(" anonymousUser: ").append(toIndentedString(anonymousUser)).append("\n"); + sb.append(" clients: ").append(toIndentedString(clients)).append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb.append(" protocols: ").append(toIndentedString(protocols)).append("\n"); + sb.append("}"); + return sb.toString(); + } + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileInfo.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileInfo.java new file mode 100644 index 000000000000..b67704435a9e --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileInfo.java @@ -0,0 +1,295 @@ +/* + * 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.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Information about a single file. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class FileInfo { + @JsonProperty("bytes_used") + private Long bytesUsed = null; + @JsonProperty("creation_time") + private OffsetDateTime creationTime = null; + @JsonProperty("fill_enabled") + private Boolean fillEnabled = null; + @JsonProperty("is_empty") + private Boolean isEmpty = null; + @JsonProperty("is_snapshot") + private Boolean isSnapshot = null; + @JsonProperty("is_vm_aligned") + private Boolean isVmAligned = null; + @JsonProperty("modified_time") + private OffsetDateTime modifiedTime = null; + @JsonProperty("name") + private String name = null; + @JsonProperty("overwrite_enabled") + private Boolean overwriteEnabled = null; + @JsonProperty("path") + private String path = null; + @JsonProperty("size") + private Long size = null; + @JsonProperty("target") + private String target = null; + + /** + * Type of the file. + */ + public enum TypeEnum { + FILE("file"), + DIRECTORY("directory"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + } + + @JsonProperty("type") + private TypeEnum type = null; + + @JsonProperty("unique_bytes") + private Long uniqueBytes = null; + + @JsonProperty("unix_permissions") + private Integer unixPermissions = null; + + /** + * The actual number of bytes used on disk by this file. If byte_offset and length parameters are specified, this will return the bytes used by the file within the given range. + * @return bytesUsed + **/ + public Long getBytesUsed() { + return bytesUsed; + } + + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public FileInfo fillEnabled(Boolean fillEnabled) { + this.fillEnabled = fillEnabled; + return this; + } + + public Boolean isFillEnabled() { + return fillEnabled; + } + + public void setFillEnabled(Boolean fillEnabled) { + this.fillEnabled = fillEnabled; + } + + + public Boolean isIsEmpty() { + return isEmpty; + } + + public void setIsEmpty(Boolean isEmpty) { + this.isEmpty = isEmpty; + } + + public Boolean isIsSnapshot() { + return isSnapshot; + } + + public void setIsSnapshot(Boolean isSnapshot) { + this.isSnapshot = isSnapshot; + } + + + public Boolean isIsVmAligned() { + return isVmAligned; + } + + + public OffsetDateTime getModifiedTime() { + return modifiedTime; + } + + public FileInfo name(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public FileInfo overwriteEnabled(Boolean overwriteEnabled) { + this.overwriteEnabled = overwriteEnabled; + return this; + } + + public Boolean isOverwriteEnabled() { + return overwriteEnabled; + } + + public void setOverwriteEnabled(Boolean overwriteEnabled) { + this.overwriteEnabled = overwriteEnabled; + } + + public FileInfo path(String path) { + this.path = path; + return this; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + public FileInfo target(String target) { + this.target = target; + return this; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public FileInfo type(TypeEnum type) { + this.type = type; + return this; + } + + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public Long getUniqueBytes() { + return uniqueBytes; + } + + public FileInfo unixPermissions(Integer unixPermissions) { + this.unixPermissions = unixPermissions; + return this; + } + + public Integer getUnixPermissions() { + return unixPermissions; + } + + public void setUnixPermissions(Integer unixPermissions) { + this.unixPermissions = unixPermissions; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileInfo fileInfo = (FileInfo) o; + return Objects.equals(this.name, fileInfo.name) && + Objects.equals(this.path, fileInfo.path); + } + + @Override + public int hashCode() { + return Objects.hash(bytesUsed, creationTime, fillEnabled, isEmpty, isSnapshot, isVmAligned, modifiedTime, name, overwriteEnabled, path, size, target, type, uniqueBytes, unixPermissions); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileInfo {\n"); + sb.append(" bytesUsed: ").append(toIndentedString(bytesUsed)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" fillEnabled: ").append(toIndentedString(fillEnabled)).append("\n"); + sb.append(" isEmpty: ").append(toIndentedString(isEmpty)).append("\n"); + sb.append(" isSnapshot: ").append(toIndentedString(isSnapshot)).append("\n"); + sb.append(" isVmAligned: ").append(toIndentedString(isVmAligned)).append("\n"); + sb.append(" modifiedTime: ").append(toIndentedString(modifiedTime)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" overwriteEnabled: ").append(toIndentedString(overwriteEnabled)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" uniqueBytes: ").append(toIndentedString(uniqueBytes)).append("\n"); + sb.append(" unixPermissions: ").append(toIndentedString(unixPermissions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Job.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Job.java new file mode 100644 index 000000000000..a1a0c2698f14 --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Job.java @@ -0,0 +1,119 @@ +/* + * 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.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author Administrator + * + */ +@JsonInclude(Include.NON_NULL) +public class Job { + + @JsonProperty("uuid") + String uuid; + @JsonProperty("description") + String description; + @JsonProperty("state") + String state; + @JsonProperty("message") + String message; + @JsonProperty("code") + String code; + @JsonProperty("_links") + private Links links; + + @JsonProperty("error") + private JobError error; + public JobError getError () { return error; } + public void setError (JobError error) { this.error = error; } + public Links getLinks() { return links; } + public void setLinks(Links links) { this.links = links; } + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getState() { + return state; + } + public void setState(String state) { + this.state = state; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + @Override + public String toString() { + return "JobDTO [uuid=" + uuid + ", description=" + description + ", state=" + state + ", message=" + + message + ", code=" + code + "]"; + } + + public static class Links { + @JsonProperty("message") + private Self self; + public Self getSelf() { return self; } + public void setSelf(Self self) { this.self = self; } + } + + public static class Self { + @JsonProperty("message") + private String href; + public String getHref() { return href; } + public void setHref(String href) { this.href = href; } + } + + public static class JobError { + @JsonProperty("message") + String errorMesssage; + @JsonProperty("code") + String code; + public String getErrorMesssage () { return errorMesssage; } + public void setErrorMesssage (String errorMesssage) { this.errorMesssage = errorMesssage; } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + @Override + public String toString() { + return "JobError [errorMesssage=" + errorMesssage + ", code=" + code + "]"; + } + } +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Nas.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Nas.java index 5fdd1f772f0f..27590d3fde25 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Nas.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Nas.java @@ -45,5 +45,4 @@ public void setExportPolicy(ExportPolicy exportPolicy) { this.exportPolicy = exportPolicy; } - } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Volume.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Volume.java index 73d11312bc0e..3d384c56db2e 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Volume.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Volume.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_NULL) @@ -50,6 +51,12 @@ public class Volume { @JsonProperty("anti_ransomware") private AntiRansomware antiRansomware; + @JsonProperty("aggregates") + private List aggregates = null; + + @JsonProperty("size") + private Long size = null; + // Getters and setters public String getUuid() { return uuid; @@ -111,6 +118,15 @@ public void setAntiRansomware(AntiRansomware antiRansomware) { this.antiRansomware = antiRansomware; } + public List getAggregates () { return aggregates; } + + public void setAggregates (List aggregates) { this.aggregates = aggregates; } + + public Long getSize () { return size; } + + public void setSize (Long size) { this.size = size; } + + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/request/VolumeRequestDTO.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/request/VolumeRequestDTO.java deleted file mode 100644 index 7f758211fe86..000000000000 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/request/VolumeRequestDTO.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.request; - -import java.util.List; - -public class VolumeRequestDTO { - private String name; - private List aggregates; - private SvmDTO svm; - - // getters and setters - public String getName() { return name; } - public void setName(String name) { this.name = name; } - public List getAggregates() { return aggregates; } - public void setAggregates(List aggregates) { this.aggregates = aggregates; } - public SvmDTO getSvm() { return svm; } - public void setSvm(SvmDTO svm) { this.svm = svm; } - - public static class AggregateDTO { - private String name; - public String getName() { return name; } - public void setName(String name) { this.name = name; } - } - - public static class SvmDTO { - private String name; - public String getName() { return name; } - public void setName(String name) { this.name = name; } - } -} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponseDTO.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponse.java similarity index 58% rename from plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponseDTO.java rename to plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponse.java index b90806c63420..a794c191c493 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponseDTO.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/JobResponse.java @@ -18,29 +18,13 @@ */ package org.apache.cloudstack.storage.feign.model.response; -public class JobResponseDTO { +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.cloudstack.storage.feign.model.Job; + +public class JobResponse { + @JsonProperty("job") private Job job; public Job getJob() { return job; } public void setJob(Job job) { this.job = job; } - public static class Job { - private String uuid; - private Links links; - public String getUuid() { return uuid; } - public void setUuid(String uuid) { this.uuid = uuid; } - public Links getLinks() { return links; } - public void setLinks(Links links) { this.links = links; } - } - - public static class Links { - private Self self; - public Self getSelf() { return self; } - public void setSelf(Self self) { this.self = self; } - } - - public static class Self { - private String href; - public String getHref() { return href; } - public void setHref(String href) { this.href = href; } - } } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/VolumeDetailsResponseDTO.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/VolumeDetailsResponseDTO.java deleted file mode 100644 index e7016dbc6801..000000000000 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/response/VolumeDetailsResponseDTO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.response; - - -import org.apache.cloudstack.storage.feign.model.Aggregate; -import org.apache.cloudstack.storage.feign.model.Nas; -import org.apache.cloudstack.storage.feign.model.Qos; - -import java.util.List; - -public class VolumeDetailsResponseDTO { - private String uuid; - private String createTime; - private String name; - private long size; - private String state; - private String style; - private List aggregates; - private Nas nas; - private Qos qos; - private Svm svm; - private String antiRansomwareState; - - // getters and setters - public String getUuid() { return uuid; } - public void setUuid(String uuid) { this.uuid = uuid; } - public String getCreateTime() { return createTime; } - public void setCreateTime(String createTime) { this.createTime = createTime; } - public String getName() { return name; } - public void setName(String name) { this.name = name; } - public long getSize() { return size; } - public void setSize(long size) { this.size = size; } - public String getState() { return state; } - public void setState(String state) { this.state = state; } - public String getStyle() { return style; } - public void setStyle(String style) { this.style = style; } - public List getAggregates() { return aggregates; } - public void setAggregates(List aggregates) { this.aggregates = aggregates; } - public Nas getNas() { return nas; } - public void setNas(Nas nas) { this.nas = nas; } - public Qos getQos() { return qos; } - public void setQos(Qos qos) { this.qos = qos; } - public Svm getSvm() { return svm; } - public void setSvm(Svm svm) { this.svm = svm; } - public String getAntiRansomwareState() { return antiRansomwareState; } - public void setAntiRansomwareState(String antiRansomwareState) { this.antiRansomwareState = antiRansomwareState; } - - public static class Svm { - private String name; - private String uuid; - public String getName() { return name; } - public void setName(String name) { this.name = name; } - public String getUuid() { return uuid; } - public void setUuid(String uuid) { this.uuid = uuid; } - } -}