How to delete grafana dashboard using curl command? - grafana

I am trying to delete grafana dashboard using curl command, but it is not deleting, the below curl command I tried to delete the dashboard,
curl -XPOST -d '{"name":"mydashboard"}' http://localhost:3000/api/dashboards/db -u admin:admin -H "Content-Type: application/json"

Run the below command,
curl -k -X DELETE -u admin:admin http://localhost:3000/api/dashboards/db/dashboardslug_name
where dashboardslug_name is the name while save the dashboard and not the dashboard title displaying in the web url.

Related

Cannot import grafana dashboard via grafana HTTP API

I am trying to import existing json file using HTTP API, but the 'curl' command throwing the error.
I am using the below command to import existing json file,
curl --user admin:admin "http://localhost:3000/api/dashboards/db" -X POST -H "Content-Type:application/json;charset=UTF-8" --data-binary #/u04/sys_monitor/my_Metrics.json
If i run the above command, it is throwing the error like "[{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]"
I tried to run the below command,
curl --fail --insecure --user admin:admin --request "POST" "http://localhost:3000/api/dashboards/db" --header "Content-Type: application/json" --data-binary #/u04/sys_monitor/my_Metrics.json
For the above command execution i am getting the error like,
curl: (22) The requested URL returned error: 422 Unprocessable Entity
Where i am doing wrong, kindly assist me,
The below comment is working but not updated the dashboard in grafana,
curl --user admin:admin -vvv "http://localhost:3000/api/dashboards/db" -X POST -d #My_Metrics.json -H 'Content-Type: application/json'

How to delete service zookeeper from ambari?

I am using this command to delete service from ambari:
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://192.168.24.226:8080/api/v1/clusters/zwlbs/services/Zookeeper
response:
{
"status" : 404,
"message" : "org.apache.ambari.server.controller.spi.NoSuchResourceException: The specified resource doesn't exist: Service not found, clusterName=zwlbs, serviceName=ZOOKEEPER_SERVER"
}
I've aready tried:
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://192.168.24.226:8080/api/v1/clusters/zwlbs/services/Zookeeper_Service
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://192.168.24.226:8080/api/v1/clusters/zwlbs/services/ZOOKEEPER
What can i do to delete ZooKeeper service?The service is aready installed.
the service name is UPPERCASE:
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://192.16824.226:8080/api/v1/clusters/zwlbs/services/ZOOKEEPER

Calling an PingAccess APIs from Powershell

I am trying to call PingAccess APIs to configure my PingAccess.
I am new to using APIs to do this, and have a question.
I am trying to use CURL to the API .
curl -k -u Administrator:dummypsswd -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v
When I run this I get the following error.
I still dont know why am I unauthorized. Any help is appreciated.
When you have special characters in your password you'll need to enclose the username/password tuple in double quotes:
curl -k -u "Administrator:dummypsswdwithspecialcharslike&&" -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v

How to insert objects with links and retrieve them

I'm trying this with curl:
first insert a document:
curl --user admin:admin -X POST -d '{"#class":"Question"}' http://127.0.0.1:2480/document/home/
{"#type":"d","#rid":"#13:3","#version":6,"#class":"Question"}
second insert a document with a reference to the first one inside the items list
curl --user admin:admin -X POST -d '{"#class":"Question", "items":[{"#rid":"#13:3"}]}' http://127.0.0.1:2480/document/home/
{"#type":"d","#rid":"#13:2","#version":2,"#class":"Question","items":[{"#rid":"#13:3"}]}
finally I tried to get the last document:
curl --user admin:admin -X GET http://127.0.0.1:2480/document/home/13:2
{"#type":"d","#rid":"#13:2","#version":2,"#class":"Question","items":[{"#rid":"#13:3"}]}
But I need this:
{"#type":"d","#rid":"#13:2","#version":2,"#class":"Question","items":[{"#type":"d","#rid":"#13:3","#version":6,"#class":"Question"}]}
This is the documentation page:
https://github.com/orientechnologies/orientdb/wiki/OrientDB-REST
Edit:
I tried this and it did not work
curl --user admin:admin -X GET http://127.0.0.1:2480/document/home/13:2/*:-1
{"#type":"d","#rid":"#13:2","#version":2,"#class":"Question","items":[{"#rid":"#13:3"}]}
The second insert must contains the RID only:
{"#type":"d","#rid":"#13:2","#version":2,"#class":"Question","items":["#13:3"]}
To retrieve the full tree/graph set the fetch plan. Take a look at: https://github.com/orientechnologies/orientdb/wiki/OrientDB-REST#get---document
Use:
curl --user admin:admin -X GET http://127.0.0.1:2480/document/home/13:2/*:-1

How to create a connector-connection-pool in Glassfish 3.1.2 with REST interface

For a remote administration of multiple Glassfish 3.1.2.2 instances I want to configure resource adapter connection pool and connector resources. These configuration can only be done after the resource adapter deployment.
All works if I do things with asadmin.
Get Access via REST works as expected.
Example:
curl --user admin:pwd -X GET -H "Accept: application/JSON"
http://localhost:4848/management/domain/resources/connector-connection-pool
Now I want to create a connection pool using the following command with REST
asadmin create-connector-connection-pool --raname MulticastDNS-connector
--connectiondefinition multicastdns.outbound.MulticastDNSRegistry multicastdns/pool
I followed some of the Oracle examples http://docs.oracle.com/cd/E18930_01/html/821-2416/gjipx.html#gjijx or http://docs.oracle.com/cd/E19798-01/821-1751/gjijx/index.html
But all things I tried got 400 Bad Requests.
Example:
curl --user admin:pwd -X POST -H "Accept: application/JSON" -H "Content-Type: application/json"
-d '{"id":"multicastdn%2fspool","connectiondefinitionname":"multicastdns.outbound.MulticastDNSRegistry","resourceAdapterName":"MulticastDNS-connector"}'\
http://localhost:4848/management/domain/resources/connector-connection-pool -v
# other check
curl --user admin:pwd -X POST -H "Accept: application/JSON" \
-d id=multicastdns%2fpool \
-d connectiondefinitionname=multicastdns.outbound.MulticastDNSRegistry \
-d resourceAdapterName=MulticastDNS-connector \
http://localhost:4848/management/domain/resources/connector-connection-pool -v
Simular results if I want to delete a existing resource.
curl --user admin:pwd -X DELETE -H "Accept: application/JSON" \
http://localhost:4848/management/domain/resources/connector-connection-pool/multicastdns%2fpool -v
# other try
curl --user admin:pwd -X DELETE -H "Accept: application/JSON" \
-d id=multicastdns%2fpool \
http://localhost:4848/management/domain/resources/connector-connection-pool -v
Same issue if try the second step with connector resource
asadmin create-connector-resource --poolname multicastdns/pool jca/multicastdns
Get via REST works but add and delete an entry won't work.
Thanx florian