-
Notifications
You must be signed in to change notification settings - Fork 2
API documentation
The API is split in differents levels or scopes: Cluster, node group, node and auth. This is the root of the URL to call the API
http://[GONARCH_SERVER]:2423/api/v1/[endpoint]Description: Create a new cluster in your workspace.
Endpoint: cluster/add
Method: PUT
Parameters:
-
name: Cluster name. This field must be unique
-
primary: The Primary **IP **(not DNS) with port separated by :
-
repl_credentials: user and password for replicaion user in MySQL separated by :
-
promotion rule: The desired rules to decide if a node is promotable or not.:
-
Synced: Only replicas that are fully in sync with primary are candidates to an eventual promotion
-
Available: Any replica alive is a candidate to get promoted.
-
{
"name": "mysql8-eu",
"primary": "20.199.109.77:3306",
"repl_credentials": "repl:repl",
"promotion_rule" : "synced"
}Output:
-
0:.- OK: Cluster created
-
1.- ERROR: The cluster name already exists
-
2.- ERROR: Node not reachable. Either the IP + port or the user + pass are not correct
-
3.- ERROR: Node not reachable. Either the IP + port or the user + pass are not correct
-
4.- ERROR: The node used is not the primary.
Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu", "primary": "20.199.109.77:3306", "repl_credentials": "repl:repl", "promotion_rule" : "synced"}' "http://127.0.0.1:2423/api/v1/cluster/add"Description: Remove an existing cluster from your workspace.
Endpoint: cluster/remove
Method: DELETE
Parameters:
- name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
{
"name": "mysql8-eu"
}Output:
-
0:.- OK: Cluster removed
-
1.- ERROR: The indicated cluster does not exists. Error in cluster name
Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu"}' "http://127.0.0.1:2423/api/v1/cluster/remove"Description: Retrieve the primary IP and port for a given cluster.
Endpoint: cluster/primary
Method: GET
Parameters:
- name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
{
"name": "mysql8-eu"
}Output:
-
1:.- ERROR: Cluster does not exists
-
GET Output
{
"ip": "20.199.119.77",
"port": 3306
}Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu"}' "http://127.0.0.1:2423/api/v1/cluster/primary"Description: Summary of clusters created in that workspace.
Endpoint: cluster/list
Method: GET
Parameters:
- none
Output:
-
1.- WARNING: The cluster list is empty
-
GET output. What means each field?
[
{
"name": "mysql8-eu",
"created_at": "2023-05-18 14:54:53",
"huser": "repl",
"hpass": "repl",
"maint_mode": 0,
"promotion_rule": "synced"
}
]Example:
$> curl -X PUT -H "Content-Type: application/json" "http://127.0.0.1:2423/api/v1/cluster/list"Description: Fetch all teh details for a given cluster.
Endpoint: cluster/details
Method: GET
Parameters:
- name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
{
"name": "mysql8-eu"
}Output:
-
1.- WARNING: The cluster list is empty
-
GET output. What means each field?
{
"cluster_name": "mysql8-eu",
"creation_date": "2023-05-18 14:54:53",
"promotion_rule": "synced",
"maintenance_mode": 0,
"writer_endpoint": "192.168.1.154:3001",
"reader_endpoint": "192.168.1.154:3002",
"instances": [
{
"instance_id": 1,
"instance_name": "mysql-europe-03",
"hostname:port": "20.199.119.77:3306",
"node_group": "mysql8-eu-ng-01",
"reachable": 1,
"access_level": "rw",
"version": "8.0.33-0ubuntu0.20.04.2",
"replication": {
"replication_mode": "gtid",
"role": "primary",
"promotable": 0,
"gtid_details": [
{
"source_instance": "mysql-europe-01",
"coordinates": "1-53"
},
{
"source_instance": "mysql-europe-03",
"coordinates": "1-28"
},
{
"source_instance": "mysql-europe-02",
"coordinates": "1-17"
}
]
}
},
{
"instance_id": 3,
"instance_name": "mysql-europe-01",
"hostname:port": "51.103.29.180:3306",
"node_group": "mysql8-eu-ng-01",
"reachable": 1,
"access_level": "r",
"version": "8.0.33-0ubuntu0.20.04.2",
"replication": {
"replication_mode": "gtid",
"role": "replica",
"promotable": 1,
"replication_lag": 0,
"io_thread_running": "Yes",
"sql_thread_running": "Yes",
"binlog_coordinates": "bin03.000005:132485",
"gtid_details": [
{
"source_instance": "mysql-europe-01",
"coordinates": "1-53"
},
{
"source_instance": "mysql-europe-03",
"coordinates": "1-471"
},
{
"source_instance": "mysql-europe-02",
"coordinates": "1-17"
}
]
}
},
{
"instance_id": 2,
"instance_name": "mysql-europe-02",
"hostname:port": "20.188.59.210:3306",
"node_group": "mysql8-eu-ng-01",
"reachable": 1,
"access_level": "r",
"version": "8.0.33-0ubuntu0.20.04.2",
"replication": {
"replication_mode": "gtid",
"role": "replica",
"promotable": 1,
"replication_lag": 0,
"io_thread_running": "Yes",
"sql_thread_running": "Yes",
"binlog_coordinates": "bin03.000005:132485",
"gtid_details": [
{
"source_instance": "mysql-europe-01",
"coordinates": "1-53"
},
{
"source_instance": "mysql-europe-03",
"coordinates": "1-471"
},
{
"source_instance": "mysql-europe-02",
"coordinates": "1-17"
}
]
}
}
]
}Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu"}' "http://127.0.0.1:2423/api/v1/cluster/details"Description: Edit the promotion rule for a given cluster.
Endpoint: cluster/edit/promotion_rule
Method: PUT
Parameters:
-
name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
-
flag: Option to change the cluster. Options:
-
Synced: Only replicas that are fully in sync with primary are candidates to an eventual promotion
-
Available: Any replica alive is a candidate to get promoted.
-
{
"name": "europe-80-01",
"flag": "available"
}Output:
-
0:.- OK: promotion rule changed and effective
-
1.- ERROR: The indicated cluster does not exists. Error in cluster name
-
2.- ERROR: Flag is not valid. Please select between synced or available. Use only one of those two flags
Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu", "flag": "available"}' "http://127.0.0.1:2423/api/v1/cluster/edit/promotion_rule"Description: Edit the access level for the primary.
Endpoint: cluster/edit/access_level
Method: PUT
Parameters:
-
name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
-
flag: Option to change the access level for the primary. Options:
- rw: Primary will be open to receive wrtie and read traffic.
- w: Primary will be open to write traffic only.
{
"name": "europe-80-01",
"flag": "w"
}Output:
-
0:.- OK: access level changed and effective
-
1.- ERROR: The indicated cluster does not exists. Error in cluster name
-
2.- ERROR: Flag is not valid. Accepted values for access level are w (Write only) or rw (Read & write)
Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu", "flag": "w"}' "http://127.0.0.1:2423/api/v1/cluster/edit/access_level"Description: Remove a given replica by Id. It doesn't work to remove a priamary/
Endpoint: node/remove
Method: DELETE
Parameters:
-
name: Cluster name. Identifier to elminate the cluster and any related metadata in the backend DB
-
node_id: Unique identifier for the replica to remove. You can take this value from the cluster/details API call.
{
"name": "mysql8-eu",
"node_id": 3
}Output:
-
0:.- OK: Replica node removed. Note that if the replcia is still alive and replicating from the primary Gonarch will automatically include it again.
-
1.- ERROR: The indicated cluster does not exists. Error in cluster name
-
2.- ERROR: The indicated replica node does not exists or it's not a replica.
Example:
$> curl -X PUT -H "Content-Type: application/json" -d '{"name": "mysql8-eu", "node_id": 3}' "http://127.0.0.1:2423/api/v1/cluster/node/remove"