Skip to content

Commit

Permalink
PMM-12913 fix tests for /v1/inventory/services
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Mar 26, 2024
1 parent 1699d7f commit 8c5b6ff
Show file tree
Hide file tree
Showing 20 changed files with 2,919 additions and 1,246 deletions.
1 change: 1 addition & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ gen-api: ## Generate PMM API
api/backup/v1/json/v1.json \
api/advisors/v1/json/v1.json \
api/alerting/v1/json/v1.json \
api/dump/v1/json/v1.json \
api/qan/v1/json/v1.json
bin/swagger validate api/swagger/swagger.json

Expand Down
50 changes: 50 additions & 0 deletions api/MIGRATION_EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# API Migration Examples

## Some dos and don'ts

### Don't URLEncode the prefix - it won't work
curl -s -X PUT -d '{"postgres_exporter":{"enable":false}}' "http://admin:[email protected]:8080/v1/inventory/agents/%2Fagent_id%2Ff56ee4e8-116c-496b-812f-a803dd2fe88d"

### Don't use plain bold prefix - it won't work
curl -s -X PUT -d '{"postgres_exporter":{"enable":false}}' "http://admin:[email protected]:8080/v1/inventory/agents//agent_id/f56ee4e8-116c-496b-812f-a803dd2fe88d"

### Do pass UUID as an URL path segment
curl -s -X PUT -d '{"postgres_exporter":{"enable":false}}' http://admin:[email protected]:8080/v1/inventory/agents/f56ee4e8-116c-496b-812f-a803dd2fe88d

## Examples

### POST /v1/inventory/Agents/Change -> PUT /v1/inventory/agents/{agent_id}
curl -s -X PUT -d '{"postgres_exporter":{"enable":true}}' http://admin:[email protected]:8080/v1/inventory/agents/f56ee4e8-116c-496b-812f-a803dd2fe88d

### POST /v1/inventory/Agents/Get -> GET /v1/inventory/agents/{agent_id}
curl -s -X GET http://admin:[email protected]:8080/v1/inventory/agents/02ecd9e3-d7b8-4d94-9c75-060b8e6e3e84

### POST /v1/inventory/Agents/List -> GET /v1/inventory/agents?agent_type=AGENT_TYPE_POSTGRES_EXPORTER
curl -s -X GET http://admin:[email protected]:8080/v1/inventory/agents
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?agent_type=AGENT_TYPE_POSTGRES_EXPORTER
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?agent_type=AGENT_TYPE_PMM_AGENT
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?pmm_agent_id=pmm-server
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?pmm_agent_id=/agent_id/02ecd9e3-d7b8-4d94-9c75-060b8e6e3e84
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?pmm_agent_id=02ecd9e3-d7b8-4d94-9c75-060b8e6e3e84
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?service_id=/service_id/6984244c-0a18-4508-a219-3977e8fb01d0
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents?service_id=6984244c-0a18-4508-a219-3977e8fb01d0

### POST /v1/inventory/Agents/GetLogs - GET /v1/inventory/agents/{agent_id}/logs
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents/49bef198-299c-41b3-ba05-578defe63678/logs
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/agents/49bef198-299c-41b3-ba05-578defe63678/logs?limit=10

### POST /v1/inventory/Nodes/Get -> GET /v1/inventory/nodes/{node_id}
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/nodes/32c914d1-daf0-468a-aa9d-4ebb65ab2ee9

### POST /v1/inventory/Services/Get -> GET /v1/inventory/services/{service_id}
curl -s -X GET http://admin:admin@localhost:8080/v1/inventory/services/d4dfdccf-c07c-48a6-a101-b119b04d880f

### POST /v1/inventory/Services/Change -> PUT /v1/inventory/services/{service_id}
curl -s -X PUT -d '{"cluster": "test2","environment":"dev","replication_set":"main"}' http://admin:admin@localhost:8080/v1/inventory/services/d4dfdccf-c07c-48a6-a101-b119b04d880f
### add/update custom labels
curl -s -X PUT -d '{"custom_labels":{"values":{"env":"foo","bar":"123"}}}' http://admin:admin@localhost:8080/v1/inventory/services/d4dfdccf-c07c-48a6-a101-b119b04d880f
### remove a standard label and all custom labels
curl -s -X PUT -d '{"replication_set":"","custom_labels":{}}' http://admin:admin@localhost:8080/v1/inventory/services/d4dfdccf-c07c-48a6-a101-b119b04d880f

### POST /v1/inventory/Services/ListTypes -> POST /v1/inventory/services:getTypes
curl -s -X POST http://admin:admin@localhost:8080/v1/inventory/services:getTypes
4 changes: 2 additions & 2 deletions api/MIGRATION_TO_V3.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ POST /v1/inventory/Services/Add POST /v1/inventory/services
POST /v1/inventory/Services/Change PUT /v1/inventory/services/{service_id} ✅
POST /v1/inventory/Servicse/Get GET /v1/inventory/services/{service_id} ✅
POST /v1/inventory/Services/List GET /v1/inventory/services ✅
POST /v1/inventory/Services/Remove DELETE /v1/inventory/services/{service_id} ✅ pass ?force=true to remove service with agents
POST /v1/inventory/Services/ListTypes GET /v1/inventory/services/types
POST /v1/inventory/Services/Remove DELETE /v1/inventory/services/{service_id} ✅ pass ?force=true to remove a service with agents
POST /v1/inventory/Services/ListTypes POST /v1/inventory/services:getTypes
POST /v1/inventory/Services/CustomLabels/Add PUT /v1/inventory/services/{service_id} ✅ NOTE: merged into PUT /v1/inventory/services/{id}
POST /v1/inventory/Services/CustomLabels/Remove PUT /v1/inventory/services/{service_id} ✅ NOTE: merged into PUT /v1/inventory/services/{id}

Expand Down
Loading

0 comments on commit 8c5b6ff

Please sign in to comment.