Examples¶
List of examples for supported API methods.
ARTIFACTS AND STORAGE¶
Folder Info¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-FolderInfo
r = af.artifacts_and_storage.folder_info(repo_key, folder_path)
# repo_key is the name of the repository in Artifactory
# folder_path is the path of the folder inside the repo
# To get information on the root repo, use "", as argument for folder_path
File Info¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-FileInfo
r = af.artifacts_and_storage.file_info(repo_key, file_path)
# repo_key is the name of the repository in Artifactory
# file path is the path of the file inside the repo
Get Storage Summary Info¶
r = af.artifacts_and_storage.get_storage_summary_info()
Item Last Modified¶
r = af.artifacts_and_storage.item_last_modified(repo_key, item_path)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
File Statistics¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-FileStatistics
r = af.artifacts_and_storage.file_statistics(repo_key, item_path)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
Item Properties¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ItemProperties
r = af.artifacts_and_storage.item_properties(repo_key, item_path)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
# Standard example
r = af.artifacts_and_storage.item_properties("my_repo", "folder/artifact.png")
# Retrieve specific propertie(s)
r = af.artifacts_and_storage.item_properties(repo_key, item_path, properties="version")
r = af.artifacts_and_storage.item_properties(repo_key, item_path, properties="version, owner")
Set Item Properties¶
r = af.artifacts_and_storage.set_item_properties(repo_key, item_path, properties)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
# Single property
r = af.artifacts_and_storage.set_item_properties(repo_key, item_path, "version=1.0")
# Set multiple properties
r = af.artifacts_and_storage.set_item_properties(repo_key, item_path, "version=1.0;author=smith")
# Additionnal options from the documentation can be supplied as a string
r = af.artifacts_and_storage.set_item_properties(repo_key, item_path, "version=1.0;author=smith", options=string_of_options)
# options_string is a string of the possible options
# Such as [&recursive=1]
Delete Item Properties¶
r = af.artifacts_and_storage.delete_item_properties(repo_key, item_path, properties)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
# Delete a single property
r = af.artifacts_and_storage.delete_item_properties(repo_key, item_path, "version")
# Delete multiple properties
r = af.artifacts_and_storage.delete_item_properties(repo_key, item_path, "version,author")
Set Item SHA256 Checksum¶
params = {"repo_key": my_repo_key, "path": mypath}
# repo_key is the name of the repository in Artifactory
# artifact_path is the path of the artifact inside the repo
r = af.artifacts_and_storage.set_item_sha256_checksum(params)
Retrieve Artifact¶
r = af.artifacts_and_storage.retrieve_artifact(repo_key, artifact_path)
# repo_key is the name of the repository in Artifactory
# artifact_path is the path of the artifact inside the repo
# Save the file locally
with open("myartifact.png", "wb") as artifact:
artifact.write(r.content)
Retrieve Folder or Repository Archive¶
r = af.artifacts_and_storage.retrieve_folder_or_repository_archive(repo_key, path, archive_type)
# repo_key is the name of the repository in Artifactory
# path is the path of the folder inside the repo
# archive_type can be "zip", "tar", "tar.gz", "tgz"
# Checksums can be included
r = af.artifacts_and_storage.retrieve_folder_or_repository_archive(repo_key, path, archive_type, include_checksums=True)
# Save the archive locally
with open("myarchive.archive_type", "wb") as archive:
archive.write(r.content)
Trace Artifact Retrieval¶
r = af.artifacts_and_storage.trace_artifact_retrieval(repo_key, item_path)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
# with this method the response is a Python requests response object
# use r.text
print(r.text)
Create Directory¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CreateDirectory
r = af.artifacts_and_storage.create_directory(repo_key, directory_path)
# repo_key is the name of the repository in Artifactory
# directory_path is the path of the directory inside the repo
# Known issue : when trying to create a directory that already exists,
# response will not say already exist and nothing will happen.
Deploy Artifact¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DeployArtifact
r = af.artifacts_and_storage.deploy_artifact(repo_key, local_artifact_path, target_artifact_path)
# repo_key is the name of the repository in Artifactory
# target_artifact_path is the path of the artifact inside the repo
# local_artifact_path is the path of the artifact on the local machine
# Standard example
r = af.artifacts_and_storage.deploy_artifact("myrepo", "myartifact_on_my_machine.png", "directory/my_remote_artifact.png")
# It is possible to attach properties as part of deploying an artifact using
# Artifactory's Matrix Parameters :
# https://www.jfrog.com/confluence/display/RTF4X/Using+Properties+in+Deployment+and+Resolution
# Single property
r = af.artifacts_and_storage.deploy_artifact("myrepo", "myartifact_on_my_machine", "myartifact;prop1=value")
# Multiple properties
r = af.artifacts_and_storage.deploy_artifact("myrepo", "myartifact_on_my_machine", "myartifact;prop1=value;prop2=value2")
Deploy Artifact by Checksum¶
r = af.artifacts_and_storage.deploy_artifact_by_checksum(repo_key, target_artifact_path, sha_type, sha_value):
# repo_key is the name of the repository in Artifactory
# target_artifact_path is the path of the artifact inside the repo
# sha_type is "sha1" or "sha256"
# sha_value is the value of the sha (string)
# Standard example
sha_type = "sha1"
sha_value = "e1a13e64b0414015d43dd80eed7876d7cee5e50e"
r = af.artifacts_and_storage.deploy_artifact_by_checksum("my_repo", "my_remote_artifact", sha_type, sha_value)
# It is possible to attach properties as part of deploying an artifact using
# Artifactory's Matrix Parameters :
# https://www.jfrog.com/confluence/display/RTF4X/Using+Properties+in+Deployment+and+Resolution
# Single property
r = af.artifacts_and_storage.deploy_artifact_by_checksum("myrepo", "myartifact;prop1=value", sha_type, sha_value)
# Multiple properties
r = af.artifacts_and_storage.deploy_artifact_by_checksum("myrepo", "myartifact;prop1=value;prop2=value2", sha_type, sha_value)
Delete Item¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DeleteItem
r = af.artifacts_and_storage.delete_item(repo_key, path_to_item)
# repo_key is the name of the repository in Artifactory
# path_to_item is the path to the item (repo or artifact) in the repo
# use "" as argument for path_to_item to delete all the content of a repository
Copy Item¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CopyItem
r = af.artifacts_and_storage.copy_item(src_repo_key, src_item_path, target_repo_key, target_item_path)
# src_repo_key is the name of the repository in Artifactory
# src_item_path is the path to the item (repo or artifact) in the repo
# target_repo_key is the name of the target repository in Artifactory
# target_item_path is the path of the item in the target repository
# Additionnal options from the documentation can be supplied as a string
r = af.artifacts_and_storage.copy_item(src_repo_key, src_item_path, target_repo_key, target_item_path, options=string_of_options)
# Such as "[&dry=1][&suppressLayouts=0/1(default)][&failFast=0/1]"
Move Item¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-MoveItem
r = af.artifacts_and_storage.move_item(src_repo_key, src_item_path, target_repo_key, target_item_path)
# src_repo_key is the name of the repository in Artifactory
# src_item_path is the path to the item (repo or artifact) in the repo
# target_repo_key is the name of the target repository in Artifactory
# target_item_path is the path of the item in the target repository
# Additionnal options from the documentation can be supplied as a string
r = af.artifacts_and_storage.move_item(src_repo_key, src_item_path, target_repo_key, target_item_path, options=string_of_options)
# Such as [&dry=1][&suppressLayouts=0/1(default)][&failFast=0/1]
Artifact Sync Download¶
r = af.artifacts_and_storage.artifact_sync_download(repo_key, artifact_path)
# repo_key is the name of the repository in Artifactory
# artifact_path is the path of the artifact inside the repo
# Additionnal options from the documentation can be supplied as a string
r = af.artifacts_and_storage.artifact_sync_download(repo_key, artifact_path, options=string_of_options)
# Such as [?content=none/progress][&mark=numOfBytesToPrintANewProgressMark]
# If no content parameter is specified the file content is downloaded to the client.
File List¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-FileList
r = af.artifacts_and_storage.file_list(repo_key, folder_path)
# repo_key is the name of the repository in Artifactory
# folder_path is the path of the folder inside the repo
# To get information on the root repo, use "", as argument for folder_path
# Additionnal options from the documentation can be supplied as a string
r = af.artifacts_and_storage.file_list(repo_key, folder_path, options=string_of_options)
# Such as [&depth=n][&listFolders=0/1][&mdTimestamps=0/1][&includeRootPath=0/1]
Get Background Tasks¶
r = af.artifacts_and_storage.get_background_tasks()
Empty Trash Can¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-EmptyTrashCan
r = af.artifacts_and_storage.empty_trash_can()
Delete Item From Trash Can¶
r = af.artifacts_and_storage.delete_item_from_trash_can(path_in_trashcan)
# path_in_trashcan is the path of the item inside the trashcan, typically : repo_name/folder/file
Restore Item From Trash Can¶
r = af.artifacts_and_storage.restore_item_from_trash_can(path_in_trashcan, target_path)
# path_in_trashcan is the path of the item inside the trashcan, typically : repo_name/folder/file
# target_path is the path where the item will be restored, repo_name/folder/file
Optimize System Storage¶
r = af.artifacts_and_storage.optimize_system_storage()
REPOSITORIES¶
Get Repositories¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetRepositories
r = af.repositories.get_repositories()
# Additionnal options from the documentation can be supplied as a string
r = af.repositories.get_repositories(options=string_of_options)
# Such as [?type=repositoryType (local|remote|virtual|distribution)]
# [&packageType=maven|gradle|ivy|sbt|helm|cocoapods|opkg|rpm|nuget|cran|gems|npm|bower|debian|composer|pypi|docker|vagrant|gitlfs|go|yum|conan|chef|puppet|generic]
Repository Configuration¶
r = af.repositories.repository_configuration(repo_key)
# repo_key is the name of the repository in Artifactory
Create Repository¶
params = {}
params["key"] = "my_repo_name"
params["rclass"] = "local"
params["packageType"] = "debian"
# for remote repos : params["url"] = "http://..."
# for virtual repos : params["repositories"] = ["repo1", "repo2"]
r = af.repositories.create_repository(params)
# params is a dictionary (some fields are mandatory) of the repository settings
# https://www.jfrog.com/confluence/display/RTF/Repository+Configuration+JSON#RepositoryConfigurationJSON-application/vnd.org.jfrog.artifactory.repositories.LocalRepositoryConfiguration+json
Update Repository Configuration¶
params = {}
params["key"] = "my_repo_name"
params["description"] = "new_description"
r = af.repositories.update_repository_configuration(params)
# params is a dictionary (some fields are mandatory) of the repository settings that will be updated
Delete Repository¶
r = af.repositories.delete_repository(repo_key)
# repo_key is the name of the repository in Artifactory
Calculate YUM Repository Metadata¶
r = af.repositories.calculate_yum_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.calculate_yum_repository_metadata(repo_key, options=string_of_options)
# Such as [?path={path to repodata dir][&async=0/1]
# a GPG passphrase can be supplied
gpg_passphrase = "abc"
r = af.calculate_yum_repository_metadata(repo_key, x_gpg_passphrase=gpg_passphrase)
Calculate NuGet Repository Metadata¶
r = af.repositories.calculate_nuget_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
Calculate Npm Repository Metadata¶
r = af.repositories.calculate_npm_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
Calculate Maven Index¶
r = af.repositories.calculate_maven_index(options)
# options is a string of the possible options
# Such as [?repos=x[,y]][&force=0/1]
Calculate Maven Metadata¶
r = af.repositories.calculate_maven_metadata(repo_key, folder_path)
# repo_key is the name of the repository in Artifactory
# folder_path is the path of the folder inside the repo
# Additionnal options from the documentation can be supplied as a string
r = af.repositories.calculate_maven_metadata(repo_key, folder_path, options=string_of_options)
# Such as {nonRecursive=true | false}
Calculate Debian Repository Metadata¶
r = af.repositories.calculate_debian_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.calculate_debian_repository_metadata(repo_key, options=string_of_options)
# Such as [?async=0/1][?writeProps=0/1]
# a GPG passphrase can be supplied
gpg_passphrase = "abc"
r = af.calculate_debian_repository_metadata(repo_key, x_gpg_passphrase=gpg_passphrase)
Calculate Opkg Repository Metadata¶
r = af.repositories.calculate_opkg_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.calculate_opkg_repository_metadata(repo_key, options=string_of_options)
# Such as [?async=0/1][?writeProps=0/1]
# a GPG passphrase can be supplied
gpg_passphrase = "abc"
r = af.calculate_opkg_repository_metadata(repo_key, x_gpg_passphrase=gpg_passphrase)
Calculate Bower Index¶
r = af.repositories.calculate_bower_index(repo_key)
# repo_key is the name of the repository in Artifactory
Calculate Helm Chart Index¶
r = af.repositories.calculate_helm_chart_index(repo_key)
# repo_key is the name of the repository in Artifactory
Calculate CRAN Repository Metadata¶
r = af.repositories.calculate_cran_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.repositories.calculate_cran_repository_metadata(repo_key, options=string_of_options)
# Such as [?async=0/1]
Calculate Conda Repository Metadata¶
r = af.repositories.calculate_conda_repository_metadata(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.repositories.calculate_conda_repository_metadata(repo_key, options=string_of_options)
# Such as [?async=0/1]
SEARCHES¶
Artifactory Query Language¶
query = "aql_querry_string"
r = af.searches.artifactory_query_language(query)
# Example : query = "items.find({"repo":{"$eq":"my-repo"}})"
List Docker Repositories¶
r = af.searches.list_docker_repositories(repo_key)
# repo_key is the name of the repository in Artifactory
# Additionnal options from the documentation can be supplied as a string
r = af.searches.list_docker_repositories(repo_key, options=string_of_options)
# Such as ?n=<n from the request>&last=<last tag value from previous response>
List Docker Tags¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ListDockerTags
r = af.searches.list_docker_tags(repo_key, image_path)
# repo_key is the name of the repository/registry in Artifactory
# image_path is the path of the docker image in the repository/registry
# Additionnal options from the documentation can be supplied as a string
r = af.searches.list_docker_repositories(repo_key, image_path, options=string_of_options)
# Such as ?n=<n from the request>&last=<last tag value from previous response>
SECURITY¶
Get Users¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetUsers
r = af.security.get_users()
Get User Details¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetUserDetails
r = af.security.get_user_details(username)
# username is the name of the user in Artifactory
Get User Encrypted Password¶
r = af.security.get_user_encrypted_password()
Create or Replace User¶
params = {}
params["name"] = "my_username"
params["admin"] = "false"
params["email"] = "myuser@orange.com"
params["password"] = "password"
r = af.security.create_or_replace_user(params)
# username is the name of the user in Artifactory
# params ia a dictionary of desired fields to use to create the user and their value(s)
# https://www.jfrog.com/confluence/display/RTF4X/Security+Configuration+JSON
Update User¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateUser
params = {}
params["admin"] = "true"
r = af.security.update_user(params)
# username is the name of the user in Artifactory
# params ia a dictionary of desired fields to update and their value(s)
# https://www.jfrog.com/confluence/display/RTF4X/Security+Configuration+JSON
Delete User¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DeleteUser
r = af.security.delete_user(username)
# username is the name of the user in Artifactory.
Get Locked Out Users¶
r = af.security.get_locked_out_users()
Unlock Locked Out User¶
r = af.security.unlock_locked_out_user(username)
# username is the name of the user in Artifactory.
Unlock Locked Out Users¶
r = af.security.unlock_locked_out_users(user_list)
# user_list is a python list of the users to unlock
Unlock All Locked Out Users¶
r = af.security.unlock_all_locked_out_users()
Create API Key¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CreateAPIKey
r = af.security.create_api_key()
Regenerate API Key¶
r = af.security.regenerate_api_key()
Get API Key¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetAPIKey
r = af.security.get_api_key()
Revoke API Key¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-RevokeAPIKey
r = af.security.revoke_api_key()
Revoke User API Key¶
r = af.security.revoke_user_api_key(username)
# username is the name of the user in Artifactory
Get Groups¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetGroups
r = af.security.get_groups()
Get Group Details¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-GetGroupDetails
r = af.security.get_group_details(group_name)
# group_name is the name of the group in Artifactory.
Create or Replace Group¶
params = {}
params["group_name"] = "my_group"
r = af.security.create_or_replace_group(params)
# params is a python dictionnary which should be like :
# https://www.jfrog.com/confluence/display/RTF4X/Security+Configuration+JSON
Update Group¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateGroup
params = {}
params["group_name"] = "my_group"
params["description"] = "my_description"
r = af.security.update_group(params)
# params is a python dictionnary which should be like :
# https://www.jfrog.com/confluence/display/RTF4X/Security+Configuration+JSON
Delete Group¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DeleteGroup
r = af.security.delete_group(group_name)
# group_name is the name of the group in Artifactory.
Get Permission Targets¶
r = af.security.get_permission_targets()
Get Permission Target Details¶
r = af.security.get_permission_target_details(permission_target_name)
# permission_target_name is the name of the permission in Artifactory.
Create or Replace Permission Target¶
params = {}
params["name"] = "my_permission"
params["repositories"] = ["myrepo1", "myrepo2"]
r = af.security.create_or_replace_permission_target(params)
# https://www.jfrog.com/confluence/display/RTF4X/Security+Configuration+JSON
Delete Permission Target¶
r = af.security.delete_permission_target(permission_target_name)
# permission_target_name is the name of the permission in Artifactory.
Effective Item Permissions¶
r = af.security.effective_item_permissions(repo_key, item_path)
# repo_key is the name of the repository in Artifactory
# item_path is the path of the item inside the repo
# To get information on the root repo, use "", as argument for item_path
SYSTEM AND CONFIGURATION¶
System Info¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-SystemInfo
r = af.system_and_configuration.system_info()
System Health Ping¶
r = af.system_and_configuration.system_health_ping()
General Configuration¶
r = af.system_and_configuration.general_configuration()
Save General Configuration¶
r = af.system_and_configuration.save_general_configuration(xml_file_path)
# xml_file_path is the path on the local machine of the configuration file to be pushed
License Information¶
r = af.system_and_configuration.license_information()
Install License¶
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-InstallLicense
params = {"licenseKey": "license_string"}
r = af.system_and_configuration.install_license(params)
Version and Addons Information¶
r = af.system_and_configuration.version_and_addons_information()
Get Reverse Proxy Configuration¶
r = af.system_and_configuration.get_reverse_proxy_configuration()
Get Reverse Proxy Configuration¶
r = af.system_and_configuration.get_reverse_proxy_configuration()
Get Reverse Proxy Snippet¶
r = af.system_and_configuration.get_reverse_proxy_snippet()