EDB Postgres Enterprise Manager REST APIs v1.0.0
================================================

**EDB Postgres Enterprise Manager** uses a token-based authentication
mechanism to allow access to exposed REST APIs.

PEM uses tokens for authentication purposes. To generate a token, please
refer the section Token. After receiving a token string, you should
include the token string in the ‘X-Auth-Token’ header when calling any
resources except https://PEM-SERVER-IP/api/token/.

**NOTE:**

- **EDB Postgres Enterprise Manager** *is referred as* **PEM** *in this
  documentation.*

- **PEM** \*uses self-certified SSL certificates, so you may encounter
  errors such as ‘SSL certificate problem: self signed certificate’. You
  may need to use an ‘insecure’ connection to connect to the server.

**Rest api versions:**

- v1

- v2

- v3

- v4

- v5

- v6

- v7

- v8

- v9

- v10

- v11

- v12

- v13

- v14 (Current)

Base URLs:

- https://PEM-SERVER-IP/api

Email: EnterpriseDB Web: EnterpriseDB License: Limited Use Software
License Agreement

Token
-----

A string generated and used by PEM REST APIs for authentication purposes

TokenGeneration
^^^^^^^^^^^^^^^

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X POST https://PEM-SERVER-IP/api/token/ \
     -H Content-Type: application/json \
     -H Accept: application/json

.. code:: python

   import requests
   headers = {
     Content-Type: application/json,
     Accept: application/json
   }

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

   print(r.json())

.. code:: javascript

   const inputBody = {
     "username": "string",
     "password": "string"
   };
   const headers = {
     Content-Type:application/json,
     Accept:application/json
   };

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

``POST /token/``

- Generate a token for authentication.\*

This URL creates a token to be used by the other REST APIs exposed by
PEM. You must provide a valid username and password, which will be
validated during the process.

The token will be valid for 20 mins.

**Body parameter**

.. code:: json

   {
     "username": "string",
     "password": "string"
   }

Parameters
^^^^^^^^^^

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

  body,body,object,true,Creates the token using the /token/ URL first.
  » username,body,string,true,"Validates username, which has pem_user role."
  » password,body,string,true,Password for the username

**Example responses**

.. raw:: html

   <Details summary="201 Response">

.. code:: json

   {
     "issuedAt": "2019-08-24T14:15:22Z",
     "expiresAt": "2019-08-24T14:15:22Z",
     "schema_version": 0,
     "backend_schema_version": 0,
     "version_long": 0,
     "version": "string",
     "supported_api_versions": [
       "string"
     ],
     "deprecated_api_versions": [
       "string"
     ]
   }

.. raw:: html

   </Details>

Responses
^^^^^^^^^

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

  201, `Created <https://tools.ietf.org/html/rfc7231#section-6.3.2>`__ ,Token was created and can be found as 'X-Subject-Token' in the response header.,Inline
  401, `Unauthorized <https://tools.ietf.org/html/rfc7235#section-3.1>`__ ,The given information is not valid.,None
  500, `Internal Server Error <https://tools.ietf.org/html/rfc7231#section-6.6.1>`__ ,Something went wrong.,None
  503, `Service Unavailable <https://tools.ietf.org/html/rfc7231#section-6.6.4>`__ ,PEM backend database server is down. Service is not available now.,None

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

Status Code **201**

- Contains information related to when the token was generated and when
  it expired.\*

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

  » issuedAt,string(date-time),false,none,Token was generated at this time.
  » expiresAt,string(date-time),false,none,Provides date and time when the token expires.
  » schema_version,integer,false,none,Application-supported schema version
  » backend_schema_version,integer,false,none,Backend database schema version
  » version_long,integer,false,none,Version represented in long format
  » version,string,false,none,String reprentation of the PEM version
  » supported_api_versions,[string],false,none,List of supported API versions
  » deprecated_api_versions,[string],false,none,List of deprecated API versions

Response Headers
^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Status,Header,Type,Format,Description
  :widths: auto
  :align: left
  :class: longtable

  201,X-Subject-Token,string,"","Returns the new token, which can be used with REST APIs for further operations"

..  Note::
   This operation does not require authentication

delete\_\ *token*
^^^^^^^^^^^^^^^^^

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X DELETE https://PEM-SERVER-IP/api/token/ \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     X-Auth-Token: string
   }

   r = requests.delete(https://PEM-SERVER-IP/api/token/, headers = headers)

   print(r.json())

.. code:: javascript


   const headers = {
     X-Auth-Token:string
   };

   fetch(https://PEM-SERVER-IP/api/token/,
   {
     method: DELETE,

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

``DELETE /token/``

- Release the token.\*

Invalidates the token. It will no longer be available for further
operations.

.. _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 of authorization

**Example responses**

.. _responses-1:

Responses
^^^^^^^^^

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

  204, `No Content <https://tools.ietf.org/html/rfc7231#section-6.3.5>`__ ,Successfully released the token from PEM.,""
  This token can not be used for any further operations.,None,"",""

.. _response-schema-1:

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

..  Note::
   This operation does not require authentication

.. toctree::
  :maxdepth: 3

  Using--pem_rest_api--v14--index
