Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Mon 4791 bulk actions ack downtime #8475

Merged
merged 12 commits into from
Mar 30, 2020
4 changes: 3 additions & 1 deletion config/Modules/Centreon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ jms_serializer:
centreon:
namespace_prefix: "Centreon\\Domain"
path: '%kernel.root_dir%/../config/packages/serializer/Centreon'

application:
namespace_prefix: "Centreon\\Application"
path: '%kernel.root_dir%/../config/packages/serializer/Application'
parameters:
api.header: "Api-Version"
api.version.latest: "2.0"
Expand Down
10 changes: 10 additions & 0 deletions config/packages/serializer/Application/Request.AckRequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Centreon\Application\Request\AckRequest:
properties:
acknowledgement:
type: Centreon\Domain\Acknowledgement\Acknowledgement
groups:
- 'bulk_acknowledge'
resources:
type: array<Centreon\Domain\Monitoring\Resource>
groups:
- 'bulk_acknowledge'
10 changes: 10 additions & 0 deletions config/packages/serializer/Application/Request.DowntimeRequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Centreon\Application\Request\DowntimeRequest:
properties:
downtime:
type: Centreon\Domain\Downtime\Downtime
groups:
- 'resource_dt'
resources:
type: array<Centreon\Domain\Monitoring\Resource>
groups:
- 'resource_dt'
6 changes: 6 additions & 0 deletions config/packages/serializer/Centreon/Downtime.Downtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Centreon\Domain\Downtime\Downtime:
- 'Default'
- 'downtime_main'
- 'downtime_event_list'
- 'resource_dt'
deletionTime:
type: DateTime
groups:
Expand All @@ -66,12 +67,14 @@ Centreon\Domain\Downtime\Downtime:
- 'Default'
- 'downtime_main'
- 'downtime_event_list'
- 'resource_dt'
endTime:
type: DateTime
groups:
- 'Default'
- 'downtime_main'
- 'downtime_event_list'
- 'resource_dt'
internalId:
type: int
isFixed:
Expand All @@ -80,6 +83,7 @@ Centreon\Domain\Downtime\Downtime:
- 'Default'
- 'downtime_main'
- 'downtime_event_list'
- 'resource_dt'
pollerId:
type: int
groups:
Expand All @@ -91,6 +95,7 @@ Centreon\Domain\Downtime\Downtime:
- 'Default'
- 'downtime_main'
- 'downtime_event_list'
- 'resource_dt'
actualStartTime:
type: DateTime
groups:
Expand All @@ -113,3 +118,4 @@ Centreon\Domain\Downtime\Downtime:
type: bool
groups:
- 'downtime_host_add'
- 'resource_dt'
31 changes: 24 additions & 7 deletions config/packages/validator/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ Centreon\Domain\Acknowledgement\Acknowledgement:
comment:
- Type:
type: string
- NotNull: ~
groups: [ack_resource]
- NotNull:
groups: [ack_resource]
isNotifyContacts:
- Type:
type: boolean
- NotNull: ~
groups: [ack_resource]
- NotNull:
groups: [ack_resource]
isPersistentComment:
- Type:
type: boolean
Expand Down Expand Up @@ -35,33 +39,42 @@ Centreon\Domain\Acknowledgement\Acknowledgement:
withServices:
- Type:
type: boolean
groups: [add_host_acks, add_host_ack]
groups: [add_host_acks, add_host_ack, ack_resource]

# Used to validate the Downtime entity
Centreon\Domain\Downtime\Downtime:
properties:
startTime:
- Type:
type: DateTime
- NotNull: ~
groups: [resource_dt]
- NotNull:
groups: [resource_dt]
endTime:
- Type:
type: DateTime
- NotNull: ~
groups: [resource_dt]
- NotNull:
groups: [resource_dt]
isFixed:
- Type:
type: boolean
groups: [resource_dt]
duration:
- Type:
type: integer
- NotNull: ~
groups: [resource_dt]
- NotNull:
groups: [resource_dt]
authorId:
- Type:
type: integer
comment:
- Type:
type: string
- NotNull: ~
groups: [resource_dt]
- NotNull:
groups: [resource_dt]
hostId:
- Type:
type: integer
Expand All @@ -71,6 +84,10 @@ Centreon\Domain\Downtime\Downtime:
pollerId:
- Type:
type: integer
withServices:
- Type:
type: boolean
groups: [resource_dt]

# Used to validate the Check entity
Centreon\Domain\Check\Check:
Expand Down
10 changes: 8 additions & 2 deletions config/routes/Centreon/acknowledgement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ centreon_application_acknowledgement_findoneacknowledgement:
acknowledgementId: '\d+'
controller: 'Centreon\Application\Controller\AcknowledgementController::findOneAcknowledgement'

centreon_application_acknowledgement_disacknowledge_resources:
centreon_application_monitoring_disacknowledge_resources:
methods: POST
path: /monitoring/acknowledgements/disacknowledge
path: /monitoring/resources/disacknowledge
controller: 'Centreon\Application\Controller\AcknowledgementController::massDisacknowledgeResources'
condition: "request.attributes.get('version') >= 2.0"

centreon_application_monitoring_acknowledge_resources:
methods: POST
path: /monitoring/resources/acknowledge
controller: 'Centreon\Application\Controller\AcknowledgementController::massAcknowledgeResources'
condition: "request.attributes.get('version') >= 2.0"
6 changes: 6 additions & 0 deletions config/routes/Centreon/downtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ monitoring.downtime.cancelOneDowntime:
downtimeId: '\d+'
controller: 'Centreon\Application\Controller\DowntimeController::cancelOneDowntime'
condition: "request.attributes.get('version.is_beta') == true"

centreon_application_monitoring_resources_downtime:
methods: POST
path: /monitoring/resources/downtime
controller: 'Centreon\Application\Controller\DowntimeController::massDowntimeResources'
condition: "request.attributes.get('version') >= 2.0"
117 changes: 108 additions & 9 deletions doc/API/centreon-api-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ paths:
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalServerError'
/monitoring/acknowledgements/disacknowledge:
/monitoring/resources/disacknowledge:
post:
tags:
- Acknowledgement
Expand All @@ -602,14 +602,7 @@ paths:
content:
application/json:
schema:
type: object
properties:
body:
type: array
items:
allOf:
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Host'
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Service'
$ref: '#/components/schemas/Acknowledgment.Disacknowledge.Bulk'
responses:
'204':
description: "OK"
Expand Down Expand Up @@ -1679,6 +1672,42 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/monitoring/resources/acknowledge:
post:
tags:
- Acknowledgement
summary: "Acknowledge multiple resources"
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Acknowledgment.Bulk'
responses:
'204':
description: "Command Sent"
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalServerError'
/monitoring/resources/downtime:
post:
tags:
- Downtime
summary: "Set downtime for multiple resources"
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Downtime.Bulk'
responses:
'204':
description: "Command Sent"
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalServerError'
components:
securitySchemes:
Token:
Expand Down Expand Up @@ -2162,6 +2191,38 @@ components:
type: boolean
description: "Indicates whether the server configuration is activated"
example: true
Acknowledgement.Resource:
type: object
properties:
comment:
type: string
description: "Short description of the acknowledgement"
example: "Acknowledged by admin"
with_services:
type: boolean
description: "Indicates whether we should add the downtime on the host-related services"
example: true
is_notify_contacts:
type: boolean
description: "Indicates whether notification is sent to the contacts linked to the host or service"
example: false
Acknowledgment.Bulk:
type: object
properties:
acknowledgment:
$ref: '#/components/schemas/Acknowledgement.Resource'
resources:
type: array
items:
allOf:
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Host'
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Service'
Acknowledgment.Disacknowledge.Bulk:
type: array
items:
allOf:
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Host'
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Service'
Acknowledgement.Host:
type: object
properties:
Expand Down Expand Up @@ -2393,6 +2454,44 @@ components:
type: integer
description: "ID of the service on which the downtime is set"
example : 5
Downtime.Resource:
type: object
properties:
comment:
type: string
description: "Short description of the downtime"
example: "Downtime set by admin"
with_services:
type: boolean
description: "Indicates whether we should add the downtime on the host-related services"
example: true
is_fixed:
type: boolean
description: "Indicates whether the downtime is fixed"
example: true
duration:
type: integer
description: "Downtime duration in seconds"
example: 7200
start_time:
type: string
format: date-time
description: "Scheduled start date of the downtime (ISO8601)"
end_time:
type: string
format: date-time
description: "Scheduled end date of the downtime (ISO8601)"
Downtime.Bulk:
type: object
properties:
downtime:
$ref: '#/components/schemas/Downtime.Resource'
resources:
type: array
items:
allOf:
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Host'
- $ref: '#/components/schemas/Monitoring.Resource.Disacknowledge.Service'
Check.Host:
type: object
properties:
Expand Down
Loading