forked from eclipse-hawkbit/hawkbit
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mgmt/actions confirm (eclipse-hawkbit#2271)
* Extend MGMT API to be possible to confirm/deny Actions on Targets as Operators. * Added tests * Fixed permissions in api doc * added missing license header --------- Co-authored-by: vasilchev <[email protected]>
- Loading branch information
Showing
4 changed files
with
285 additions
and
3 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionConfirmationRequestBodyPut.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.hawkbit.mgmt.json.model.action; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
/** | ||
* New update actions require confirmation when confirmation flow is switched on. | ||
* The confirmation message has a mandatory field confirmation with possible values: "confirmed" and "denied". | ||
*/ | ||
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class MgmtActionConfirmationRequestBodyPut { | ||
|
||
@NotNull | ||
@Valid | ||
@Schema(description = "Action confirmation state") | ||
private final Confirmation confirmation; | ||
|
||
@Schema(description = "(Optional) Individual status code", example = "200") | ||
private final Integer code; | ||
|
||
@Schema(description = "List of detailed message information", example = "[ \"Feedback message\" ]") | ||
private final List<String> details; | ||
|
||
/** | ||
* Constructs a confirmation-feedback | ||
* | ||
* @param confirmation confirmation value for the action. Valid values are "Confirmed" and "Denied | ||
* @param code code for confirmation | ||
* @param details messages | ||
*/ | ||
@JsonCreator | ||
public MgmtActionConfirmationRequestBodyPut( | ||
@JsonProperty(value = "confirmation", required = true) final Confirmation confirmation, | ||
@JsonProperty(value = "code") final Integer code, | ||
@JsonProperty(value = "details") final List<String> details) { | ||
this.confirmation = confirmation; | ||
this.code = code; | ||
this.details = details; | ||
} | ||
|
||
public List<String> getDetails() { | ||
if (details == null) { | ||
return Collections.emptyList(); | ||
} | ||
return Collections.unmodifiableList(details); | ||
} | ||
|
||
public enum Confirmation { | ||
/** | ||
* Confirm the action. | ||
*/ | ||
CONFIRMED("confirmed"), | ||
|
||
/** | ||
* Deny the action. | ||
*/ | ||
DENIED("denied"); | ||
|
||
private final String name; | ||
|
||
Confirmation(final String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonValue | ||
public String getName() { | ||
return name; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.