Blackout
========

Manage alert blackouts. A blackout suppresses alerts for a specific
agent or server for a defined period.

get\_\ *blackout*
-----------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/blackout/ \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/blackout/, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /blackout/``

*List blackouts*

Returns blackout records from pem.blackout (active + future scheduled).
Optionally filter by object_type, object_id, or source. Pass
include_history=true to also return archived records from
pem.blackout_history.

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  object_type,query,integer,false,Filter by object type: 100 (agent) or 200 (server)
  object_id,query,integer,false,Filter by specific object ID
  source,query,string,false,"Filter by source: manual, scheduled, or auto"
  include_history,query,boolean,false,"If true, also include archived blackout records"

Enumerated Values
'''''''''''''''''

.. csv-table::
  :header: Parameter,Value
  :widths: 25,25
  :align: left
  :class: longtable

  object_type,100
  object_type,200
  source,manual
  source,scheduled
  source,auto

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "blackouts": [
       {
         "id": 0,
         "start_time": "2019-08-24T14:15:22Z",
         "end_time": "2019-08-24T14:15:22Z",
         "object_type": 0,
         "object_id": 0,
         "source": "manual",
         "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
         "created_by": "string",
         "created_at": "2019-08-24T14:15:22Z"
       }
     ]
   }

.. raw:: html

   </Details>

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,List of blackout records,Inline

Response Schema
^^^^^^^^^^^^^^^

Status Code **200**

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 12,8,8,8,12
  :align: left
  :class: longtable

  » blackouts,[oneOf],false,none,"Active blackout records. When include_history=true, may also contain BlackoutHistory objects with additional actual_end_time and archived fields."

*oneOf*

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 12,8,8,8,12
  :align: left
  :class: longtable

  »» _anonymous_,:ref:`Alert blackout management<Alert blackout management>` ,false,none,none
  »»» id,integer,false,none,none
  »»» start_time,string(date-time),false,none,none
  »»» end_time,string(date-time)¦null,false,none,none
  »»» object_type,integer,false,none,"100=agent, 200=server"
  »»» object_id,integer,false,none,none
  »»» source,string,false,none,none
  »»» batch_id,string(uuid)¦null,false,none,none
  »»» created_by,string,false,none,none
  »»» created_at,string(date-time),false,none,none

*xor*

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 12,8,8,8,12
  :align: left
  :class: longtable

  »» _anonymous_,:ref:`BlackoutHistory<BlackoutHistory>` ,false,none,Archived blackout record. Returned by GET /blackout/?include_history=true (mixed with live rows) and by GET /blackout/{id} when the id is found only in pem.blackout_history.
  »»» id,integer,false,none,none
  »»» start_time,string(date-time),false,none,none
  »»» scheduled_end_time,string(date-time)¦null,false,none,Original end_time when the blackout was created
  »»» actual_end_time,string(date-time),false,none,When the blackout actually ended
  »»» object_type,integer,false,none,"100=agent, 200=server"
  »»» object_id,integer,false,none,none
  »»» source,string,false,none,none
  »»» batch_id,string(uuid)¦null,false,none,none
  »»» created_by,string,false,none,none
  »»» created_at,string(date-time),false,none,none
  »»» archived,boolean,false,none,Always true for history records

.. _enumerated-values-1:

Enumerated Values
'''''''''''''''''

.. csv-table::
  :header: Property,Value
  :widths: 25,25
  :align: left
  :class: longtable

  source,manual
  source,scheduled
  source,auto
  source,manual
  source,scheduled
  source,auto

..  Note::
   This operation does not require authentication

post\_\ *blackout*
------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X POST https://PEM-SERVER-IP/pem/api/v17/blackout/ \
     -H Content-Type: application/json \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Content-Type: application/json,
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.post(https://PEM-SERVER-IP/pem/api/v17/blackout/, headers = headers)

   print(r.json())

.. code:: javascript

   const inputBody = {
     "start_time": "2019-08-24T14:15:22Z",
     "duration": 1,
     "object_type": 100,
     "object_ids": [
       0
     ]
   };
   const headers = {
     Content-Type:application/json,
     Accept:application/json,
     X-Auth-Token:string
   };

   fetch(https://PEM-SERVER-IP/pem/api/v17/blackout/,
   {
     method: POST,
     body: inputBody,
     headers: headers
   })
   .then(function(res) {
       return res.json();
   }).then(function(body) {
       console.log(body);
   });

``POST /blackout/``

*Create one or more blackouts*

Creates blackout records for specified objects. Multiple object_ids can
be provided to create a batch.

**Body parameter**

.. code:: json

   {
     "start_time": "2019-08-24T14:15:22Z",
     "duration": 1,
     "object_type": 100,
     "object_ids": [0]
   }

.. _parameters-1:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  body,body,object,true,none
  » start_time,body,string(date-time),true,When the blackout starts (ISO 8601)
  » duration,body,integer,true,"Length of the blackout in hours. Must be an integer from 1 to 24, matching the values offered by the Schedule Alert Blackout dialog so that REST-created blackouts render correctly in the UI."
  » object_type,body,integer,true,"100 = agent, 200 = server"
  » object_ids,body,[integer],true,Array of agent or server IDs

.. _enumerated-values-2:

Enumerated Values
'''''''''''''''''

.. csv-table::
  :header: Parameter,Value
  :widths: 25,25
  :align: left
  :class: longtable

  » duration,1
  » duration,2
  » duration,3
  » duration,4
  » duration,5
  » duration,6
  » duration,7
  » duration,8
  » duration,9
  » duration,10
  » duration,11
  » duration,12
  » duration,13
  » duration,14
  » duration,15
  » duration,16
  » duration,17
  » duration,18
  » duration,19
  » duration,20
  » duration,21
  » duration,22
  » duration,23
  » duration,24
  » object_type,100
  » object_type,200

**Example responses**

.. raw:: html

   <Details summary="201 Response">

.. code:: json

   {
     "ids": [0],
     "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20"
   }

.. raw:: html

   </Details>

.. _responses-1:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  201,:ref:`8. Scheduled blackout created (dialog)<8. Scheduled blackout created (dialog)>` ,Blackout(s) created successfully,Inline
  428, `Precondition Required <https://tools.ietf.org/html/rfc6585#section-3>`__ ,"Validation error (invalid input, constraint violation)",None

.. _response-schema-1:

Response Schema
^^^^^^^^^^^^^^^

Status Code **201**

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 12,8,8,8,12
  :align: left
  :class: longtable

  » ids,[integer],false,none,none
  » batch_id,string(uuid),false,none,none

..  Note::
   This operation does not require authentication

get\_\ *blackout*\ {blackout_id}
--------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id}", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /blackout/{blackout_id}``

*Get a specific blackout*

Returns a blackout record. If the id is not present in pem.blackout, the
handler falls back to pem.blackout_history and returns the archived
record (distinguishable by “archived”: true and the presence of
actual_end_time / scheduled_end_time fields). Returns 404 if the id is
not found in either table.

.. _parameters-2:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  blackout_id,path,integer,true,none

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "id": 0,
     "start_time": "2019-08-24T14:15:22Z",
     "end_time": "2019-08-24T14:15:22Z",
     "object_type": 0,
     "object_id": 0,
     "source": "manual",
     "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
     "created_by": "string",
     "created_at": "2019-08-24T14:15:22Z"
   }

.. raw:: html

   </Details>

.. _responses-2:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,"Blackout record. May be a live row from pem.blackout (Blackout schema) or, when the id is found only in pem.blackout_history, an archived row (BlackoutHistory schema with archived=true).",Inline
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,Blackout not found,None

.. _response-schema-2:

Response Schema
^^^^^^^^^^^^^^^

.. _enumerated-values-3:

Enumerated Values
'''''''''''''''''

.. csv-table::
  :header: Property,Value
  :widths: 25,25
  :align: left
  :class: longtable

  source,manual
  source,scheduled
  source,auto
  source,manual
  source,scheduled
  source,auto

..  Note::
   This operation does not require authentication

delete\_\ *blackout*\ {blackout_id}
-----------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X DELETE https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.delete(https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/{blackout_id}", {
     method: "DELETE",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``DELETE /blackout/{blackout_id}``

*End a blackout*

Ends (archives) a blackout record, moving it to history.

.. _parameters-3:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  blackout_id,path,integer,true,none

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "id": 0,
     "deleted": true,
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-3:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Blackout ended and archived,Inline
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,Blackout not found,None

.. _response-schema-3:

Response Schema
^^^^^^^^^^^^^^^

Status Code **200**

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 12,8,8,8,12
  :align: left
  :class: longtable

  » id,integer,false,none,ID of the ended blackout
  » deleted,boolean,false,none,Always true on success
  » warnings,\ :ref:`Platform Compatibility <Blackout>` ],false,none,"Optional non-fatal warnings — present only when the archive INSERT affected fewer rows than the DELETE returned (e.g. RLS or trigger drift on pem.blackout_history). Each warning carries the BlackoutId, ArchivedCount, and ExpectedArchived for diagnostics."
  »» code,string,true,none,"Stable warning identifier. Known codes: `manual_post_state_unavailable` (toggle response-shape SELECT failed after COMMIT), `in_blackout_post_state_unavailable` (likewise for the synced flag), `flag_select_failed` (status helper fell back to records-derived in_blackout), `history_archive_incomplete` (DELETE archived fewer rows than expected — investigate RLS / triggers on pem.blackout_history)."
  »» message,string,true,none,none

..  Note::
   This operation does not require authentication

get\_\ *blackout_server*\ {sid}
-------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /blackout/server/{sid}``

*Get blackout status for a server*

Returns the synced alert_blackout flag and the breakdown of active
records by source for the specified server.

.. _parameters-4:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  sid,path,integer,true,Server id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "object_type": 100,
     "object_id": 0,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "scheduled": [
       {
         "id": 0,
         "start_time": "2019-08-24T14:15:22Z",
         "end_time": "2019-08-24T14:15:22Z",
         "object_type": 0,
         "object_id": 0,
         "source": "manual",
         "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
         "created_by": "string",
         "created_at": "2019-08-24T14:15:22Z"
       }
     ],
     "auto": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-4:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Blackout status for the server.,:ref:`ObjectBlackoutStatus<ObjectBlackoutStatus>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No server with the given id exists.,None
  428, `Precondition Required <https://tools.ietf.org/html/rfc6585#section-3>`__ ,The server id was not provided in the path.,None

..  Note::
   This operation does not require authentication

put\_\ *blackout_server*\ {sid}
-------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X PUT https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.put(https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}", {
     method: "PUT",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``PUT /blackout/server/{sid}``

*Enable manual blackout for a server*

Idempotent. Inserts a manual indefinite record if none exists for this
server; otherwise returns the existing record with changed=false. Only
one active manual record per object is allowed (enforced by
pem.idx_blackout_one_active_indefinite).

.. _parameters-5:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  sid,path,integer,true,Server id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "changed": true,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "ended_records": [
       {
         "id": 0,
         "source": "manual",
         "scheduled_end": "2019-08-24T14:15:22Z",
         "ended_early": true
       }
     ],
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-5:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Toggle result. changed=true on first enable; changed=false on idempotent no-op.,:ref:`ObjectBlackoutToggleResult<ObjectBlackoutToggleResult>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No object with the given id exists.,None

..  Note::
   This operation does not require authentication

delete\_\ *blackout_server*\ {sid}
----------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X DELETE https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.delete(https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/server/{sid}", {
     method: "DELETE",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``DELETE /blackout/server/{sid}``

*End all blackouts on a server*

Idempotent. Ends every active blackout record on this server regardless
of source (manual + scheduled + auto). Matches the dashboard checkbox
unchecking-an-already-active behaviour: the user intent is “alerts back
on now”. Records that had started are archived to pem.blackout_history;
future-scheduled records are simply deleted.

.. _parameters-6:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  sid,path,integer,true,Server id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "changed": true,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "ended_records": [
       {
         "id": 0,
         "source": "manual",
         "scheduled_end": "2019-08-24T14:15:22Z",
         "ended_early": true
       }
     ],
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-6:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Toggle result. changed=true when at least one record was ended; changed=false on idempotent no-op.,:ref:`ObjectBlackoutToggleResult<ObjectBlackoutToggleResult>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No object with the given id exists.,None

..  Note::
   This operation does not require authentication

get\_\ *blackout_agent*\ {aid}
------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /blackout/agent/{aid}``

*Get blackout status for an agent*

Returns the synced alert_blackout flag and the breakdown of active
records by source for the specified agent.

.. _parameters-7:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  aid,path,integer,true,Agent id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "object_type": 100,
     "object_id": 0,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "scheduled": [
       {
         "id": 0,
         "start_time": "2019-08-24T14:15:22Z",
         "end_time": "2019-08-24T14:15:22Z",
         "object_type": 0,
         "object_id": 0,
         "source": "manual",
         "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
         "created_by": "string",
         "created_at": "2019-08-24T14:15:22Z"
       }
     ],
     "auto": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-7:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Blackout status for the agent.,:ref:`ObjectBlackoutStatus<ObjectBlackoutStatus>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No agent with the given id exists.,None
  428, `Precondition Required <https://tools.ietf.org/html/rfc6585#section-3>`__ ,The agent id was not provided in the path.,None

..  Note::
   This operation does not require authentication

put\_\ *blackout_agent*\ {aid}
------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X PUT https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.put(https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}", {
     method: "PUT",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``PUT /blackout/agent/{aid}``

*Enable manual blackout for an agent*

Idempotent. Inserts a manual indefinite record if none exists for this
agent; otherwise returns the existing record with changed=false. Only
one active manual record per object is allowed (enforced by
pem.idx_blackout_one_active_indefinite).

.. _parameters-8:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  aid,path,integer,true,Agent id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "changed": true,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "ended_records": [
       {
         "id": 0,
         "source": "manual",
         "scheduled_end": "2019-08-24T14:15:22Z",
         "ended_early": true
       }
     ],
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-8:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Toggle result. changed=true on first enable; changed=false on idempotent no-op.,:ref:`ObjectBlackoutToggleResult<ObjectBlackoutToggleResult>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No object with the given id exists.,None

..  Note::
   This operation does not require authentication

delete\_\ *blackout_agent*\ {aid}
---------------------------------

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X DELETE https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.delete(https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/blackout/agent/{aid}", {
     method: "DELETE",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``DELETE /blackout/agent/{aid}``

*End all blackouts on an agent*

Idempotent. Ends every active blackout record on this agent regardless
of source (manual + scheduled + auto). Matches the dashboard checkbox
unchecking-an-already-active behaviour: the user intent is “alerts back
on now”. Records that had started are archived to pem.blackout_history;
future-scheduled records are simply deleted.

.. _parameters-9:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,Token for authentication
  aid,path,integer,true,Agent id

**Example responses**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "changed": true,
     "in_blackout": true,
     "manual": {
       "id": 0,
       "start_time": "2019-08-24T14:15:22Z",
       "end_time": "2019-08-24T14:15:22Z",
       "object_type": 0,
       "object_id": 0,
       "source": "manual",
       "batch_id": "4da22c97-b7d5-4e31-8c3a-03870ebc7b20",
       "created_by": "string",
       "created_at": "2019-08-24T14:15:22Z"
     },
     "ended_records": [
       {
         "id": 0,
         "source": "manual",
         "scheduled_end": "2019-08-24T14:15:22Z",
         "ended_early": true
       }
     ],
     "warnings": [
       {
         "code": "string",
         "message": "string"
       }
     ]
   }

.. raw:: html

   </Details>

.. _responses-9:

Responses
^^^^^^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Toggle result. changed=true when at least one record was ended; changed=false on idempotent no-op.,:ref:`ObjectBlackoutToggleResult<ObjectBlackoutToggleResult>` 
  404, `Not Found <https://tools.ietf.org/html/rfc7231#section-6.5.4>`__ ,No object with the given id exists.,None

..  Note::
   This operation does not require authentication
