{"id":21030689,"url":"https://github.com/cdancy/artifactory-rest","last_synced_at":"2025-05-15T11:32:58.483Z","repository":{"id":4669806,"uuid":"52278973","full_name":"cdancy/artifactory-rest","owner":"cdancy","description":"java client, based on jclouds, for working with Artifactory's REST API","archived":false,"fork":false,"pushed_at":"2024-04-18T10:07:54.000Z","size":1690,"stargazers_count":6,"open_issues_count":10,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T08:42:35.590Z","etag":null,"topics":["artifactory","artifactory-rest","ci","cicd","java","jclouds"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdancy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-22T14:27:21.000Z","updated_at":"2023-04-16T02:48:45.000Z","dependencies_parsed_at":"2023-11-28T14:47:47.637Z","dependency_job_id":"a86bbf2c-7e0c-4c92-86d7-a19d22fd2a8b","html_url":"https://github.com/cdancy/artifactory-rest","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fartifactory-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fartifactory-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fartifactory-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fartifactory-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdancy","download_url":"https://codeload.github.com/cdancy/artifactory-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254330932,"owners_count":22053079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artifactory","artifactory-rest","ci","cicd","java","jclouds"],"created_at":"2024-11-19T12:19:50.071Z","updated_at":"2025-05-15T11:32:55.296Z","avatar_url":"https://github.com/cdancy.png","language":"Java","readme":"\n[![Build Status](https://travis-ci.org/cdancy/artifactory-rest.svg?branch=master)](https://travis-ci.org/cdancy/artifactory-rest)\n[![codecov](https://codecov.io/gh/cdancy/artifactory-rest/branch/master/graph/badge.svg)](https://codecov.io/gh/cdancy/artifactory-rest)\n[![Download](https://api.bintray.com/packages/cdancy/java-libraries/artifactory-rest/images/download.svg) ](https://bintray.com/cdancy/java-libraries/artifactory-rest/_latestVersion)\n[![Stack Overflow](https://img.shields.io/badge/stack%20overflow-artifactory\u0026#8211;rest-4183C4.svg)](https://stackoverflow.com/questions/tagged/artifactory+rest)\n\n# artifactory-rest\n![alt tag](http://maven.inria.fr/img/artifactory_logo_720.png)\n\njava client, based on jclouds, to interact with Artifactory's REST API. \n\n## Motivation\nShortly after writing the [etcd-rest](https://github.com/cdancy/etcd-rest) library I had a use-case for automating various functions against Artifactory. This included, but was not limited to: querying for groups of artifacts, deleting groups of artifacts, adding properties to groups of artifacts, etc. Furthermore I needed to do this in DevOps/CICD fashion: meaning I wanted to be able to configure it (endpoint, credentials, token, http properties, etc) and build the client by inferring these values from `System Proprties`, `Environment Variables`, or a combination of the 2. I started looking at the [artifactory-java-client](https://github.com/JFrogDev/artifactory-client-java) and could immediately tell it was not going to suffice. This is not a shot at them but more an admission that they simply designed things in a different way than what I required. Nevertheless I continued forward and thought maybe I could write some sort of wrapper to do what I needed. After playing for a bit, and getting my first initial PR together, I had the painful feeling that getting a change in, whilst writing tests, was just too much work. It's for this reason I noted the above `etcd-rest` library as it is built on top of `jclouds`, has an easy to use and understand client interface, has a built in model for writing mock and integration tests, makes adding new code amount to little more than wiring up a new interface method with a handful of annotations, and could do everything I wanted.\n\nIt's with this in mind that I created the `artifactory-rest` library and its sister project the [gradle-artifactory-rest-plugin](https://github.com/cdancy/gradle-artifactory-rest-plugin). These are both DevOps/CICD focused, are easy to use, and easy to contribute back to. All boiler plate http code has been abstracted away leaving the developer to focus solely on wiring up a new `endpoint` (interface method) with the appropriate annotations.\n\n## On jclouds, apis and endpoints\nBeing built on top of `jclouds` means things are broken up into [Apis](https://github.com/cdancy/artifactory-rest/tree/master/src/main/java/com/cdancy/artifactory/rest/features). \n`Apis` are just Interfaces that are analagous to a resource provided by the server-side program (e.g. /api/repositories, /api/search, /api/storage, etc..). \nThe methods within these Interfaces are analagous to an endpoint provided by these resources (e.g. GET /api/repositories/my-repo, POST /api/search/aql, DELETE /api/storage/my-repo/my-item, etc..). \nThe user only needs to be concerned with which `Api` they need and then calling its various methods. These methods, much like any java library, return domain objects \n(e.g. POJO's) modeled after the json returned by `artifactory`. \n\nInteracting with the remote service becomes transparent and allows developers to focus on getting\nthings done rather than the internals of the API itself, or how to build a client, or how to parse the json. \n\n## On new features\n\nNew Api's or endpoints are generally added as needed and/or requested. If there is something you want\nto see just open an ISSUE and ask or send in a PullRequest. However, putting together a PullRequest\nfor a new feature is generally the faster route to go as it's much easier to review a PullRequest\nthan to create one ourselves. There is no problem doing so of course but if you need something done\nnow than a PullRequest is your best bet otherwise you may have to patiently wait for one of our\ncontributors to take up the work.\n\n## Latest Release\n\nCan be sourced from maven like so:\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.github.cdancy\u003c/groupId\u003e\n      \u003cartifactId\u003eartifactory-rest\u003c/artifactId\u003e\n      \u003cversion\u003eX.Y.Z\u003c/version\u003e\n      \u003cclassifier\u003esources|tests|javadoc|all\u003c/classifier\u003e (Optional)\n    \u003c/dependency\u003e\n\t\n## Documentation\n\njavadocs can be found via [github pages here](http://cdancy.github.io/artifactory-rest/docs/javadoc/)\n\n## Examples on how to build a _ArtifactoryClient_\n\nWhen using `Basic` (e.g. username and password) authentication:\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .endPoint(\"http://127.0.0.1:8080/artifactory\") // Optional and can be sourced from system/env. Falls back to http://127.0.0.1:8080/artifactory\n    .credentials(\"admin:password\") // Optional and can be sourced from system/env and can be Base64 encoded.\n    .build();\n\n    Version version = client.api().systemApi().version();\n\nWhen using `Bearer` (e.g. jfrog token) authentication:\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .endPoint(\"http://127.0.0.1:8080/artifactory\") // Optional and can be sourced from system/env. Falls back to http://127.0.0.1:8080/artifactory\n    .token(\"123456789abcdef\") // Optional and can be sourced from system/env.\n    .build();\n\n    Version version = client.api().systemApi().version();\n\nWhen using `Anonymous` authentication or sourcing from system/environment (as described below):\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .endPoint(\"http://127.0.0.1:8080/artifactory\") // Optional and can be sourced from system/env. Falls back to http://127.0.0.1:8080/artifactory\n    .build();\n\n    Version version = client.api().systemApi().version();\n\n## On `System Property` and `Environment Variable` setup\n\nClient's do NOT need to supply the endPoint or authentication as part of instantiating the\n_ArtifactoryClient_ object. Instead one can supply them through `System Properties`, `Environment\nVariables`, or a combination of the 2. `System Properties` will be searched first and if not\nfound we will attempt to query the `Environment Variables`. If neither turns up anything\nthan anonymous access is assumed.\n\nSetting the `endpoint` can be done like so (searched in order):\n\n    `System.setProperty(\"artifactory.rest.endpoint\", \"http://my-artifactory-instance:12345/artifactory\")`\n    `export ARTIFACTORY_REST_ENDPOINT=http://my-artifactory-instance:12345/artifactory`\n\nSetting the `credentials`, which represents `Basic` authentication and is optionally Base64 encoded, can be done like so (searched in order):\n\n    `System.setProperty(\"artifactory.rest.credentials\", \"username:password\")`\n    `export ARTIFACTORY_REST_CREDENTIALS=username:password`\n\nSetting the `token`, which represents `Bearer` authentication, can be done like so (searched in order):\n\n    `System.setProperty(\"artifactory.rest.token\", \"abcdefg1234567\")`\n    `export ARTIFACTORY_REST_TOKEN=abcdefg1234567`\n\n## On Overrides\n\nBecause we are built on top of jclouds we can take advantage of overriding various internal _HTTP_ properties by\npassing in a `Properties` object or, and in following with the spirit of this library, configuring them\nthrough `System Properties` of `Environment Variables`. The properties a given client can configure can be\nfound [HERE](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/Constants.java).\n\nWhen configuring through a `Properties` object you must pass in the keys exactly as they are named within jclouds:\n\n    Properties props = new Properties();\n    props.setProperty(\"jclouds.so-timeout\", \"60000\");\n    props.setProperty(\"jclouds.connection-timeout\", \"120000\");\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .overrides(props)\n    .build();\n\n    Version version = client.api().systemApi().version();\n\nWhen configuring through `System Properties` you must prepend the jclouds name with `artifactory.rest.`:\n\n    System.setProperty(\"artifactory.rest.jclouds.so-timeout\", \"60000\");\n    System.setProperty(\"artifactory.rest.jclouds.connection-timeout\", \"120000\");\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .build();\n\n    Version version = client.api().systemApi().version();\n\nWhen configuring through `Environment Variables` you must CAPITALIZE all characters,\nreplace any `.` with `_`, and prepend the jclouds name with `ARTIFACTORY_REST_`:\n\n    export ARTIFACTORY_REST_JCLOUDS_SO-TIMEOUT=60000\n    export ARTIFACTORY_REST_JCLOUDS_CONNECTION-TIMEOUT=120000\n\n    ArtifactoryClient client = ArtifactoryClient.builder()\n    .build();\n\n    Version version = client.api().systemApi().version();\n\nIt should be noted that when using this feature a merge happens behind the scenes between all\npossible ways one can pass in _overrides_. Meaning if you pass in a `Properties` object, and\nthere are `System Properties` and `Environment Variables` set, then all 3 will be merged into\na single `Properties` object which in turn will be passed along to _jclouds_. When it comes to \nprecedence passed in `Properties` take precedence over `System Properties` which in turn \ntake precedence over `Environment Variables`.\n\n## Examples\n\nThe [mock](https://github.com/cdancy/artifactory-rest/tree/master/src/test/java/com/cdancy/artifactory/rest/features) and [live](https://github.com/cdancy/artifactory-rest/tree/master/src/test/java/com/cdancy/artifactory/rest/features) tests provide many examples\nthat you can use in your own code. If there are any questions feel free to open an issue and ask.\n\n## Components\n\n- jclouds \\- used as the backend for communicating with Artifactory's REST API\n- AutoValue \\- used to create immutable value types both to and from the artifactory program\n    \n## Testing\n\nRunning mock tests can be done like so:\n\n    ./gradlew mockTest\n\t\nRunning integration tests can be done like so (requires Artifactory instance):\n\n    ./gradlew integTest\n\nVarious [properties](https://github.com/cdancy/artifactory-rest/tree/master/gradle.properties) exist for you to configure how the `integTest` task can be run should the defaults not suffice.\n\t\n# Additional Resources\n\n* [Artifactory REST API](https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API)\n* [Apache jclouds](https://jclouds.apache.org/start/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdancy%2Fartifactory-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdancy%2Fartifactory-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdancy%2Fartifactory-rest/lists"}