Hi :) I'm trying to mimic the oc cli API call to the master node that initiates a deployment. So eventually, I can have a chatbot that can initiate a deployment without needing to install the oc cli.
What is the API call to initiate a deployment?
When I look at what the oc cli is doing with oc deploy <app> --latest --loglevel=9. I see it fetching information only:
curl -k -v -XGET -H "Authorization: Bearer <token>" -H "User-Agent: oc/v1.3.0 (darwin/amd64) openshift/d451518" -H "Accept: application/json, */*" https://<host>:<port>/oapi/v1/namespaces/<namespace>/deploymentconfigs/<app>
curl -k -v -XGET -H "User-Agent: oc/v1.3.0+52492b4 (darwin/amd64) kubernetes/52492b4" -H "Authorization: Bearer <token>" -H "Accept: application/json, */*" https://<host>:<port>/api/v1/namespaces/<namespace>/replicationcontrollers/<app>-15
Where does it make the call to initiate the deployment? And how do I mimic it?
I wasn't able to find anything in these docs:
https://docs.openshift.org/latest/rest_api/openshift_v1.html
https://docs.openshift.org/latest/rest_api/kubernetes_v1.html
Thank you for your time!
Not sure if this is where you are wanting to go but your maybe looking for this
create instantiate of a DeploymentRequest
POST /oapi/v1/namespaces/{namespace}/deploymentconfigs/{name}/instantiate
https://docs.openshift.org/latest/rest_api/openshift_v1.html#create-instantiate-of-a-deploymentrequest
https://docs.openshift.org/latest/rest_api/openshift_v1.html#v1-deploymentrequest
Related
curl -vkg http://collectserver/ -H 'Authorization: Basic abc123==' -d "appName=APP_NAME&appUrls=http://myhost/myapp/"
This is working curl to add apps in javamelody monitoring
And I also tested for delete application
curl -v
"http://collectserver/collectServer?action=remove_application&application=$APP_NAME" -H 'Authorization: Basic abdvcgvh'
Now I want to create curl to list all added application using curl command plz help
You can call the same URL with the parameters "?part=applications&format=json" or "?part=applications&format=xml"
You will get a map in json, which lists the applications as keys.
For example, curl -v "http://collectserver/collectServer?part=applications&format=json" -H 'Authorization: Basic abdvcgvh'
I am using Jira cloud and trying to import the Xunit json report (result.json) generated by cucumber to Jira with Xray using Jira rest API, I've tried various ways to import the reports from command line but so far no luck.
Ex:
curl -H "Content-Type: application/json" -X POST -u ID:token -F "file=D:\Report.json" "https://raheel.atlassian.net/api/v2/import/execution"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/api/3/issue/DEM-9"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/raven/2.0/api/Test Execution/DEM-12"
**Error:**
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: https://raheel.atlassian.net/rest/raven/2.0/api/Test%20Execution/DEM-12</message></status>
token=$(curl -H "Content-Type: application/json" -X POST --data #"{ "client_id": "ID","client_secret": "secret" }" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"') curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"D:\Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
First of all, it seems that you are using Xray Cloud (i.e. Xray for Jira Cloud).
The proper documentation for Xray Cloud's REST API can be found here.
First, you need to create an API key (pair of client id and client secret) on Xray settings.
Then you need to authenticate in order to obtain a token that you'll need to provide in all following requests.
The following example, shows a way of setting a shell variable with the token value, so it can be used in subsequent requests
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
Then you can invoke the REST API endpoint to submit the Cucumber JSON report.
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
Please note that in order to import Cucumber related results using a cucumber JSON report, your Scenarios need to be properly tagged. You need to follow one of the flows detailed here.
I am trying to pass {"BPM": 456} to my localhost:8080.
When I try it with Postman it mseems to work fine.
On the other hand, when I try it with the following curl command, it doesnt seem to work.
curl -d {"BPM":456} -H "Content-Type: application/json" -X POST http://localhost:8080/
It doesnt work, I will appreciate any guidance with this.
i think you should check the port 8080. Or if you using a Virtual Host in localhost. Check the host and port configuration again.
I tried your commend using my localhost ,It works.
For some funny reason, using the syntax below did not work.
curl -d {"BPM":456} -H "Content-Type: application/json" -X POST http://localhost:8080/
I had to use pass the call in this format:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"BPM":456}' \
http://localhost:8080
Following what says here, I got a connection refused using this curl:
curl -v -H "Content-Type: application/json" -H "Accept: application/xml" -H "X-Auth-Token: 756cfb31e062216544215f54447e2716" -H "Tenant-Id: your-tenant-id" -X POST "http://saggita.lab.fi-ware.org:8080/sdc/rest/vdc/{your-tenant-id}/productInstance"
I changed it to what seems the appropriate URL:
cat test-data | curl --insecure -v -H "Content-Type: application/json" -H "Accept: application/xml" -H "X-Auth-Token: 756cfb31e062216544215f54447e2716" -H "Tenant-Id: your-tenant-id" -X POST "https://saggita.lab.fi-ware.org:8443/sdc/rest/vdc/{your-tenant-id}/productInstance" --data-binary #-
Comment: I used the file test-data as payload, I show later what payload I am using.
With that petition (with the appropriate auth token and specific parameters for my environment) I got:
Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
Seems is expecting JSON instead of XML, so I rearranged like this:
cat test-data | curl --insecure -v -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-Auth-Token: 756cfb31e062216544215f54447e2716" -H "Tenant-Id: your-tenant-id" -X POST "https://saggita.lab.fi-ware.org:8443/sdc/rest/vdc/{your-tenant-id}/productInstance" --data-binary #-
And I got this message no matter how I change payload:
{"message":"The entity is not valid","code":42}
I tried this two payloads (with the example of installing apache):
<productInstanceDto>
<vm>
<ip>MYIP</ip>
<fqn>same as hostname, I don't have DNS resolution</fqn>
<hostname>MYHOSTNAME</hostname>
</vm>
<product>
<productDescription/>
<name>apache2</name>
</product>
<attributes>
<key>custom_att_02</key>
<value>default_value_plain</value>
<type>Plain</type>
</attributes>
</productInstanceDto>
What I see as a very minimialist and clear payload
<productInstanceDto>
<vm>
<ip>MYIP</ip>
</vm>
<product>
<name>apache2</name>
</product>
</productInstanceDto>
By the way, I see so unfortunate fields like fqdn (could be missing, no dns resolution on that server), version (why I have to know the version of the product I want to install, this does not appear in the Product Catalogue), the missing of VM_ID parameter: available, easy and unique.
What I'm doing wrong?
Thanks
You are using the FIWARE Lab infrastructure for using the SDC component. However, they are some requirements to install software inside the VM, for instance, having chef/puppet installed, to have the VM registered in the chef-server (you can have a look at https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Software_Deployment_%26_Configuration_-_Installation_and_Administration_Guide). Thus, my suggestion if you want to use SDC in FIWARE Lab infrastructure is that you use the blueprint capabilities in the cloud portal (cloud.lab.fiware.org), which deploy the VMs, prepare the VMs, register the VMs in the chef-server and so on. You can have a look at the video blueprints in http://help.lab.fiware.org/.
My Url is Like:
https://<ip:port>/TestRESTServices/objects/test-folder
JSON data that I want to pass is:
{
"name":"test-1",
"parent-uuid":"126"
}
test-1 is the folder name which i want to create.
When i invoke this url with the data in Poster plugin in firefox via POST it works fine and folder test-1 is created.
//using Content Type : "application/json"
How can I invoke/call this REST API using cURL ?
Need Help.
This is what i tried:
curl -i -H "Accept: application/json" -X POST -d '{"name":"test-1","parent-uuid":"126"}' https://<ip:port>/TestRESTServices/objects/test-folder
It throws an error that curl: (52) Empty reply from server
Unfortunately I don't have a REST API online to try it, but resources that I found suggest the following approaches:
curl -v -H "Content-Type: application/json" -X POST --data "#issue.json" -u login:password http://redmine/issues.json
where the issues.json is a file containing the JSON request.
Resources I found useful:
1, 2
Hope it helps!
For Authentication : Give the userid/password as admin:password
TOKEN=$(curl -s -k -X POST --basic -u "admin:password" "{host}/TestAuthServices/auth/tokens" | sed -rn 's/\{"Token":"([^"]+)".+/\1/p')
After getting this token call curl as:
curl -s -k -X POST -H "Content-Type: application/json" -H "Authorization: X-SAML ${TOKEN}" -d '{"name":"test","parent-uuid":"126"}' "{host}/TestRESTServices/objects/test-folder"