Przeglądaj źródła

Add services API to api-refs

Daniel Vincze 5 lat temu
rodzic
commit
4f70416270

+ 9 - 0
coriolis/api-refs/api_samples/service/service-create-req.json

@@ -0,0 +1,9 @@
+{
+    "service": {
+        "host": "coriolis-worker-ONbgH1NV",
+        "binary": "coriolis-worker",
+        "topic": "coriolis_worker",
+        "mapped_regions": ["5e31066c-3512-4e8d-9e68-0a5de3d35c5f"],
+        "enabled": false
+    }
+}

+ 95 - 0
coriolis/api-refs/api_samples/service/service-create-resp.json

@@ -0,0 +1,95 @@
+{
+    "service": {
+        "created_at": "2021-02-01T11:19:44.000000",
+        "updated_at": null,
+        "deleted_at": null,
+        "deleted": "0",
+        "id": "07c3343b-970d-437a-b670-e88e78dab3fc",
+        "host": "coriolis-worker-ONbgH1NV",
+        "binary": "coriolis-worker",
+        "topic": "coriolis_worker",
+        "enabled": false,
+        "status": "UP",
+        "providers": {
+            "openstack": {
+                "types": [
+                    4,
+                    8,
+                    16,
+                    32,
+                    64,
+                    128,
+                    256,
+                    512,
+                    4096,
+                    16384,
+                    32768,
+                    65536,
+                    131072,
+                    262144,
+                    524288,
+                    1048576
+                ]
+            },
+            // ...
+        },
+        "specs": {
+            "application": "coriolis-worker",
+            "packages": [
+                "adal==1.2.6",
+                "alembic==1.5.2"
+                // ...
+            ],
+            "os_info": [
+                "NAME=\"Ubuntu\"",
+                "VERSION=\"18.04.5 LTS (Bionic Beaver)\"",
+                "ID=ubuntu",
+                "ID_LIKE=debian",
+                "PRETTY_NAME=\"Ubuntu 18.04.5 LTS\"",
+                "VERSION_ID=\"18.04\"",
+                "HOME_URL=\"https://www.ubuntu.com/\"",
+                "SUPPORT_URL=\"https://help.ubuntu.com/\"",
+                "BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"",
+                "PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"",
+                "VERSION_CODENAME=bionic",
+                "UBUNTU_CODENAME=bionic",
+                ""
+            ],
+            "hostname": "coriolis-worker-ONbgH1NV",
+            "ip_addresses": [
+                {
+                    "eth0": {
+                        "ipv4": [
+                            {
+                                "addr": "10.107.9.58",
+                                "netmask": "255.255.254.0",
+                                "broadcast": "10.107.9.255"
+                            }
+                        ],
+                        "ipv6": [
+                            {
+                                "addr": "fe80::250:56ff:fe89:91f4%eth0",
+                                "netmask": "ffff:ffff:ffff:ffff::/64"
+                            }
+                        ]
+                    }
+                },
+                {
+                    "docker0": {
+                        "ipv4": [
+                            {
+                                "addr": "172.17.0.1",
+                                "netmask": "255.255.0.0",
+                                "broadcast": "172.17.255.255"
+                            }
+                        ],
+                        "ipv6": null
+                    }
+                }
+            ]
+        },
+        "mapped_regions": [
+            "5e31066c-3512-4e8d-9e68-0a5de3d35c5f"
+        ]
+    }
+}

+ 97 - 0
coriolis/api-refs/api_samples/service/service-list-resp.json

@@ -0,0 +1,97 @@
+{
+    "services": [
+        {
+            "created_at": "2021-02-01T11:19:44.000000",
+            "updated_at": null,
+            "deleted_at": null,
+            "deleted": "0",
+            "id": "07c3343b-970d-437a-b670-e88e78dab3fc",
+            "host": "coriolis-worker-ONbgH1NV",
+            "binary": "coriolis-worker",
+            "topic": "coriolis_worker",
+            "enabled": false,
+            "status": "UP",
+            "providers": {
+                "openstack": {
+                    "types": [
+                        4,
+                        8,
+                        16,
+                        32,
+                        64,
+                        128,
+                        256,
+                        512,
+                        4096,
+                        16384,
+                        32768,
+                        65536,
+                        131072,
+                        262144,
+                        524288,
+                        1048576
+                    ]
+                },
+                // ...
+            },
+            "specs": {
+                "application": "coriolis-worker",
+                "packages": [
+                    "adal==1.2.6",
+                    "alembic==1.5.2",
+                    // ...
+                ],
+                "os_info": [
+                    "NAME=\"Ubuntu\"",
+                    "VERSION=\"18.04.5 LTS (Bionic Beaver)\"",
+                    "ID=ubuntu",
+                    "ID_LIKE=debian",
+                    "PRETTY_NAME=\"Ubuntu 18.04.5 LTS\"",
+                    "VERSION_ID=\"18.04\"",
+                    "HOME_URL=\"https://www.ubuntu.com/\"",
+                    "SUPPORT_URL=\"https://help.ubuntu.com/\"",
+                    "BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"",
+                    "PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"",
+                    "VERSION_CODENAME=bionic",
+                    "UBUNTU_CODENAME=bionic",
+                    ""
+                ],
+                "hostname": "coriolis-worker-ONbgH1NV",
+                "ip_addresses": [
+                    {
+                        "eth0": {
+                            "ipv4": [
+                                {
+                                    "addr": "10.107.9.58",
+                                    "netmask": "255.255.254.0",
+                                    "broadcast": "10.107.9.255"
+                                }
+                            ],
+                            "ipv6": [
+                                {
+                                    "addr": "fe80::250:56ff:fe89:91f4%eth0",
+                                    "netmask": "ffff:ffff:ffff:ffff::/64"
+                                }
+                            ]
+                        }
+                    },
+                    {
+                        "docker0": {
+                            "ipv4": [
+                                {
+                                    "addr": "172.17.0.1",
+                                    "netmask": "255.255.0.0",
+                                    "broadcast": "172.17.255.255"
+                                }
+                            ],
+                            "ipv6": null
+                        }
+                    }
+                ]
+            },
+            "mapped_regions": [
+                "5e31066c-3512-4e8d-9e68-0a5de3d35c5f"
+            ]
+        }
+    ]
+}

+ 95 - 0
coriolis/api-refs/api_samples/service/service-show-resp.json

@@ -0,0 +1,95 @@
+{
+    "service": {
+        "created_at": "2021-02-01T11:19:44.000000",
+        "updated_at": null,
+        "deleted_at": null,
+        "deleted": "0",
+        "id": "07c3343b-970d-437a-b670-e88e78dab3fc",
+        "host": "coriolis-worker-ONbgH1NV",
+        "binary": "coriolis-worker",
+        "topic": "coriolis_worker",
+        "enabled": false,
+        "status": "UP",
+        "providers": {
+            "openstack": {
+                "types": [
+                    4,
+                    8,
+                    16,
+                    32,
+                    64,
+                    128,
+                    256,
+                    512,
+                    4096,
+                    16384,
+                    32768,
+                    65536,
+                    131072,
+                    262144,
+                    524288,
+                    1048576
+                ]
+            },
+            // ...
+        },
+        "specs": {
+            "application": "coriolis-worker",
+            "packages": [
+                "adal==1.2.6",
+                "alembic==1.5.2",
+                // ...
+            ],
+            "os_info": [
+                "NAME=\"Ubuntu\"",
+                "VERSION=\"18.04.5 LTS (Bionic Beaver)\"",
+                "ID=ubuntu",
+                "ID_LIKE=debian",
+                "PRETTY_NAME=\"Ubuntu 18.04.5 LTS\"",
+                "VERSION_ID=\"18.04\"",
+                "HOME_URL=\"https://www.ubuntu.com/\"",
+                "SUPPORT_URL=\"https://help.ubuntu.com/\"",
+                "BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"",
+                "PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"",
+                "VERSION_CODENAME=bionic",
+                "UBUNTU_CODENAME=bionic",
+                ""
+            ],
+            "hostname": "coriolis-worker-ONbgH1NV",
+            "ip_addresses": [
+                {
+                    "eth0": {
+                        "ipv4": [
+                            {
+                                "addr": "10.107.9.58",
+                                "netmask": "255.255.254.0",
+                                "broadcast": "10.107.9.255"
+                            }
+                        ],
+                        "ipv6": [
+                            {
+                                "addr": "fe80::250:56ff:fe89:91f4%eth0",
+                                "netmask": "ffff:ffff:ffff:ffff::/64"
+                            }
+                        ]
+                    }
+                },
+                {
+                    "docker0": {
+                        "ipv4": [
+                            {
+                                "addr": "172.17.0.1",
+                                "netmask": "255.255.0.0",
+                                "broadcast": "172.17.255.255"
+                            }
+                        ],
+                        "ipv6": null
+                    }
+                }
+            ]
+        },
+        "mapped_regions": [
+            "5e31066c-3512-4e8d-9e68-0a5de3d35c5f"
+        ]
+    }
+}

+ 6 - 0
coriolis/api-refs/api_samples/service/service-update-req.json

@@ -0,0 +1,6 @@
+{
+    "service": {
+        "enabled": true,
+        "mapped_regions": ["5e31066c-3512-4e8d-9e68-0a5de3d35c5f"]
+    }
+}

+ 95 - 0
coriolis/api-refs/api_samples/service/service-update-resp.json

@@ -0,0 +1,95 @@
+{
+    "service": {
+        "created_at": "2021-02-01T11:19:44.000000",
+        "updated_at": "2021-02-01T11:42:04.000000",
+        "deleted_at": null,
+        "deleted": "0",
+        "id": "07c3343b-970d-437a-b670-e88e78dab3fc",
+        "host": "coriolis-worker-ONbgH1NV",
+        "binary": "coriolis-worker",
+        "topic": "coriolis_worker",
+        "enabled": true,
+        "status": "UP",
+        "providers": {
+            "openstack": {
+                "types": [
+                    4,
+                    8,
+                    16,
+                    32,
+                    64,
+                    128,
+                    256,
+                    512,
+                    4096,
+                    16384,
+                    32768,
+                    65536,
+                    131072,
+                    262144,
+                    524288,
+                    1048576
+                ]
+            },
+            // ...
+        },
+        "specs": {
+            "application": "coriolis-worker",
+            "packages": [
+                "adal==1.2.6",
+                "alembic==1.5.2",
+                // ...
+            ],
+            "os_info": [
+                "NAME=\"Ubuntu\"",
+                "VERSION=\"18.04.5 LTS (Bionic Beaver)\"",
+                "ID=ubuntu",
+                "ID_LIKE=debian",
+                "PRETTY_NAME=\"Ubuntu 18.04.5 LTS\"",
+                "VERSION_ID=\"18.04\"",
+                "HOME_URL=\"https://www.ubuntu.com/\"",
+                "SUPPORT_URL=\"https://help.ubuntu.com/\"",
+                "BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"",
+                "PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"",
+                "VERSION_CODENAME=bionic",
+                "UBUNTU_CODENAME=bionic",
+                ""
+            ],
+            "hostname": "coriolis-worker-ONbgH1NV",
+            "ip_addresses": [
+                {
+                    "eth0": {
+                        "ipv4": [
+                            {
+                                "addr": "10.107.9.58",
+                                "netmask": "255.255.254.0",
+                                "broadcast": "10.107.9.255"
+                            }
+                        ],
+                        "ipv6": [
+                            {
+                                "addr": "fe80::250:56ff:fe89:91f4%eth0",
+                                "netmask": "ffff:ffff:ffff:ffff::/64"
+                            }
+                        ]
+                    }
+                },
+                {
+                    "docker0": {
+                        "ipv4": [
+                            {
+                                "addr": "172.17.0.1",
+                                "netmask": "255.255.0.0",
+                                "broadcast": "172.17.255.255"
+                            }
+                        ],
+                        "ipv6": null
+                    }
+                }
+            ]
+        },
+        "mapped_regions": [
+            "5e31066c-3512-4e8d-9e68-0a5de3d35c5f"
+        ]
+    }
+}

+ 1 - 0
coriolis/api-refs/source/index.rst

@@ -13,3 +13,4 @@ This is a reference for the Coriolis API.
 .. include:: provider.inc
 .. include:: region.inc
 .. include:: replica.inc
+.. include:: service.inc

+ 96 - 0
coriolis/api-refs/source/parameters.yaml

@@ -65,6 +65,12 @@ replica_tasks_execution_id_path:
   in: path
   type: uuid
   required: true
+service_id_path:
+  description: |
+    The ID of the service.
+  in: path
+  type: uuid
+  required: true
 # query variables
 instance_limit:
   description: |
@@ -1080,6 +1086,96 @@ schemas:
   in: body
   type: object
   required: true
+service_binary:
+  description: |
+    The name of the service binary.
+  in: body
+  type: string
+  required: true
+service_created_at:
+  description: |
+    Timestamp of service creation.
+  in: body
+  type: string
+  required: true
+service_deleted:
+  description: |
+    Value representing whether the service is deleted or not.
+  in: body
+  type: string
+  required: true
+service_deleted_at:
+  description: |
+    Timestamp of service deletion.
+  in: body
+  type: string
+  required: true
+service_enabled:
+  description: |
+    Boolean representing whether the service is enabled or not.
+  in: body
+  type: boolean
+  required: true
+service_host:
+  description: |
+    The hostname of the service.
+  in: body
+  type: string
+  required: true
+service_id:
+  description: |
+    The ID of the service.
+  in: body
+  type: uuid
+  required: true
+service_mapped_regions:
+  description: |
+    Array of regions mapped to this service.
+  in: body
+  type: array
+  required: false
+service_object:
+  description: |
+    Object containing information about the service.
+  in: body
+  type: object
+  required: true
+service_providers:
+  description: |
+    Object containing mappings of provider names and provider types available to this service.
+  in: body
+  type: object
+  required: true
+service_specs:
+  description: |
+    Object containing miscellaneous specifications about the service.
+  in: body
+  type: object
+  required: true
+service_status:
+  description: |
+    The status of the service. Possible values: "UP", "DOWN", "UNKNOWN".
+  in: body
+  type: string
+  required: true
+service_topic:
+  description: |
+    The name of the service's messaging topic.
+  in: body
+  type: string
+  required: true
+service_updated_at:
+  description: |
+    Timestamp of last service update.
+  in: body
+  type: string
+  required: true
+services_array:
+  description: |
+    Array of service objects.
+  in: body
+  type: array
+  required: true
 skip_os_morphing:
   description: |
     Boolean whether to skip os morphing or not.

+ 229 - 0
coriolis/api-refs/source/service.inc

@@ -0,0 +1,229 @@
+.. -*- rst -*-
+
+========
+Services
+========
+
+Lists, creates, updates, shows details for, and deletes services.
+
+
+List Services
+=============
+
+.. rest_method:: GET /services
+
+Lists all services.
+
+Normal response codes: 200
+
+Error response codes:   unauthorized(401),
+forbidden(403)
+
+Response
+--------
+
+.. rest_parameters:: parameters.yaml
+
+    - services : services_array
+    - created_at : service_created_at
+    - updated_at : service_updated_at
+    - deleted_at : service_deleted_at
+    - deleted : service_deleted
+    - id : service_id
+    - host : service_host
+    - binary : service_binary
+    - topic : service_topic
+    - enabled : service_enabled
+    - status : service_status
+    - providers : service_providers
+    - specs : service_specs
+    - mapped_regions : service_mapped_regions
+
+**Example of Service List Response**
+
+    .. literalinclude:: ../api_samples/service/service-list-resp.json
+        :language: javascript
+
+Show service
+============
+
+.. rest_method:: GET /services/{service_id}
+
+Shows details about a service.
+
+**Preconditions**
+
+The service must exist.
+
+Normal response codes: 200
+
+Error response codes: unauthorized(401),
+forbidden(403), itemNotFound(404)
+
+Request
+-------
+
+.. rest_parameters:: parameters.yaml
+
+    - service_id : service_id_path
+
+Response
+--------
+.. rest_parameters:: parameters.yaml
+
+    - service : service_object
+    - created_at : service_created_at
+    - updated_at : service_updated_at
+    - deleted_at : service_deleted_at
+    - deleted : service_deleted
+    - id : service_id
+    - host : service_host
+    - binary : service_binary
+    - topic : service_topic
+    - enabled : service_enabled
+    - status : service_status
+    - providers : service_providers
+    - specs : service_specs
+    - mapped_regions : service_mapped_regions
+
+**Example of Service Show Response**
+
+    .. literalinclude:: ../api_samples/service/service-show-resp.json
+        :language: javascript
+
+Create Service
+==============
+
+.. rest_method:: POST /services
+
+Creates a service.
+
+Normal response codes: 200
+
+Error response codes: unauthorized(401), forbidden(403)
+
+Request
+-------
+
+.. rest_parameters:: parameters.yaml
+
+    - service : service_object
+    - host : service_host
+    - binary : service_binary
+    - topic : service_topic
+    - enabled : service_enabled
+    - mapped_regions : service_mapped_regions
+
+**Example of Service Create Request**
+
+    .. literalinclude:: ../api_samples/service/service-create-req.json
+        :language: javascript
+
+Response
+--------
+
+.. rest_parameters:: parameters.yaml
+
+    - service : service_object
+    - created_at : service_created_at
+    - updated_at : service_updated_at
+    - deleted_at : service_deleted_at
+    - deleted : service_deleted
+    - id : service_id
+    - host : service_host
+    - binary : service_binary
+    - topic : service_topic
+    - enabled : service_enabled
+    - status : service_status
+    - providers : service_providers
+    - specs : service_specs
+    - mapped_regions : service_mapped_regions
+
+**Example of Service Create Response**
+
+    .. literalinclude:: ../api_samples/service/service-create-resp.json
+        :language: javascript
+
+Update service
+==============
+
+.. rest_method:: PUT /services/{service_id}
+
+Updates the already existing service, modifying the mapped regions or availability.
+
+**Preconditions**
+
+The service must exist.
+
+Normal Response Codes: 200
+
+Error response codes:   unauthorized(401),
+forbidden(403), itemNotFound(404)
+
+Request
+-------
+
+.. rest_parameters:: parameters.yaml
+
+    - service_id : service_id_path
+    - service : service_object
+    - mapped_regions : service_mapped_regions
+    - enabled : service_enabled
+
+**Example of Service Update Request**
+
+    .. literalinclude:: ../api_samples/service/service-update-req.json
+        :language: javascript
+
+Response
+--------
+
+.. rest_parameters:: parameters.yaml
+
+    - service : service_object
+    - created_at : service_created_at
+    - updated_at : service_updated_at
+    - deleted_at : service_deleted_at
+    - deleted : service_deleted
+    - id : service_id
+    - host : service_host
+    - binary : service_binary
+    - topic : service_topic
+    - enabled : service_enabled
+    - status : service_status
+    - providers : service_providers
+    - specs : service_specs
+    - mapped_regions : service_mapped_regions
+
+**Example of service Update Response**
+
+    .. literalinclude:: ../api_samples/service/service-update-resp.json
+        :language: javascript
+
+Delete service
+==============
+
+.. rest_method:: DELETE /services/{service_id}
+
+Deletes a service.
+
+**Preconditions**
+
+The service must exist.
+
+Normal response codes: 204
+
+Error response codes: itemNotFound(404),unauthorized(401),
+forbidden(403)
+
+Request
+-------
+
+.. rest_parameters:: parameters.yaml
+
+    - service_id : service_id_path
+
+Response
+--------
+
+There is no response body for a successful deletion of a service.