How to write a tekton result api example call - tekton

I'd like to query the results of taskruns from tektoncd result api, but I have a hard time putting the query together. Can you help me, please?
I've completed the steps at https://github.com/tektoncd/results/blob/main/docs/install.md
Not sure how a curl call would look like.

Example API call querying for Tekton-related objects:
curl -k --header 'Authorization: Bearer xxx' \
https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/YOUR_NAMESPACE_HERE/pipelineruns | jq '.[]'
curl -k --header 'Authorization: Bearer xxx' \
https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/YOUR_NAMESPACE_HERE/taskruns/YOUR_RESOURCE_NAME_HERE | jq '.[]'
See Kubernetes docs, for guidance building URLs when querying the API
Knowing of a taskrun name, we can query for its results with the following:
curl -s -k --header 'Authorization: Bearer xxx' \
https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/ci/taskruns/scalelite-recording-importer-1.3.4-1-build \
| jq .status.taskResults
[
{
"name": "IMAGE_DIGEST",
"type": "string",
"value": "sha256:14e52d648f6e99e4b339272658b2a7d57f81f145b0f3f178a0deccb65300a75c"
}
]

Related

Why I can't delete Link between person and group identities with Platform of Trust's Identity API?

I have created account on Sandbox
I have then created a group with
curl -i -X POST \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d \
"{
\"context\": \"https://standards.oftrust.net/v2/Context/Identity/Group/\",
\"type\": \"Group\",
\"data\": {
\"name\": \"Company Oy\"
}
}" "https://api-sandbox.oftrust.net/identities/v1"
I have also created a Link between person and group, I used MemberOf
curl -i --request POST \
--url https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId} \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'content-type: application/json' \
--data '{
"context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
"type": "Member"
}'
I got successful response that link was created between those identities.
Trying to delete this link now, but I get as response 404 and message Link not found.
What I try is according with example from documentation
curl -i -X DELETE \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId}/MemberOf"
[UPDATE]: I discovered also in Identity API documentation that can list all links of identity.
And have made this for group identity:
curl -i -X GET \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://api-sandbox.oftrust.net/identities/v1/<group_id>/links"
The response shows that link between group and person identities.
Firstly, make sure you respected the id values (their order) for From and To. They should be the same you get in response of https://api-sandbox.oftrust.net/identities/v1/<group_id>/links
Secondly, delete Link endpoint needs to be used with a type, as exemplified. In this case MemberOf. But looking at the creation of the link there is a typo: context used is correct, but the type is Member. Type should match the last part of the name in context => MemberOf
In this case, since you are trying to delete it, simply use Member
curl -i -X DELETE \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId}/Member"

Active Collab API - URL Structure Self Hosted

I'm trying to use the Active Collab API to retain project information for reporting purposes. I basically just want to make a daily API call and safe the JSON for further reporting in another tool.
For this reason I don't want to use an SDK or anything, just a plain API call to retain the data.
Can someone please guide me because I couldn't find the correct url structure for a self-hosted system.
I found a solution with the help from the support.
First you have to obtain a token like this:
curl --location --request POST 'https://YOUR.SITE/api/v1/issue-token' \
--header 'Content-Type: application/json' \
--data-raw '{
"username" : "YOUR EMAIL",
"password" : "YOUR PASSWORD",
"client_name" : "xxx",
"client_vendor" : "xxx"
}'
And in the next step you can use the API as documented here by calls like this one:
curl --location --request GET 'https://YOUR.SITE/api/v1/projects' \
--header 'Content-Type: application/json' \
--header 'X-Angie-AuthApiToken: YOUR TOKEN'

curl response is on one line rather than multiple

I used the following curl command to receive tweets as well as info of tweets from a specific account:
curl --request POST \
--url https://api.twitter.com/1.1/tweets/search/fullarchive/production.json \
--header 'authorization: Bearer AAAAAAAAAAAAAAAAAAAAAHzE8wAAAAAATpIskAbraT5V0OSNaWKwrt%2Fz99I%3DcS8seKux26Ic3wcNjpAwPVFJ5I055ZuLyYAQNTMsIx55o1nIK5' \
--header 'content-type: application/json' \
--data '{
"query":"from:TwitterDev lang:en",
"maxResults": "100",
"fromDate":"201802010000",
"toDate":"201802282359"
}'
the response I receive is all on one line, my question is how can I separate the line of response based on each tweet received?

Php script for google firewall API

I am trying to do a simple script to change firewall rules on my VM hosting. I used the google API explorer, and the script generated is as follows
curl --request PUT \ 'https://www.googleapis.com/compute/v1/projects/learnstoresg/global/firewalls/intranet2?requestId=00000000-0000-0000-0000-000000000033' \
--header 'Authorization: Bearer [YOUR_BEARER_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"allowed":[{"IPProtocol":"TCP","ports":["4033","4016"]}],"sourceRanges":["101.127.7.227"]}' \
--compressed
Anyone has an example of php script for google firewall or can help me convert this CURL statement into a php script?

GoCD POST requests return "The resource you requested was not found!"

I have GoCD instance and want to automate regular actions like scheduling pipelines and checking pipelines statuses using GoCD API.
When I do GET request it works:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/status' \
-u 'kagarlickij:Pa$$w0rd' | jq
..but when I do POST request it returns "The resource you requested was not found!":
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/pause' \
-u 'kagarlickij:Pa$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' -H 'Content-Type: application/json' \
-X POST -d '{"pause_cause": "Investigating build failures"}' | jq
..another POST example:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/schedule' \
-u 'kagarlickij:P#$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' -H 'Content-Type: application/json' \
-X POST -d #gocd.json | jq
json content:
{
"environment_variables": {},
"materials": {},
"update_materials_before_scheduling": false
}
Any ideas how pipelines could be started using API?
Some GoCD API calls require 'Confirm': 'true' header.
In you case, you can try running curl like this:
curl 'https://gocd.demo.kagarlickij.com/go/api/pipelines/frankenstein/pause' \
-u 'kagarlickij:Pa$$w0rd' \
-H 'Accept: application/vnd.go.cd.v1+json' \
-H 'Content-Type: application/json' \
-H 'Confirm: true' \
-X POST -d '{"pause_cause": "Investigating build failures"}' | jq
I can recommend my lib yagocd for GoCD, which takes cares about version incompatibilities and makes working with GoCD API much easier.
The answer turned out to be very simple - that API actions require GoCD v18.2.0 but I had v18.0.0
After upgrade API calls work as expected