Rename and split rest resources ddi, mgmt and system

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-20 17:33:03 +02:00
parent 8a22ea3df3
commit c3c405c986
169 changed files with 3081 additions and 1871 deletions

View File

@@ -0,0 +1,58 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* The representation of an meta data in the REST API.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MetadataRest {
@JsonProperty(required = true)
private String key;
@JsonProperty
private String value;
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*/
public void setKey(final String key) {
this.key = key;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value
* the value to set
*/
public void setValue(final String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,97 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import org.springframework.hateoas.ResourceSupport;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for BaseEntity to RESTful API representation.
*
*/
public abstract class MgmtBaseEntity extends ResourceSupport {
@JsonProperty
private String createdBy;
@JsonProperty
private Long createdAt;
@JsonProperty
private String lastModifiedBy;
@JsonProperty
private Long lastModifiedAt;
/**
* @return the createdBy
*/
public String getCreatedBy() {
return createdBy;
}
/**
* @param createdBy
* the createdBy to set
*/
@JsonIgnore
public void setCreatedBy(final String createdBy) {
this.createdBy = createdBy;
}
/**
* @return the createdAt
*/
public Long getCreatedAt() {
return createdAt;
}
/**
* @param createdAt
* the createdAt to set
*/
@JsonIgnore
public void setCreatedAt(final Long createdAt) {
this.createdAt = createdAt;
}
/**
* @return the lastModifiedBy
*/
public String getLastModifiedBy() {
return lastModifiedBy;
}
/**
* @param lastModifiedBy
* the lastModifiedBy to set
*/
@JsonIgnore
public void setLastModifiedBy(final String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
/**
* @return the lastModifiedAt
*/
public Long getLastModifiedAt() {
return lastModifiedAt;
}
/**
* @param lastModifiedAt
* the lastModifiedAt to set
*/
@JsonIgnore
public void setLastModifiedAt(final Long lastModifiedAt) {
this.lastModifiedAt = lastModifiedAt;
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A generic abstract rest model which contains only a ID for use-case e.g.
* which allows only posting or putting an ID into the request body, e.g. for
* assignments.
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtId {
@JsonProperty
private Long id;
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(final Long id) {
this.id = id;
}
}

View File

@@ -0,0 +1,55 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for NamedEntity to RESTful API representation.
*
*/
public abstract class MgmtNamedEntity extends MgmtBaseEntity {
@JsonProperty(required = true)
private String name;
@JsonProperty
private String description;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(final String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*/
public void setDescription(final String description) {
this.description = description;
}
}

View File

@@ -0,0 +1,80 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for PollStatus to RESTful API representation.
*
*
*
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtPollStatus {
@JsonProperty
private Long lastRequestAt;
@JsonProperty
private Long nextExpectedRequestAt;
@JsonProperty
private boolean overdue;
/**
* @return the lastRequestAt
*/
public Long getLastRequestAt() {
return lastRequestAt;
}
/**
* @param lastRequestAt
* the lastRequestAt to set
*/
public void setLastRequestAt(final Long lastRequestAt) {
this.lastRequestAt = lastRequestAt;
}
/**
* @return the nextExpectedRequestAt
*/
public Long getNextExpectedRequestAt() {
return nextExpectedRequestAt;
}
/**
* @param nextExpectedRequestAt
* the nextExpectedRequestAt to set
*/
public void setNextExpectedRequestAt(final Long nextExpectedRequestAt) {
this.nextExpectedRequestAt = nextExpectedRequestAt;
}
/**
* @return the overdue
*/
public boolean isOverdue() {
return overdue;
}
/**
* @param overdue
* the overdue to set
*/
public void setOverdue(final boolean overdue) {
this.overdue = overdue;
}
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.ResourceSupport;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A list representation with meta data for pagination, e.g. containing the
* total elements and size of content. The content of the actual list is stored
* in the {@link #content} field.
*
* @param <T>
* the type of elements in this list
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_NULL)
public class PagedList<T> extends ResourceSupport {
@JsonProperty
private final List<T> content;
@JsonProperty
private final long total;
private final int size;
/**
* creates a new paged list with the given {@code content} and {@code total}
* .
*
* @param content
* the actual content of the list
* @param total
* the total amount of elements
* @throws NullPointerException
* in case {@code content} is {@code null}.
*/
@JsonCreator
public PagedList(@JsonProperty("content") @NotNull final List<T> content, @JsonProperty("total") final long total) {
this.size = content.size();
this.total = total;
this.content = content;
}
/**
* @return the size of the content list
*/
public int getSize() {
return size;
}
/**
* @return the total amount of elements
*/
public long getTotal() {
return total;
}
public List<T> getContent() {
return content;
}
}

View File

@@ -0,0 +1,94 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.action;
import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for Action to RESTful API representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtAction extends MgmtBaseEntity {
/**
* API definition for {@link UpdateAction}.
*/
public static final String ACTION_UPDATE = "update";
/**
* API definition for {@link CancelAction}.
*/
public static final String ACTION_CANCEL = "cancel";
public static final String ACTION_FINISHED = "finished";
public static final String ACTION_PENDING = "pending";
@JsonProperty("id")
private Long actionId;
@JsonProperty
private String type;
@JsonProperty
private String status;
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final String status) {
this.status = status;
}
/**
* @return the actionId
*/
public Long getActionId() {
return actionId;
}
/**
* @param actionId
* the actionId to set
*/
public void setActionId(final Long actionId) {
this.actionId = actionId;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,132 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.action;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for ActionStatus to RESTful API representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtActionStatus {
/**
* Action is finished successfully for this target.
*/
public static final String AS_FINISHED = "finished";
/**
* Action has failed for this target.
*/
public static final String AS_ERROR = "error";
/**
* Action is still running but with warnings.
*/
public static final String AS_WARNING = "warning";
/**
* Action is still running for this target.
*/
public static final String AS_RUNNING = "running";
/**
* Action has been canceled for this target.
*/
public static final String AS_CANCELED = "canceled";
/**
* Action has been presented to the target.
*/
public static final String AS_RETRIEVED = "retrieved";
/**
* Action has been canceled for this target.
*/
public static final String AS_CANCELING = "canceling";
@JsonProperty("id")
private Long statusId;
@JsonProperty
private String type;
@JsonProperty
private List<String> messages;
@JsonProperty
private Long reportedAt;
/**
* @return the statusId
*/
public Long getStatusId() {
return statusId;
}
/**
* @param statusId
* the statusId to set
*/
public void setStatusId(final Long statusId) {
this.statusId = statusId;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final String type) {
this.type = type;
}
/**
* @return the messages
*/
public List<String> getMessages() {
return messages;
}
/**
* @param messages
* the messages to set
*/
public void setMessages(final List<String> messages) {
this.messages = messages;
}
/**
* @return the reportedAt
*/
public Long getReportedAt() {
return reportedAt;
}
/**
* @param reportedAt
* the reportedAt to set
*/
public void setReportedAt(final Long reportedAt) {
this.reportedAt = reportedAt;
}
}

View File

@@ -0,0 +1,146 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.artifact;
import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
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;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* A json annotated rest model for Artifact to RESTful API representation.
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtArtifact extends MgmtBaseEntity {
@JsonProperty(required = true)
private ArtifactType type;
@JsonProperty("id")
private Long artifactId;
@JsonProperty
private MgmtArtifactHash hashes;
@JsonProperty
private String providedFilename;
@JsonProperty
private Long size;
/**
* @param type
* the type to set
*/
public void setType(final ArtifactType type) {
this.type = type;
}
/**
* @param hashes
* the hashes to set
*/
@JsonIgnore
public void setHashes(final MgmtArtifactHash hashes) {
this.hashes = hashes;
}
/**
* @param artifactId
* the artifactId to set
*/
@JsonIgnore
public void setArtifactId(final Long artifactId) {
this.artifactId = artifactId;
}
/**
* @return the type
*/
public ArtifactType getType() {
return type;
}
/**
* @return the artifactId
*/
public Long getArtifactId() {
return artifactId;
}
/**
* @return the hashes
*/
public MgmtArtifactHash getHashes() {
return hashes;
}
/**
* @return the providedFilename
*/
public String getProvidedFilename() {
return providedFilename;
}
/**
* @param providedFilename
* the providedFilename to set
*/
@JsonIgnore
public void setProvidedFilename(final String providedFilename) {
this.providedFilename = providedFilename;
}
/**
* Type maps to either {@link LocalArtifact} or {@link ExternalArtifact}.
*
*
*
*
*/
public enum ArtifactType {
LOCAL("local"), EXTERNAL("external");
private final String name;
private ArtifactType(final String name) {
this.name = name;
}
/**
* @return the name
*/
@JsonValue
public String getName() {
return name;
}
}
/**
* @return the size
*/
public Long getSize() {
return size;
}
/**
* @param size
* the size to set
*/
@JsonIgnore
public void setSize(final Long size) {
this.size = size;
}
}

View File

@@ -0,0 +1,58 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.artifact;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Hashes for given Artifact.
*
*
*/
public class MgmtArtifactHash {
@JsonProperty
private String sha1;
@JsonProperty
private String md5;
/**
* Default constructor.
*/
public MgmtArtifactHash() {
}
/**
* Public constructor.
*
* @param sha1
* @param md5
*/
public MgmtArtifactHash(final String sha1, final String md5) {
super();
this.sha1 = sha1;
this.md5 = md5;
}
/**
* @return the sha1
*/
public String getSha1() {
return sha1;
}
/**
* @return the md5
*/
public String getMd5() {
return md5;
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* Definition of the {@link ActionType} for the REST management API.
*
*
*
*
*/
public enum MgmtActionType {
/**
* The soft action type.
*/
SOFT("soft"),
/**
* The forced action type.
*/
FORCED("forced"),
/**
* The time forced action type.
*/
TIMEFORCED("timeforced");
private final String name;
private MgmtActionType(final String name) {
this.name = name;
}
/**
* @return the name
*/
@JsonValue
public String getName() {
return name;
}
}

View File

@@ -0,0 +1,144 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import java.util.ArrayList;
import java.util.List;
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;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for DistributionSet to RESTful API
* representation.
*
*
*
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSet extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true)
private Long dsId;
@JsonProperty
private String version;
@JsonProperty
private List<MgmtSoftwareModule> modules = new ArrayList<>();
@JsonProperty
private boolean requiredMigrationStep;
@JsonProperty
private String type;
@JsonProperty
private Boolean complete;
/**
* @return the id
*/
public Long getDsId() {
return dsId;
}
/**
* @param id
* the id to set
*/
@JsonIgnore
public void setDsId(final Long id) {
dsId = id;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version
* the version to set
*/
public void setVersion(final String version) {
this.version = version;
}
/**
* @return the requiredMigrationStep
*/
public boolean isRequiredMigrationStep() {
return requiredMigrationStep;
}
/**
* @param requiredMigrationStep
* the requiredMigrationStep to set
*/
public void setRequiredMigrationStep(final boolean requiredMigrationStep) {
this.requiredMigrationStep = requiredMigrationStep;
}
/**
* @return the modules
*/
public List<MgmtSoftwareModule> getModules() {
return modules;
}
/**
* @param modules
* the modules to set
*/
public void setModules(final List<MgmtSoftwareModule> modules) {
this.modules = modules;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final String type) {
this.type = type;
}
/**
* @return the complete
*/
public Boolean getComplete() {
return complete;
}
/**
* @param complete
* the complete to set
*/
public void setComplete(final Boolean complete) {
this.complete = complete;
}
}

View File

@@ -0,0 +1,162 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for DistributionSet for POST.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut {
// deprecated format from the time where os, application and runtime where
// statically defined
@JsonProperty
private MgmtSoftwareModuleAssigment os;
@JsonProperty
private MgmtSoftwareModuleAssigment runtime;
@JsonProperty
private MgmtSoftwareModuleAssigment application;
// deprecated format - END
@JsonProperty
private List<MgmtSoftwareModuleAssigment> modules;
@JsonProperty
private boolean requiredMigrationStep;
@JsonProperty
private String type;
/**
* @return the os
*/
public MgmtSoftwareModuleAssigment getOs() {
return os;
}
/**
* @param os
* the os to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setOs(final MgmtSoftwareModuleAssigment os) {
this.os = os;
return this;
}
/**
* @return the runtime
*/
public MgmtSoftwareModuleAssigment getRuntime() {
return runtime;
}
/**
* @param runtime
* the runtime to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setRuntime(final MgmtSoftwareModuleAssigment runtime) {
this.runtime = runtime;
return this;
}
/**
* @return the application
*/
public MgmtSoftwareModuleAssigment getApplication() {
return application;
}
/**
* @param application
* the application to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setApplication(final MgmtSoftwareModuleAssigment application) {
this.application = application;
return this;
}
/**
* @return the requiredMigrationStep
*/
public boolean isRequiredMigrationStep() {
return requiredMigrationStep;
}
/**
* @param requiredMigrationStep
* the requiredMigrationStep to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setRequiredMigrationStep(final boolean requiredMigrationStep) {
this.requiredMigrationStep = requiredMigrationStep;
return this;
}
/**
* @return the modules
*/
public List<MgmtSoftwareModuleAssigment> getModules() {
return modules;
}
/**
* @param modules
* the modules to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setModules(final List<MgmtSoftwareModuleAssigment> modules) {
this.modules = modules;
return this;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPost setType(final String type) {
this.type = type;
return this;
}
}

View File

@@ -0,0 +1,88 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for DistributionSet for PUT/POST.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetRequestBodyPut {
@JsonProperty
private String name;
@JsonProperty
private String description;
@JsonProperty
private String version;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPut setName(final String name) {
this.name = name;
return this;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPut setDescription(final String description) {
this.description = description;
return this;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version
* the version to set
*
* @return updated body
*/
public MgmtDistributionSetRequestBodyPut setVersion(final String version) {
this.version = version;
return this;
}
}

View File

@@ -0,0 +1,73 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body of Target for assignment operations (ID only).
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetAssignmentRequestBody {
@JsonProperty
private String id;
private long forcetime;
private MgmtActionType type;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(final String id) {
this.id = id;
}
/**
* @return the type
*/
public MgmtActionType getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final MgmtActionType type) {
this.type = type;
}
/**
* @return the forcetime
*/
public long getForcetime() {
return forcetime;
}
/**
* @param forcetime
* the forcetime to set
*/
public void setForcetime(final long forcetime) {
this.forcetime = forcetime;
}
}

View File

@@ -0,0 +1,73 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Response Body of Target for assignment operations.
*
*
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetAssignmentResponseBody {
private int assigned;
private int alreadyAssigned;
private int total;
/**
* @return the assigned
*/
public int getAssigned() {
return assigned;
}
/**
* @param assigned
* the assigned to set
*/
public void setAssigned(final int assigned) {
this.assigned = assigned;
}
/**
* @return the alreadyAssigned
*/
public int getAlreadyAssigned() {
return alreadyAssigned;
}
/**
* @param alreadyAssigned
* the alreadyAssigned to set
*/
public void setAlreadyAssigned(final int alreadyAssigned) {
this.alreadyAssigned = alreadyAssigned;
}
/**
* @return the total
*/
public int getTotal() {
return total;
}
/**
* @param total
* the total to set
*/
public void setTotal(final int total) {
this.total = total;
}
}

View File

@@ -0,0 +1,130 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionsettype;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for DistributionSetType POST.
*
*/
public class MgmtDistributionSetTypeRequestBodyPost {
@JsonProperty(required = true)
private String name;
@JsonProperty
private String description;
@JsonProperty
private String key;
@JsonProperty
private List<MgmtSoftwareModuleTypeAssigment> mandatorymodules;
@JsonProperty
private List<MgmtSoftwareModuleTypeAssigment> optionalmodules;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPost setName(final String name) {
this.name = name;
return this;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPost setDescription(final String description) {
this.description = description;
return this;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPost setKey(final String key) {
this.key = key;
return this;
}
/**
* @return the mandatory modules
*/
public List<MgmtSoftwareModuleTypeAssigment> getMandatorymodules() {
return mandatorymodules;
}
/**
* @param mandatorymodules
* the mandatory modules to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPost setMandatorymodules(
final List<MgmtSoftwareModuleTypeAssigment> mandatorymodules) {
this.mandatorymodules = mandatorymodules;
return this;
}
/**
* @return the optional modules
*/
public List<MgmtSoftwareModuleTypeAssigment> getOptionalmodules() {
return optionalmodules;
}
/**
* @param optionalmodules
* the optional modules to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPost setOptionalmodules(
final List<MgmtSoftwareModuleTypeAssigment> optionalmodules) {
this.optionalmodules = optionalmodules;
return this;
}
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionsettype;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for DistributionSetType PUT, i.e. update.
*
*/
public class MgmtDistributionSetTypeRequestBodyPut {
@JsonProperty
private String description;
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtDistributionSetTypeRequestBodyPut setDescription(final String description) {
this.description = description;
return this;
}
}

View File

@@ -0,0 +1,66 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionsettype;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for SoftwareModuleType to RESTful API
* representation.
*
*
*
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetTypeRest extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true)
private Long moduleId;
@JsonProperty
private String key;
/**
* @return the moduleId
*/
public Long getModuleId() {
return moduleId;
}
/**
* @param moduleId
* the moduleId to set
*/
public void setModuleId(final Long moduleId) {
this.moduleId = moduleId;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*/
public void setKey(final String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,70 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rollout;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutCondition {
private Condition condition = Condition.THRESHOLD;
private String expression = "100";
/**
*
*/
public MgmtRolloutCondition() {
// needed for jackson json creator.
}
public MgmtRolloutCondition(final Condition condition, final String expression) {
this.condition = condition;
this.expression = expression;
}
/**
* @return the condition
*/
public Condition getCondition() {
return condition;
}
/**
* @param condition
* the condition to set
*/
public void setCondition(final Condition condition) {
this.condition = condition;
}
/**
* @return the expession
*/
public String getExpression() {
return expression;
}
/**
* @param expession
* the expession to set
*/
public void setExpression(final String expession) {
this.expression = expession;
}
public enum Condition {
THRESHOLD;
}
}

View File

@@ -0,0 +1,58 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rollout;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutErrorAction {
private ErrorAction action = ErrorAction.PAUSE;
private String expression = null;
/**
* @return the action
*/
public ErrorAction getAction() {
return action;
}
/**
* @param action
* the action to set
*/
public void setAction(final ErrorAction action) {
this.action = action;
}
/**
* @return the expression
*/
public String getExpression() {
return expression;
}
/**
* @param expression
* the expression to set
*/
public void setExpression(final String expression) {
this.expression = expression;
}
public enum ErrorAction {
PAUSE;
}
}

View File

@@ -0,0 +1,124 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rollout;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutResponseBody extends MgmtNamedEntity {
private String targetFilterQuery;
private Long distributionSetId;
@JsonProperty(value = "id", required = true)
private Long rolloutId;
@JsonProperty(required = true)
private String status;
@JsonProperty(required = true)
private Long totalTargets;
@JsonProperty(required = true)
private final Map<String, Long> totalTargetsPerStatus = new HashMap<>();
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final String status) {
this.status = status;
}
/**
* @return the rolloutId
*/
public Long getRolloutId() {
return rolloutId;
}
/**
* @param rolloutId
* the rolloutId to set
*/
public void setRolloutId(final Long rolloutId) {
this.rolloutId = rolloutId;
}
/**
* @return the targetFilterQuery
*/
public String getTargetFilterQuery() {
return targetFilterQuery;
}
/**
* @param targetFilterQuery
* the targetFilterQuery to set
*/
public void setTargetFilterQuery(final String targetFilterQuery) {
this.targetFilterQuery = targetFilterQuery;
}
/**
* @return the distributionSetId
*/
public Long getDistributionSetId() {
return distributionSetId;
}
/**
* @param distributionSetId
* the distributionSetId to set
*/
public void setDistributionSetId(final Long distributionSetId) {
this.distributionSetId = distributionSetId;
}
/**
* @param totalTargets
* the totalTargets to set
*/
public void setTotalTargets(final Long totalTargets) {
this.totalTargets = totalTargets;
}
/**
* @return the totalTargets
*/
public Long getTotalTargets() {
return totalTargets;
}
/**
* @return the totalTargetsPerStatus
*/
public Map<String, Long> getTotalTargetsPerStatus() {
return totalTargetsPerStatus;
}
}

View File

@@ -0,0 +1,175 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rollout;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Model for request containing a rollout body e.g. in a POST request of
* creating a rollout via REST API.
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutRestRequestBody extends MgmtNamedEntity {
private String targetFilterQuery;
private long distributionSetId;
private int amountGroups = 1;
private MgmtRolloutCondition successCondition = new MgmtRolloutCondition();
private MgmtRolloutSuccessAction successAction = new MgmtRolloutSuccessAction();
private MgmtRolloutCondition errorCondition = null;
private MgmtRolloutErrorAction errorAction = null;
private Long forcetime;
private MgmtActionType type;
/**
* @return the finishCondition
*/
public MgmtRolloutCondition getSuccessCondition() {
return successCondition;
}
/**
* @param successCondition
* the finishCondition to set
*/
public void setSuccessCondition(final MgmtRolloutCondition successCondition) {
this.successCondition = successCondition;
}
/**
* @return the successAction
*/
public MgmtRolloutSuccessAction getSuccessAction() {
return successAction;
}
/**
* @param successAction
* the successAction to set
*/
public void setSuccessAction(final MgmtRolloutSuccessAction successAction) {
this.successAction = successAction;
}
/**
* @return the errorCondition
*/
public MgmtRolloutCondition getErrorCondition() {
return errorCondition;
}
/**
* @param errorCondition
* the errorCondition to set
*/
public void setErrorCondition(final MgmtRolloutCondition errorCondition) {
this.errorCondition = errorCondition;
}
/**
* @return the targetFilterQuery
*/
public String getTargetFilterQuery() {
return targetFilterQuery;
}
/**
* @param targetFilterQuery
* the targetFilterQuery to set
*/
public void setTargetFilterQuery(final String targetFilterQuery) {
this.targetFilterQuery = targetFilterQuery;
}
/**
* @return the distributionSetId
*/
public long getDistributionSetId() {
return distributionSetId;
}
/**
* @param distributionSetId
* the distributionSetId to set
*/
public void setDistributionSetId(final long distributionSetId) {
this.distributionSetId = distributionSetId;
}
/**
* @return the groupSize
*/
public int getAmountGroups() {
return amountGroups;
}
/**
* @param groupSize
* the groupSize to set
*/
public void setAmountGroups(final int groupSize) {
this.amountGroups = groupSize;
}
/**
* @return the forcetime
*/
public Long getForcetime() {
return forcetime;
}
/**
* @param forcetime
* the forcetime to set
*/
public void setForcetime(final Long forcetime) {
this.forcetime = forcetime;
}
/**
* @return the type
*/
public MgmtActionType getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final MgmtActionType type) {
this.type = type;
}
/**
* @return the errorAction
*/
public MgmtRolloutErrorAction getErrorAction() {
return errorAction;
}
/**
* @param errorAction
* the errorAction to set
*/
public void setErrorAction(final MgmtRolloutErrorAction errorAction) {
this.errorAction = errorAction;
}
}

View File

@@ -0,0 +1,70 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rollout;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutSuccessAction {
private SuccessAction action = SuccessAction.NEXTGROUP;
private String expression = null;
/**
*
*/
public MgmtRolloutSuccessAction() {
// needed for json creator
}
public MgmtRolloutSuccessAction(final SuccessAction action, final String expression) {
this.action = action;
this.expression = expression;
}
/**
* @return the action
*/
public SuccessAction getAction() {
return action;
}
/**
* @param action
* the action to set
*/
public void setAction(final SuccessAction action) {
this.action = action;
}
/**
* @return the expession
*/
public String getExpression() {
return expression;
}
/**
* @param expession
* the expession to set
*/
public void setExpression(final String expession) {
this.expression = expession;
}
public enum SuccessAction {
NEXTGROUP;
}
}

View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.rolloutgroup;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Model for the rollout group annotated with json-annotations for easier
* serialization and de-serialization.
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtRolloutGroupResponseBody extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true)
private Long rolloutGroupId;
@JsonProperty(required = true)
private String status;
/**
* @return the rolloutGroupId
*/
public Long getRolloutGroupId() {
return rolloutGroupId;
}
/**
* @param rolloutGroupId
* the rolloutGroupId to set
*/
public void setRolloutGroupId(final Long rolloutGroupId) {
this.rolloutGroupId = rolloutGroupId;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final String status) {
this.status = status;
}
}

View File

@@ -0,0 +1,112 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
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;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for SoftwareModule to RESTful API representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModule extends MgmtNamedEntity {
/**
* API definition for {@link SoftwareModule.Type#RUNTIME}.
*/
public static final String SM_RUNTIME = "runtime";
/**
* API definition for {@link SoftwareModule.Type#OS}.
*/
public static final String SM_OS = "os";
/**
* API definition for {@link SoftwareModule.Type#APPLICATION}.
*/
public static final String SM_APPLICATION = "application";
@JsonProperty(value = "id", required = true)
private Long moduleId;
@JsonProperty(required = true)
private String version;
@JsonProperty(required = true)
private String type;
@JsonProperty
private String vendor;
/**
* @return the moduleId
*/
public Long getModuleId() {
return moduleId;
}
/**
* @param moduleId
* the moduleId to set
*/
@JsonIgnore
public void setModuleId(final Long moduleId) {
this.moduleId = moduleId;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version
* the version to set
*/
public void setVersion(final String version) {
this.version = version;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final String type) {
this.type = type;
}
/**
* @return the vendor
*/
public String getVendor() {
return vendor;
}
/**
* @param vendor
* the vendor to set
*/
public void setVendor(final String vendor) {
this.vendor = vendor;
}
}

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* Request Body of SoftwareModule for assignment operations (ID only).
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModuleAssigment extends MgmtId {
}

View File

@@ -0,0 +1,124 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for SoftwareModule POST.
*
*/
public class MgmtSoftwareModuleRequestBodyPost {
@JsonProperty(required = true)
private String name;
@JsonProperty(required = true)
private String version;
@JsonProperty(required = true)
private String type;
@JsonProperty
private String description;
@JsonProperty
private String vendor;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPost setName(final String name) {
this.name = name;
return this;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version
* the version to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPost setVersion(final String version) {
this.version = version;
return this;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPost setType(final String type) {
this.type = type;
return this;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPost setDescription(final String description) {
this.description = description;
return this;
}
/**
* @return the vendor
*/
public String getVendor() {
return vendor;
}
/**
* @param vendor
* the vendor to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPost setVendor(final String vendor) {
this.vendor = vendor;
return this;
}
}

View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for SoftwareModule PUT.
*
*/
public class MgmtSoftwareModuleRequestBodyPut {
@JsonProperty
private String description;
@JsonProperty
private String vendor;
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPut setDescription(final String description) {
this.description = description;
return this;
}
/**
* @return the vendor
*/
public String getVendor() {
return vendor;
}
/**
* @param vendor
* the vendor to set
*
* @return updated body
*/
public MgmtSoftwareModuleRequestBodyPut setVendor(final String vendor) {
this.vendor = vendor;
return this;
}
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for SoftwareModuleType to RESTful API
* representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModuleType extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true)
private Long moduleId;
@JsonProperty
private String key;
@JsonProperty
private int maxAssignments;
/**
* @return the moduleId
*/
public Long getModuleId() {
return moduleId;
}
/**
* @param moduleId
* the moduleId to set
*/
public void setModuleId(final Long moduleId) {
this.moduleId = moduleId;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*/
public void setKey(final String key) {
this.key = key;
}
/**
* @return the maxAssignments
*/
public int getMaxAssignments() {
return maxAssignments;
}
/**
* @param maxAssignments
* the maxAssignments to set
*/
public void setMaxAssignments(final int maxAssignments) {
this.maxAssignments = maxAssignments;
}
}

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* Request Body of SoftwareModuleType for assignment operations (ID only).
*
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModuleTypeAssigment extends MgmtId {
}

View File

@@ -0,0 +1,102 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for SoftwareModuleType POST.
*
*/
public class MgmtSoftwareModuleTypeRequestBodyPost {
@JsonProperty(required = true)
private String name;
@JsonProperty
private String description;
@JsonProperty
private String key;
@JsonProperty
private int maxAssignments;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*
* @return updated body
*/
public MgmtSoftwareModuleTypeRequestBodyPost setName(final String name) {
this.name = name;
return this;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtSoftwareModuleTypeRequestBodyPost setDescription(final String description) {
this.description = description;
return this;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
* @return updated body
*/
public MgmtSoftwareModuleTypeRequestBodyPost setKey(final String key) {
this.key = key;
return this;
}
/**
* @return the maxAssignments
*/
public int getMaxAssignments() {
return maxAssignments;
}
/**
* @param maxAssignments
* the maxAssignments to set
*
* @return updated body
*/
public MgmtSoftwareModuleTypeRequestBodyPost setMaxAssignments(final int maxAssignments) {
this.maxAssignments = maxAssignments;
return this;
}
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for SoftwareModuleType PUT.
*
*/
public class MgmtSoftwareModuleTypeRequestBodyPut {
@JsonProperty
private String description;
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*
* @return updated body
*/
public MgmtSoftwareModuleTypeRequestBodyPut setDescription(final String description) {
this.description = description;
return this;
}
}

View File

@@ -0,0 +1,36 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for PUT.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtAssignedDistributionSetRequestBody {
@JsonProperty(value = "id", required = true)
private Long distributionSetId;
public Long getDistributionSetId() {
return distributionSetId;
}
public MgmtAssignedDistributionSetRequestBody setDistributionSetId(final Long distributionSetId) {
this.distributionSetId = distributionSetId;
return this;
}
}

View File

@@ -0,0 +1,36 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for PUT.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtAssignedTargetRequestBody {
@JsonProperty(required = true)
private String controllerId;
public String getControllerId() {
return controllerId;
}
public MgmtAssignedTargetRequestBody setControllerId(final String controllerId) {
this.controllerId = controllerId;
return this;
}
}

View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* * A json annotated rest model for DSAssigmentResult to RESTful API
* representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetTagAssigmentResult {
@JsonProperty
private List<MgmtDistributionSet> assignedDistributionSets;
@JsonProperty
private List<MgmtDistributionSet> unassignedDistributionSets;
public List<MgmtDistributionSet> getAssignedDistributionSets() {
return assignedDistributionSets;
}
public List<MgmtDistributionSet> getUnassignedDistributionSets() {
return unassignedDistributionSets;
}
public void setAssignedDistributionSets(final List<MgmtDistributionSet> assignedDistributionSets) {
this.assignedDistributionSets = assignedDistributionSets;
}
public void setUnassignedDistributionSets(final List<MgmtDistributionSet> unassignedDistributionSets) {
this.unassignedDistributionSets = unassignedDistributionSets;
}
}

View File

@@ -0,0 +1,49 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
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;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for Tag to RESTful API representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTag extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true)
private Long tagId;
@JsonProperty
private String colour;
@JsonIgnore
public void setTagId(final Long tagId) {
this.tagId = tagId;
}
public Long getTagId() {
return tagId;
}
public void setColour(final String colour) {
this.colour = colour;
}
public String getColour() {
return colour;
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request Body for PUT/POST.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTagRequestBodyPut {
@JsonProperty
private String colour;
@JsonProperty
private String name;
@JsonProperty
private String description;
public String getName() {
return name;
}
public MgmtTagRequestBodyPut setName(final String name) {
this.name = name;
return this;
}
public String getDescription() {
return description;
}
public MgmtTagRequestBodyPut setDescription(final String description) {
this.description = description;
return this;
}
public MgmtTagRequestBodyPut setColour(final String colour) {
this.colour = colour;
return this;
}
public String getColour() {
return colour;
}
}

View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model.tag;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* * A json annotated rest model for TargetTagAssigmentResult to RESTful API
* representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetTagAssigmentResult {
@JsonProperty
private List<MgmtTarget> assignedTargets;
@JsonProperty
private List<MgmtTarget> unassignedTargets;
public void setAssignedTargets(final List<MgmtTarget> assignedTargets) {
this.assignedTargets = assignedTargets;
}
public List<MgmtTarget> getAssignedTargets() {
return assignedTargets;
}
public void setUnassignedTargets(final List<MgmtTarget> unassignedTargets) {
this.unassignedTargets = unassignedTargets;
}
public List<MgmtTarget> getUnassignedTargets() {
return unassignedTargets;
}
}

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved.
*/
package org.eclipse.hawkbit.mgmt.json.model.target;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
/**
* Request Body of DistributionSet for assignment operations (ID only).
*
*/
public class MgmtDistributionSetAssigment extends MgmtId {
private long forcetime;
private MgmtActionType type;
/**
* @return the type
*/
public MgmtActionType getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(final MgmtActionType type) {
this.type = type;
}
/**
* @return the forcetime
*/
public long getForcetime() {
return forcetime;
}
/**
* @param forcetime
* the forcetime to set
*/
public void setForcetime(final long forcetime) {
this.forcetime = forcetime;
}
}

View File

@@ -0,0 +1,170 @@
/**
* Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved.
*/
package org.eclipse.hawkbit.mgmt.json.model.target;
import java.net.URI;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus;
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;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for Target to RESTful API representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTarget extends MgmtNamedEntity {
@JsonProperty(required = true)
private String controllerId;
@JsonProperty
private String updateStatus;
@JsonProperty
private Long lastControllerRequestAt;
@JsonProperty
private Long installedAt;
@JsonProperty
private String ipAddress;
@JsonProperty
private String address;
@JsonProperty
private MgmtPollStatus pollStatus;
@JsonProperty
private String securityToken;
/**
* @return the controllerId
*/
public String getControllerId() {
return controllerId;
}
/**
* @param controllerId
* the controllerId to set
*/
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
/**
* @return the updateStatus
*/
public String getUpdateStatus() {
return updateStatus;
}
/**
* @param updateStatus
* the updateStatus to set
*/
public void setUpdateStatus(final String updateStatus) {
this.updateStatus = updateStatus;
}
/**
* @return the lastControllerRequestAt
*/
public Long getLastControllerRequestAt() {
return lastControllerRequestAt;
}
/**
* @param lastControllerRequestAt
* the lastControllerRequestAt to set
*/
@JsonIgnore
public void setLastControllerRequestAt(final Long lastControllerRequestAt) {
this.lastControllerRequestAt = lastControllerRequestAt;
}
/**
* @return the installedAt
*/
public Long getInstalledAt() {
return installedAt;
}
/**
* @param installedAt
* the installedAt to set
*/
@JsonIgnore
public void setInstalledAt(final Long installedAt) {
this.installedAt = installedAt;
}
/**
* @return the pollStatus
*/
public MgmtPollStatus getPollStatus() {
return pollStatus;
}
/**
* @param pollStatus
* the pollStatus to set
*/
@JsonIgnore
public void setPollStatus(final MgmtPollStatus pollStatus) {
this.pollStatus = pollStatus;
}
/**
* @return the ipAddress
*/
public String getIpAddress() {
return ipAddress;
}
/**
* @param ipAddress
* the ipAddress to set
*/
@JsonIgnore
public void setIpAddress(final String ipAddress) {
this.ipAddress = ipAddress;
}
/**
* @return the securityToken
*/
public String getSecurityToken() {
return securityToken;
}
public String getAddress() {
return address;
}
@JsonIgnore
public void setAddress(final String address) {
if (address != null) {
URI.create(address);
}
this.address = address;
}
/**
* @param securityToken
* the securityToken to set
*/
@JsonIgnore
public void setSecurityToken(final String securityToken) {
this.securityToken = securityToken;
}
}

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved.
*/
package org.eclipse.hawkbit.mgmt.json.model.target;
import java.util.HashMap;
import java.util.Map;
/**
* {@link Map} with attributes of SP Target.
*
*/
public class MgmtTargetAttributes extends HashMap<String, String> {
}

View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved.
*/
package org.eclipse.hawkbit.mgmt.json.model.target;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Request body for target PUT/POST commands.
*
*/
public class MgmtTargetRequestBody {
@JsonProperty(required = true)
private String name;
private String description;
@JsonProperty(required = true)
private String controllerId;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @return the controllerId
*/
public String getControllerId() {
return controllerId;
}
/**
* @param name
* the name to set
*/
public MgmtTargetRequestBody setName(final String name) {
this.name = name;
return this;
}
/**
* @param description
* the description to set
*/
public MgmtTargetRequestBody setDescription(final String description) {
this.description = description;
return this;
}
/**
* @param controllerId
* the controllerId to set
*/
public MgmtTargetRequestBody setControllerId(final String controllerId) {
this.controllerId = controllerId;
return this;
}
}

View File

@@ -0,0 +1,362 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MetadataRest;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPut;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling for DistributionSet CRUD operations.
*/
@RequestMapping(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetRestApi {
/**
* Handles the GET request of retrieving all DistributionSets .
*
* @param pagingOffsetParam
* the offset of list of sets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all set for a defined or default page request with
* status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<PagedList<MgmtDistributionSet>> getDistributionSets(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single DistributionSet .
*
* @param distributionSetId
* the ID of the set to retrieve
*
* @return a single DistributionSet with status OK.
*
* @throws EntityNotFoundException
* in case no DistributionSet with the given ID exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<MgmtDistributionSet> getDistributionSet(
@PathVariable("distributionSetId") final Long distributionSetId);
/**
* Handles the POST request of creating new distribution sets . The request
* body must always be a list of sets.
*
* @param sets
* the DistributionSets to be created.
* @return In case all sets could successful created the ResponseEntity with
* status code 201 - Created but without ResponseBody. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<List<MgmtDistributionSet>> createDistributionSets(
@RequestBody final List<MgmtDistributionSetRequestBodyPost> sets);
/**
* Handles the DELETE request for a single DistributionSet .
*
* @param distributionSetId
* the ID of the DistributionSet to delete
* @return status OK if delete as successful.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}")
public ResponseEntity<Void> deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId);
/**
* Handles the UPDATE request for a single DistributionSet .
*
* @param distributionSetId
* the ID of the DistributionSet to delete
* @param toUpdate
* with the data that needs updating
*
* @return status OK if update as successful with updated content.
*
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<MgmtDistributionSet> updateDistributionSet(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final MgmtDistributionSetRequestBodyPut toUpdate);
/**
* Handles the GET request of retrieving assigned targets to a specific
* distribution set.
*
* @param distributionSetId
* the ID of the distribution set to retrieve the assigned
* targets
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return status OK if get request is successful with the paged list of
* targets
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedTargets", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<PagedList<MgmtTarget>> getAssignedTargets(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving installed targets to a specific
* distribution set.
*
* @param distributionSetId
* the ID of the distribution set to retrieve the assigned
* targets
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return status OK if get request is successful with the paged list of
* targets
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/installedTargets", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<PagedList<MgmtTarget>> getInstalledTargets(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the POST request of assigning multiple targets to a single
* distribution set.
*
* @param distributionSetId
* the ID of the distribution set within the URL path parameter
* @param targetIds
* the IDs of the target which should get assigned to the
* distribution set given in the response body
* @return status OK if the assignment of the targets was successful and a
* complex return body which contains information about the assigned
* targets and the already assigned targets counters
*/
@RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedTargets", consumes = {
"application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<MgmtTargetAssignmentResponseBody> createAssignedTarget(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MgmtTargetAssignmentRequestBody> targetIds);
/**
* Gets a paged list of meta data for a distribution set.
*
* @param distributionSetId
* the ID of the distribution set for the meta data
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=key==abc}
* @return status OK if get request is successful with the paged list of
* meta data
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<PagedList<MetadataRest>> getMetadata(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Gets a single meta data value for a specific key of a distribution set.
*
* @param distributionSetId
* the ID of the distribution set to get the meta data from
* @param metadataKey
* the key of the meta data entry to retrieve the value from
* @return status OK if get request is successful with the value of the meta
* data
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<MetadataRest> getMetadataValue(
@PathVariable("distributionSetId") final Long distributionSetId,
@PathVariable("metadataKey") final String metadataKey);
/**
* Updates a single meta data value of a distribution set.
*
* @param distributionSetId
* the ID of the distribution set to update the meta data entry
* @param metadataKey
* the key of the meta data to update the value
* @return status OK if the update request is successful and the updated
* meta data result
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<MetadataRest> updateMetadata(@PathVariable("distributionSetId") final Long distributionSetId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MetadataRest metadata);
/**
* Deletes a single meta data entry from the distribution set.
*
* @param distributionSetId
* the ID of the distribution set to delete the meta data entry
* @param metadataKey
* the key of the meta data to delete
* @return status OK if the delete request is successful
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/metadata/{metadataKey}")
public ResponseEntity<Void> deleteMetadata(@PathVariable("distributionSetId") final Long distributionSetId,
@PathVariable("metadataKey") final String metadataKey);
/**
* Creates a list of meta data for a specific distribution set.
*
* @param distributionSetId
* the ID of the distribution set to create meta data for
* @param metadataRest
* the list of meta data entries to create
* @return status created if post request is successful with the value of
* the created meta data
*/
@RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/metadata", consumes = {
MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<List<MetadataRest>> createMetadata(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MetadataRest> metadataRest);
/**
* Assigns a list of software modules to a distribution set.
*
* @param distributionSetId
* the ID of the distribution set to assign software modules for
* @param softwareModuleIDs
* the list of software modules ids to assign
* @return http status
*
* @throws EntityNotFoundException
* in case no distribution set with the given
* {@code distributionSetId} exists.
*/
@RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedSM", consumes = {
MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<Void> assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final List<MgmtSoftwareModuleAssigment> softwareModuleIDs);
/**
* Deletes the assignment of the software module form the distribution set.
*
* @param distributionSetId
* the ID of the distribution set to reject the software module
* for
* @param softwareModuleId
* the software module id to get rejected form the distribution
* set
* @return status OK if rejection was successful.
* @throws EntityNotFoundException
* in case no distribution set with the given
* {@code distributionSetId} exists.
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/assignedSM/{softwareModuleId}")
public ResponseEntity<Void> deleteAssignSoftwareModules(
@PathVariable("distributionSetId") final Long distributionSetId,
@PathVariable("softwareModuleId") final Long softwareModuleId);
/**
* Handles the GET request for retrieving the assigned software modules of a
* specific distribution set.
*
* @param distributionSetId
* the ID of the distribution to retrieve
* @param pagingOffsetParam
* the offset of list of sets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @return a list of the assigned software modules of a distribution set
* with status OK, if none is assigned than {@code null}
* @throws EntityNotFoundException
* in case no distribution set with the given
* {@code distributionSetId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedSM", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<PagedList<MgmtSoftwareModule>> getAssignedSoftwareModules(
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam);
}

View File

@@ -0,0 +1,212 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedDistributionSetRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtDistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling for DistributionSetTag CRUD operations.
*
*/
@RequestMapping(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetTagRestApi {
/**
* Handles the GET request of retrieving all DistributionSet tags.
*
* @param pagingOffsetParam
* the offset of list of DistributionSet tags for pagination,
* might not be present in the rest request then default value
* will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all target tags for a defined or default page request
* with status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtTag>> getDistributionSetTags(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single distribution set tag.
*
* @param distributionsetTagId
* the ID of the distribution set tag to retrieve
*
* @return a single distribution set tag with status OK.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionsetTagId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> getDistributionSetTag(
@PathVariable("distributionsetTagId") final Long distributionsetTagId);
/**
* Handles the POST request of creating new distribution set tag. The
* request body must always be a list of tags.
*
* @param tags
* the distribution set tags to be created.
* @return In case all modules could successful created the ResponseEntity
* with status code 201 - Created. The Response Body are the created
* distribution set tags but without ResponseBody.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTag>> createDistributionSetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags);
/**
*
* Handles the PUT request of updating a single distribution set tag.
*
* @param distributionsetTagId
* the ID of the distribution set tag
* @param restDSTagRest
* the the request body to be updated
* @return status OK if update is successful and the updated distribution
* set tag.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{distributionsetTagId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> updateDistributionSetTag(
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final MgmtTagRequestBodyPut restDSTagRest);
/**
* Handles the DELETE request for a single distribution set tag.
*
* @param distributionsetTagId
* the ID of the distribution set tag
* @return status OK if delete as successfully.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionsetTagId}")
ResponseEntity<Void> deleteDistributionSetTag(
@PathVariable("distributionsetTagId") final Long distributionsetTagId);
/**
* Handles the GET request of retrieving all assigned distribution sets by
* the given tag id.
*
* @param distributionsetTagId
* the ID of the distribution set tag
*
* @return the list of assigned distribution sets.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
ResponseEntity<List<MgmtDistributionSet>> getAssignedDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId);
/**
* Handles the POST request to toggle the assignment of distribution sets by
* the given tag id.
*
* @param distributionsetTagIds
* the ID of the distribution set tag to retrieve
* @param assignedDSRequestBodies
* list of distribution set ids to be toggled
*
* @return the list of assigned distribution sets and unassigned
* distribution sets.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING
+ "/toggleTagAssignment")
ResponseEntity<MgmtDistributionSetTagAssigmentResult> toggleTagAssignment(
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);
/**
* Handles the POST request to assign distribution sets to the given tag id.
*
* @param distributionsetTagId
* the ID of the distribution set tag to retrieve
* @param assignedDSRequestBodies
* list of distribution sets ids to be assigned
*
* @return the list of assigned distribution set.
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
ResponseEntity<List<MgmtDistributionSet>> assignDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);
/**
* Handles the DELETE request to unassign all distribution set from the
* given tag id.
*
* @param distributionsetTagId
* the ID of the distribution set tag to retrieve
* @return http status code
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
ResponseEntity<Void> unassignDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId);
/**
* Handles the DELETE request to unassign one distribution set from the
* given tag id.
*
* @param distributionsetTagId
* the ID of the distribution set tag
* @param distributionsetId
* the ID of the distribution set to unassign
* @return http status code
* @throws EntityNotFoundException
* in case the given {@code distributionsetTagId} doesn't
* exists.
*/
@RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DISTRIBUTIONSET_REQUEST_MAPPING
+ "/{distributionsetId}")
ResponseEntity<Void> unassignDistributionSet(@PathVariable("distributionsetTagId") final Long distributionsetTagId,
@PathVariable("distributionsetId") final Long distributionsetId);
}

View File

@@ -0,0 +1,254 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRest;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling for SoftwareModule and related Artifact CRUD
* operations.
*
*/
@RequestMapping(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetTypeRestApi {
/**
* Handles the GET request of retrieving all DistributionSetTypes.
*
* @param pagingOffsetParam
* the offset of list of modules for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
*
* @return a list of all DistributionSetType for a defined or default page
* request with status OK. The response is always paged. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtDistributionSetTypeRest>> getDistributionSetTypes(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single DistributionSetType
* within.
*
* @param distributionSetTypeId
* the ID of the module type to retrieve
*
* @return a single softwareModule with status OK.
* @throws EntityNotFoundException
* in case no with the given {@code softwareModuleId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtDistributionSetTypeRest> getDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId);
/**
* Handles the DELETE request for a single Distribution Set Type.
*
* @param distributionSetTypeId
* the ID of the module to retrieve
* @return status OK if delete as sucessfull.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}")
ResponseEntity<Void> deleteDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId);
/**
* Handles the PUT request of updating a Distribution Set Type.
*
* @param distributionSetTypeId
* the ID of the software module in the URL
* @param restDistributionSetType
* the module type to be updated.
* @return status OK if update is successful
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetTypeId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtDistributionSetTypeRest> updateDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType);
/**
* Handles the POST request of creating new DistributionSetTypes. The
* request body must always be a list of types.
*
* @param distributionSetTypes
* the modules to be created.
* @return In case all modules could successful created the ResponseEntity
* with status code 201 - Created but without ResponseBody. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtDistributionSetTypeRest>> createDistributionSetTypes(
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes);
/**
* Handles the GET request of retrieving the list of mandatory software
* module types in that distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @return Unpaged list of module types and OK in case of success.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModuleType>> getMandatoryModules(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId);
/**
* Handles the GET request of retrieving the single mandatory software
* module type in that distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param softwareModuleTypeId
* of SoftwareModuleType.
* @return Unpaged list of module types and OK in case of success.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES
+ "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModuleType> getMandatoryModule(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles the GET request of retrieving the single optional software module
* type in that distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param softwareModuleTypeId
* of SoftwareModuleType.
* @return Unpaged list of module types and OK in case of success.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES
+ "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModuleType> getOptionalModule(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles the GET request of retrieving the list of optional software
* module types in that distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @return Unpaged list of module types and OK in case of success.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModuleType>> getOptionalModules(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId);
/**
* Handles DELETE request for removing a mandatory module from the
* DistributionSetType.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param softwareModuleTypeId
* of the SoftwareModuleType to remove
*
* @return OK if the request was successful
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES
+ "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> removeMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles DELETE request for removing an optional module from the
* DistributionSetType.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param softwareModuleTypeId
* of the SoftwareModuleType to remove
*
* @return OK if the request was successful
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES
+ "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> removeOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles the POST request for adding a mandatory software module type to a
* distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param smtId
* of the SoftwareModuleType to add
*
* @return OK if the request was successful
*/
@RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> addMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtId smtId);
/**
* Handles the POST request for adding an optional software module type to a
* distribution set type.
*
* @param distributionSetTypeId
* of the DistributionSetType.
* @param smtId
* of the SoftwareModuleType to add
*
* @return OK if the request was successful
*/
@RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/"
+ MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> addOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@RequestBody final MgmtId smtId);
}

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
*
*/
@RequestMapping(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
public interface MgmtDownloadArtifactRestApi {
/**
* Handles the GET request for downloading an artifact.
*
* @param softwareModuleId
* of the parent SoftwareModule
* @param artifactId
* of the related LocalArtifact
* @param servletResponse
* of the servlet
* @param request
* of the client
*
* @return responseEntity with status ok if successful
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}/download")
@ResponseBody
ResponseEntity<Void> downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId, final HttpServletResponse servletResponse,
final HttpServletRequest request);
}

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* A resource for download artifacts.
*
*/
@RequestMapping(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE)
public interface MgmtDownloadRestApi {
/**
* Handles the GET request for downloading an artifact.
*
* @param downloadId
* the generated download id
* @param response
* of the servlet
* @return {@link ResponseEntity} with status {@link HttpStatus#OK} if
* successful
*/
@RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING)
@ResponseBody
ResponseEntity<Void> downloadArtifactByDownloadId(@PathVariable final String downloadId,
final HttpServletResponse response);
}

View File

@@ -0,0 +1,183 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
/**
* Constants for RESTful API.
*
*
*
*/
public final class MgmtRestConstants {
/**
* API version definition. We are using only major versions.
*/
public static final String API_VERSION = "v1";
/**
* The base URL mapping of the SP rest resources.
*/
public static final String BASE_V1_REQUEST_MAPPING = "/rest/v1";
/**
* The default limit parameter in case the limit parameter is not present in
* the request.
*
* @see #REQUEST_PARAMETER_PAGING_LIMIT
*/
public static final int REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE = 50;
/**
* String representation of
* {@link #REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE}.
*/
public static final String REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT = "50";
/**
* The software module URL mapping rest resource.
*/
public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules";
public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE = "/api/" + API_VERSION + "/downloadserver/";
public static final String DOWNLOAD_ID_V1_REQUEST_MAPPING = "downloadId/{downloadId}";
/**
* The target URL mapping, href link for assigned distribution set.
*/
public static final String TARGET_V1_ASSIGNED_DISTRIBUTION_SET = "assignedDS";
/**
* The target URL mapping, href link for installed distribution set.
*/
public static final String TARGET_V1_INSTALLED_DISTRIBUTION_SET = "installedDS";
/**
* The target URL mapping, href link for target attributes.
*/
public static final String TARGET_V1_ATTRIBUTES = "attributes";
/**
* The target URL mapping, href link for target actions.
*/
public static final String TARGET_V1_ACTIONS = "actions";
/**
* The target URL mapping, href link for canceled actions.
*/
public static final String TARGET_V1_CANCELED_ACTION = "canceledaction";
/**
* The target URL mapping, href link for canceled actions.
*/
public static final String TARGET_V1_ACTION_STATUS = "status";
/**
* The target URL mapping rest resource.
*/
public static final String TARGET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targets";
/**
* The tag URL mapping rest resource.
*/
public static final String TARGET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettags";
/**
* The tag URL mapping rest resource.
*/
public static final String TARGET_TAG_TAGERTS_REQUEST_MAPPING = "/{targetTagId}/targets";
/**
* The tag URL mapping rest resource.
*/
public static final String DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING
+ "/distributionsettags";
/**
* The tag URL mapping rest resource.
*/
public static final String DISTRIBUTIONSET_REQUEST_MAPPING = "/{distributionsetTagId}/distributionsets";
/**
* The default offset parameter in case the offset parameter is not present
* in the request.
*
* @see #REQUEST_PARAMETER_PAGING_OFFSET
*/
public static final String REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET = "0";
/**
* Limit http parameter for the limitation of returned values for a paged
* request.
*/
public static final String REQUEST_PARAMETER_PAGING_LIMIT = "limit";
/**
* The maximum limit of entities returned by rest resources.
*/
public static final int REQUEST_PARAMETER_PAGING_MAX_LIMIT = 500;
/**
* Paging http parameter for the offset for a paged request.
*/
public static final String REQUEST_PARAMETER_PAGING_OFFSET = "offset";
/**
* The request parameter for sorting. The value of the sort parameter must
* be in the following pattern. Example:
* http://www.bosch.com/iap/sp/rest/targets?sort=field_1:ASC,field_2:DESC,
* field_3:ASC
*/
public static final String REQUEST_PARAMETER_SORTING = "sort";
/**
* The request parameter for searching. The value of the search parameter
* must be in the FIQL syntax.
*/
public static final String REQUEST_PARAMETER_SEARCH = "q";
/**
* The software module type URL mapping rest resource.
*/
public static final String SOFTWAREMODULETYPE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremoduletypes";
public static final String DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING
+ "/distributionsettypes";
/**
* The software module URL mapping rest resource.
*/
public static final String DISTRIBUTIONSET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/distributionsets";
/**
* The rollout URL mapping rest resource.
*/
public static final String ROLLOUT_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/rollouts";
/**
* Request parameter for async
*/
public static final String REQUEST_PARAMETER_ASYNC = "async";
/**
* The target URL mapping, href link for artifact download.
*/
public static final String SOFTWAREMODULE_V1_ARTIFACT = "artifacts";
/**
* The target URL mapping, href link for type information.
*/
public static final String SOFTWAREMODULE_V1_TYPE = "type";
public static final String DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULES = "optionalmodules";
public static final String DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES = "mandatorymodules";
public static final String DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES = "optionalmoduletypes";
public static final String DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES = "mandatorymoduletypes";
// constant class, private constructor.
private MgmtRestConstants() {
}
}

View File

@@ -0,0 +1,208 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling rollout CRUD operations.
*
*/
@RequestMapping(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
public interface MgmtRolloutRestApi {
/**
* Handles the GET request of retrieving all rollouts.
*
* @param pagingOffsetParam
* the offset of list of rollouts for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all rollouts for a defined or default page request with
* status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<PagedList<MgmtRolloutResponseBody>> getRollouts(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single rollout.
*
* @param rolloutId
* the ID of the rollout to retrieve
* @return a single rollout with status OK.
* @throws EntityNotFoundException
* in case no rollout with the given {@code rolloutId} exists.
*/
@RequestMapping(value = "/{rolloutId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" })
ResponseEntity<MgmtRolloutResponseBody> getRollout(@PathVariable("rolloutId") final Long rolloutId);
/**
* Handles the POST request for creating rollout.
*
* @param rollout
* the rollout body to be created.
* @return In case rollout could successful created the ResponseEntity with
* status code 201 with the successfully created rollout. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
* @throws EntityNotFoundException
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtRolloutResponseBody> create(@RequestBody final MgmtRolloutRestRequestBody rolloutRequestBody);
/**
* Handles the POST request for starting a rollout.
*
* @param rolloutId
* the ID of the rollout to be started.
* @return OK response (200) if rollout could be started. In case of any
* exception the corresponding errors occur.
* @throws EntityNotFoundException
* @see RolloutManagement#startRollout(Rollout)
* @see ResponseExceptionHandler
*/
@RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/start", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_ASYNC, defaultValue = "false") final boolean startAsync);
/**
* Handles the POST request for pausing a rollout.
*
* @param rolloutId
* the ID of the rollout to be paused.
* @return OK response (200) if rollout could be paused. In case of any
* exception the corresponding errors occur.
* @throws EntityNotFoundException
* @see RolloutManagement#pauseRollout(Rollout)
* @see ResponseExceptionHandler
*/
@RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/pause", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> pause(@PathVariable("rolloutId") final Long rolloutId);
/**
* Handles the POST request for resuming a rollout.
*
* @param rolloutId
* the ID of the rollout to be resumed.
* @return OK response (200) if rollout could be resumed. In case of any
* exception the corresponding errors occur.
* @throws EntityNotFoundException
* @see RolloutManagement#resumeRollout(Rollout)
* @see ResponseExceptionHandler
*/
@RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/resume", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> resume(@PathVariable("rolloutId") final Long rolloutId);
/**
* Handles the GET request of retrieving all rollout groups referred to a
* rollout.
*
* @param pagingOffsetParam
* the offset of list of rollout groups for pagination, might not
* be present in the rest request then default value will be
* applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all rollout groups referred to a rollout for a defined
* or default page request with status OK. The response is always
* paged. In any failure the JsonResponseExceptionHandler is
* handling the response.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups(
@PathVariable("rolloutId") final Long rolloutId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request for retrieving a single rollout group.
*
* @param rolloutId
* the rolloutId to retrieve the group from
* @param groupId
* the groupId to retrieve the rollout group
* @return the OK response containing the MgmtRolloutGroupResponseBody
* @throws EntityNotFoundException
*/
@RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MgmtRolloutGroupResponseBody> getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId,
@PathVariable("groupId") final Long groupId);
/**
* Retrieves all targets related to a specific rollout group.
*
* @param rolloutId
* the ID of the rollout
* @param groupId
* the ID of the rollout group
* @param pagingOffsetParam
* the offset of list of rollout groups for pagination, might not
* be present in the rest request then default value will be
* applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a paged list of targets related to a specific rollout and rollout
* group.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}/targets", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<PagedList<MgmtTarget>> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId,
@PathVariable("groupId") final Long groupId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
}

View File

@@ -0,0 +1,282 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MetadataRest;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
/**
* REST Resource handling for SoftwareModule and related Artifact CRUD
* operations.
*
*/
@RequestMapping(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
public interface MgmtSoftwareModuleRestAPI {
/**
* Handles POST request for artifact upload.
*
* @param softwareModuleId
* of the parent SoftwareModule
* @param file
* that has to be uploaded
* @param optionalFileName
* to override {@link MultipartFile#getOriginalFilename()}
* @param md5Sum
* checksum for uploaded content check
* @param sha1Sum
* checksum for uploaded content check
*
* @return In case all sets could successful be created the ResponseEntity
* with status code 201 - Created but without ResponseBody. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtArtifact> uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestParam("file") final MultipartFile file,
@RequestParam(value = "filename", required = false) final String optionalFileName,
@RequestParam(value = "md5sum", required = false) final String md5Sum,
@RequestParam(value = "sha1sum", required = false) final String sha1Sum);
/**
* Handles the GET request of retrieving all meta data of artifacts assigned
* to a software module.
*
* @param softwareModuleId
* of the parent SoftwareModule
*
* @return a list of all artifacts for a defined or default page request
* with status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
ResponseEntity<List<MgmtArtifact>> getArtifacts(@PathVariable("softwareModuleId") final Long softwareModuleId);
/**
* Handles the GET request of retrieving a single Artifact meta data
* request.
*
* @param softwareModuleId
* of the parent SoftwareModule
* @param artifactId
* of the related LocalArtifact
*
* @return responseEntity with status ok if successful
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
ResponseEntity<MgmtArtifact> getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId);
/**
* Handles the DELETE request for a single SoftwareModule.
*
* @param softwareModuleId
* the ID of the module that has the artifact
* @param artifactId
* of the artifact to be deleted
*
* @return status OK if delete as successful.
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/artifacts/{artifactId}")
@ResponseBody
ResponseEntity<Void> deleteArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId);
/**
* Handles the GET request of retrieving all softwaremodules.
*
* @param pagingOffsetParam
* the offset of list of modules for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
*
* @return a list of all modules for a defined or default page request with
* status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtSoftwareModule>> getSoftwareModules(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single software module.
*
* @param softwareModuleId
* the ID of the module to retrieve
*
* @return a single softwareModule with status OK.
* @throws EntityNotFoundException
* in case no with the given {@code softwareModuleId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModule> getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId);
/**
* Handles the POST request of creating new softwaremodules. The request
* body must always be a list of modules.
*
* @param softwareModules
* the modules to be created.
* @return In case all modules could successful created the ResponseEntity
* with status code 201 - Created but without ResponseBody. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(
@RequestBody final List<MgmtSoftwareModuleRequestBodyPost> softwareModules);
/**
* Handles the PUT request of updating a software module.
*
* @param softwareModuleId
* the ID of the software module in the URL
* @param restSoftwareModule
* the modules to be updated.
* @return status OK if update is successful
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModule> updateSoftwareModule(
@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule);
/**
* Handles the DELETE request for a single software module.
*
* @param softwareModuleId
* the ID of the module to retrieve
* @return status OK if delete as sucessfull.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}")
ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId);
/**
* Gets a paged list of meta data for a software module.
*
* @param softwareModuleId
* the ID of the software module for the meta data
* @param pagingOffsetParam
* the offset of list of meta data for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=key==abc}
* @return status OK if get request is successful with the paged list of
* meta data
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<PagedList<MetadataRest>> getMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Gets a single meta data value for a specific key of a software module.
*
* @param softwareModuleId
* the ID of the software module to get the meta data from
* @param metadataKey
* the key of the meta data entry to retrieve the value from
* @return status OK if get request is successful with the value of the meta
* data
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MetadataRest> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey);
/**
* Updates a single meta data value of a software module.
*
* @param softwareModuleId
* the ID of the software module to update the meta data entry
* @param metadataKey
* the key of the meta data to update the value
* @return status OK if the update request is successful and the updated
* meta data result
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<MetadataRest> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MetadataRest metadata);
/**
* Deletes a single meta data entry from the software module.
*
* @param softwareModuleId
* the ID of the software module to delete the meta data entry
* @param metadataKey
* the key of the meta data to delete
* @return status OK if the delete request is successful
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/metadata/{metadataKey}")
ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey);
/**
* Creates a list of meta data for a specific software module.
*
* @param softwareModuleId
* the ID of the distribution set to create meta data for
* @param metadataRest
* the list of meta data entries to create
* @return status created if post request is successful with the value of
* the created meta data
*/
@RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/metadata", consumes = {
MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
ResponseEntity<List<MetadataRest>> createMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final List<MetadataRest> metadataRest);
}

View File

@@ -0,0 +1,117 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPut;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling for SoftwareModule and related Artifact CRUD
* operations.
*
*/
@RequestMapping(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)
public interface MgmtSoftwareModuleTypeRestApi {
/**
* Handles the GET request of retrieving all SoftwareModuleTypes .
*
* @param pagingOffsetParam
* the offset of list of modules for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
*
* @return a list of all module type for a defined or default page request
* with status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtSoftwareModuleType>> getTypes(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single software module type .
*
* @param softwareModuleTypeId
* the ID of the module type to retrieve
*
* @return a single softwareModule with status OK.
* @throws EntityNotFoundException
* in case no with the given {@code softwareModuleId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleTypeId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModuleType> getSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles the DELETE request for a single software module type .
*
* @param softwareModuleTypeId
* the ID of the module to retrieve
* @return status OK if delete as successfully.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleTypeId}")
ResponseEntity<Void> deleteSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId);
/**
* Handles the PUT request of updating a software module type .
*
* @param softwareModuleTypeId
* the ID of the software module in the URL
* @param restSoftwareModuleType
* the module type to be updated.
* @return status OK if update is successful
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleTypeId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSoftwareModuleType> updateSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId,
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType);
/**
* Handles the POST request of creating new SoftwareModuleTypes. The request
* body must always be a list of types.
*
* @param softwareModuleTypes
* the modules to be created.
* @return In case all modules could successful created the ResponseEntity
* with status code 201 - Created but without ResponseBody. In any
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes);
}

View File

@@ -0,0 +1,279 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssigment;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Api for handling target operations.
*/
@RequestMapping(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
public interface MgmtTargetRestApi {
/**
* Handles the GET request of retrieving a single target.
*
* @param targetId
* the ID of the target to retrieve
* @return a single target with status OK.
* @throws EntityNotFoundException
* in case no target with the given {@code targetId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTarget> getTarget(@PathVariable("targetId") final String targetId);
/**
* Handles the GET request of retrieving all targets.
*
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all targets for a defined or default page request with
* status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtTarget>> getTargets(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the POST request of creating new targets. The request body must
* always be a list of targets.
*
* @param targets
* the targets to be created.
* @return In case all targets could successful created the ResponseEntity
* with status code 201 with a list of successfully created
* entities. In any failure the JsonResponseExceptionHandler is
* handling the response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets);
/**
* Handles the PUT request of updating a target. The ID is within the URL
* path of the request. A given ID in the request body is ignored. It's not
* possible to set fields to {@code null} values.
*
* @param targetId
* the path parameter which contains the ID of the target
* @param targetRest
* the request body which contains the fields which should be
* updated, fields which are not given are ignored for the
* udpate.
* @return the updated target response which contains all fields also fields
* which have not updated
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{targetId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTarget> updateTarget(@PathVariable("targetId") final String targetId,
@RequestBody final MgmtTargetRequestBody targetRest);
/**
* Handles the DELETE request of deleting a target.
*
* @param targetId
* the ID of the target to be deleted
* @return If the given targetId could exists and could be deleted Http OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> deleteTarget(@PathVariable("targetId") final String targetId);
/**
* Handles the GET request of retrieving the attributes of a specific
* target.
*
* @param targetId
* the ID of the target to retrieve the attributes.
* @return the target attributes as map response with status OK
* @throws EntityNotFoundException
* in case no target with the given {@code targetId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/attributes", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTargetAttributes> getAttributes(@PathVariable("targetId") final String targetId);
/**
* Handles the GET request of retrieving the Actions of a specific target.
*
* @param targetId
* to load actions for
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=status==pending}
* @return a list of all Actions for a defined or default page request with
* status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtAction>> getActionHistory(@PathVariable("targetId") final String targetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a specific Actions of a specific
* Target.
*
* @param targetId
* to load the action for
* @param actionId
* to load
* @return the action
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtAction> getAction(@PathVariable("targetId") final String targetId,
@PathVariable("actionId") final Long actionId);
/**
* Handles the DELETE request of canceling an specific Actions of a specific
* Target.
*
* @param targetId
* the ID of the target in the URL path parameter
* @param actionId
* the ID of the action in the URL path parameter
* @param force
* optional parameter, which indicates a force cancel
* @return status no content in case cancellation was successful
* @throws CancelActionNotAllowedException
* if the given action is not active and cannot be canceled.
* @throws EntityNotFoundException
* if the target or the action is not found
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}/actions/{actionId}")
ResponseEntity<Void> cancelAction(@PathVariable("targetId") final String targetId,
@PathVariable("actionId") final Long actionId,
@RequestParam(value = "force", required = false, defaultValue = "false") final boolean force);
/**
* Handles the GET request of retrieving the ActionStatus of a specific
* target and action.
*
* @param targetId
* of the the action
* @param actionId
* of the status we are intend to load
* @param pagingOffsetParam
* the offset of list of targets for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @return a list of all ActionStatus for a defined or default page request
* with status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtActionStatus>> getActionStatusList(@PathVariable("targetId") final String targetId,
@PathVariable("actionId") final Long actionId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam);
/**
* Handles the GET request of retrieving the assigned distribution set of an
* specific target.
*
* @param targetId
* the ID of the target to retrieve the assigned distribution
* @return the assigned distribution set with status OK, if none is assigned
* than {@code null} content (e.g. "{}")
* @throws EntityNotFoundException
* in case no target with the given {@code targetId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/assignedDS", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtDistributionSet> getAssignedDistributionSet(@PathVariable("targetId") final String targetId);
/**
* Changes the assigned distribution set of a target.
*
* @param targetId
* of the target to change
* @param dsId
* of the distributionset that is to be assigned
* @return http status
*
* @throws EntityNotFoundException
* in case no target with the given {@code targetId} exists.
*
*/
@RequestMapping(method = RequestMethod.POST, value = "/{targetId}/assignedDS", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> postAssignedDistributionSet(@PathVariable("targetId") final String targetId,
@RequestBody final MgmtDistributionSetAssigment dsId);
/**
* Handles the GET request of retrieving the installed distribution set of
* an specific target.
*
* @param targetId
* the ID of the target to retrieve
* @return the assigned installed set with status OK, if none is installed
* than {@code null} content (e.g. "{}")
* @throws EntityNotFoundException
* in case no target with the given {@code targetId} exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/installedDS", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtDistributionSet> getInstalledDistributionSet(@PathVariable("targetId") final String targetId);
}

View File

@@ -0,0 +1,194 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.rest.api;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTargetTagAssigmentResult;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
* REST Resource handling for TargetTag CRUD operations.
*
*/
@RequestMapping(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
public interface MgmtTargetTagRestApi {
/**
* Handles the GET request of retrieving all target tags.
*
* @param pagingOffsetParam
* the offset of list of target tags for pagination, might not be
* present in the rest request then default value will be applied
* @param pagingLimitParam
* the limit of the paged request, might not be present in the
* rest request then default value will be applied
* @param sortParam
* the sorting parameter in the request URL, syntax
* {@code field:direction, field:direction}
* @param rsqlParam
* the search parameter in the request URL, syntax
* {@code q=name==abc}
* @return a list of all target tags for a defined or default page request
* with status OK. The response is always paged. In any failure the
* JsonResponseExceptionHandler is handling the response.
*/
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtTag>> getTargetTags(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam);
/**
* Handles the GET request of retrieving a single target tag.
*
* @param targetTagId
* the ID of the target tag to retrieve
*
* @return a single target tag with status OK.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetTagId}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> getTargetTag(@PathVariable("targetTagId") final Long targetTagId);
/**
* Handles the POST request of creating new target tag. The request body
* must always be a list of tags.
*
* @param tags
* the target tags to be created.
* @return In case all modules could successful created the ResponseEntity
* with status code 201 - Created. The Response Body are the created
* target tags but without ResponseBody.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags);
/**
*
* Handles the PUT request of updating a single targetr tag.
*
* @param targetTagId
* the ID of the target tag
* @param restTargetTagRest
* the the request body to be updated
* @return status OK if update is successful and the updated target tag.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTag> updateTagretTag(@PathVariable("targetTagId") final Long targetTagId,
@RequestBody final MgmtTagRequestBodyPut restTargetTagRest);
/**
* Handles the DELETE request for a single target tag.
*
* @param targetTagId
* the ID of the target tag
* @return status OK if delete as successfully.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/{targetTagId}")
ResponseEntity<Void> deleteTargetTag(@PathVariable("targetTagId") final Long targetTagId);
/**
* Handles the GET request of retrieving all assigned targets by the given
* tag id.
*
* @param targetTagId
* the ID of the target tag to retrieve
*
* @return the list of assigned targets.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId);
/**
* Handles the POST request to toggle the assignment of targets by the given
* tag id.
*
* @param targetTagId
* the ID of the target tag to retrieve
* @param assignedTargetRequestBodies
* list of target ids to be toggled
*
* @return the list of assigned targets and unassigned targets.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING
+ "/toggleTagAssignment")
ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignment(
@PathVariable("targetTagId") final Long targetTagId,
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);
/**
* Handles the POST request to assign targets to the given tag id.
*
* @param targetTagId
* the ID of the target tag to retrieve
* @param assignedTargetRequestBodies
* list of target ids to be assigned
*
* @return the list of assigned targets.
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);
/**
* Handles the DELETE request to unassign all targets from the given tag id.
*
* @param targetTagId
* the ID of the target tag to retrieve
* @return http status code
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
ResponseEntity<Void> unassignTargets(@PathVariable("targetTagId") final Long targetTagId);
/**
* Handles the DELETE request to unassign one target from the given tag id.
*
* @param targetTagId
* the ID of the target tag
* @param controllerId
* the ID of the target to unassign
* @return http status code
* @throws EntityNotFoundException
* in case the given {@code targetTagId} doesn't exists.
*/
@RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING
+ "/{controllerId}")
ResponseEntity<Void> unassignTarget(@PathVariable("targetTagId") final Long targetTagId,
@PathVariable("controllerId") final String controllerId);
}

View File

@@ -0,0 +1,65 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.mgmt.json.model;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Unit Tests - Management API")
@Stories("Paged List Handling")
public class PagedListTest {
@Test
@Description("Ensures that a null payload entitiy throws an exception.")
public void createListWithNullContentThrowsException() {
try {
new PagedList<>(null, 0);
fail("as content is null");
} catch (final NullPointerException e) {
}
}
@Test
@Description("Create list with payload and verify content.")
public void createListWithContent() {
final long knownTotal = 2;
final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1");
knownContentList.add("content2");
assertListSize(knownTotal, knownContentList);
}
private void assertListSize(final long knownTotal, final List<String> knownContentList) {
final PagedList<String> pagedList = new PagedList<>(knownContentList, knownTotal);
assertThat(pagedList.getTotal()).as("total size is wrong").isEqualTo(knownTotal);
assertThat(pagedList.getSize()).as("list size is wrong").isEqualTo(knownContentList.size());
}
@Test
@Description("Create list with payload and verify size values.")
public void createListWithSmallerTotalThanContentSizeIsOk() {
final long knownTotal = 0;
final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1");
knownContentList.add("content2");
assertListSize(knownTotal, knownContentList);
}
}