Refactor Ceilometer alarm API

This patch refactors Ceilometer alarm API to make it be maintainable
and readable.

Change-Id: I321e01ee87ea122f740fdbadc4258983b41faf00
This commit is contained in:
Ha Van Tu 2016-09-14 17:50:10 +07:00
parent b2eadb424f
commit 3e4c37a7c3
2 changed files with 135 additions and 109 deletions

View File

@ -24,7 +24,7 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- alarm_id: alarm_id_path
Response Parameters
@ -32,21 +32,22 @@ Response Parameters
.. rest_parameters:: parameters.yaml
- alarm: alarm_response
- alarm_actions: alarm_actions
- alarm_id: alarm_id
- combination_rule: combination_rule
- description: description
- enabled: enabled
- insufficient_data_actions: insufficient_data_actions
- timestamp: timestamp
- name: name
- ok_actions: ok_actions
- project_id: project_id
- state_timestamp: state_timestamp
- threshold_rule: threshold_rule
- repeat_actions: repeat_actions
- state: state
- type: type
- combination_rule: alarm_combination_rule
- description: alarm_description
- enabled: alarm_enabled
- insufficient_data_actions: alarm_insufficient_data_actions
- timestamp: alarm_timestamp
- name: alarm_name
- ok_actions: alarm_ok_actions
- project_id: alarm_project_id
- state_timestamp: alarm_state_timestamp
- threshold_rule: alarm_threshold_rule
- repeat_actions: alarm_repeat_actions
- state: alarm_state
- type: alarm_type
- user_id: user_id
Response Example
@ -75,8 +76,8 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- data: data
- alarm_id: alarm_id_path
- alarm: alarm_request
Response Parameters
@ -84,22 +85,23 @@ Response Parameters
.. rest_parameters:: parameters.yaml
- alarm: alarm_response
- alarm_actions: alarm_actions
- ok_actions: ok_actions
- description: description
- timestamp: timestamp
- enabled: enabled
- combination_rule: combination_rule
- state_timestamp: state_timestamp
- threshold_rule: threshold_rule
- alarm_id: alarm_id
- state: state
- insufficient_data_actions: insufficient_data_actions
- repeat_actions: repeat_actions
- combination_rule: alarm_combination_rule
- description: alarm_description
- enabled: alarm_enabled
- insufficient_data_actions: alarm_insufficient_data_actions
- timestamp: alarm_timestamp
- name: alarm_name
- ok_actions: alarm_ok_actions
- project_id: alarm_project_id
- state_timestamp: alarm_state_timestamp
- threshold_rule: alarm_threshold_rule
- repeat_actions: alarm_repeat_actions
- state: alarm_state
- type: alarm_type
- user_id: user_id
- project_id: project_id
- type: type
- name: name
@ -127,7 +129,7 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- alarm_id: alarm_id_path
@ -151,8 +153,8 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- state: state
- alarm_id: alarm_id_path
- state: alarm_state
@ -183,7 +185,7 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- alarm_id: alarm_id_path
@ -232,7 +234,7 @@ Response Parameters
- threshold_rule: threshold_rule
- alarm_id: alarm_id
- state: state
- insufficient_data_actions: insufficient_data_actions
- insufficient_data_actions: alarm_insufficient_data_actions
- repeat_actions: repeat_actions
- user_id: user_id
- project_id: project_id
@ -275,22 +277,23 @@ Response Parameters
.. rest_parameters:: parameters.yaml
- alarm: alarm_response
- alarm_actions: alarm_actions
- ok_actions: ok_actions
- description: description
- timestamp: timestamp
- enabled: enabled
- combination_rule: combination_rule
- state_timestamp: state_timestamp
- threshold_rule: threshold_rule
- alarm_id: alarm_id
- state: state
- insufficient_data_actions: insufficient_data_actions
- repeat_actions: repeat_actions
- combination_rule: alarm_combination_rule
- description: alarm_description
- enabled: alarm_enabled
- insufficient_data_actions: alarm_insufficient_data_actions
- timestamp: alarm_timestamp
- name: alarm_name
- ok_actions: alarm_ok_actions
- project_id: alarm_project_id
- state_timestamp: alarm_state_timestamp
- threshold_rule: alarm_threshold_rule
- repeat_actions: alarm_repeat_actions
- state: alarm_state
- type: alarm_type
- user_id: user_id
- project_id: project_id
- type: type
- name: name
@ -320,7 +323,7 @@ Request
.. rest_parameters:: parameters.yaml
- alarm_id: alarm_id
- alarm_id: alarm_id_path
- q: q

View File

@ -2,7 +2,7 @@
{}
# variables in path
alarm_id_1:
alarm_id_path:
description: |
The UUID of the alarm.
in: path
@ -52,12 +52,6 @@ aggregate:
in: query
required: false
type: object
data:
description: |
An alarm within the request body.
in: query
required: false
type: string
direct:
description: |
Indicates whether the samples are POST ed
@ -135,13 +129,6 @@ samples:
in: query
required: false
type: array
state_1:
description: |
The alarm state. A valid value is ``ok``,
``alarm``, or ``insufficient data``.
in: query
required: true
type: string
# variables in body
alarm_actions:
@ -150,12 +137,76 @@ alarm_actions:
in: body
required: true
type: array
alarm_combination_rule:
description: |
The rules for the combination alarm type.
in: body
required: true
type: string
alarm_description:
description: |
Describes the alarm.
in: body
required: true
type: string
alarm_enabled:
description: |
If ``true``, evaluation and actioning is enabled
for the alarm.
in: body
required: true
type: boolean
alarm_id:
description: |
The UUID of the alarm.
in: body
required: true
type: string
alarm_insufficient_data_actions:
description: |
The list of actions that the alarm performs when
the alarm state is ``insufficient_data``.
in: body
required: true
type: array
alarm_name:
description: |
The name of the alarm.
in: body
required: true
type: string
alarm_ok_actions:
description: |
The list of actions that the alarm performs when
the alarm state is ``ok``.
in: body
required: true
type: array
alarm_repeat_actions:
description: |
If set to ``true``, the alarm notifications are
repeated. Otherwise, this value is ``false``.
in: body
required: true
type: boolean
alarm_request:
description: |
An alarm within the request body.
in: body
required: false
type: string
alarm_state:
description: |
The state of the alarm.
in: body
required: true
type: string
alarm_state_timestamp:
description: |
The date and time of the alarm state.
in: body
required: true
type: string
alarm_storage:
description: |
Defines the capabilities for the storage that
@ -164,6 +215,25 @@ alarm_storage:
in: body
required: true
type: object
alarm_threshold_rule:
description: |
The rules for the threshold alarm type.
in: body
required: true
type: string
alarm_timestamp:
description: |
The date and time of the alarm.
in: body
required: true
type: string
alarm_type:
description: |
The type of the alarm, which is either
``threshold`` or ``combination``.
in: body
required: true
type: string
alarms:history:query:complex:
description: |
If ``true``, the complex query capability for
@ -246,13 +316,6 @@ duration_start:
in: body
required: true
type: string
enabled:
description: |
If ``true``, evaluation and actioning is enabled
for the alarm.
in: body
required: true
type: boolean
event_storage:
description: |
If ``true``, the capabilities for the storage
@ -285,13 +348,6 @@ id:
in: body
required: true
type: string
insufficient_data_actions:
description: |
The list of actions that the alarm performs when
the alarm state is ``insufficient_data``.
in: body
required: true
type: array
links:
description: |
A list that contains a self link and associated
@ -377,13 +433,6 @@ name_1:
in: body
required: true
type: string
ok_actions:
description: |
The list of actions that the alarm performs when
the alarm state is ``ok``.
in: body
required: true
type: array
period_end:
description: |
The period end date and time in UTC format.
@ -428,13 +477,6 @@ recorded_at:
in: body
required: true
type: string
repeat_actions:
description: |
If set to ``true``, the alarm notifications are
repeated. Otherwise, this value is ``false``.
in: body
required: true
type: boolean
resource_id:
description: |
The UUID of the resource for which the
@ -518,12 +560,6 @@ state:
in: body
required: true
type: string
state_timestamp:
description: |
The date and time of the alarm state.
in: body
required: true
type: string
statistics:aggregation:selectable:avg:
description: |
If ``true``, the ``avg`` capability is available
@ -648,12 +684,6 @@ sum:
in: body
required: true
type: number
threshold_rule:
description: |
The rules for the threshold alarm type.
in: body
required: true
type: string
timestamp:
description: |
The date and time in UTC format when the
@ -680,13 +710,6 @@ type:
in: body
required: true
type: string
type_1:
description: |
The type of the alarm, which is either
``threshold`` or ``combination``.
in: body
required: true
type: string
type_2:
description: |
The meter type. The type value is gauge, delta,