Hi,
I’am trying to use the API and searching a service by name in an environment.
So, in first, I get the environment like this :
GET /v1/environment?name=myTestStack
which returns a JSON document with a “services” url like this :
GET /v1/environments/1e22/services
This returns the services list in my stack. I just want to get only one by its name, so I tried to call :
GET /v1/environments/1e22/services?name=myServiceName
But it still returns the whole list. The filter does not seem to work here. I tried calling the services endpoint with the same filter and it works, but when I apply it in /environments/1e22/services, it does’nt work.
Ok, thank you @denise. Do you have any idea when this problem will be fixed?
Because I need this to automatically updrade a service under an environment and to do this I though to catch the environment first, then list all services of this environment and filter by name to call the upgrade action.
Perhaps do you have another way to do this? Knowing that my CI/CD tool only works with names (not ids) and that the same service “toto” can appear in many enviroments (cattle stacks).
The problem is that nested resource URLs (services of environment 1s22) are essentially a different class of filter and using that takes precedence over the user-specified filters. That will be fixed eventually (along with the infuriatingly inconsistent naming of stack vs environment ).
In the meantime this is functionally equivalent:
$environments = GET /v1/environments?name=myStack
$environmentId = $environments.data[0].id
$services = GET /v1/services?environmentId=${environmentId}&name=myServiceName
$service = $services.data[0]