Skip to content

Commit e8fd7b2

Browse files
authored
DOC-2693 RS: DB availability REST API reference (#562)
1 parent 213e1a0 commit e8fd7b2

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
Title: Database availability requests
3+
alwaysopen: false
4+
categories:
5+
- docs
6+
- operate
7+
- rs
8+
description: REST API requests to check database availability
9+
headerRange: '[1-2]'
10+
linkTitle: availability
11+
weight: $weight
12+
---
13+
14+
| Method | Path | Description |
15+
|--------|------|-------------|
16+
| [GET](#get-db-endpoint-availability) | `/v1/local/bdbs/{uid}/endpoint/availability` | Verifies local database endpoint availability |
17+
| [GET](#get-db-availability) | `/v1/bdbs/{uid}/availability` | Verifies database availability |
18+
19+
## Get database endpoint availability {#get-db-endpoint-availability}
20+
21+
```sh
22+
GET /v1/local/bdbs/{uid}/endpoint/availability
23+
```
24+
25+
Verifies the local database endpoint is available. This request does not redirect to the primary node.
26+
27+
### Permissions
28+
29+
| Permission name | Roles |
30+
|-----------------|-------|
31+
| [view_bdb_info]({{< relref "/operate/rs/references/rest-api/permissions#view_bdb_info" >}}) | admin<br />cluster_member<br />cluster_viewer<br />db_member<br />db_viewer |
32+
33+
### Request {#get-endpoint-request}
34+
35+
#### Example HTTP request
36+
37+
```sh
38+
GET /local/bdbs/1/endpoint/availability
39+
```
40+
41+
#### Headers
42+
43+
| Key | Value | Description |
44+
|-----|-------|-------------|
45+
| Host | cnm.cluster.fqdn | Domain name |
46+
| Accept | application/json | Accepted media type |
47+
48+
#### URL parameters
49+
50+
| Field | Type | Description |
51+
|-------|------|-------------|
52+
| uid | integer | The unique ID of the database. |
53+
54+
### Response {#get-endpoint-response}
55+
56+
Returns the status code `200 OK` if the local database endpoint is available.
57+
58+
If the local database endpoint is unavailable, returns an error status code and a JSON object that contains `error_code` and `description` fields.
59+
60+
### Error codes {#get-endpoint-error-codes}
61+
62+
When errors are reported, the server may return a JSON object with
63+
`error_code` and `description` fields that provide additional information.
64+
The following are possible `error_code` values:
65+
66+
| Code | Description |
67+
|------|-------------|
68+
| no_quorum | Master healthcheck failed (no quorum in the cluster) |
69+
| db_not_found | Database does not exist in the cluster |
70+
| bdb_endpoint_unavailable | Local database endpoint is not available |
71+
72+
### Status codes {#get-endpoint-status-codes}
73+
74+
| Code | Description |
75+
|------|-------------|
76+
| [200 OK](https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok) | Database endpoint is available |
77+
| [503 Service Unavailable](https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavailable) | Database endpoint is unavailable. |
78+
79+
80+
## Get database availability {#get-db-availability}
81+
82+
```sh
83+
GET /v1/bdbs/{uid}/availability
84+
```
85+
86+
Gets the availability status of a database.
87+
88+
- If the OSS Cluster API is enabled, verifies all endpoints for this database are available.
89+
90+
- Otherwise, verifies the database has at least one available endpoint.
91+
92+
### Permissions
93+
94+
| Permission name | Roles |
95+
|-----------------|-------|
96+
| [view_bdb_info]({{< relref "/operate/rs/references/rest-api/permissions#view_bdb_info" >}}) | admin<br />cluster_member<br />cluster_viewer<br />db_member<br />db_viewer |
97+
98+
### Request {#get-db-request}
99+
100+
#### Example HTTP request
101+
102+
```sh
103+
GET /bdbs/1/availability
104+
```
105+
106+
#### Headers
107+
108+
| Key | Value | Description |
109+
|-----|-------|-------------|
110+
| Host | cnm.cluster.fqdn | Domain name |
111+
| Accept | application/json | Accepted media type |
112+
113+
#### URL parameters
114+
115+
| Field | Type | Description |
116+
|-------|------|-------------|
117+
| uid | integer | The unique ID of the database. |
118+
119+
### Response {#get-db-response}
120+
121+
Returns the status code `200 OK` if the database is available.
122+
123+
If the database is unavailable, returns an error status code and a JSON object that contains `error_code` and `description` fields.
124+
125+
### Error codes {#get-db-error-codes}
126+
127+
When errors are reported, the server may return a JSON object with
128+
`error_code` and `description` fields that provide additional information.
129+
The following are possible `error_code` values:
130+
131+
| Code | Description |
132+
|------|-------------|
133+
| no_quorum | Master healthcheck failed (no quorum in the cluster) |
134+
| db_not_found | Database does not exist in the cluster |
135+
| bdb_unavailable | Database is not available |
136+
137+
### Status codes {#get-db-status-codes}
138+
139+
| Code | Description |
140+
|------|-------------|
141+
| [200 OK](https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok) | Database is available |
142+
| [503 Service Unavailable](https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavailable) | Database is unavailable or doesn't have quorum. |

0 commit comments

Comments
 (0)