How to remove meta-data from jql query? - optimization

I have the following curl command:
curl -k -u sandboxer:sandboxer -D- -X POST -H "Content-Type: application/json" --data
'{"jql":"project = BNAP AND resolution = null AND status != Resolved AND status != Rejected",
"maxResults":2 ,
"fields":["KEY","versions","description","status","resolution"]}'
https://127.0.0.1/rest/api/latest/search 1> newtest
I recieve a JSON object with meta-data,
{"expand":"schema,names"
,"startAt":0
,"maxResults":2
,"total":74
...
All I am intersted in is what follows, issues. I could take care of this in my application, but I am wondering if there is a way I could just tell JIRA 'Don't send me meta-data'. Is there?

Use the Speakeasy plugin to create a custom request/response as a Jira extension:
Speakeasy plugin
Installing Speakeasy
Developing Speakeasy Extensions

Related

Apicurio registry - Documentation tab for artifact is empty

When I upload artifact to the ApiCurio registry using UI it works fine but if I use CURL for the same artifact, Documentation tab is empty. Any ideas?
I use:
curl -X POST -H "Content-type: application/json" -H "X-Registry-ArtifactType: OPENAPI" -H "X-Registry-ArtifactId: test" --data "{$body}" http://registry:8080/api/artifacts
should use "$body" instead of "{$body}"

Confluent schema-registry how to http post json-schema

Confluent 5.5.0 understands not just Avro schemas, but also json-schema and protobuf. I have a valid json-schema that I'm trying to curl to the schema registry server, but I keep getting the response
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data #$tmpfile ${schemaregistry}/subjects/${topic}-value/versions?schemaType=JSONSCHEMA
{"error_code":42201,"message":"Either the input schema or one its references is invalid"}
The manual is unclear about how to use the schemaType parameter. I've tried as a query parameter, as a field in the json, ...
The $tmpfile I'm posting is a json with one top-level field named schema that contains a quote-escaped json-schema. The same mechanism works perfectly for Avro schemas.
Looking in the logging from the schema registry, I see that it tries to parse the provided data as an Avro schema, so no wonder it fails.
Any help? And Confluent: please clarify and fix your documentation!
Ah I got it. The documentation is unclear and wrong!
You have to add a field inside the posted json. The field name is schemaType, and its value must be JSON, and not JSONSCHEMA (what the documentation says).
For others here's an example that shows how to put local files with an avro and json schema into the schema-registry:
#!/bin/bash
schemaregistry="$1"
tmpfile=$(mktemp)
topic=avro-topic
export SCHEMA=$(cat schema.avsc)
echo '{"schema":""}' | jq --arg schema "$SCHEMA" '.schema = $schema' \
> $tmpfile
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data #$tmpfile ${schemaregistry}/subjects/${topic}-value/versions
topic=json-topic
export SCHEMA=$(cat schema.json)
echo '{"schema":"","schemaType":"JSON"}' | jq --arg schema "$SCHEMA" '.schema = $schema' \
> $tmpfile
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data #$tmpfile ${schemaregistry}/subjects/${topic}-value/versions
rm $tmpfile
According to the Confluent schema registry API documentation one can check the supported schema types by calling
curl --silent -X GET http://localhost:8081/schemas/types
This should result in
["JSON","PROTOBUF","AVRO"]
for the current version (5.5) so the output might help to set a proper schemaType-attribute.
Nonetheless as #bart van deenen pointed out here, the API doc is (still) wrong.

Where do I find the project ID for the GitLab API?

I use GitLab on their servers. I would like to download my latest built artifacts (build via GitLab CI) via the API like this:
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.com/api/v3/projects/1/builds/8/artifacts"
Where do I find this project ID? Or is this way of using the API not intended for hosted GitLab projects?
I just found out an even easier way to get the project id: just see the HTML content of the gitlab page hosting your project. There is an input with a field called project_id, e.g:
<input type="hidden" name="project_id" id="project_id" value="335" />
The latest version of GitLab 11.4 at the time of this writing now puts the Project ID at the top of the frontpage of your repository.
Screenshot:
On the Edit Project page there is a Project ID field in the top right corner.
(You can also see the ID on the CI/CD pipelines page, in the exameple code of the Triggers section.)
In older versions, you can see it on the Triggers page, in the URLs of the example code.
You can query for your owned projects:
curl -XGET --header "PRIVATE-TOKEN: XXXX" "https://gitlab.com/api/v4/projects?owned=true"
You will receive JSON with each owned project:
[
{
"id":48,
"description":"",
"default_branch":"master",
"tag_list":[
...
You are also able to get the project ID from the triggers configuration in your project which already has some sample code with your ID.
From the Triggers page:
curl -X POST \
-F token=TOKEN \
-F ref=REF_NAME \
https://<GitLab Installation>/api/v3/projects/<ProjectID>/trigger/builds
As mentioned here, all the project scoped APIs expect either an ID or the project path (URL encoded).
So just use https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-foss directly when you want to interact with a project.
Enter the project.
On the Left Hand menu click Settings -> General -> Expand General Settings
It has a label Project ID and is next to the project name.
This is on version GitLab 10.2
Provide the solution that actually solve the problem the api of getting the project id for specific gitlab project
curl -XGET -H "Content-Type: application/json" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" http://<YOUR-GITLAB-SERVER>/api/v3/projects/<YOUR-NAMESPACE>%2F<YOUR-PROJECT-NAME> | python -mjson.tool
Or maybe you just want the project id:
curl -XGET -H "Content-Type: application/json" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" http://<YOUR-GITLAB-SERVER>/api/v3/projects/<YOUR-NAMESPACE>%2F<YOUR-PROJECT-NAME> | python -c 'import sys, json; print(json.load(sys.stdin)["id"])'
Note that the repo url(namespace/repo name) is encoded.
If you know your project name, you can get the project id by using the following API:
curl --header "Private-Token: <your_token>" -X GET https://gitlab.com/api/v4/projects?search=<exact_project_name>
This will return a JSON that includes the id:
[
{
"id":<project id>, ...
}
]
Just for the record, if someone else has the need to download artifacts from gitlab.com created via gitlab-ci
Create a private token within your browser
Get the project id via curl -XGET --header "PRIVATE-TOKEN: YOUR_AD_HERE?" "https://gitlab.com/api/v3/projects/owned"
Download the last artifact from your master branch created via a gitlab-ci step called release curl -XGET --header "PRIVATE-TOKEN: YOUR_AD_HERE?" -o myapp.jar "https://gitlab.com/api/v3/projects/4711/builds/artifacts/master/download?job=release"
I am very impressed about the beauty of gitlab.
You can view it under the repository name
You can query projects with search attribute e.g:
http://gitlab.com/api/v3/projects?private_token=xxx&search=myprojectname
As of Gitlab API v4, the following API returns all projects that you own:
curl --header 'PRIVATE-TOKEN: <your_token>' 'https://gitlab.com/api/v4/projects?owned=true'
The response contains project id. Gitlab access tokens can be created from this page- https://gitlab.com/profile/personal_access_tokens
No answer suits generic needs, the most similar is intended only for the gitlab site, not specific sites. This can be used to find the ID of the project streamer in the Gitlab server my-server.com, for example:
$ curl --silent --header 'Authorization: Bearer MY-TOKEN-XXXX' \
'https://my-server.com/api/v4/projects?per_page=100&simple=true'| \
jq -rc '.[]|select(.name|ascii_downcase|startswith("streamer"))'| \
jq .id
168
Remark that
this gives only the first 100 projects, if you have more, you should request the pages that follow (&page=2, 3, ...) or run a different API (e.g. groups/:id/projects).
jq is quite flexible. Here we're just filtering a project, you can do multiple things with it.
There appears to be no way to retrieve only the Project ID using the gitlab api. Instead, retrieve all the owner's projects and loop through them until you find the matching project, then return the ID. I wrote a script to get the project ID:
#!/bin/bash
projectName="$1"
namespace="$2"
default=$(sudo cat .namespace)
namespace="${namespace:-$default}"
json=$(curl --header "PRIVATE-TOKEN: $(sudo cat .token)" -X GET
'https://gitlab.com/api/v4/projects?owned=true' 2>/dev/null)
id=0
idMatch=0
pathWithNamespaceMatch=0
rowToMatch="\"$(echo "$namespace/$projectName" | tr '[:upper:]' '[:lower:]')\","
for row in $(echo "${json}" | jq -r '.'); do
[[ $idMatch -eq 1 ]] && { idMatch=0; id=${row::-1}; }
[[ $pathWithNamespaceMatch -eq 1 ]] && { pathWithNamespaceMatch=0; [[ "$row" == "$rowToMatch" ]] && { echo "$id"; return 0; } }
[[ ${row} == "\"path_with_namespace\":" ]] && pathWithNamespaceMatch=1
[[ ${row} == "\"id\":" ]] && idMatch=1
done
echo 'Error! Could not retrieve projectID.'
return 1
It expects the default namespace to be stored in a file .namespace and the private token to be stored in a file .token. For increased security, its best to run chmod 000 .token; chmod 000 .namespace; chown root .namespace; chown root .token
If your project name is unique, it is handy to follow the answer by shunya, search by name, refer API doc.
If you have stronger access token and the Gitlab contains a few same name projects within different groups, then search within group is more convenient. API doc here. e.g.
curl --header "PRIVATE-TOKEN: <token>" -X GET https://gitlab.com/api/v4/groups/<group_id>/search?scope=projects&search=<project_name>
The group ID can be found from the Settings page under the group domain.
And to fetch the project id from the output, you can do:
curl --header "PRIVATE-TOKEN: <token>" -X GET https://gitlab.com/api/v4/groups/<group_id>/search?scope=projects&search=<project_name> | jq '[0].id'
To get id from all projects, use:
curl --header 'PRIVATE-TOKEN: XXXXXXXXXXXXXXXXXXXXXXX' 'https://gitlab.com/api/v4/projects?owned=true' > curloutput
grep -oPz 'name\":\".*?\"|{\"id\":[0-9]+' curloutput | sed 's/{\"/\n/g' | sed 's/name//g' |sed 's/id\"://g' |sed 's/\"//g' | sort -u -n
Not Specific to question, but somehow reached here, might help others
I used chrome to get a project ID
Go to the desired project example gitlab.com/username/project1
Inspect network tab
see the first garphql request in network tab
You can search for the project path
curl -s 'https://gitlab.com/api/v4/projects?search=my/path/to/my/project&search_namespaces=true' --header "PRIVATE-TOKEN: $GITLAB_TOKEN" |python -mjson.tool |grep \"id\"
https://docs.gitlab.com/ee/api/projects.html
Which will only match your project and will not find other unnecessary projects
My favorite method is to pull from the CI/CD pipeline so on build it dynamically assigns the project id.
Simply assign a variable in your code to = CI_PROJECT_ID

How to upload APK to Saucelabs

I want to upload my APK to Saucelabs, How can I do that?
Is there any tab do so ?
I am trying with Curl command as well, which is not working for me
Yes, U have to use curl command correctly.
Use below Link to download curl :
http://curl.haxx.se/download.html
After that use below curl command :
curl -u YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/YOUR_SAUCE_USERNAME/YOUR_ANDROID_APP.apk

React Native Sentry Source maps not working

I have tried to get source maps working with react native and sentry but I keep getting this type of output with no meaningful line numbers:
i#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:
[Filtered]#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:
[Filtered]#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:59:1255
[native code]
I did the following to create and upload the source maps for my release:
1. Create map/bundle artifacts
curl http://127.0.0.1:8081/index.ios.map -o index.ios.map
curl http://127.0.0.1:8081/index.ios.bundle -o index.ios.bundle
2. Edit last link in index.ios.bundle to point to map
WAS: `//# sourceMappingURL=/index.ios.map`
NOW: `//# sourceMappingURL=index.ios.map`
3. Create Release on Sentry
curl https://app.getsentry.com/api/0/projects/appname/releases/ -u "username": -X POST -d '{"version": "version_num"}' -H 'Content-Type: application/json'
4. POST artifacts to Sentry release
curl https://app.getsentry.com/api/0/projects/appname/releases/version_num/files/ -u "username": -X POST -F file=#index.ios.bundle
curl https://app.getsentry.com/api/0/projects/appname/releases/version_num/files/ -u "username": -X POST -F file=#index.ios.map
Have I missed something? Been playing around with this for some time and can't get it to work. Any help would be much appreciated! Thanks