Enabling and Disabling Storage Plugin - apache-drill

I am running Apache Drill in Window 8.1 OS, having latest version of Drill (1.7).
I want to enable or disable storage plugin programatically (using C# code).
Is there any way to do so.?

You can update drill plugin via REST API.
I am taking MongoDB plugin as an example.
Enable
curl -X POST -H "Content-Type: application/json" -d '{"name":"mongoPlugin", "config":{"type":"mongo","enabled":true,"connection":"mongodb://localhost:27017/"}}' http://localhost:8047/storage/mongoPlugin.json
Change "enabled" to false to disable it.
Disable
curl -X POST -H "Content-Type: application/json" -d '{"name":"mongoPlugin", "config":{"type":"mongo","enabled":false,"connection":"mongodb://localhost:27017/"}}' http://localhost:8047/storage/mongoPlugin.json
Check drill docs for more details.
You already answered about creating plugins using C#. Just change payload as mentioned above.

For Enabling or Disabling Storage Plugin in Window Environment. First we have to download curl.exe file from Download Curl
. Set the path of curl.exe file in Environment Variable:-
Follow these steps:-
Download curl zip
Extract the contents (if you have downloaded the correct version you should find curl.exe)
Place curl.exe in a folder where you keep your software (e.g. D:\software\curl\curl.exe)
To run curl from the command line
a) Right-hand-click on "My Computer" icon
b) Select Properties
c) Click 'Advanced system settings' link
d) Go to tab [Advanced] - 'Environment Variables' button
e) Under System variable select 'Path' and Edit button
f) Add a semicolon followed by the path to where you placed your curl.exe (e.g. ;D:\software\curl).
Now Open Command Prompt and run following command:-
For Disabling Storage Plugin:-
curl http://localhost:8047/storage/DemoMySQl/enable/false
For Enabling:-
curl http://localhost:8047/storage/DemoMySQl/enable/true
Note:- DemoMySQl is storage plugin name.

Related

Use cURL to pull data from Web into excel

Guys I'm currently working with cURL for the first time.
What I am trying to do is pull data from a website usimg cURL
an put them into excel using the following commmand. I have to use an API-Key
to get the data.
curl -H "X-API-Key: API_KEY_NUMBER" http://example.com/api/exports/model/62f0d0dc24757f6e5bb0b723 -o "text.xlsx"
This works fine so far, the problem is that if want to open it in Excel it tells me that the file can not be opened because the file format or the file extension is invalid.
If i change the file extension to
curl -H "X-API-Key: API_KEY_NUMBER" http://example.com/api/exports/model/62f0d0dc24757f6e5bb0b723 -o "text.txt"
it opens in a text file but with all the data that i need. Now I am looking for a way to solve this.

How do I force tika server to exclude the TesseractOCRParser using curl

I'm running tika-server-1.23.jar with tesseract and extracting text from files using curl via php. Sometimes it takes too long to run with OCR so I'd like, occasionally, to exclude running tesseract. I can do this by inserting
<parser-exclude class="org.apache.tika.parser.ocr.TesseractOCRParser"/>
in the tika config xml file but this means it never runs tesseract.
Can I force the tika server to skip using tesseract selectively at each request via curl and, if so, how?
I've got a workaround where I'm running two instances of the tika server each with a different config file listening on different ports but this is sub-optimal.
Thanks in advance.
You can set the OCR strategy using headers for PDF files, which includes an option not to OCR:
curl -T test.pdf http://localhost:9998/tika --header "X-Tika-PDFOcrStrategy: no_ocr"
There isn't really an equivalent for other file types, but there is a similar header prefix call X-Tika-OCR that allows you to set configuration on the TesseractOCRConfig instance when used on any file type.
You have some options which could be of interest in your scenario:
maxFileSizeToOcr - which you could set to 0
timeout - which you could set to the timeout you are willing to give
tesseractPath - which you can set to anything, as if it can't find it, it can't execute
So, for example, if you want to skip a file you could set the max file size to 0 which means it will not be processed:
curl -T testOCR.jpg http://localhost:9998/tika --header "X-Tika-OCRmaxFileSizeToOcr: 0"
Or set the path to /dummy:
curl -T testOCR.jpg http://localhost:9998/tika --header "X-Tika-OCRtesseractPath: /dummy"
You can of course also use these headers with PDF files too, should you wish.

How to translate my cURL command into Chrome command?

I want to fire a POST request in command line, to post my image to a image searching site. At first, I tried cURL and get this command which works:
curl -i -X POST -F file=#search.png http://saucenao.com/search.php
It will post a file in FORM to the searching site and returns a HTML page result full with JavaScript which makes it hard to read in terminal. And it's also hard to preview online image in terminal.
Then I remember that I can open Chrome with arguments in command line, which I think may solve my problem. After some digging, I found Chrome switches, but seams it's just about Chrome starting flags (I'm not sure is this right, but I didn't find how to fire a post request like cURL do.)
So, can I use Chrome in command line to start it with a POST request just like my cURL command above?
There are a couple of things you could do.
You could write a script in JavaScript that will send the POST request and display the results inside the <body> element or the like;
You could keep the cURL command and use the -o (or --output) to save the resulting HTML in a file (but lose the -i switch, to avoid having the headers in the file), then open the file in Chrome or whichever browser you prefer. You could combine the two commands as a one-liner in any operating system. If you use Ubuntu, for example:
$ curl -o search.html -X POST -F file=#search.png http://saucenao.com/search.php && google-chrome search.html && rm search.html
According to this answer you could use bcat in order to avoid using a temporary file. Install it by apt-get install ruby-bcat and then just run
$ curl -X POST -F file=#search.png http://saucenao.com/search.php | bcat
I think the easier option is #2, but whichever you prefer.

Programmatically change the repository URL of a Hudson job

Is there a way to change the repository URL of a Hudson job using the Hudson CLI API?
There is no way to change the repository URL using the Hudson CLI. However there is a workaround that can be automated with little effort.
Workaround:
We can use cURL to download the config.xml of the job using the following command (note that in order to run cURL commands you have to setup cURL):
curl -X GET http://your-hudson-server/job/TheNameOfTheJob/config.xml -o localCopy.xml
The configuration file will contain something similar to this (depending on the Version Control used):
<scm-property>
<originalValue class="hudson.scm.SubversionSCM">
<locations>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>https://your-repository</remote>
The value of the <remote> tag is the repository url (also check the credentials for the new repository).
There are several cURL ways to submit the modified version of config.xml back on the server. One way is:
curl -X POST http://your-hudson-server/job/TheNameOfTheJob/config.xml --data-binary "#newconfig.xml"

Folder/File smart link enable/disable call in Box V2 API

Recently an article on the box dev blog talked about an update in the V2 API functionality. http://developers.blog.box.com/2012/07/13/more-v2-updates/.
I am specifically talking about the share link for file/folders. The article says the API can be used to create/delete share links and also change the permission.But i do not see any such API on the http://developers.box.com/docs page.
Does anybody have any idea about this discrepancy? Is this available now in V2 or not?
Smart links are treated as an attribute of a folder or file and can be created by updating the metadata about the folder or file. This is done through the PUT method. You can see this here for files and here for folders.
For example, if you wanted to enable a shared link for a file you would make this call using cURL:
curl https://api.box.com/2.0/files/FILE_ID \
-H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" \
-d {"shared_link": {"access": "open"}} \
-X PUT