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

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

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"

Openam policy decision with (session and ldap filter) environment condition

I think I am doing something stupid and can't find documentation around it.
I have this above policy set in openAM and trying to validate it with json/policies?_action=evaluate. But I can't find how would I have to pass the environment key and values for the above-configured condition? I have tried them in a cookie or in headers but don't seem to get it right. should I add them in the environment and then write the script to handle (and return authorize true) that from the request in the openAM services? OR do I have to add custom service in for identity and that would handle this? OR am I missing this completely?
request for validate is:
curl -X POST \
'http://0.0.0.0:8080/openam/json/policies?_action=evaluate' \
-H 'Accept: */*' \
-H 'Accept-API-Version: resource=1.0' \
-H 'Content-Type: application/json' \
-H 'Cookie: iPlanetDirectoryPro=<token-of-web-agent>' \
-H 'Host: 0.0.0.0:8080' \
-d '{
"resources":["/members"],
"application":"iPlanetAMWebAgentService",
"subject":{
"ssoToken":"<ssoToken-of-demo-user>"
},
"environment": {}
}'

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?

IBM Watson TTS example return a blank audio file

I have some troubles with the Watson TTS example provided by IBM using cURL :
curl -X POST -u {USERNAME}:{PASSWORD} \
--header "Content-Type: application/json" \
--header "Accept: audio/wav" \
--data '{"text":"hello world"}' \
--output hello_world.wav \
"https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize"
I am running this cURL command through GitBASH but the audio file output I'm getting is blank and does not contain any audio.
I've tried changing :
--data '{"text":"hello world"}' \
to :
--data "{\"text\":\"hello world\"}" \
But I get the same result.
Remove the {} around your username and password credentials, which by the way are now compromise.
You will should revoke these credentials and create a fresh set of credentials, which you should try endevour to keep secret and not post in public forums.

Authentication of arangodb APIs of dbserver and agency is failed

I uses the arangodb(0.9.3) to start cluster(current version 3.2.1).
there are some problemsin authentication.
query1 post to coordinator(port=8529) with basic auth, response 200
curl -X GET \
http://xx.xx.xx.xx:8529/_db/KnowledgeGraph/_api/collection/CarInfo \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 897691e4-c4fc-5588-b217-0da53bc368ba'
query2 post to agency(port=8531) with basic auth, response 401
curl -X GET \
http://xx.xx.xx.xx:8531/_api/agency/config \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 5160250f-4471-84aa-e377-bd0b99ba9926'
I want to use logger-follow to monitor the change of data in cluster. query3 post to dbserver(port=8530) with basic auth, response 401. If my cluster start without --auth.jwt-secret /my/path/to/jwt, such query has response 200.
curl -X GET \
'http://xx.xx.xx.xx:8530/_api/replication/logger-follow?from=0' \
-H 'authorization: Basic cm9vdDptaHh6a2hs' \
-H 'cache-control: no-cache' \
-H 'postman-token: 11b09c7f-85b1-4ed3-ca78-f28cf86c331b'
Is there some difference of authentication between agency/dbserver with coordinator?
Or is there something wrong with authentication of agency/dbserver?