Rest API to get list of artifacts from Nexus OSS 3.x Repository - rest

I have created a raw repository in Nexus 3.x and I'm able to upload artifacts to the same. Now I want get the list of all artifacts residing inside that repo using Rest API.
Any help is appreciated.

in the current Nexus3.14.0-04 the REST API has become final (no longer "beta") and the curl you need is:
curl -X GET "http://localhost:8081/service/rest/v1/components?repository=central" -H "accept: application/json"
this will return each "component" (group, name, version) with all its assets = each individual file (pom, sha1, md5, jar) who constitue the component
The result is a JSON string.
If instead you want to perform a COMPONENTS search - based on a groupId, artifactId - you can use this curl:
curl -X GET "http://localhost:8081/service/rest/v1/search?repository=central&format=maven2&maven.groupId=com.fasterxml.jackson.core&maven.artifactId=jackson-core&maven.extension=jar" -H "accept: application/json"
this returns COMPONENTS with child ASSETS.
The variant to retrieve only the ASSETS, without grouping them by COMPONENT, is GET /service/rest/v1/search/assets?repository=central&format=maven2&maven.groupId=com.fasterxml.jackson.core&maven.artifactId=jackson-core&maven.extension=jar

You can use the - still in beta - new API for Nexus. It's available by default on the version 3.3.0 and more: http://localhost:8082/swagger-ui/
Basically, you retrieve the json output from this URL: http://localhost:8082/service/siesta/rest/beta/assets?repositoryId=YOURREPO
Only 10 records will be displayed at a time and you will have to use the continuationToken provided to request the next 10 records for your repository by calling: http://localhost:8082/service/siesta/rest/beta/assets?continuationToken=46525652a978be9a87aa345bdb627d12&repositoryId=YOURREPO
More information here: http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content

Related

IBM Urbancode Deploy get current component versions deployed to an environment

I am trying get current component version of component that is deployed to an environment in UCD via REST API/Curl command . Below is sample code which returns all versions of that component which is available in UCD. It does not give me latest version of that component deployed to an environment. Any help / suggestion?
curl -k -u userName:passw0rd \
-H "Accept: application/json" \
"https://myserver.example.com:8443/rest/deploy/environment/{environmentID}/versions/{componentID}"
uDeploy has a bunch of api endpoints that are undocumented. I could not figure out how to do this from their docs but inspecting the uDeploy web interface many times can help you find the endpoint to hit.
https://{your-udeploy-url}/rest/deploy/environment/{your-environment-id}/latestDesiredInventory/true?rowsPerPage=10000&pageNumber=1&orderField=name&sortType=desc
This will return json that you can parse to get the versions deployed in an environment.

Clockify API: Group Report by Project and aggregate by Task

Calling the REST-Api, I want to get a list of tasks with their corresponding summed tracked time grouped by their project. As an example, if I have the following time entries:
2h, Task1, ProjectA
1h, Task1, ProjectA
3h, Task2, ProjectB
30m, Task2, ProjectA
I would like to get the following report:
ProjectA
Task1, 3h
Task2, 30m
ProjectB
Task2, 3h
At the moment this is possible via the UI, but I could not find a way to do this by calling the API.
Does anyone know how this works?
Unfortunately there is no endpoint that would return data grouped that way without additional formatting on the client side.
If you're up for some data transformation on the client you can use for example:
GET workspaces/{workspaceId}/reports/summary
It will contain a section 'projectAndTotalTime' which will show summed time entry duration per project, and a section 'timeEntries' with individual entries that you can group/sort by project on the client.
With Clockify's new API this is possible, here an example with cURL:
curl --request POST \
--url https://reports.api.clockify.me/v1/workspaces/<YOUR WORKSPACE>/reports/summary \
--header 'content-type: application/json' \
--header 'x-api-key: <YOUR API KEY>' \
--data '{
"dateRangeStart": "2020-07-13T00:00:00.000Z",
"dateRangeEnd": "2020-08-13T23:59:59.000Z",
"summaryFilter": {"groups": ["PROJECT", "TASK"]},
"exportType": "JSON"
}'
You can even select different export types, see https://clockify.me/developers-api#tag-Reports.

Diff between arbitrary commits in BitBucket

I am running bitbucket server v4.14. I want to be able to get diff of any two commits for a repo. I saw this posted at https://bitbucket.org/site/master/issues/4779/ability-to-diff-between-any-two-commits
However the same does not work, probably cause the version I am running is older. The compare page directly takes me to diff across branches. I do not want any UI element, just a URL is fine.
Thanks
This feature is not available to Bitbucket 4.14.
You can get this data using the REST API. Try to execute the following command:
curl -s --user USER:PASS --request GET https://BITBUCKET-SERVER/rest/api/1.0/projects/PROJECT/repos/REPOSITORY/commits?since=SINCE-COMMIT\&until=UNTIL-COMMIT | jq --raw-output '.values[] | .displayId+ " " + .author.name'
AFAIK there is only rest api endpoint. There is a since parameter that you can pass. See the docs for more details.

How do I upload a file with metadata to jfrog artifactory with curl

I upload a file like this:
curl -u ${CREDS} --upload-file ${file} ${url}
Is there a way to add a body or headers that will set some metadata for the file? Like build number.
You can actually deploy artifacts with properties to Artifactory OSS using matrix parameters, for example:
curl -uadmin:password -T file.tar "http://localhost:8081/artifactory/generic-local/file.tar;foo=bar;"
And get the artifact properties using REST API, for example:
curl -uadmin:password "http://localhost:8081/artifactory/api/storage/generic-local/file.tar?properties"
Viewing properties from the UI and other features are limited to the Pro edition.
Seems this is a pro feature. Documentation: Set Item Properties
PUT /api/storage/{repoKey}{itemPath}?properties=p1=v1[,v2][|p2=v3][&recursive=1]
Not helping me :-/

Cannot set more than one Meta data with OpenStack Swift Object

I am trying to set metadata with a Object stored in Swift Container. I am using following command (note that my container is 'container1' and object is 'employee.json':
curl -X POST -H "X-Auth-Token:$TOKEN" -H 'X-Object-Meta-metadata1: value' $STORAGE_URL/container1/employee.json
It works fine with one metadata. But whenever, I am trying to set more than one metadata issuing several curl commands, only the last metadata value is actually set.
I think, there should not be a limit that you can set only one metadata for a swift object. Am I doing anything wrong?
FYI: I am using Havana release of Openstack Swift.
Thank you.
I think, I have figured it out... Its my bad that I did not read documentation sincerely.
It [1] says, "A POST request will delete all existing metadata added with a previous PUT/POST."
So, I tried this and it worked...
curl -X POST -H "X-Auth-Token:$TOKEN" -H 'X-Object-Meta-p1:[P1]' -H 'X-Object-Meta-p2:[P1]' $STORAGE_URL/container1/employee.json
Here, instead of two POST requests, now I have set multiple metadata in a single POST request.
Again, thanks.
Ref:
http://docs.openstack.org/api/openstack-object-storage/1.0/content/update-object-metadata.html