1

I'm writing devops pipelines in a Docker Enterprise 3.2 environment.

I am able to fetch all stacks from the UCP API. Now I need to fetch single stacks but the documentation seems to omit completely this resource.

Is there anything as:

ucp_url/api/stacks/my_awesome_stack_name

or

ucp_url/api/stacks?name=my_awesome_stack_name

?

avi.elkharrat
  • 6,100
  • 6
  • 41
  • 47
  • To whom ever voted up this question: THX! I found the solution to my question and I completely forgot to post the answer!! – avi.elkharrat Mar 12 '20 at 09:55

1 Answers1

0

Short answer

The field namespace is the identifier of the stack. Calling api/stacks/my_namespace will get the desired stack.

How I found this

After fiddling a bit with the documentation and the api, I realized that the stacks resource is just another collection that can be selected using its identifier.

When you invoke api/stacks you'll receive a collection of stacks looking like this:

[
  {
    "namespace": "my_awesome_namespace_1",
    "services": []
    ...
    "namespace": "my_awesome_namespace_2",
    "services": []
    ...
  }
]

I simply tried api/stacks/my_awesome_namespace_1 and received the desired object in json format.

And beyond

I believe the most important thing to this answer is that this method could be generalized to any UCP resource.

  1. fetch all resources of a given resource type
  2. try to determine which field is the identifier
  3. try calling my_awesome_resource/my_awesome_resource_identifier
  4. cheer up :)
avi.elkharrat
  • 6,100
  • 6
  • 41
  • 47