Is GitHub CLI "--jq" argument (to select values from the response) processed on the server or on the client? - http

according to examples from https://cli.github.com/manual/gh_api:
# print only specific fields from the response
$ gh api repos/{owner}/{repo}/issues --jq '.[].title'
GitHUb CLI (gh) can use the '-q' or '--jq' argument followed by a query string to select values from the response and e.g. display only certain fields.
I'd like to do a similar thing using either CURL, postman or JavaScript fetch().
So my question is: is the --jq query string sent (somehow) by gh CLI as part of an http request and processed on the server (to reduce the amount of data in the response), or is it only applied on the client side as post-processing of the data received ?
And if that query string can be passed to and processed on the server, how should it be specified if I need to make the request not with gh but with curl, postman or javascript fetch() method?
I fear the processing is actually done on the client, meaning the http response will always provide the full data...
Can someone confirm this?
Thanks!

The response is filtered on the client. You can verify yourself by taking a look at the source code:
if opts.FilterOutput != "" && serverError == "" {
// TODO: reuse parsed query across pagination invocations
err = jq.Evaluate(responseBody, bodyWriter, opts.FilterOutput)
if err != nil {
return
}
}

curl, postman, fetch
Your goal is to make an HTTP Request, not use the gh CLI.
GitHub's GraphQL API is what you seek:
To create integrations, retrieve data, and automate your workflows, use the GitHub GraphQL API. The GitHub GraphQL API offers more precise and flexible queries than the GitHub REST API.
GraphQL only returns the data requested. The data is "processed" on the API server and then sent to the client.

Related

Third party to PeopleSoft SSO integration

I have to write sign on peoplecode to make a service call by passing token (sent from third party) to API and get the responce (if token is valid responce will have username) in json format to create a PS_TOKEN.
I am fresher to peoplecode. How can I run HTTP POST request by passing token and get the response using Peoplecode?
You would create a synchronous service operation in the Integration Broker. The Integration Broker works best if you are sending XML or JSON. If this is just a regular HTTP POST with fields then it can cause some issues with the Integration Broker. I had a similar case and could not get the basic HTTP Post to work but instead ended up using HTTP POST multipart/form-data and was able to get that to work.
Steps I had to do to make this work.
Create a Message (document based or rowset based are both possible)
Create Service Operation and related objects
Create Transform App Engine to convert the Message to a HTTP POST multipart/form-data
Create a routing and modify the connector properties to send the content type of multipart/form-data. Also call the Transform app engine as part of the routing.
The issue with a application/x-www-form-urlencoded POST is that it seems PeopleSoft does another url encoding after the Transform, which is the last time you can touch the output with code. This final url encoding was encoding the = sign in the form post which made the format invalid.
Your other option would be to write this is Java and call the Java class from within PeopleSoft (or mix the Java objects in with PeopleCode). If you choose to go this way then the App Server needs to have connectivity to your authentication server. My only experience with this is I had a client that used this approach and had issues under heavy load. It was never determined the cause of the performance issue, they switched to LDAP instead to resolve the issue.

In okhttp I'd like to handle Last-Modified and ETags but without caching the whole response

I'm using okhttp and Retrofit to call a REST service. The data that is returned from that service is store in my Android app inside an sqlite database.
Whenever I call the REST api, if the data hasn't changed (determined by either ETag or Last-Modified header) I want to have the Retrofit callback do nothing (data in DB is ok). Otherwise I want to download the updated JSON from the REST service and update the database (via the onSuccess method of my callback).
The okhttp examples on caching all setup disk caches for the responses, I just need to cache/store the Etag/last-modified time of each request (and not the whole response).
Should I be doing this through a custom Cache implementation that I pass to okhttp, or is there a better interface I should be using with okhttp or Retrofit?
Once I have the implementation setup do I just need to handle the 304 "errors" in my onFailure callback and do nothing?
To know if you've got a 304 as response, in the onResponse callback you can catch it as follows:
if (response.raw().networkResponse().code() == 304){
// Do what you want to do
}
At least, this is when you are using Retrofit 2 and okHttp 3. Not sure about earlier versions, but I guess it would be kind of the same? You could always try to find a 304 response when setting breakpoints in the response.

how do i resend a request after processing it inside my apigee endpoint

I have a endpoint called get user data which accepts a token
I need to read this token in my apigee and send it to tokenVarificationExtUrl
which gets back to me with
a) valid 200
b) userid attached with that token
now what i have to do is i need to read the response header and then conditionally check it for 200 success and then extract the userid from the response.
Once its extracted i need to attach it with another request; which i need to send to getUserData external url
which will get back to me with required user details.
I am successful of extracting data and doing conditional check. I am seeking help for
how do i send another request to getUserData external url.
You need to use a few policies in your proxy.
For example
For checking a header and throwing an error, you may want to use rasie fault policy conditionally
For making an API call to external end-point you can use service callout policy or a standard target
For exrtacting response data from json or xml payload you can use json path of xpath policies
and so on.
I suppose you may want to take a look at a few sample proxies with these functions to be able to design your own.
Check this link out. http://apigee.com/docs/content/using-sample-api-proxies

How can I add custom JSON parameter in JIRA webhook?

I have a web-servise which listens to the JSON requests from different data sources. I want to identify data source by special parameter data-source. My question is how I can add field "data-source": "jira" to the webhook JSON body?
EDIT
For now my solution is to add to my webhook uri http://127.0.0.1:8080/DC data source parameter like this: http://127.0.0.1:8080/DC?data-source=jira, then check data source type and if it is equal to jira send request JSON body to method jiraJsonParser().
But I'm not sure if it is the best solution, isn't it?
I had a similar need, and solved the problem by creating a REST API with flask that acts as an aggregator/translator to accept requests from multiple tools, format the request as needed, and pass it on to it's intended target. For example, I have a Jira 'build request' ticket that sends a POST request via webhook to my API upon ticket creation. The API accepts the request, formats it as needed, fwd's the request on to Jenkins to run a build. As each part of the build runs, Jenkins sends requests back to the API, which get formatted as needed, and the original Jira ticket gets updated with the details/status of the build.
Here's a good article on building a REST API with flask - http://blog.luisrei.com/articles/flaskrest.html

Amazon Dynamodb Exception error

when we are calling dynamodb with http rest api it is giving this error
Can i know what is the problem? what are all the required things we need to append in the dynamodb url??
http://dynamodb.us-east-1.amazonaws.com/?aws_access_key=XXXXXXXXXXXXXXXX&aws_secret_access_key=ZZZZZZZZZZZZZZZZZZZZZZ
Do we need to append anything more parameters with this url please let me know??
http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/UsingJSON.html#JSONMajorExample
Your solution is in the same link
http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/MakingHTTPRequests.html
If you don't use one of the AWS SDKs, you can perform Amazon DynamoDB operations over HTTP using the POST request method. The POST method requires you to specify the operation in the header of the request and provide the data for the operation in JSON format in the body of the request.
You need to make POST request with all the required parameters mentioned in that page.

Resources