Skip to content

Commit

Permalink
REST doc / Mgmt DS - fix missed info (#1621)
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 Mgmt API - DistributionSets

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Feb 8, 2024
1 parent 3808d86 commit ad02242
Show file tree
Hide file tree
Showing 13 changed files with 759 additions and 358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,29 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
* Request body for maintenance window PUT/POST commands, based on a schedule
* defined as cron expression, duration in HH:mm:ss format and time zone as
* offset from UTC.
*
*/
@Data
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtMaintenanceWindowRequestBody {

@JsonProperty
@Schema(example = "10 12 14 3 8 ? 2023")
@Schema(description = """
Schedule for the maintenance window start in quartz cron notation, such as '0 15 10 * * ? 2018'
for 10:15am every day during the year 2018""", example = "10 12 14 3 8 ? 2023")
private String schedule;

@JsonProperty
@Schema(example = "00:10:00")
@Schema(description = "Duration of the window, such as '02:00:00' for 2 hours", example = "00:10:00")
private String duration;

@JsonProperty
@Schema(example = "+00:00")
@Schema(description = "A time-zone offset from Greenwich/UTC, such as '+02:00'", example = "+00:00")
private String timezone;

public String getSchedule() {
return schedule;
}

/**
* @param schedule
* is the cron expression to be used for scheduling maintenance
* window(s). Expression has 6 mandatory fields and a last
* optional field: "second minute hour dayofmonth month weekday
* year".
*/
public void setSchedule(final String schedule) {
this.schedule = schedule;
}

public String getDuration() {
return duration;
}

/**
* @param duration
* in HH:mm:ss format specifying the duration of a maintenance
* window, for example 00:30:00 for 30 minutes.
*/
public void setDuration(final String duration) {
this.duration = duration;
}

public String getTimezone() {
return timezone;
}

/**
* @param timezone
* is the time zone specified as +/-hh:mm offset from UTC. For
* example +02:00 for CET summer time and +00:00 for UTC. The
* start time of a maintenance window calculated based on the
* cron expression is relative to this time zone.
*/
public void setTimezone(final String timezone) {
this.timezone = timezone;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,20 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
* The representation of an meta data in the REST API for POST/Create.
*
*/
@Data
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtMetadata {

@JsonProperty(required = true)
@Schema(example = "someKnownKey")
@Schema(description = "Metadata property key", example = "someKnownKey")
private String key;
@JsonProperty
@Schema(example = "someKnownKeyValue")
@Schema(description = "Metadata property value", example = "someKnownKeyValue")
private String value;

public String getKey() {
return key;
}

public void setKey(final String key) {
this.key = key;
}

public String getValue() {
return value;
}

public void setValue(final String value) {
this.value = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Objects;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
Expand All @@ -33,9 +34,19 @@
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = """
{
"id" : 13,
"_links" : {
"self" : {
"href" : "https://management-api.host.com/rest/v1/targets/target2/actions/13"
}
}
}""")
public class MgmtActionId extends RepresentationModel<MgmtActionId> {

@JsonProperty("id")
@Schema(description = "ID of the action")
private long actionId;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand All @@ -32,32 +31,75 @@
@EqualsAndHashCode(callSuper = true)
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(example = """
{
"createdBy" : "bumlux",
"createdAt" : 1682408575642,
"lastModifiedBy" : "bumlux",
"lastModifiedAt" : 1682408575643,
"name" : "DS",
"description" : "Updated Desc: 2LaONizh7WZp0on6XEOZI9AwEYIjj77YZskEmA2LVrKtAOXj9vvqACopEghLMqt6DIWpIahn6XM4jUlRZ1T5SZS2NWMuWHGoFIg1",
"version" : "1.0",
"modules" : [ {
"createdBy" : "bumlux",
"createdAt" : 1682408575640,
"lastModifiedBy" : "bumlux",
"lastModifiedAt" : 1682408575644,
"name" : "Firmware",
"description" : "Updated Desc: 2LaONizh7WZp0on6XEOZI9AwEYIjj77YZskEmA2LVrKtAOXj9vvqACopEghLMqt6DIWpIahn6XM4jUlRZ1T5SZS2NWMuWHGoFIg1",
"version" : "1.0.5",
"type" : "os",
"typeName" : "OS",
"vendor" : "vendor Limited Inc, California",
"deleted" : false,
"encrypted" : false,
"_links" : {
"self" : {
"href" : "https://management-api.host.com/rest/v1/softwaremodules/76"
}
},
"id" : 76
}""")
public class MgmtDistributionSet extends MgmtNamedEntity {

@JsonProperty(value = "id", required = true)
@Schema(example = "51")
@Schema(description = "The technical identifier of the entity", example = "51")
private Long dsId;

@JsonProperty
@Schema(example = "1.4.2")
@Schema(description = "Package version", example = "1.4.2")
private String version;

@JsonProperty
private List<MgmtSoftwareModule> modules = new ArrayList<>();
@JsonProperty
@Schema(example = "false")
@Schema(description = """
True if DS is a required migration step for another DS. As a result the DS’s assignment will not be cancelled
when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false")
private boolean requiredMigrationStep;

@JsonProperty
@Schema(example = "test_default_ds_type")
@Schema(description = "The type of the distribution set", example = "test_default_ds_type")
private String type;

@JsonProperty
@Schema(example = "OS (FW) mandatory, runtime (FW) and app (SW) optional")
@Schema(description = "The type name of the distribution set",
example = "OS (FW) mandatory, runtime (FW) and app (SW) optional")
private String typeName;

@JsonProperty
@Schema(example = "true")
@Schema(description = """
True of the distribution set software module setup is complete as defined by the
distribution set type""", example = "true")
private Boolean complete;

@JsonProperty
@Schema(example = "false")
@Schema(description = "Deleted flag, used for soft deleted entities", example = "false")
private boolean deleted;

@JsonProperty
@Schema(example = "true")
@Schema(description = "True by default and false after the distribution set is invalidated by the user",
example = "true")
private boolean valid;

@JsonProperty
private List<MgmtSoftwareModule> modules = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetReque
@JsonProperty
private List<MgmtSoftwareModuleAssigment> modules;
@JsonProperty
@Schema(example = "test_default_ds_type")
@Schema(description = "The type of the distribution set", example = "test_default_ds_type")
private String type;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
public class MgmtDistributionSetRequestBodyPut {

@JsonProperty
@Schema(example = "dsOne")
@Schema(description = "The name of the entity", example = "dsOne")
private String name;
@JsonProperty
@Schema(example = "Description of the distribution set.")
@Schema(description = "The description of the entity", example = "Description of the distribution set.")
private String description;
@JsonProperty
@Schema(example = "1.0.0")
@Schema(description = "Package version", example = "1.0.0")
private String version;
@JsonProperty
@Schema(example = "false")
@Schema(description = """
True if DS is a required migration step for another DS. As a result the DS’s assignment will not be cancelled
when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false")
private Boolean requiredMigrationStep;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public class MgmtInvalidateDistributionSetRequestBody {

@NotNull
@JsonProperty
@Schema(description = "Type of cancelation for actions referring to the given distribution set")
private MgmtCancelationType actionCancelationType;
@JsonProperty
@Schema(example = "true")
@Schema(description = "Defines if rollouts referring to this distribution set should be canceled", example = "true")
private boolean cancelRollouts;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindowRequestBody;
Expand All @@ -25,11 +26,18 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetAssignmentRequestBody {

@Schema(description = "The technical identifier of the entity", example = "target4")
private String id;
@Schema(description = "Forcetime in milliseconds", example = "1682408575278")
private long forcetime;
@Schema(description = "The type of the assignment")
private MgmtActionType type;
@Schema(description = "Separation of download and install by defining a maintenance window for the installation")
private MgmtMaintenanceWindowRequestBody maintenanceWindow;
@Schema(description = "Importance of the assignment. Allowed values: 0 - 1000", example = "100")
private Integer weight;
@Schema(description = "(Available with user consent flow active) Defines, if the confirmation is required for " +
"an action. Confirmation is required per default")
private Boolean confirmationRequired;

/**
Expand All @@ -41,4 +49,4 @@ public class MgmtTargetAssignmentRequestBody {
public MgmtTargetAssignmentRequestBody(@JsonProperty(required = true, value = "id") final String id) {
this.id = id;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.hateoas.RepresentationModel;
Expand All @@ -29,7 +30,11 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetAssignmentResponseBody extends RepresentationModel<MgmtTargetAssignmentResponseBody> {

@Schema(description = """
Targets that had this distribution set already assigned (in "offline" case this includes
targets that have arbitrary updates running)""")
private int alreadyAssigned;
@Schema(description = "The newly created actions as a result of this assignment")
private List<MgmtActionId> assignedActions;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import lombok.EqualsAndHashCode;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand All @@ -30,23 +29,23 @@
public class MgmtSoftwareModule extends MgmtNamedEntity {

@JsonProperty(value = "id", required = true)
@Schema(example = "6")
@Schema(description = "The technical identifier of the entity", example = "6")
private Long moduleId;
@JsonProperty(required = true)
@Schema(example = "1.0.0")
@Schema(description = "Package version", example = "1.0.0")
private String version;
@JsonProperty(required = true)
@Schema(example = "os")
@Schema(description = "The software module type of the entity", example = "os")
private String type;
@Schema(example = "OS")
@Schema(description = "The software module type name of the entity", example = "OS")
private String typeName;
@JsonProperty
@Schema(example = "Vendor Limited, California")
@Schema(description = "The software vendor", example = "Vendor Limited, California")
private String vendor;
@JsonProperty
@Schema(example = "false")
@Schema(description = "If the software module is deleted", example = "false")
private boolean deleted;
@JsonProperty
@Schema(example = "false")
@Schema(description = "If the software module is encrypted", example = "false")
private boolean encrypted;
}
Loading

0 comments on commit ad02242

Please sign in to comment.