Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Artifactory API in Clojure
Clojure
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/clj_artifactory
test/clj_artifactory/test
README.md
project.clj

README.md

Description

Artifactory API in Clojure.

Examples

Item info:

(item-info "http://localhost:8081/artifactory/" "libs-release-local" "/junit")

Returns:

{"modifiedBy" "admin", "path" "/junit", "lastUpdated" "2011-07-24T21:20:37.299-04:00", 
 "created" "2011-07-24T21:20:37.295-04:00", 
 "uri" "http://localhost:8081/artifactory/api/storage/libs-release-local//junit", 
 "repo" "libs-release-local", 
 "metadataUri" "http://localhost:8081/artifactory/api/storage/libs-release-local//junit?mdns", 
 "createdBy" "admin", 
 "children" [{"uri" "/junit", "folder" true}], "lastModified" "2011-07-24T21:20:37.299-04:00"}

Delete item (with authentication):

All functions that require authentication must be wrapped using the with-auth macro.

(with-auth "admin" "password"
 (delete-item "http://localhost:8081/artifactory/" "libs-release-local" "/junit"))

Returns:

""

Extending

API calls are written using the api-call macro. The macro expects the following parameters:

(api-call call-name [param1* {:optional-key-param1 default-val1}*] [method-name uri ring-request-object])

The macro defines a function call-name that takes the specified parameters, but in addition also creates a required first position argument for the hostname, and an additional optional keyword argument :squash-ex, which specifies whether or not exceptions would be ignored from within call-name.

As a result, all api calls require the hostname to be passed in first, and :squash-ex could be used anywhere after all the required arguments.

Example of a fictitious api call:

(api-call delete-repository
  [repo :saved-file "/etc/hosts"]
  [:delete (str "/repo/delete" repo) 
           {:query-params {"file-to-save" saved-file}}]) 

Above defines a function that deletes all items in a repository with an option to save one file from being deleted ("/etc/hosts" won't be deleted by default).

Here's how to call such delete-repository:

; Delete all items under repository.
(delete-repository "http://localhost/artifactory" "libs-release-local")
; Delete all items under repository but save one file.
(delete-repository "http://localhost/artifactory" "libs-release-local" :saved-file "/etc/passwd")
; Delete all items under repository, and throw an exception if any exception occurs with the delete-repository.
(delete-repository "http://localhost/artifactory" "libs-release-local" :squash-ex false)
Something went wrong with that request. Please try again.