5.7.1. Overview of the API interface

The API allows:
  • Display the list by theme of existing endpoints

  • To be able to filter this list

  • Know all the information of each endpoint

  • To run the endpoint,

  • Know its curl command

  • Know its URL request

Note

The API is named swagger.

Access to this interface is available in the title bar of the main interface.

../../_images/HOME_REP2.PNG
After pressing the `API` button (4) of the title bar, the following screen is displayed.
The window includes:
../../_images/GCENTER-API-01.PNG

Item

Description

1

`Schemes`: parameter indicating the protocol used (HTTPS)

2

Current account name: here account administrator

3

`Django Logout` button: allows to exit the API

4

Button `Authorize`: allows to define the necessary authentication in curl commands

5

Endpoints are sorted by theme (tag)

6

Filtration field: allows to filter themes

In this interface, all API endpoints are available and usable.
The use of the different endpoints is subject to the same rights as in the GCenter web interfaces.

Note

A feature requiring administrator rights cannot be used by a user with only operator rights.


5.7.1.1. Detail for an endpoint

The information displayed for an endpoint is as follows:

../../_images/GCENTER-API-02.PNG

Item

Description

1

Title line. It includes the action (here GET), the name of the endpoint (here/api/gcaps), the accesses (here Administrators and Opertors), the description of the endpoint

2

`Try it out` button: runs the endpoint with current parameters

8

Field `Parameters`: displays the optional or mandatory parameters to execute the query. For mandatory parameters, refer to the box (6).
This area includes the parameters needed for the selected API. In this example, there are two: the page number and the number of results per page.

7

  • Parameter `page`: enter a page number. This example depends on the API

6

  • `Responses` area: area that displays information based on whether or not the `Try it out` button has been activated

Note

If a parameter is mandatory, an asterisk with `required` is displayed.

Note

In this screen, it is not possible to enter parameters. To do this, you must execute the query.


5.7.1.1.1. Zone `Responses` if the `Try it out` button is not activated

If the `Try it out` button is not activated then the `Responses` zone contains the information for the expected response:

../../_images/GCENTER-API-02.PNG

Item

Description

5

Link `Model`: by clicking on this text, the window (3) displays the model of the expected answer

4

Link `Example Value`: by clicking on this text, the window (3) displays an example of the expected response with values for example.
Values are, for type integer (value 0), for type string (value = string), for type boolean (value = true)

3

Field of view: contains the content selected by the active option (4) or (5).
An example of content is given below.

5.7.1.1.1.1. Sample Output Template

The output model gives the structure of the data that will be displayed as output after execution of the request.

../../_images/GCENTER-API-04.PNG

Item

Description

1

`count`: number. For this parameter, its characteristics are indicated (integer).

2

`results`: expected results

3

`GcapReadOnly`: GCap settings
For each parameter (id, fqdn,is_paired...), the characteristics are displayed

5.7.1.1.2. Example with default values

In this example, the information is displayed with the following defaults:

  • Parameters of type integer are displayed with `0`

  • Parameters of type string are displayed with `string` text

  • Parameters of type boolean are displayed with `true` text

../../_images/GCENTER-API-03.PNG

The marking is the same as in the output model.


5.7.1.1.3. Zone `Responses` if the `Try it out button is activated

After clicking the `Try it out` button, the parameter entry area is activated.
The following screen is displayed:
../../_images/GCENTER-API-05.PNG

Item

Description

1

`Execute` button: to execute the query with the current parameters

2

`Cancel` button: cancels the request

3

`Responses` zone has not changed

After clicking the `Execute` button, the query is launched and the next window is displayed.

../../_images/GCENTER-API-06.PNG

Benchmark

Description

1

`Clear` button: to return to the state before execution

2

Display Area `Curl`: displays the Curl query

3

Display area `URL`: displays the URL request

4

Display Area `Server response`: displays the server response to the request. It includes the following

5

  • `Code`: if code 200 then execution is ok.
    If the message `code 400 Undocumented Error Bad Request` is displayed, verify that the required parameters are entered.

6

  • `Responses body`: in this section the information requested is displayed

7

  • `Responses headers`: field detailing the answer header

8

  • `Responses headers`: value in ms of the duration of the request