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
governanceNameStringGovernance instance name
digestStringPermission token to connect to the registry
additionalConfigCenterTypeStringAdditional config center type: “zookeeper” / “etcd”
additionalConfigCenterServerListStringService address of additional config center
additionalDigestStringPermission token to connect to the additional config center
activatedBooleanIs it active
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": [
    {
      "name": "string",
      "registryCenterType": "Zookeeper",
      "serverLists": "string",
      "governanceName": "string",
      "digest": "string",
      "additionalConfigCenterType": "Zookeeper",
      "additionalConfigCenterServerList": "string",
      "additionalDigest": "string",
      "activated": true
    },
    {
      "name": "string",
      "registryCenterType": "Etcd",
      "serverLists": "string",
      "governanceName": "string",
      "digest": "string",
      "additionalConfigCenterType": "Zookeeper",
      "additionalConfigCenterServerList": "string",
      "additionalDigest": "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
governanceNameStringYData governance instance name
registryCenterTypeStringYRegistry type: “zookeeper” / “etcd”
serverListsStringYService address of Registration Center
digestStringNPermission token to connect to the registry
additionalConfigCenterTypeStringNAdditional config center type: “zookeeper” / “etcd”
additionalConfigCenterServerListStringNService address of additional config center
additionalDigestStringNPermission token to connect to the additional config center
{
  "name": "string",
  "governanceName": "string",
  "registryCenterType": "Zookeeper",
  "serverLists": "string"
  "additionalConfigCenterType": "Zookeeper",
  "additionalConfigCenterServerList": "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
governanceNameStringData governance instance name
digestStringPermission token to connect to the registry
additionalConfigCenterTypeStringAdditional config center type: “zookeeper” / “etcd”
additionalConfigCenterServerListStringService address of additional config center
additionalDigestStringPermission token to connect to the additional config center
activatedBooleanIs it active
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": {
    "name": "string",
    "registryCenterType": "Zookeeper",
    "serverLists": "string",
    "governanceName": "string",
    "digest": "string",
    "additionalConfigCenterType": "Zookeeper",
    "additionalConfigCenterServerList": "string",
    "additionalDigest": "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", "primary_replica_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 properties configuration related interfaces

5.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"}

5.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}

6.Arrange interfaces related to governance

6.1 Get running instance information

GET /api/governance/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 }]
}

6.2 Modify running instance status

PUT /api/governance/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}

6.3 Get replica data source information

GET /api/governance/datasource

Request

Response

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

ParameterField typeDescribe
successBooleanIs the request successful
errorCodeIntegerError code
errorMsgStringWrong description
schemaStringSchema name
primaryDataSourceNameStringThe name of primary data source
replicaDataSourceNameStringThe name of replica data source
enabledBooleanEnable status of replica data source
{
  "success": true,
  "errorCode": 0,
  "errorMsg": null,
  "model": [
    {
      "schema": "primary_replica_db",
      "primaryDataSourceName": "primary_ds",
      "replicaDataSourceName": "replica_ds_0",
      "enabled": true
    },
    {
      "schema": "primary_replica_db",
      "primaryDataSourceName": "primary_ds",
      "replicaDataSourceName": "replica_ds_1",
      "enabled": true
    }
  ]
}

6.4 Modify replica status

PUT /api/governance/datasource

Request

ParameterField typeEssentialDescribe
schemaStringSchema name
primaryDataSourceNameStringThe name of primary data source
replicaDataSourceNameStringThe name of replica data source
enabledBooleanEnable status of replica data source
{
  "schema": "primary_replica_db",
  "primaryDataSourceName": "primary_ds",
  "replicaDataSourceName": "replica_ds_0",
  "enabled": true
}

Response

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

7. shardingscaling

7.1 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 }

7.2 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 }

7.3 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 }

7.4 Start scaling job

POST /api/shardingscaling/job/start

Body

ParameterDescribe
ruleConfiguration.sourcesource data source configuration
ruleConfiguration.targettarget data source configuration
jobConfiguration.concurrencysync task proposed concurrency

Data source configuration:

ParameterDescribe
typedata source type(available parameters:shardingSphereJdbc,jdbc)
parameterdata source parameter

Parameter configuration:

type = shardingSphereJdbc

ParameterDescribe
dataSourcesharding sphere data source configuration
rulesharding sphere data source table rule

type = jdbc

ParameterDescribe
namejdbc name
ruleConfiguration.targetDataSources.jdbcUrljdbc url
ruleConfiguration.targetDataSources.usernamejdbc username
ruleConfiguration.targetDataSources.passwordjdbc password

Example

curl -X POST \
  http://localhost:8088/api/shardingscaling/job/start \
  -H 'content-type: application/json' \
  -d '{
        "ruleConfiguration": {
          "source": {
            "type": "shardingSphereJdbc",
            "parameter": {
              "dataSource":"
                dataSources:
                  ds_0:
                    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
                    props:
                      driverClassName: com.mysql.jdbc.Driver
                      jdbcUrl: jdbc:mysql://127.0.0.1:3306/scaling_0?useSSL=false
                      username: scaling
                      password: scaling
                  ds_1:
                    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
                    props:
                      driverClassName: com.mysql.jdbc.Driver
                      jdbcUrl: jdbc:mysql://127.0.0.1:3306/scaling_1?useSSL=false
                      username: scaling
                      password: scaling
                ",
              "rule":"
                rules:
                - !SHARDING
                  tables:
                    t_order:
                      actualDataNodes: ds_$->{0..1}.t_order_$->{0..1}
                      databaseStrategy:
                        standard:
                          shardingColumn: order_id
                          shardingAlgorithmName: t_order_db_algorith
                      logicTable: t_order
                      tableStrategy:
                        standard:
                          shardingColumn: user_id
                          shardingAlgorithmName: t_order_tbl_algorith
                  shardingAlgorithms:
                    t_order_db_algorith:
                      type: INLINE
                      props:
                        algorithm-expression: ds_$->{order_id % 2}
                    t_order_tbl_algorith:
                      type: INLINE
                      props:
                        algorithm-expression: t_order_$->{user_id % 2}
                "
            }
          },
          "target": {
              "type": "jdbc",
              "parameter": {
                "username": "root",
                "password": "root",
                "jdbcUrl": "jdbc:mysql://127.0.0.1:3307/sharding_db?serverTimezone=UTC&useSSL=false"
              }
          }
        },
        "jobConfiguration":{
          "concurrency":"3"
        }
      }'

Response


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

7.5 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 } } }] } }

7.6 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" } ] }

7.7 Stop scaling job

GET /api/shardingscaling/job/stop

Body

ParameterDescribe
jobIdjob id

Example

curl -X GET \
  http://localhost:8888/scaling/job/stop/1

Response


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