salt state to run JSON API - json

I am quite new to SALT, I need to query a JSON API through slat state, may I know how best I should do. I am trying below is of no help though.
Salt ‘*’ cmd.run ‘curl --insecure -u "username:password" -X POST -H "Content-Type: application/json" -d '{"action":"RouterName","method":"methodname","data":[{"limit":100000, "uid" : "Query UID"}],"tid":1}' https:///zport/dmd/device_router’
Can I use any state file to query JSON API of my application through SALT.

There is a difference between module and state.
Modules: Module runs the command/function every time and does not care if the task needs to be run or not.
State: On the other hand, the state cares about the status of the task that needs to be executed. Based on the result, it decides if the task should be run or the system is in the desired state that the task wants it to be.
More about this issue this.
To somehow answer your question, you cannot be sure what is the state of a server that you are trying to curl from. That means, that you need to use a module to get the current output and decide upon that.

Related

How do I save a historical (past) dataset in Foundry

I want to save a version of my dataset called (order_clean). But not the current version. The version I want to save is from the past. I understand this is a historical transaction that still exists within my retention policy window. How would I be able to do this?
This can be done via an API call and hitting a specific endpoint.
This answer assumes a working knowledge around authorization tokens and curl requests:
Obtain the desired dataset’s RID (Example in screenshot below), as well as the transaction ID of the transaction corresponding to the version of the dataset you want.
[
Create a new branch in your specific dataset by running a curl request populated as follows:
curl -X POST -H "Content-type: application/json" -H "Authorization: Bearer YOUR_AUTH_TOKEN" "STACK_URL/foundry-catalog/api/catalog/datasets/YOUR_DATASET_RID/branchesUnrestricted2/NEW_BRANCH_NAME" -d '{"parentRef": "YOUR_TRANSACTION_ID", "parentBranchId": "master"}'
Replace YOUR_AUTH_TOKEN, STACK_URL, YOUR_DATASET_RID, NEW_BRANCH_NAME and YOUR_TRANSACTION_ID with appropriate values. Short lived authentication token can be generated following these instructions.
Save the branch into a new dataset with a transform in a Code Repo, specifying the Input with the path to the dataset as well as the new branch’s name from #2.

I'm using the Newsblur API and I want to export a list of all the stories in a feed to a file. But when I enter my password, I get an error

I've recently gotten into RSS and I started using Newsblur. And I've…kind of bitten off more than I can chew.
I subscribed to some feeds that post wayyyyy too often and it’s super overwhelming. Before I unsubscribe or use that intelligence trainer feature Newsblur has, I want to get a list of all the entries that are already there so I don’t miss anything I’d actually be interested in. I'm assuming this will I'm guessing this is something I can do through the API, but before asking here I wanted to see if anything the Newsblur API page lists would work.
I attempted to log in through the command prompt first, and I attempted this (I used something like this for Feedbin earlier and it worked like a charm so I thought it might work here):
curl --request POST --user "<username>:<password>" http://newsblur.com/api/login'
{"code": -1, "errors": {"username": ["Please enter a username."]}, "result": "ok", "authenticated": false}
(Angle brackets not included, of course. Also not sure if I should separate the input and the output?)
I then attempted to run that command without the password and I thought I had it because it prompted me for a password, but after I put it in, it still gave me the same error. I tried pasting the password, I've tried actually typing it out, but to no avail.
curl --request POST --user "<username>" http://newsblur.com/api/login
Enter host password for user '<username>':
{"code": -1, "errors": {"username": ["Please enter a username."]}, "result": "ok", "authenticated": false}
I even tried using -u instead of --user but the same exact thing happened. I never really used curl before though so maybe I'm missing something really obvious?
I cannot validate this against a live api service at the moment, but after taking a look at the docs, I believe Newsblur is not using Basic Auth authentication (which is what -u/--user effectively does) - it expects you to pass user and password in the body of the request to /api.
And it probably sets a cookie in the response that must be sent in the requests that follow, so you may want to consult curl docs on how to work with cookies.

etherscan or ethplorer doesn't see test transaction

I want to get address transaction list and as I can see that is possible only if dancing with a tambourine. So I decided to use some third party service(which I think shame for ethereum developers but we have that what we have). But those service can't see transactions or balance on the address even balance showing via command
curl -X POST http://localhost:8545 -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":"0xcd88f3430a2e01e61554e655719e0f92d3e1ba37", "pending"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0xde0b6b3a7640000"}
(sent via goerli)
but when I perform request like
https://api.etherscan.io/api?module=account&action=txlist&address=0xcd88f3430a2e01e61554e655719e0f92d3e1ba37&sort=asc&apikey=...
I get
message "No transactions found"
Or on
https://kovan-api.ethplorer.io/getAddressTransactions/0xcd88f3430a2e01e61554e655719e0f92d3e1ba37?apiKey=...
[]
Can you please explain to me what happen and how easily to extract transaction list for the address.
Found it, need to use different domain for goerli transactions
https://api-goerli.etherscan.io/

Jenkins remote API - trigger job with static pulldown paramters

I am attempting to trigger a Jenkins build remotely via curl that has required parameters. These parameters are in the form of a static pull down.
I am able to trigger the build remotely via curl, but the parameters are not being passed - it appears that it is just taking the first (default) from each pull down.
Here is the curl command:
export json="{\"parameter\": [{\"name\": \"ENV\", \"value\": \"dev-1\"},{\"name\": \"PLATFORM\", \"value\": \"desktop\"},{\"name\": \"PRODUCT\", \"value\": \"Test\"}]}"
curl -H ".crumb:xxxxxxxxxxxxxxxxxxxxxx" -X POST http://server:8080/job/job_name/buildWithParameters -d token=tokenId --data-urlencode json="$json"
From what I can tell the JSON is valid - is there a different set of elements required for a static pull down list?
Thanks!
Use http://server:8080/job/job_name/build instead of buildWithParameters, as shown in the example for using the remote access api.
I'm not sure what's the reason for the difference, and it was a bit confusing for me at first, but when using buildWithParameters you need to add the parameters to the url as you found out with your wget command - and at the same time you can also add parameters when using the normal build trigger.
Note that when you trigger a build this way, it will still work if you leave out some parameters, but for those the default value won't be used (they will be unspecified).
I got this to work using wget instead of curl, but I'd still be interested in knowing how to make this work with curl if anyone has pointers.
This command works:
wget --delete-after --auth-no-challenge --http-user=${userID} --http-password=${authToken} http://server:8080/job/job_name/buildWithParameters?token=runme\&ENV='dev-1'\&PLATFORM='desktop'\&PRODUCT='Test'

End-of-file command in JSON HTTP POST request from putty

It is merely a childish question, but I have stuck upon an HTTP POST request through putty command line. After performing the initial request:
~$ POST <url:port/directory>
Please enter content (application/x-www-form-urlencoded) to be POSTed:
...(content posted there)
I have no option to send the command, since the only keyboard sequence working is CTRL-Z, which stops the procedure, other than sending the command. Is there any other interaction for the END-OF-FILE?
CTRL-D will simulate EOF. You can also pipe into POST, which may make things easier for testing, for example:
cat ~/my-json-file.json | POST <url:port/directory>