I need to restart a server group, using the HTTP API. I can't figure out what the correct syntax is.
I tried a lot of
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("operation", "something-something");
requestMap.put("address", "something-something");
final Response response = managementContext
.request()
.header("X-Requested-By", WildflyUtils.class.getName())
.post(Entity.json(requestMap));
or "by hand":
{"operation":"something-something", "address":"something-something", "json.pretty":1}
I'm guessing around. Does someone know which command is best and what the correct syntax for the address is, or where a useful documentation for the HTTP API is? The official documentation (https://docs.jboss.org/author/display/WFLY10/The+HTTP+management+API) is somewhat small.
I do not know whether it help but I tried with the curl:
curl --digest -u "username:password" 'http://localhost:9990/management' --header "Content-Type: application/json" -d '{"operation":"restart-servers","address":[{"server-group":"your_server_group"}]}'
for standalone:
curl --digest -u "username:password" 'http://localhost:9990/management' --header "Content-Type: application/json" -d '{"operation":"reload","address":[]}'
You should take a look at WildFly 11.0 Model Reference, but I am afraid this does not cover the domain mode.
I had a small demo code here. In your case you should do:
requestMap.put("address", "[\"server-group",\"myServerGroup\"]");
requestMap.put("operation", "restart-servers");
requestMap.put("blocking", "true/false");
requestMap.put("start-mode", "normal/suspend");
Related
I'm trying to create an annotation in Grafana via the HTTP-API.
Due to the official docs I need to add a timestamp.
Example Request (from official docs)
POST /api/annotations HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"dashboardId":468,
"panelId":1,
"time":1507037197339,
"isRegion":true,
"timeEnd":1507180805056,
"tags":["tag1","tag2"],
"text":"Annotation Description"
}
But what kind of timestamp is it? I couldn't find any information about it.
I tested it with the current unix timestamp but the annotation will not show up.
Maybe helpful: My last alert from yesterday (13. Dez 2017, 07:02PM UTC+1) corresponds to "time": 1513101762000,.
Time should be in epoch in milliseconds based on their docs from the find method:
Query Parameters:
from: epoch datetime in milliseconds. Optional.
to: epoch datetime in milliseconds. Optional.
Check here for some code examples:
http://currentmillis.com/
Also, if you don't see them showing up on your dashboard be sure to use the header token authentication against the API and make sure you created the token API for the same org that the dashboard lives under.
A curl request would look similar too:
curl -i -XPOST -H "Authorization: Bearer <token>" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"time":1513187523781,"isRegion":false,"tags":["test1"],"text":"Testing Annotations API"}' "https://grafana.host/api/annotations"
I try export and import nifi templates via nifi rest api; but when i tried to delete controller-services, connections or import a template i get the response message "The revision must be specified." with '400 bad request' status from nifi rest api. I didn't understand what i have to do.
This my request for delete a control-service,
request "/controller-services/{id}" (id is, The controller service id.)
curl -X DELETE \
http://localhost:8090/nifi-api/controller-services/015b1030-a099-13d3-812c-77772afcaeb0 \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
and the response is "The revision must be specified."
status : "400 Bad Request"
Any idea please?
I finally got some answers about my mistake after reading this article
It seems you have to add two information to request url; version and clientId.
After make a call and get a component form nifi instance, it sends a version number inside a DTO to you as explained here
like this:
and finally i made a call like below and it worked:
curl -X DELETE \
'http://localhost:8090/nifi-api/controller-services/015b1030-a099-13d3-812c-77772afcaeb0?version=0&clientId=5ed15669-015d-1000-99cf-bc9c6f378085' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
I've testing a Cosmos instance base on this QSG (https://github.com/telefonicaid/fiware-cosmos/blob/master/doc/manuals/quick_start_guide_new.md), everything works appropriately until I reach Step 5: Run your first MapReduce job.
I get "Error in IDM communication" message by running below code:
curl -X POST "http://computing.cosmos.lab.fiware.org:12000/tidoop/v1/user/netzahdzc/jobs" -d '{"jar":"jars/hadoop-mapreduce-examples.jar","class_name":"wordcount","args":["hdfs://storage.cosmos.lab.fiware.org/user/netzahdzc/testdir","hdfs://storage.cosmos.lab.fiware.org/user/netzahdzc/testoutput"]}' -H "Content-Type: application/json" -H "X-Auth-Token: xxxxx"
The reason I'm writing is because I wonder if as it is implied on this post (Fiware response 503 - Service unavailable) this still a glitch or I am doing something wrong.
This is the last test I did:
curl -X POST "http://computing.cosmos.lab.fiware.org:12000/tidoop/v1/user/USERNAME/jars" -d '{"jar":"jars/hadoop-mapreduce-examples.jar","class_name":"wordcount","args":["hdfs://storage.cosmos.lab.fiware.org:14000/webhdfs/v1/user/USERNAME/SERVICE/SERVICE_PATH/OBJECT_ID/OBJECT_ID.txt","hdfs://storage.cosmos.lab.fiware.org:14000/webhdfs/v1/user/USERNAME/testoutput"]}' -H "Content-Type: application/json" -H "X-Auth-Token: XXXXXXXXXX"
This is the reply:
curl: (52) Empty reply from server
Any hint?
I used kaa rest api for changing my configuration as follow:
curl -v -S -u devuser:devuser123 -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"applicationId": "2",
"schemaId": "65539",
"endpointGroupId": "32768",
"body": "{\"timeConfig\":{\"org.kaaproject.configuration.unchangedT\":\"unchanged\"},\"dailySchedules\":{\"org.kaaproject.configuration.unchangedT\":\"unchanged\"},\"enabled\":{\"boolean":false},\"relays\":{\"array\":[false,false,false,true,true,false,false,false]},\"samplePeriod\":{\"int\":9}}",
}' 'http://localhost:8080/kaaAdmin/rest/api/configuration' | python -mjson.tool
But I get HTTP/1.1 400 Bad Request. Does my post parameters seems OK? any suggestion will be appreciated.
Finally I found the problem. Kaa Rest API Works perfect. It was about mismatching schemaID and endpointgroupId. I got the correct values from kaa web interface:
http://localhost:8080/kaaAdmin/#config:appId=2&endGroupId=32768&create=false&active=true&random=0.19035219790078206&schemaId=65539
. since the 400 ERROR CODE is not present in Rest documentation, I had no clue that where was the problem.
Rundeck supports triggering jobs via their API. The API documentation is available under documentation.
We are using API version 13 which does not yet support application/json. Therefore i need to use the XML based request.
In my previous attempts, i always get the response:
<result error="true" apiversion="13">
<error code="api.error.job.options-invalid">
<message>Job options were not valid: Option 'container' is required. Option 'version' is required.
</message>
</error>
</result>
Since there is no example request provided, i am searching for an example payload to trigger the job.
As seen in the response i have to provide the parameters "container" and "version" since they are required.
My most recent request payload was:
<executeJob>
<argString>-container containerName -version 1234567</argString>
</executeJob>
I also tried different variations of this payload, every time with the same response.
This should help you, assuming you have a token to access Rundeck with authorization to run the job
curl -D - -X "POST" -H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Rundeck-Auth-Token: <TOKEN>" \
-d '{"argString":"-arg1 val1 -arg2 val2"}' \
http://<URL>/api/16/job/<JOB_ID>/executions