1. CPM Admin API

The CPM Admin REST API is how CPM functionality is exposed both for the cpm-web user interface and also for custom written scripts or applications that a CPM developer might want to build. The REST API is developed using golang’s http package and is served up by the cpmadminserver golang program. The cpm-admin container when run exposes this REST API. The cpm-web web user interface accesses the cpm-admin REST API for all it’s functionality.

1.1. Security

1.1.1. login and return an auth token

GET /sec/login/:ID.:PSW

  • ID : the user id to authenticate with

  • PSW : the user password to authenticate with

curl  http://cpm-admin.crunchy.lab:13001/sec/login/cpm.cpm

1.1.2. logout of a user session

GET /sec/logout/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/logout/ab3ba695-533-43a4-a3c0-9a4c55288c14

1.1.3. update a user account

POST /sec/updateuser

  • Token : the generated auth token for this session

curl --data @provision-proxy.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/provisionproxy

1.1.4. change a user password

POST /sec/cp

  • Token : the generated auth token for this session

curl --data @changepassword.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/changepassword

1.1.5. add a user

POST /sec/adduser

  • Token : the generated auth token for this session

curl --data @adduser.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/adduser

1.1.6. return user information

GET /sec/getuser/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/getuser/cpm.1efbfd5-9bb2-43a0-8c91-b6f4a837a4f2

1.1.7. return all users information

GET /sec/getusers/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/getusers/1efbfd50-9b2-43a0-8c91-b6f4a837a4f2

1.1.8. delete a user

GET /sec/deleteuser/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/deleteuser/1.jkjkjadkjkajdkfjakdfjkad

1.1.9. update a CPM role

POST /sec/updaterole

  • Token : the generated auth token for this session

curl --data @updaterole.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/sec/updaterole

1.1.10. add a CPM role

POST /sec/addrole

  • Token : the generated auth token for this session

curl --data @addrole.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/sec/addrole

1.1.11. delete a CPM role

GET /sec/deleterole/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/deleterole/1.ajkajdkajdfkjadf

1.1.12. get all CPM roles

GET /sec/getroles/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/sec/getroles/1efbfd50-9b2-43a0-8c91-b6f4a837a4f2

1.1.13. get a CPM role

GET /sec/getrole/:Name.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001sec/getrole/superuser.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.2. Project Information

1.2.1. adds a project

POST /project/add

  • ID : can be empty

  • Name : the name to use for this project

  • Desc : the project description

  • CreateDt : can be empty

  • Token : the generated auth token for this session

curl -X POST -d @addproject.json http://cpm-admin:13001/project/add

1.2.2. return all projects

GET /project/getall/:Token

  • Token : the generated auth token for this session

curl http://cpm-admin.crunchy.lab:13001/project/getall/1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.2.3. return a single project

GET /project/get/:ID.Token

  • ID : id of a project

  • Token : the generated auth token for this session

curl http://cpm-admin.crunchy.lab:13001/project/get/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.2.4. delete a single project

GET /project/delete/:ID.Token

  • ID : id of a project

  • Token : the generated auth token for this session

curl http://cpm-admin.crunchy.lab:13001/project/delete/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.2.5. updates a project

POST /project/update

  • ID : the generated id of a project

  • Name : the name to use for this project

  • Desc : the description of the project

  • UpdateDate : can be empty

  • Token : the generated auth token for this session

curl -X POST -d @updateproject.json http://cpm-admin.crunchy.lab:13001/project/update

1.2.6. return a list of containers in a project

GET /projectnodes/:ID.:Token

  • ID : the unique assigned ID of a project

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/projectnodes/1.8dc0caed-39e7-47b4-878c-de1c8b0b595d

1.3. Container Information

1.3.1. stop a container postgres

GET /admin/stop-pg/:ID.:Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/stop-pg/8.1efbfd5-9bb2-43a0-8c91-b6f4a837a4f2

1.3.2. stop a container

GET /admin/stop/:ID.:Token * Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/stop/8.1efbfd50-9b2-43a0-8c91-b6f4a837a4f2

1.3.3. start a container

GET /admin/start/:ID.:Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/start/8.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.3.4. start a containers postgres database

GET /admin/start-pg/:ID.:Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/start-pg/1.8dc0caed-39e7-47b4-878c-de1c8b0b595d

1.3.5. return a container

GET /node/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/node/8.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.3.6. delete a container

GET /deletenode/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/deletenode/17.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.3.7. provision a new container

POST /provision

  • Profile : the Docker profile to use for this node

  • Image : the Docker image name to base this node on

  • ServerID : the unique ID of the server to host this container

  • ContainerName : the user picked name for this container

  • Standalone : flag for making this node available to be part of a cluster

  • Token : the generated auth token for this session

curl --data @provision.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/provision

1.3.8. return all containers not in a cluster

GET /nodes/nocluster/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/nodes/nocluster/1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.3.9. return all containers

GET /nodes/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/nodes/1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

## Proxy Information

1.3.10. create a proxy container

POST /provisionproxy

curl --data @provisionproxy.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/provisionproxy

1.3.11. return proxy information

GET /proxy/getbycontainerid/:ContainerID.:Token

  • ContainerID : the container ID of the proxy

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/proxy/getbycontainerid/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.3.12. update a proxy container

POST /proxy/update

curl --data @proxyupdate.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/proxy/update

1.4. Access Rule Information

1.4.1. get an access rule

GET /rules/get/:ID.:Token

  • ID : the access rule ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/rules/get/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.4.2. get all access rules

GET /rules/getall/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/rules/getall/1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.4.3. delete an access rule

GET /rules/delete/:ID.:Token

  • ID : the access rule ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/rules/delete/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.4.4. update an access rule

POST /rules/update

curl --data @ruleupdate.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/rules/update

1.4.5. insert an access rule

POST /rules/insert

curl --data @ruleinsert.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/rules/insert

1.4.6. get all accessrules for a container

GET /containerrules/getall/:ID.:Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/containerrules/getall/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.4.7. update accessrules for a container

POST /containerrules/update

curl --data @containerrulesupdate.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/containerrules/update

1.5. Server Information

1.5.1. perform a docker start on all containers on a given server

GET /admin/startall/:ID.:Token

  • ID : the unique ID for a server

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/startall/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.5.2. perform a docker stop on all containers on a given server

GET /admin/stopall/:ID.:Token

  • ID : the unique ID for a server

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/stopall/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.5.3. return all containers for a server

GET /nodes/forserver/:ServerID.:Token

  • ServerID : the unique ID for a server

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/nodes/forserver/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.5.4. return a server

GET /server/:ID.:Token

  • ID : the unique assigned ID of a server

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/1.8dc0caed-39e7-47b4-878c-de1c8b0b595d

1.5.5. delete a server

GET /deleteserver/:ID.:Token

  • ID : the unique assigned ID of a server

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/deleteserver/1.jkjakdjfkjadkfjkajdf

1.5.6. returns all servers

GET /servers/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/servers/789c31ff-b18f-47b3-bb63-1fd603895aa5

1.5.7. Get all the servers defined in CPM

GET /servers/:Token

  • Token : the security token used for auth

curl  http://cpm-admin.crunchy.lab:13001/servers/789c31ff-b18f-47b3-bb63-1fd603895aa5

1.5.8. add a server

GET /addserver/:ID.:Name.:IPAddress.:DockerBridgeIP.:PGDataPath.:ServerClass.:Token

  • ID : 0 for adding a new server…non-zero is to update a server

  • Name : the server name

  • IPAddress : the server IP address

  • DockerBridgeIP : the Docker Bridge IP to use for this server

  • PGDataPath : the root file path to where PG data files will be stored

  • ServerClass : the server class we are assiging to this server (low|medium|high)

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/addserver/1.foo.192-168-0-104.171-10-10-17.

1.6. Database User Information

1.6.1. add a database user to a given container

POST /dbuser/add

curl --data @dbuseradd.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/dbuser/add

1.6.2. update a database user to a given container

POST /dbuser/update

curl --data @dbuserupdate.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/dbuser/update

1.6.3. delete a database user for a given container

GET /dbuser/delete/:ContainerID.:Rolname.:Token

  • ContainerID : the container ID

  • Rolname : the role name we are deleting

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/dbuser/delete/1.foo.kjakdjfkajdkfj

1.6.4. get a database user for a given container

GET /dbuser/get/:ContainerID.:Rolname.:Token

  • ContainerID : the container ID

  • Rolname : the role name we are fetching

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/dbuser/get/1.foo.kjakdjfkajdkfj

1.6.5. get all database users for a given container

GET /dbuser/getall/:ID.:Token

  • ContainerID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/dbuser/getall/1.kjakdjfkajdkfj

1.7. Cluster Information

1.7.1. add a node to a cluster

GET /event/join-cluster/:IDList.:MasterID.:ClusterID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/event/join-cluster/1.1.1.789c31ff-b18f-47b3-bb63-1fd603895aa5

1.7.2. cause a postgres fail over on a given container

GET /admin/failover/:ID.:Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/admin/failover/1.789c31ff-b18f-47b3-bb63-1fd603895aa5

1.7.3. return all containers for a given cluster

GET /clusternodes/:ClusterID.:Token

  • ClusterID : the unique ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/clusternodes/2.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.7.4. perform a docker stop on a given clusters set of containers

GET /cluster/stop/:ID.:Token

  • ID : the unique assigned ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/stop/2.1efbfd50-9bb243a0-8c91-b6f4a837a4f2

1.7.5. perform a docker start on a given clusters set of containers

GET /cluster/start/:ID.:Token

  • ID : the unique assigned ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/start/2.1efbfd50-9bb243a0-8c91-b6f4a837a4f2

1.7.6. return a cluster

GET /cluster/:ID.:Token

  • ID : the unique assigned ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/2.1efbfd50-9bb243a0-8c91-b6f4a837a4f2

1.7.7. configure a cluster

GET /cluster/configure/:ID.:Token

  • ID : the unique assigned ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/configure/2.1efbfd50-9bb243a0-8c91-b6f4a837a4f2

1.7.8. delete a cluster and its containers

GET /cluster/delete/:ID.:Token

  • ID : the unique assigned ID of a cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/delete/1.1efbfd50-9bb243a0-8c91-b6f4a837a4f2

1.7.9. Get all the clusters for a given project

GET /projectclusters/:ID.:Token

  • ID : the user id to authenticate with

  • Token : the security token used for auth

curl  http://cpm-admin.crunchy.lab:13001/projectclusters/1.789c31ff-b18f-47b3-bb63-1fd603895aa5

1.7.10. updates or adds a cluster

POST /cluster

curl --data @postcluster.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/cluster

1.7.11. performs an auto-cluster

POST /autocluster

  • Name : the name to use for this cluster

  • ClusterType : the type of cluster (synchronous|asynchronous)

  • ClusterProfile : the cluster profile to use for cluster creation (SM|LG|MED)

  • Token : the generated auth token for this session

curl --data @autocluster.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/autocluster

1.7.12. returns all clusters

GET /clusters/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/clusters/789c31ff-b18f-47b3-bb63-1fd603895aa5

1.7.13. add a standby node to a given cluster

GET /cluster/scale/:ID.:Token

  • ID : unique id of a given cluster

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/cluster/scale/1.789c31ff-b18f-47b3-bb63-1fd603895aa5

1.8. Task Information

1.8.1. execute a task schedule immediately

POST /task/executenow

  • Token : the generated auth token for this session

curl --data @executenow.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/task/executenow

1.8.2. add a new container schedule

POST /task/addschedule

  • Token : the generated auth token for this session

curl --data @addschedule.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/task/addschedule

1.8.3. remove a container schedule

GET /task/deleteschedule/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/deleteschedule/1.kjkjadfjkajdfkjadksf

1.8.4. update a container schedule

POST /task/updateschedule

  • Token : the generated auth token for this session

curl --data @updateschedule.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/task/updateschedule

1.8.5. get all schedules for a container

GET /task/getschedules/:ContainerName.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/getschedules/foo.kjadkfjkjakdjfkadjf

1.8.6. get a container schedule

GET /task/getschedule/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/getschedule/1.fkjkjadkfjkjadsfjkdaf

1.8.7. get a schedule job status

GET /task/getstatus/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/getstatus/1.kjakdjfkajkdjfkjadfasdf

1.8.8. deletes a task schedule history

POST /task/deletestatus

curl --data @deletetaskstatus.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/task/deletestatus

1.8.9. get all scheduled job status for a container

GET /task/getallstatus/:ID.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/getallstatus/1.kjakjadfjkjaksdjfkajdf

1.8.10. TODO

GET /task/nodes/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/task/nodes/kjakjfjkadjfkjkajdf

1.9. Settings

1.9.1. saves profiles

POST /saveprofiles

curl --data @saveprofiles.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/saveprofiles

1.9.2. saves cluster profiles

POST /saveclusterprofiles

curl --data @saveclusterprofiles.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/saveclusterprofiles

1.9.3. update a setting value

POST /savesetting

curl --data @savesetting.json -H "Content-Type: application/json" -X POST \
http://cpm-admin:13001/savesetting

1.9.4. returns all settings

GET /settings/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/settings/789c31ff-b18f-7b3-bb63-1fd603895aa5

1.10. Monitoring

1.10.1. GetHC1 - health check 1 - databases down

GET /mon/healthcheck/:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/mon/healthcheck/24c715ca-2468-4450-8fee-6e2a9f7714dc

1.10.2. return container pg_settings data

GET /monitor/container/settings/:ID.Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/container/settings/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.3. return container pg_replication data

GET /monitor/container/repl/:ID.Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/container/repl/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.4. return container pg_databases data

GET /monitor/container/database/:ID.Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/container/database/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.5. return container bgwriter data

GET /monitor/container/bgwriter/:ID.Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/container/bgwriter/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.6. return container controldata data

GET /monitor/container/controldata/:ID.Token

  • ID : the container ID

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/container/controldata/1.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.7. return server monitoring data

GET /monitor/server-getinfo/:ServerID.:Metric.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin.crunchy.lab:13001/monitor/server-getinfo/1.cpmdf.1efbfd50-9bb2-43a0-8c91-b6f4a837a4f2

1.10.8. perform a load test and return the results

GET /monitor/container/loadtest/:ID.:Writes.:Token

  • Token : the generated auth token for this session

curl  http://cpm-admin:13001/monior/container/loadtest/1.1000.9a8f9a1e-9c81-4e4f-9f52-01d2ea6cd741

1.10.9. returns the CPM version number

GET /version

curl  http://cpm-admin.crunchy.lab:13001/version

2. CPM Server API

The CPM Server REST API includes functions that pertain to CPM servers such as disk volume provisioning and collection of server metrics. This API is exposed by the cpmserver golang program. Each CPM server runs a cpmserver.

2.1. Metrics

2.1.1. get iostat metrics

POST /metrics/iostat

  • Something : blank value

  • Other : blank value

curl --data @get-iostat.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/metrics/iostat

2.1.2. get df metrics

POST /metrics/df

  • Something : blank value

  • Other : blank value

curl --data @get-df.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/metrics/df

2.1.3. get memory metrics

POST /metrics/mem

  • Something : blank value

  • Other : blank value

curl --data @get-df.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/metrics/mem

2.1.4. get cpu metrics

POST /metrics/cpu

  • Something : blank value

  • Other : blank value

curl --data @get-df.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/metrics/cpu

2.2. Disk Mgmt

2.2.1. provision a disk volume

POST /disk/provision

  • Path : the disk path to provision

curl --data @get-df.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/disk/provision

2.2.2. delete a disk volume

POST /disk/delete

  • Path : the disk path to delete

curl --data @get-df.json -H "Content-Type: application/json" -X POST \
http://cpm-server:10001/disk/delete

2.2.3. get the status of the service

GET /status

  • Token : the generated auth token for this session

curl  http://cpm-server:11001/status

3. CPM Task API

The CPM Task REST API includes functions that pertain to tasks that are scheduled within CPM. Tasks include doing backups and restores currently. Tasks can also be executed upon demand by CPM users.

3.1. Misc

3.1.1. add status for an executing task

POST /status/add

{
        'Token'         :'1',
        'ID'            :'1',
        'ContainerName' :'SM',
        'StartTime'     :'SM',
        'TaskName'      :'somecontainer'
        'ProfileName'   :'somecontainer'
        'ScheduleID'    :'somecontainer'
        'Path'          :'somecontainer'
        'ElapsedTime'   :'somecontainer'
        'TaskSize'      :'somecontainer'
        'Status'        :'somecontainer'
        'UpdateDt'      :'somecontainer'
}
curl --data @add-status.json -H "Content-Type: application/json" -X POST \
http://cpm-task:10001/status/add

3.1.2. update status for an executing task

POST /status/update

{
        'ScheduleID'    :'1',
        'StatusID'      :'1',
        'DockerProfile' :'SM',
        'ProfileName'   :'SM',
        'ContainerName' :'somecontainer'
}
curl --data @update-status.json -H "Content-Type: application/json" -X POST \
http://cpm-task:10001/status/update

3.1.3. execute a task immediately

POST /executenow

{
        'ScheduleID'    :'1',
        'StatusID'      :'1',
        'DockerProfile' :'SM',
        'ProfileName'   :'SM',
        'ContainerName' :'somecontainer'
}
curl --data @executenow.json -H "Content-Type: application/json" -X POST \
http://cpm-task:10001/executenow

3.1.4. reload the cron schedule

POST /reload

{
        'Name'  :'anything'
}
curl --data @reload.json -H "Content-Type: application/json" -X POST \
http://cpm-task:10001/reload

4. CPM Container API

The CPM Container REST API includes functions that pertain to command and control of the cpm-node and cpm-pgpool containers. This API effectively implements an agent capability within each provisioned container that allows CPM to control the container when it is running.

4.1. Misc

4.1.1. status

GET /status

curl http://somecontainer:10001/status

4.1.2. write a file to the container

POST /remotewritefile

{
        'Path'  :'pg_hba.conf',
        'Filecontents'  :'...'
}
curl --data @writefile.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/remotewritefile

4.1.3. create the CPM objects within the container database

POST /seed

{
        'ContainerName' :'somecontainer'
}
curl --data @seed.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/seed

4.1.4. start Postgresql on the container

POST /startpg

{
        'ContainerName' :'somecontainer'
}
curl --data @startpg.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/startpg

4.1.5. stop Postgresql on the container

POST /stoppg

{
        'ContainerName' :'somecontainer'
}
curl --data @stoppg.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/stoppg

4.1.6. start Postgresql on a standby container

POST /startpgonstandby

{
        'ContainerName' :'somecontainer'
}
curl --data @startpgonstandby.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/startpgonstandby

4.1.7. run the postgresql initdb command on the container

POST /initdb

{
        'ContainerName' :'somecontainer'
}
curl --data @initdb.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/initdb

4.1.8. start pgpool on a pgpool container

POST /startpgpool

{
        'ContainerName' :'somecontainer',
        'Path'  :'something'
}
curl --data @startpgpool.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/startpgpool

4.1.9. stop pgpool on a pgpool container

POST /stoppgpool

{
        'ContainerName' :'somecontainer',
        'Path'          :'something'
}
curl --data @stoppgpool.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/stoppgpool

4.1.10. perform a pg_basebackup on the container

POST /basebackup

{
        'MasterHostName'        :'master',
        'Username'      :'someuser',
        'Password' :'adskjafd'
}
curl --data @basebackup.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/basebackup

4.1.11. trigger a failover on this container

POST /failover

{
        'ContainerName' :'somecontainer'
}
curl --data @failover.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/failover

4.1.12. run pg_controldata on the container and get output

POST /controldata

{
        'Path'  :'/fokj',
}
curl --data @controldata.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/controldata

4.1.13. run pgbadger on the container and get the results

POST /badgergenerate

{
        'ContainerName' :'somecontainer'
}
curl --data @badgergenerate.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/badgergenerate

4.1.14. run a database restore on the container

POST /restore

{
        'ContainerName'         :'somecontainer',
        'RestoreRemotePath'     :'/kjkjadf',
        'RestoreRemoteHost'     :'antherhost',
        'RestoreDbUser'         :'someuser',
        'RestoreDbPass'         :'jkjadfadfk',
        'RestoreSet'            :'current'
}
curl --data @restore.json -H "Content-Type: application/json" -X POST \
http://somecontainer:10001/restore