shardingsphere-ui backend API

1.User authentication related interfaces

1.1 User login

POST /api/login

Request

ParameterField typeEssentialDescribe
usernameStringYUser name
passwordStringYUser password

Example

curl -X GET http://localhost:8088/api/login

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
accessTokenStringAccess credentials
usernameStringUser name
{
    "success": true,
    "errorCode": 0,
    "errorMsg": null,
    "model": {"accessToken":"string","username":"string"}
}

Note: accessToken is obtained. All subsequent requests need to carry this voucher in request headers: Access-Token: accessToken

2.Relevant interfaces of Registration Center

2.1 Get all registry configurations

GET /api/reg-center

Example

curl -X GET http://localhost:8088/api/reg-center

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
nameStringName of Registration Center
registryCenterTypeStringRegistry type: “zookeeper” / “etcd”
serverListsStringService address of Registration Center
namespaceStringNamespace of the registry
orchestrationNameStringData governance instance name
digestStringPermission token to connect to the registry
activatedBooleanIs it active
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": [
    {
      "name": "string",
      "registryCenterType": "Zookeeper",
      "serverLists": "string",
      "namespace": "string",
      "orchestrationName": "string",
      "digest": "string",
      "activated": true
    },
    {
      "name": "string",
      "registryCenterType": "Etcd",
      "serverLists": "string",
      "namespace": "string",
      "orchestrationName": "string",
      "digest": "string",
      "activated": false
    }
  ]
}

2.2 New registry configuration

POST /api/reg-center

Example

curl -X POST http://localhost:8088/api/reg-center

Request

ParameterField typeEssentialDescribe
nameStringYName of Registration Center
registryCenterTypeStringYRegistry type: “zookeeper” / “etcd”
serverListsStringYService address of Registration Center
namespaceStringYNamespace of the registry
orchestrationNameStringYData governance instance name
digestStringNPermission token to connect to the registry
{
  "name": "string",
  "namespace": "string",
  "orchestrationName": "string",
  "registryCenterType": "Zookeeper",
  "serverLists": "string"
}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{ "success": true, "errorCode": 0, "errorMsg": null, "model": null }

2.3 Delete registry configuration

DELETE /api/reg-center

Request

ParameterField typeEssentialDescribe
nameStringYName of Registration Center
{"name":"string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

2.4 Activate And Connect TheRegistry

POST /api/reg-center/connect

Request

ParameterField typeEssentialDescribe
nameStringYName of Registration Center
{"name":"string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

Note: after the registration center is activated successfully, subsequent configuration and governance operations can be performed. Only one active registry is allowed for the service.

2.5 Get activated registry

GET /api/reg-center/activated

Request

Response

ParameterField type描述
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
nameStringName of Registration Center
registryCenterTypeStringRegistry type: “zookeeper” / “etcd”
serverListsStringService address of Registration Center
namespaceStringNamespace of the registry
orchestrationNameStringData governance instance name
digestStringPermission token to connect to the registry
activatedBooleanIs it active
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": {
    "name": "string",
    "registryCenterType": "Zookeeper",
    "serverLists": "string",
    "namespace": "string",
    "orchestrationName": "string",
    "digest": "string",
    "activated": true
  }
}

3.Configuration center schema configuration related interfaces

3.1 Get all schema names

GET /api/schema

Request

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
modelCollectionschema name list
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": ["sharding_order", "sharding_db", "master_slave_db"]
}

3.2 Get data fragmentation rules of schema

GET /api/schema/rule/{schemaName}

Request

ParameterField typeEssentialDescribe
schemaNameStringYschema name

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
modelStringyaml string
{"success":true,"errorCode":0,"errorMsg":null,"model":"yaml string"}

3.3 Modify data fragmentation rules of schema

PUT /api/schema/rule/{schemaName}

Request

ParameterField typeEssentialDescribe
schemaNameStringYschema name
ruleConfigStringYyaml string
{"ruleConfig":"yaml string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

3.4 Get the data source configuration of schema

GET /api/schema/datasource/{schemaName}

Request

ParameterField typeEssentialDescribe
schemaNameStringYschema name

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
modelStringyaml string
{"success":true,"errorCode":0,"errorMsg":null,"model":"yaml string"}

3.5 Modify the data source configuration of schema

PUT /api/schema/datasource/{schemaName}

Request

ParameterField typeEssentialDescribe
schemaNameStringYschema name
ParameterField typeEssentialDescribe
dataSourceConfigStringYyaml string
{"dataSourceConfig":"yaml string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

4.ShardingSphere-Proxy Authentication

4.1 Get the authentication configuration of sharding proxy

GET /api/authentication

Request

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
usernameStringLogin user name
passwordStringLogin password
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": { "username": "string", "password": "string" }
}

4.2 Modify the authentication configuration of sharding proxy

PUT /api/authentication

Request

ParameterField typeEssentialDescribe
usernameStringYLogin user name
passwordStringYLogin password
{"username":"string","password":"string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

5.Configuration center configmap configuration related interfaces

5.1 Get configmap configuration

GET /api/config-map

Request

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
modelMapconfig map
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": {
    "sharding-key1": "sharding-value1",
    "sharding-key2": "sharding-value2",
    "master-slave-key0": "master-slave-value0",
    "master-slave-key1": "master-slave-value1"
  }
}

5.2 Modify configmap configuration

PUT /api/config-map

Request

ConfigMap

{
  "sharding-key1": "sharding-value1",
  "sharding-key2": "sharding-value2",
  "master-slave-key0": "master-slave-value0",
  "master-slave-key1": "master-slave-value1"
}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

6.Configuration center properties configuration related interfaces

6.1 Get property configuration

GET /api/properties

Request

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
modelStringyaml string
{"success":true,"errorCode":0,"errorMsg":null,"model":"yaml string"}

6.2 Modify property configuration

PUT /api/properties

Request

ParameterField typeEssentialDescribe
propertiesStringYyaml string
{"properties":"yaml string"}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

7.Arrange interfaces related to governance

7.1 Get running instance information

GET /api/orchestration/instance

Request

Response

Response Body: (io.shardingsphere.shardingui.web.response.ResponseResult<java.util.Collection<io.shardingsphere.shardingui.common.dto.InstanceDTO>>)

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
serverIpStringIP
instanceIdStringInstance ID
enabledBooleanInstance ID enable status
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": [{ "serverIp": "string", "instanceId": "string", "enabled": true }]
}

7.2 Modify running instance status

PUT /api/orchestration/instance

Request

ParameterField typeEssentialDescribe
instanceIdStringYRunning instance ID
enabledBooleanYInstance ID enabling status, true: enabled, false: Disabled
{"instanceId":"string","enabled":false}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

7.3 Get from library information

GET /api/orchestration/datasource

Request

Response

Response Body: (io.shardingsphere.shardingui.web.response.ResponseResult<java.util.Collection<io.shardingsphere.shardingui.common.dto.SlaveDataSourceDTO>>)

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
schemaStringSchema name of the slave Library
masterDataSourceNameStringThe name of the master library corresponding to the slave Library
slaveDataSourceNameStringName from library
enabledBooleanEnable status from library
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": [
    {
      "schema": "master_slave_db",
      "masterDataSourceName": "master_ds",
      "slaveDataSourceName": "slave_ds_0",
      "enabled": true
    },
    {
      "schema": "master_slave_db",
      "masterDataSourceName": "master_ds",
      "slaveDataSourceName": "slave_ds_1",
      "enabled": true
    }
  ]
}

7.4 Modify slave status

PUT /api/orchestration/datasource

Request

ParameterField typeEssentialDescribe
schemaStringSchema name of the slave Library
masterDataSourceNameStringThe name of the master library corresponding to the slave Library
slaveDataSourceNameStringName from library
enabledBooleanEnable status from library
{
  "schema": "master_slave_db",
  "masterDataSourceName": "master_ds",
  "slaveDataSourceName": "slave_ds_0",
  "enabled": true
}

Response

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
{"success":true,"errorCode":0,"errorMsg":null,"model":null}

shardingscaling

Get sharding scaling service

GET /api/shardingscaling

Example


curl -X GET http://localhost:8088/api/shardingscaling

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": { "serviceName": "scaling", "serviceType": "ShardingScaling", "serviceUrl": "localhost:8084" } } OR { "success": false, "errorCode": 0, "errorMsg": "No configured sharding scaling services", "model": null }

Add sharding scaling service

POST /api/shardingscaling

Body

ParameterDescribe
serviceNameuser defined name of service
serviceTypeFixed value ShardingScaling
serviceUrluser defined url of service

Example


curl -X POST \ http://localhost:8088/api/shardingscaling \ -H 'content-type: application/json' \ -d '{ "serviceName": "scaling", "serviceType": "ShardingScaling", "serviceUrl": "localhost:8084" }'

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": null }

Delete sharding scaling service

DELETE /api/shardingscaling

Example


curl -X DELETE http://localhost:8088/api/shardingscaling

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": null }

Start scaling job

POST /api/shardingscaling/job/start

Body

ParameterDescribe
ruleConfiguration.sourceDatasourcesource sharding proxy data source configuration
ruleConfiguration.sourceRulesource sharding proxy table rule configuration
ruleConfiguration.destinationDataSources.namedestination sharding proxy name
ruleConfiguration.destinationDataSources.urldestination sharding proxy jdbc url
ruleConfiguration.destinationDataSources.usernamedestination sharding proxy username
ruleConfiguration.destinationDataSources.passworddestination sharding proxy password
jobConfiguration.concurrencysync task proposed concurrency

Example


curl -X POST \ http://localhost:8088/api/shardingscaling/job/start \ -H 'content-type: application/json' \ -d '{ "ruleConfiguration": { "sourceDatasource": "ds*0: !!YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n props:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\''\n connectionTimeout: 30000\n idleTimeout: 60000\n maxLifetime: 1800000\n maxPoolSize: 50\n minPoolSize: 1\n maintenanceIntervalMilliseconds: 30000\n readOnly: false\n", "sourceRule": "defaultDatabaseStrategy:\n inline:\n algorithmExpression: ds*\${user_id % 2}\n shardingColumn: user_id\ntables:\n t1:\n actualDataNodes: ds_0.t1\n keyGenerateStrategy:\n column: order_id\n type: SNOWFLAKE\n logicTable: t1\n tableStrategy:\n inline:\n algorithmExpression: t1\n shardingColumn: order_id\n t2:\n actualDataNodes: ds_0.t2\n keyGenerateStrategy:\n column: order_item_id\n type: SNOWFLAKE\n logicTable: t2\n tableStrategy:\n inline:\n algorithmExpression: t2\n shardingColumn: order_id\n", "destinationDataSources": { "name": "dt_0", "password": "123456", "url": "jdbc:mysql://127.0.0.1:3306/test2?serverTimezone=UTC&useSSL=false", "username": "root" } }, "jobConfiguration": { "concurrency": 3 } }'

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": null }

Get scaling progress

GET /api/shardingscaling/job/progress/{jobId}

Example


curl -X GET \ http://localhost:8088/api/shardingscaling/job/progress/1

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": { "id": 1, "jobName": "Local Sharding Scaling Job", "status": "RUNNING/STOPPED" "syncTaskProgress": [{ "id": "127.0.0.1-3306-test", "status": "PREPARING/MIGRATE_HISTORY_DATA/SYNCHRONIZE_REALTIME_DATA/STOPPING/STOPPED", "historySyncTaskProgress": [{ "id": "history-test-t1#0", "estimatedRows": 41147, "syncedRows": 41147 }, { "id": "history-test-t1#1", "estimatedRows": 42917, "syncedRows": 42917 }, { "id": "history-test-t1#2", "estimatedRows": 43543, "syncedRows": 43543 }, { "id": "history-test-t2#0", "estimatedRows": 39679, "syncedRows": 39679 }, { "id": "history-test-t2#1", "estimatedRows": 41483, "syncedRows": 41483 }, { "id": "history-test-t2#2", "estimatedRows": 42107, "syncedRows": 42107 }], "realTimeSyncTaskProgress": { "id": "realtime-test", "delayMillisecond": 1576563771372, "logPosition": { "filename": "ON.000007", "position": 177532875, "serverId": 0 } } }] } }

List scaling jobs

GET /api/shardingscaling/job/list

Example


curl -X GET \ http://localhost:8088/api/shardingscaling/job/list

Response


{ "success": true, "errorCode": 0, "model": [ { "jobId": 1, "jobName": "Local Sharding Scaling Job", "status": "RUNNING" } ] }

Stop scaling job

POST /api/shardingscaling/job/stop

Body

ParameterDescribe
jobIdjob id

Example


curl -X POST \ http://localhost:8088/api/shardingscaling/job/stop \ -H 'content-type: application/json' \ -d '{ "jobId":1 }'

Response


{ "success": true, "errorCode": 0, "errorMsg": null, "model": null }