Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Typed interactions with the Jfrog Artifactory REST API

Project description

Python Artifactory

Codacy Badge Build Status

python-artifactory is a Python library to access the Artifactory REST API.

This library enables you to manage Artifactory resources such as users, groups, permissions, repositories & artifacts in your applications. It requires at least Python 3.6

Table of contents

Usage

Authentication

from pyartifactory import Artifactory
art = Artifactory(url="ARTIFACTORY_URL", auth=('USERNAME','PASSORD_OR_API_KEY'))

SSL Cert Verification Options

Specify a local cert to use as client side certificate

from pyartifactory import Artifactory
art = Artifactory(url="ARTIFACTORY_URL", auth=('USERNAME','PASSORD_OR_API_KEY'), cert="/path_to_file/server.pem")

Disable host cert verification

from pyartifactory import Artifactory
art = Artifactory(url="ARTIFACTORY_URL", auth=('USERNAME','PASSORD_OR_API_KEY'), verify=False)

Admin objects

User

First, you need to create a new Artifactory object.

from pyartifactory import Artifactory
art = Artifactory(url="ARTIFACTORY_URL", auth=('USERNAME','PASSORD_OR_API_KEY'))

Get the list of users:

users = art.users.list()

Get a single user:

users = art.users.get("test_user")

Create/Update a user:

from pyartifactory.models.User import NewUser

# Create User
user = NewUser(name="test_user", password="test_password", email="user@user.com")
new_user = art.users.create(user)

# Update user
user.email = "test@test.com"
updated_user = art.users.update(user)

Delete a user:

art.users.delete("test_user")

Group

Get the list of groups:

users = art.groups.list()

Get a single group:

users = art.groups.get("group_name")

Create/Update a group:

from pyartifactory.models.Group import Group

# Create a Group
group = Group(name="test_group", description="test_group")
new_group = art.groups.create(group)

# Update user
group.description = "test_group_2"
updated_group = art.groups.update(group)

Delete a group:

art.groups.delete("test_group")

Security

A set of methods for performing operations on apiKeys, passwords ...

>>> art.security.
art.security.create_api_key(          art.security.get_encrypted_password(  art.security.revoke_api_key(
art.security.get_api_key(             art.security.regenerate_api_key(      art.security.revoke_user_api_key(

Repository

Get the list of repositories:

repositories = art.repositories.list()

Get a single repository (Local, Virtual or Remote):

local_repo = art.groups.get_local_repo("local_repo_name")
virtual_repo = art.groups.get_virtual_repo("virtual_repo_name")
remote_repo = art.groups.get_remote_repo("remote_repo_name")

Create/Update a repository:

from pyartifactory.models.Repository import LocalRepository, VirtualRepository, RemoteRepository

# Create a repository
local_repo = LocalRepository(key="test_local_repo")
new_local_repo = art.repositories.create_local_repo(local_repo)

# Update a repository
local_repo.description = "test_local_repo"
updated_local_repo = art.repositories.update_local_repo(local_repo)

# Same process for Virtual and Remote repositories

Delete a repository:

art.repositories.delete("test_local_repo")

Permission

Get the list of permissions:

permissions = art.permissions.list()

Get a single permission:

users = art.permissions.get("test_permission")

Create/Update a permission:

from pyartifactory.models.Permission import Permission

# Create a permission
permission = Permission(
    **{
        "name": "test_permission",
        "repositories": ["test_repository"],
        "principals": {
            "users": {"test_user": ["r", "w", "n", "d"]},
            "groups": {"developers": ["r"]},
        },
    }
)
perm = art.permissions.create(permission)

# Update permission
permission.repositories = ["test_repository_2"]
updated_permission = art.permissions.update(permission)

Delete a permission:

art.permissions.delete("test_permission")

Artifacts & Builds

Artifacts

TBD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyartifactory, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size PyArtifactory-1.0.2-py3-none-any.whl (11.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size PyArtifactory-1.0.2.tar.gz (10.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page