Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12913 Migrate api endpoints to REST #2880

Open
wants to merge 87 commits into
base: v3-api-breaking-changes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
8b787b4
PMM-12913 Add a resource name to endpoints ending with /v1
ademidoff Mar 6, 2024
dd00b48
PMM-12913 fix the linter error (goconst)
ademidoff Mar 8, 2024
581e273
PMM-12913 migrate /v1/version
ademidoff Mar 11, 2024
1db0345
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff Mar 11, 2024
559c7f3
Merge branch 'PMM-12913-migrate-api-endpoints-to-restful' of github.c…
ademidoff Mar 11, 2024
cb7876e
PMM-12913 migrate /v1/readyz
ademidoff Mar 12, 2024
a2cfd00
PMM-12913 all endpoints begin with `/v1`
ademidoff Mar 12, 2024
5b850e3
PMM-12913 make gen
ademidoff Mar 12, 2024
8c6c4f6
PMM-12913 migrate /v1/settings/Get
ademidoff Mar 12, 2024
0e99c6f
PMM-12913 fix unit test fo /v1/server/settings
ademidoff Mar 13, 2024
9711084
PMM-12913 migrate /v1/settings/Change
ademidoff Mar 13, 2024
53c8bc1
PMM-12913 migrate /v1/AWSInstanceCheck
ademidoff Mar 13, 2024
5468b44
PMM-12913 fix alerting api tests
ademidoff Mar 14, 2024
431cb46
PMM-12913 fix ManagementService being disabled
ademidoff Mar 14, 2024
3d157e6
PMM-12913 fix backup API tests
ademidoff Mar 15, 2024
9aabc16
PMM-12913 temporarily allow /v1/version
ademidoff Mar 15, 2024
51a75e7
PMM-12913 update admins' readme
ademidoff Mar 15, 2024
48afac7
PMM-12913 fix the Agent connect path in auth
ademidoff Mar 16, 2024
75cd92c
PMM-12913 fix wrong grpc paths
ademidoff Mar 16, 2024
95d4b0b
PMM-12913 fix the port in readme
ademidoff Mar 16, 2024
15f215f
PMM-12913 fix some grpc paths
ademidoff Mar 17, 2024
f003f63
PMM-12913 add check-agent-setup script
ademidoff Mar 17, 2024
a314087
PMM-12913 migrate /v1/server/leaderHealthCheck endpoint
ademidoff Mar 19, 2024
969240e
PMM-12913 migrate /v1/settings/Get
ademidoff Mar 19, 2024
f8d4a7d
PMM-12913 fix the api test
ademidoff Mar 19, 2024
648d12d
PMM-12913 migrate /v1/updates/Start
ademidoff Mar 19, 2024
e4e8ff7
PMM-12913 fix actions
ademidoff Mar 19, 2024
bf33deb
PMM-12913 migrate /logs.zip
ademidoff Mar 19, 2024
0ecd19d
PMM-12913 fix auth_server_test
ademidoff Mar 19, 2024
ef336bd
PMM-12913 migrate /v1/updates/Status
ademidoff Mar 21, 2024
dcecf86
PMM-12913 migrate /v1/users
ademidoff Mar 21, 2024
4e1b050
PMM-12913 migrate /v1/inventory/Agents
ademidoff Mar 22, 2024
f19b2f1
PMM-12913 fix logs_test
ademidoff Mar 22, 2024
4f5ed6e
PMM-12913 use an interface for commonAgentParams
ademidoff Mar 22, 2024
77150a7
PMM-12913 re-add `/agent_id/`
ademidoff Mar 22, 2024
a13cf16
PMM-12913 migrate /v1/inventory/Agents/Get
ademidoff Mar 22, 2024
9ac20bc
PMM-12913 migrate /v1/inventory/Agents/Remove
ademidoff Mar 22, 2024
39b9316
PMM-12913 migrate /v1/inventory/Agents/GetLogs
ademidoff Mar 24, 2024
b20073a
PMM-12913 migrate /v1/inventory/Nodes
ademidoff Mar 24, 2024
1699d7f
PMM-12913 migrate /v1/inventory/Services
ademidoff Mar 24, 2024
8c5b6ff
PMM-12913 fix tests for /v1/inventory/services
ademidoff Mar 26, 2024
0b7f759
PMM-12913 migrate /v1/management/Service
ademidoff Mar 27, 2024
7df6560
PMM-12913 migrate /v1/actions
ademidoff Mar 29, 2024
425f8eb
PMM-12899 migrate /v1/alerting endpoints
ademidoff Apr 3, 2024
205c80d
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff Apr 4, 2024
12d6aaa
PMM-12899 migrate /v1/advisors emdpoints
ademidoff Apr 4, 2024
64792d5
PMM-12899 rename BackupsService to BackupService
ademidoff Apr 4, 2024
c5628b9
PMM-12899 migrate /v1/backup/Artifacts
ademidoff Apr 5, 2024
9393931
PMM-12899 migrate /v1/backup/Backups
ademidoff Apr 6, 2024
908b241
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff Apr 8, 2024
b9b5192
PMM-12913 refactor /v1/backups/locations
ademidoff Apr 8, 2024
4f0edeb
PMM-12913 refactor /v1/backups/restores
ademidoff Apr 8, 2024
c375f29
PMM-12913 refactor /v1/dumps
ademidoff Apr 8, 2024
a039868
PMM-12913 move dump and role API to v1beta1 folder
ademidoff Apr 9, 2024
3f9f9f0
PMM-12913 refactor /v1/role, rename tp /v1/accesscontrol
ademidoff Apr 9, 2024
2892180
PMM-12913 refactor /v1/management/nodes {Get,LIst}
ademidoff Apr 10, 2024
6d593de
PMM-12913 refactor /v1/management/services/List
ademidoff Apr 10, 2024
a6f6d68
PMM-12913 refactor /v1/management/services/azure
ademidoff Apr 10, 2024
f85a909
PMM-12913 refactor /v1/management/agent/List
ademidoff Apr 10, 2024
6b6d5ab
PMM-12913 migrate /v1/platform
ademidoff Apr 11, 2024
8903158
PMM-12913 migrate /v1/qan
ademidoff Apr 12, 2024
057a27e
PMM-12913 refactor the primitive types in alerting.proto
ademidoff Apr 12, 2024
1962725
PMM-12913 fix a few linter errors
ademidoff Apr 12, 2024
d6d8ad8
PMM-12913 do not show CollectorService in swagger
ademidoff Apr 17, 2024
9f0be58
PMM-12913 split /backup/GetLogs up to two endpoints
ademidoff Apr 18, 2024
e1e6c6d
PMM-12913 fix restore tests
ademidoff Apr 18, 2024
9635170
PMM-12913 update migration examples
ademidoff May 23, 2024
b8571d2
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff May 23, 2024
971adfd
PMM-12913 fix /v1/qan/metrics:getFilters being unavailable
ademidoff May 23, 2024
cae92ea
PMM-12913 fix the linter error
ademidoff May 23, 2024
2911dff
PMM-12913 fix /v1/qan/metrics:getFilters test
ademidoff May 23, 2024
38c8b06
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff May 27, 2024
9a2e6f7
PMM-12913 update migration examples
ademidoff May 27, 2024
ded7788
PMM-12913 fix an iteration bug
ademidoff May 27, 2024
21e89f2
PMM-12913 fix an issue with QAN failing to persist data
ademidoff May 29, 2024
f9b2fa1
PMM-12913 remove debug output
ademidoff May 30, 2024
cb2ef98
PMM-12913 auth_server fixes for QAN
ademidoff May 31, 2024
51589a0
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff Jun 2, 2024
6353a5b
PMM-12913 fix agent API tests
ademidoff Jun 3, 2024
7334e95
PMM-12913 fix the QAN URL routing issue
ademidoff Jun 5, 2024
d49e281
PMM-12913 remove the unnecessary PMM_NICER_API
ademidoff Jun 5, 2024
605ed44
PMM-12913 add the routing error handler
ademidoff Jun 5, 2024
3779c33
PMM-12913 minor syntax fixes
ademidoff Jun 6, 2024
d35897a
PMM-12913 remove PMM_LESS_LOG_NOISE envvar
ademidoff Jun 6, 2024
adbc985
Merge branch 'v3-api-breaking-changes' into PMM-12913-migrate-api-end…
ademidoff Jun 6, 2024
04b6196
PMM-12913 remove ID normalizers
ademidoff Jun 6, 2024
6913e01
PMM-12913 update the migration doc
ademidoff Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 21 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,23 @@ jobs:

- name: Run API linter
env:
COMMAND: 'bin/buf lint -v api'
REDIRECT: "| bin/reviewdog -f=buf -reporter=github-pr-review -fail-on-error=true"
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$( ${{ env.COMMAND }} ); exit_code=$?; [ $exit_code -ne 0 ]; then
## buf uses exit code 100 for linter warnings
if [ $exit_code != 100 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
else
echo "$out" ${{ env.REDIRECT }}
fi
else
if out=$(bin/buf lint -v api); code="$?"; test "$code" -eq 0; then
echo "$out"
exit 0
fi

echo "API linter exited with code: $code"
echo "$out"
## buf uses exit code 100 for linter warnings
if [ "$code" -ne 100 ] || ${{ github.event.pull_request == null }}; then
exit $code
fi

# One may need to suppress passing to reviewdog because of https://github.com/reviewdog/reviewdog/issues/1696
echo "$out" | bin/reviewdog -f=buf -reporter=github-pr-review -fail-on-error=true

- name: Run code linters
uses: reviewdog/action-golangci-lint@v2
with:
Expand All @@ -110,21 +111,20 @@ jobs:

- name: Run go-consistent
env:
COMMAND: 'bin/go-consistent -pedantic -exclude "tests" ./...'
REDIRECT: "| bin/reviewdog -f=go-consistent -reporter=github-pr-review -fail-on-error=true"
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$( ${{ env.COMMAND }} ); exit_code=$?; [ $exit_code -ne 0 ]; then
if [ $exit_code -gt 1 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
else
echo "$out" ${{ env.REDIRECT }}
fi
else
if out=$(bin/go-consistent -pedantic -exclude "tests" ./...); exit_code=$?; [ $exit_code -eq 0 ]; then
echo "$out"
exit 0
fi

if [ $exit_code -gt 1 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
fi

echo "$out" | bin/reviewdog -f=go-consistent -reporter=github-pr-review -fail-on-error=true

- name: Test common API
run: make test-common

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ jobs:

- name: Launch PMM Server (see docker-compose.yml)
run: |
# Note: launching the container with --wait fails for an unknown reason.
# A temporary workaround is to run it manually. To be reverted once the issue is resolved.
# make env-compose-up # the container workdir is /root/go/src/github.com/percona/pmm
docker compose --profile pmm up -d
sleep 100s
make env-compose-up # the container workdir is /root/go/src/github.com/percona/pmm
docker logs pmm-server

- name: Restore Go build cache
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ issues:
- forcetypeassert # for tests' brevity sake
- funlen # tests may be long
- gocognit # triggered by subtests
- goconst # not critical for tests
- gomnd # tests are full of magic numbers
- ireturn # we have exceptions, so need to silence them in tests
- lll # tests often require long lines
Expand Down
48 changes: 37 additions & 11 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ gen-api: ## Generate PMM API

bin/buf generate -v api

for API in api/agentlocal/v1 api/server/v1 api/inventory/v1 api/management/v1 api/actions/v1 api/advisors/v1 api/alerting/v1 api/backup/v1 api/dump/v1 api/management/v1/azure api/role/v1 api/qan/v1 api/management/v1/agent api/management/v1/node api/management/v1/service api/platform/v1 api/user/v1; do \
SPECS="\
api/agentlocal/v1 \
api/server/v1 \
api/user/v1 \
api/inventory/v1 \
api/management/v1 \
api/management/v1/service \
api/actions/v1 \
api/advisors/v1 \
api/alerting/v1 \
api/backup/v1 \
api/dump/v1beta1 \
api/accesscontrol/v1beta1 \
api/qan/v1 \
api/platform/v1"; \
for API in $$SPECS; do \
set -x ; \
bin/swagger mixin $$API/json/header.json $$API/*.swagger.json --output=$$API/json/$$(basename $$API).json --keep-spec-order; \
bin/swagger flatten --with-flatten=expand --with-flatten=remove-unused $$API/json/$$(basename $$API).json --output=$$API/json/$$(basename $$API).json ; \
Expand Down Expand Up @@ -78,7 +93,8 @@ gen-api: ## Generate PMM API
api/backup/v1/json/v1.json \
api/advisors/v1/json/v1.json \
api/alerting/v1/json/v1.json \
api/qan/v1/json/v1.json
api/dump/v1beta1/json/v1beta1.json \
api/qan/v1/json/v1.json
bin/swagger validate api/swagger/swagger.json

bin/swagger-order --output=api/swagger/swagger.json api/swagger/swagger.json
Expand All @@ -94,12 +110,8 @@ gen-api: ## Generate PMM API
api/alerting/v1/json/v1.json \
api/advisors/v1/json/v1.json \
api/backup/v1/json/v1.json \
api/dump/v1/json/v1.json \
api/management/v1/azure/json/azure.json \
api/role/v1/json/v1.json \
api/management/v1/agent/json/agent.json \
api/management/v1/node/json/node.json \
api/management/v1/service/json/service.json \
api/dump/v1beta1/json/v1beta1.json \
api/accesscontrol/v1beta1/json/v1beta1.json \
api/qan/v1/json/v1.json \
api/platform/v1/json/v1.json

Expand Down Expand Up @@ -129,7 +141,21 @@ clean: clean_swagger ## Remove generated files
find api -name '*.pb.gw.go' -print -delete
find api -name '*.validate.go' -print -delete

for API in api/agentlocal/v1 api/server/v1 api/inventory/v1 api/management/v1 api/actions/v1 api/alerting/v1 api/advisors/v1 api/backup/v1 api/dump/v1 api/role/v1 api/management/v1/agent api/management/v1/node api/management/v1/service api/qan/v1 api/platform/v1 ; do \
SPECS="\
api/agentlocal/v1 \
api/server/v1 \
api/user/v1 \
api/inventory/v1 \
api/management/v1 \
api/actions/v1 \
api/alerting/v1 \
api/advisors/v1 \
api/backup/v1 \
api/dump/v1beta1 \
api/accesscontrol/v1beta1 \
api/qan/v1 \
api/platform/v1"; \
for API in $$SPECS; do \
rm -fr $$API/json/client $$API/json/models $$API/json/$$(basename $$API).json ; \
done
rm -f api/swagger/swagger.json api/swagger/swagger-dev.json
Expand All @@ -142,8 +168,8 @@ api-test: ## Run API tests on dev env.

check: ## Run required checkers and linters
bin/buf lint -v api
LOG_LEVEL=error bin/golangci-lint run ; \
bin/go-sumtype ./... ; \
LOG_LEVEL=error bin/golangci-lint run
bin/go-sumtype ./...
bin/go-consistent -pedantic ./...

check-license: ## Run license header checks against source files
Expand Down
11 changes: 6 additions & 5 deletions admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ git, make, curl, go, gcc, pmm-server, pmm-agent

## Local setup
### To run pmm-admin commands
- Run [pmm-server docker container](https://hub.docker.com/r/percona/pmm-server) or [pmm-managed](https://github.com/percona/pmm-managed).
- Run [pmm-server docker container](https://hub.docker.com/r/percona/pmm-server) or [pmm-managed](https://github.com/percona/pmm/tree/main/managed).
- Run pmm-agent `cd ../agent`.
- Run pmm-admin commands.
```shell script
Expand All @@ -18,8 +18,9 @@ git, make, curl, go, gcc, pmm-server, pmm-agent

You should see something like this
```shell script
Agent ID: /agent_id/fcbe3cb4-a95a-43f4-aef5-c3494caa5132
Node ID : /node_id/77be6b4d-a1d9-4687-8fae-7acbaee7db47
Agent ID : /agent_id/fcbe3cb4-a95a-43f4-aef5-c3494caa5132
Node ID : /node_id/77be6b4d-a1d9-4687-8fae-7acbaee7db47
Node name: mysql-server-test-1

PMM Server:
URL : https://127.0.0.1:443/
Expand All @@ -31,10 +32,10 @@ PMM-agent:
Latency : 211.026µs

Agents:
/agent_id/3329a405-8a5d-4414-9890-b6ae4209e0cc NODE_EXPORTER RUNNING
/agent_id/3329a405-8a5d-4414-9890-b6ae4209e0cc NODE_EXPORTER RUNNING 40001
```
It means that everything works.

## Testing
pmm-admin doesn't require setting-up environment.
pmm-admin doesn't require setting-up an environment.
Run `make test` to run tests.
9 changes: 3 additions & 6 deletions admin/commands/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package commands
import (
"strings"

"github.com/AlekSi/pointer"
"github.com/pkg/errors"

"github.com/percona/pmm/admin/agentlocal"
Expand Down Expand Up @@ -77,9 +78,7 @@ func (cmd *AnnotationCommand) getCurrentNode() (*nodes.GetNodeOKBody, error) {
}

params := &nodes.GetNodeParams{
Body: nodes.GetNodeBody{
NodeID: status.NodeID,
},
NodeID: status.NodeID,
Context: Ctx,
}

Expand Down Expand Up @@ -109,9 +108,7 @@ func (cmd *AnnotationCommand) getCurrentNodeAllServices() ([]string, error) {
}

params := &services.ListServicesParams{
Body: services.ListServicesBody{
NodeID: status.NodeID,
},
NodeID: pointer.ToString(status.NodeID),
Context: Ctx,
}

Expand Down
2 changes: 1 addition & 1 deletion admin/commands/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestCredentials(t *testing.T) {
// Test reading is OK
t.Parallel()
creds, _ := ReadFromSource(credSource)
assert.Equal(t, creds.Username, "testuser")
assert.Equal(t, "testuser", creds.Username)
})

t.Run("Executing", func(t *testing.T) {
Expand Down
14 changes: 5 additions & 9 deletions admin/commands/inventory/list_agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,12 @@ func (cmd *ListAgentsCommand) RunCmd() (commands.Result, error) {
return nil, err
}

filters := agents.ListAgentsBody{
PMMAgentID: cmd.PMMAgentID,
ServiceID: cmd.ServiceID,
NodeID: cmd.NodeID,
AgentType: agentType,
}

params := &agents.ListAgentsParams{
Body: filters,
Context: commands.Ctx,
PMMAgentID: pointer.ToString(cmd.PMMAgentID),
ServiceID: pointer.ToString(cmd.ServiceID),
NodeID: pointer.ToString(cmd.NodeID),
AgentType: agentType,
Context: commands.Ctx,
}
agentsRes, err := client.Default.AgentsService.ListAgents(params)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions admin/commands/inventory/list_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (cmd *ListNodesCommand) RunCmd() (commands.Result, error) {
}

params := &nodes.ListNodesParams{
Body: nodes.ListNodesBody{NodeType: nodeType},
Context: commands.Ctx,
NodeType: nodeType,
Context: commands.Ctx,
}
result, err := client.Default.NodesService.ListNodes(params)
if err != nil {
Expand Down
14 changes: 6 additions & 8 deletions admin/commands/inventory/list_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"net"
"strconv"

"github.com/AlekSi/pointer"

"github.com/percona/pmm/admin/commands"
"github.com/percona/pmm/api/inventory/v1/json/client"
services "github.com/percona/pmm/api/inventory/v1/json/client/services_service"
Expand Down Expand Up @@ -85,15 +87,11 @@ func (cmd *ListServicesCommand) RunCmd() (commands.Result, error) {
return nil, err
}

filters := services.ListServicesBody{
ExternalGroup: cmd.ExternalGroup,
NodeID: cmd.NodeID,
ServiceType: serviceType,
}

params := &services.ListServicesParams{
Body: filters,
Context: commands.Ctx,
NodeID: pointer.ToString(cmd.NodeID),
ExternalGroup: pointer.ToString(cmd.ExternalGroup),
ServiceType: serviceType,
Context: commands.Ctx,
}
result, err := client.Default.ServicesService.ListServices(params)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions admin/commands/inventory/remove_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package inventory

import (
"github.com/AlekSi/pointer"

"github.com/percona/pmm/admin/commands"
"github.com/percona/pmm/api/inventory/v1/json/client"
agents "github.com/percona/pmm/api/inventory/v1/json/client/agents_service"
Expand All @@ -41,10 +43,8 @@ type RemoveAgentCommand struct {
// RunCmd executes the RemoveAgentCommand and returns the result.
func (cmd *RemoveAgentCommand) RunCmd() (commands.Result, error) {
params := &agents.RemoveAgentParams{
Body: agents.RemoveAgentBody{
AgentID: cmd.AgentID,
Force: cmd.Force,
},
AgentID: cmd.AgentID,
Force: pointer.ToBool(cmd.Force),
Context: commands.Ctx,
}
_, err := client.Default.AgentsService.RemoveAgent(params)
Expand Down
8 changes: 4 additions & 4 deletions admin/commands/inventory/remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package inventory

import (
"github.com/AlekSi/pointer"

"github.com/percona/pmm/admin/commands"
"github.com/percona/pmm/api/inventory/v1/json/client"
nodes "github.com/percona/pmm/api/inventory/v1/json/client/nodes_service"
Expand All @@ -41,10 +43,8 @@ type RemoveNodeCommand struct {
// RunCmd runs the command for RemoveNodeCommand.
func (cmd *RemoveNodeCommand) RunCmd() (commands.Result, error) {
params := &nodes.RemoveNodeParams{
Body: nodes.RemoveNodeBody{
NodeID: cmd.NodeID,
Force: cmd.Force,
},
NodeID: cmd.NodeID,
Force: pointer.ToBool(cmd.Force),
Context: commands.Ctx,
}
_, err := client.Default.NodesService.RemoveNode(params)
Expand Down
10 changes: 5 additions & 5 deletions admin/commands/inventory/remove_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package inventory

import (
"github.com/AlekSi/pointer"

"github.com/percona/pmm/admin/commands"
"github.com/percona/pmm/api/inventory/v1/json/client"
services "github.com/percona/pmm/api/inventory/v1/json/client/services_service"
Expand All @@ -41,11 +43,9 @@ type RemoveServiceCommand struct {
// RunCmd executes the RemoveServiceCommand and returns the result.
func (cmd *RemoveServiceCommand) RunCmd() (commands.Result, error) {
params := &services.RemoveServiceParams{
Body: services.RemoveServiceBody{
ServiceID: cmd.ServiceID,
Force: cmd.Force,
},
Context: commands.Ctx,
ServiceID: cmd.ServiceID,
Force: pointer.ToBool(cmd.Force),
Context: commands.Ctx,
}
_, err := client.Default.ServicesService.RemoveService(params)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions admin/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ func (cmd *ListCommand) RunCmd() (Result, error) {
}

servicesRes, err := client.Default.ServicesService.ListServices(&services.ListServicesParams{
Body: services.ListServicesBody{
NodeID: cmd.NodeID,
},
NodeID: pointer.ToString(cmd.NodeID),
Context: Ctx,
})
if err != nil {
Expand Down