Hello, nice to meet you all. I have couple of que...
# pactflow
f
Hello, nice to meet you all. I have couple of question about the Pactflow API. Where i should post them ?
✅ 1
y
Hey Frank, here is okay and if we can’t answer we can point you in the right direction
f
Nice. We want to call the Pactflow API from some of our contract tests itself to set some metadata like Repository URL and also adding some company wide labels like
service:green-service
team:blue
and so on. I download the latest OpenAPI Spec 3.1 from Pactflow and used the nice new Swagger-Editor to generate the Go Client code.
👌 1
So far so good. Fixed couple of minor Go code related issues. Now its working.
I just wondering i can retrieve the Participants defined labels. But there is now operation (at least i couldn't found one) to add labels.
Maybe for easier understanding here is the slightly modified Go code that was generated from Swagger-Editor.
I had to replace the undefined
*Object
type with just
*string
then it compiles. Golang don't support OpenAPI Spec 3.1 fully at the moment.
y
nice, i thought about doing that a few times, thanks for sharing. I’m away from my desk but i’ll take a look when I’m back.
f
Thanks that are you looking into that.
m
It hasn’t been published yet (thanks for the reminder), but
/labels
(with the usual pagination options) should get what you’re after
It just provides a list of labels in your account
This being said, labels are application (pacticipant) specific, so you don’t need to create them in advance
In fact, this is one better. I think you want the
PUT
to the label resource
✅ 1
f
Yes that looks like the endpoint i was looking for. Thanks. Is this endpoint available and just not documented or is it in the RoadMap ?
m
it’s available and just not published to our API docs portal yet. I’ll follow up why, it was added a few weeks back but might be held up in a publishing review
f
Thanks a lot. Will then use the Golang native http client to call that endpoint until swagger is ready.
👍 1
Have a nice day.
m
You could import the OAS file above into the swagger editor, and that should be able to generate a client for you
👍 1
f
Nice that worked.
🙌 1
Screenshot 2024-08-20 at 15.33.55.png
Sorry i have an other question. GET /labels return all labels. Is there way to retrieve only all labels for one particular pacticipants ?
Just for you to know. Works as expected:
<https://goflink.pactflow.io/labels?page=1>
Fails with 500 Internal Server Error
<https://goflink.pactflow.io/labels?page=0>
Now i get to work but i think we are use the labels in a way that was not intended. We want to add the following labels to all of our Pacticipants •
team:green
•
service:blue
Then we can easily filter Pacticipants by our services or even team. What do you think of this ? Is there an other way to achieve that as well ?
m
yes - it’s on the pacticipants resource itself i.e.
GET <host>/pacticipants/:pacticipant
✅ 1
f
Thanks a lot again. Now i finished the first implementation and its working as expected. Have a nice day.
🙌 1