semaphoreui / semaphore

Modern UI and powerful API for Ansible, Terraform, OpenTofu, PowerShell and other DevOps tools.
https://semaphoreui.com
MIT License
10.6k stars 1.07k forks source link

Semaphore API is not returning information of created objects in many cases #1416

Open ahoiroman opened 1 year ago

ahoiroman commented 1 year ago

Hello there,

in order to automate different steps I want to use the ansible-semaphore-API.

However, in some cases, the API does not return any data on success, but only HTTP 204.

Example: Keys

If I create an access key using the API, I cannot reference it in other steps of my process, e.g. to assign this key to an inventory.

Is there any reason for this behavior?

quinten-lp commented 1 month ago

Hello, I'm facing the same issue as @ahoiroman.

Here my case with examples :

I'm creating infrastucture with Pulumi and I need to create a project in Semaphore to run Ansible. I think Semaphore is useful with the API to manage my playbooks.

I can automate project creation and get back the id because the status code is 201. Next step is to add a private key to my gitlab inside the project, adding a key is OK but the status code is 204 so, I don't have the id of my ssh key in return.

I need to run a "GET" with some filters to retrieve the id but it would be nice if the status code of the endpoint /project/{project_id}/keys could return a 201 status code. In order to simplify the automation.

Same things with : /project/{project_id}/repositories /project/{project_id}/environment

So, is it possible to improve the API to change the status code of those two endpoints ?

Thanks.