Skip to content

Commit

Permalink
REST doc / DDI - fix missed info (#1618)
Browse files Browse the repository at this point in the history
When spring restdoc was replaces with swagger & open api some info was lost
This commit returns back this info for DDI API

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Feb 7, 2024
1 parent ec10950 commit fc561c3
Show file tree
Hide file tree
Showing 32 changed files with 1,203 additions and 813 deletions.
Expand Up @@ -16,6 +16,9 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
* <p>
Expand All @@ -35,12 +38,14 @@
* "execution": "closed", "result": { "final": "success", "progress": {} }
* "details": [], } }
* </p>
*
*/
@Getter
@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiActionFeedback {

@Schema(example = "2023-08-03T12:31:41.890992967Z")
@Schema(description = "Timestamp of the action", example = "2023-08-03T12:31:41.890992967Z")
private final String time;

@NotNull
Expand All @@ -50,29 +55,14 @@ public class DdiActionFeedback {
/**
* Constructs an action-feedback
*
* @param time
* time of feedback
* @param status
* status to be appended to the action
* @param time time of feedback
* @param status status to be appended to the action
*/
@JsonCreator
public DdiActionFeedback(@JsonProperty(value = "time") final String time,
public DdiActionFeedback(
@JsonProperty(value = "time") final String time,
@JsonProperty(value = "status", required = true) final DdiStatus status) {
this.time = time;
this.status = status;
}

public String getTime() {
return time;
}

public DdiStatus getStatus() {
return status;
}

@Override
public String toString() {
return "ActionFeedback [time=" + time + ", status=" + status + "]";
}

}
}
Expand Up @@ -12,6 +12,8 @@
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand All @@ -21,41 +23,39 @@

/**
* Provide action history information to the controller as part of response to
* {@link DdiRootControllerRestApi#getControllerBasedeploymentAction} and
* {@link DdiRootControllerRestApi#getControllerBaseconfirmationAction}:
* 1. Current action status at the server; 2. List of messages from action history
* that were sent to server earlier by the controller using
* {@link DdiActionFeedback}.
* {@link DdiRootControllerRestApi#getControllerDeploymentBaseAction} and
* {@link DdiRootControllerRestApi#getConfirmationBaseAction}:
* <ol>
* <li>Current action status at the server</li>
* <li>List of messages from action history</li>
* </ol>
* that were sent to server earlier by the controller using {@link DdiActionFeedback}.
*/

@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ "status", "messages" })
public class DdiActionHistory {

@JsonProperty("status")
@Schema(example = "RUNNING")
@Schema(description = "Status of the deployment based on previous feedback by the device", example = "RUNNING")
private final String actionStatus;

@JsonProperty("messages")
@Schema(description = "Messages are previously sent to the feedback channel in LIFO order by the device. Note: The first status message is set by the system and describes the trigger of the deployment")
private final List<String> messages;

/**
* Parameterized constructor for creating {@link DdiActionHistory}.
*
* @param actionStatus
* is the current action status at the server
* @param messages
* is a list of messages retrieved from action history.
* @param actionStatus is the current action status at the server
* @param messages is a list of messages retrieved from action history.
*/
@JsonCreator
public DdiActionHistory(@JsonProperty("status") final String actionStatus,
public DdiActionHistory(
@JsonProperty("status") final String actionStatus,
@JsonProperty("messages") List<String> messages) {
this.actionStatus = actionStatus;
this.messages = messages;
}

@Override
public String toString() {
return "Action history [" + "status=" + actionStatus + ", messages={" + messages.toString() + "}]";
}
}
}
Expand Up @@ -13,44 +13,36 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiActivateAutoConfirmation {

@JsonProperty(required = false)
@Schema(example = "exampleUser")
@Schema(description = "Individual value (e.g. username) stored as initiator and automatically used as confirmed" +
" user in future actions", example = "exampleUser")
private final String initiator;

@JsonProperty(required = false)
@Schema(example = "exampleRemark")
@Schema(description = "Individual value to attach a remark which will be persisted when automatically " +
"confirming future actions", example = "exampleRemark")
private final String remark;

/**
* Constructor.
*
* @param initiator
* can be null
* @param remark
* can be null
* @param initiator can be null
* @param remark can be null
*/
@JsonCreator
public DdiActivateAutoConfirmation(@JsonProperty(value = "initiator") final String initiator,
@JsonProperty(value = "remark") final String remark) {
this.initiator = initiator;
this.remark = remark;
}

@Override
public String toString() {
return "DdiActivateAutoConfirmation [initiator=" + initiator + ", remark=" + remark + ", toString()="
+ super.toString() + "]";
}

public String getInitiator() {
return initiator;
}

public String getRemark() {
return remark;
}
}
}
Expand Up @@ -12,52 +12,61 @@
import jakarta.validation.constraints.NotNull;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.RepresentationModel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Download information for all artifacts related to a specific {@link DdiChunk}
* .
*/
@Data
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = """
**_links**:
* **download** - HTTPs Download resource for artifacts. The resource supports partial download as specified by RFC7233 (range requests). Keep in mind that the target needs to have the artifact assigned in order to be granted permission to download.
* **md5sum** - HTTPs Download resource for MD5SUM file is an optional auto generated artifact that is especially useful for Linux based devices on order to check artifact consistency after download by using the md5sum command line tool. The MD5 and SHA1 are in addition available as metadata in the deployment command itself.
* **download-http** - HTTP Download resource for artifacts. The resource supports partial download as specified by RFC7233 (range requests). Keep in mind that the target needs to have the artifact assigned in order to be granted permission to download. (note: anonymous download needs to be enabled on the service account for non-TLS access)
* **md5sum-http** - HTTP Download resource for MD5SUM file is an optional auto generated artifact that is especially useful for Linux based devices on order to check artifact consistency after download by using the md5sum command line tool. The MD5 and SHA1 are in addition available as metadata in the deployment command itself. (note: anonymous download needs to be enabled on the service account for non-TLS access)
""", example = """
{
"filename" : "binaryFile",
"hashes" : {
"sha1" : "e4e667b70ff652cb9d9c8a49f141bd68e06cec6f",
"md5" : "13793b0e3a7830ed685d3ede7ff93048",
"sha256" : "c51368bf045803b429a67bdf04539a373d9fb8caa310fe0431265e6871b4f07a"
},
"size" : 11,
"_links" : {
"download" : {
"href" : "https://link-to-cdn.com/api/v1/TENANT_ID/download/controller/CONTROLLER_ID/softwaremodules/40/filename/binaryFile"
},
"download-http" : {
"href" : "http://link-to-cdn.com/api/v1/TENANT_ID/download/controller/CONTROLLER_ID/softwaremodules/40/filename/binaryFile"
},
"md5sum-http" : {
"href" : "http://link-to-cdn.com/api/v1/TENANT_ID/download/controller/CONTROLLER_ID/softwaremodules/40/filename/binaryFile.MD5SUM"
},
"md5sum" : {
"href" : "https://link-to-cdn.com/api/v1/TENANT_ID/download/controller/CONTROLLER_ID/softwaremodules/40/filename/binaryFile.MD5SUM"
}
}
}""")
public class DdiArtifact extends RepresentationModel<DdiArtifact> {

@NotNull
@JsonProperty
@Schema(example = "binary.tgz")
@Schema(description = "File name", example = "binary.tgz")
private String filename;

@JsonProperty
@Schema(description = "Artifact hashes")
private DdiArtifactHash hashes;

@JsonProperty
@Schema(example = "3")
@Schema(description = "Artifact size", example = "3")
private Long size;

public DdiArtifactHash getHashes() {
return hashes;
}

public void setHashes(final DdiArtifactHash hashes) {
this.hashes = hashes;
}

public String getFilename() {
return filename;
}

public void setFilename(final String fileName) {
filename = fileName;
}

public Long getSize() {
return size;
}

public void setSize(final Long size) {
this.size = size;
}

}
}
Expand Up @@ -14,33 +14,34 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
* Hashes for given Artifact.
* Hashes for given Artifact
*/
@NoArgsConstructor // needed for json create
@Getter
@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiArtifactHash {

@JsonProperty
@Schema(example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05")
@Schema(description = "SHA1 hash of the artifact in Base 16 format", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05")
private String sha1;

@JsonProperty
@Schema(example = "0d1b08c34858921bc7c662b228acb7ba")
@Schema(description = "MD5 hash of the artifact", example = "0d1b08c34858921bc7c662b228acb7ba")
private String md5;

@JsonProperty
@JsonInclude(Include.NON_NULL)
@Schema(example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615")
@Schema(description = "SHA-256 hash of the artifact in Base 16 format", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615")
private String sha256;

/**
* Default constructor.
*/
public DdiArtifactHash() {
// needed for json create
}

/**
* Public constructor.
*
Expand All @@ -56,25 +57,4 @@ public DdiArtifactHash(final String sha1, final String md5, final String sha256)
this.md5 = md5;
this.sha256 = sha256;
}

/**
* @return the sha1
*/
public String getSha1() {
return sha1;
}

/**
* @return the md5
*/
public String getMd5() {
return md5;
}

/**
* @return the sha256
*/
public String getSha256() {
return sha256;
}
}
}

0 comments on commit fc561c3

Please sign in to comment.