Require all fields in an alarm update request
Require all fields (state, lifecyclestate, and link) Change-Id: I7b548fd87143d2733464e0fc33195da5c4e93534
This commit is contained in:
parent
5f6227ce77
commit
8bc6de7e89
@ -13,7 +13,6 @@
|
||||
*/
|
||||
package monasca.api.app.command;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import monasca.common.model.alarm.AlarmState;
|
||||
@ -22,12 +21,14 @@ public class UpdateAlarmCommand {
|
||||
|
||||
@NotNull
|
||||
public AlarmState state;
|
||||
@NotNull
|
||||
public String lifecycleState;
|
||||
@NotNull
|
||||
public String link;
|
||||
|
||||
public UpdateAlarmCommand() {}
|
||||
|
||||
public UpdateAlarmCommand(AlarmState state, @Nullable String lifecycleState, @Nullable String link) {
|
||||
public UpdateAlarmCommand(AlarmState state, String lifecycleState, String link) {
|
||||
this.state = state;
|
||||
this.lifecycleState = lifecycleState;
|
||||
this.link = link;
|
||||
|
@ -57,12 +57,12 @@ class Alarms(alarms_api_v2.AlarmsV2API,
|
||||
if 'state' not in alarm or not alarm['state']:
|
||||
raise falcon.HTTPBadRequest('Bad request',
|
||||
"Field 'state' is required")
|
||||
|
||||
# Assume these fields are null if not provided
|
||||
if 'lifecycle_state' not in alarm:
|
||||
alarm['lifecycle_state'] = None
|
||||
if 'link' not in alarm:
|
||||
alarm['link'] = None
|
||||
if 'lifecycle_state' not in alarm or not alarm['lifecycle_state']:
|
||||
raise falcon.HTTPBadRequest('Bad Request',
|
||||
"Field 'lifecycle_state' is required")
|
||||
if 'link' not in alarm or not alarm['link']:
|
||||
raise falcon.HTTPBadRequest('Bad Request',
|
||||
"Field 'link' is required")
|
||||
|
||||
self._alarm_update(tenant_id, alarm_id, alarm['state'],
|
||||
alarm['lifecycle_state'], alarm['link'])
|
||||
|
Loading…
Reference in New Issue
Block a user