APIs for interacting with the Conjur v5 appliance
Project description
conjur-api-python3
Python3-based API SDK for Conjur OSS. The repo
also includes a self-contained CLI tool (conjur-cli
) that wraps the API
in a simple executable script/binary.
Status: Alpha
Warning: Naming and APIs are still subject to breaking changes!
Installing the code
From PyPI
$ pip3 install conjur-client
From source
$ pip3 install .
Note: On some machines, you have to use pip
instead of pip3
but in most cases,
you will want to use pip3
if it's available for your platform.
Usage
CLI
CLI can either be used with the included executable script:
conjur-cli --insecure -l https://myserver -a orgname -u admin -p secret \
variable get foo/bar
Or through the installed module:
python -m conjur --insecure -l https://myserver -a orgname -u admin -p secret list
API
Most usage is done by creating a Client instance and then invoking the API on it:
With login ID and password
#!/usr/bin/env python3
from conjur import Client
client = Client(url='https://conjur.myorg.com',
account='default',
login_id='admin',
password='mypassword',
ca_bundle='/path/to/my/ca/bundle')
print("Setting variable...")
client.set('conjur/my/variable', 'new value')
print("Fetching variable...")
new_value = client.get('conjur/my/variable')
print("Variable value is:", new_value.decode('utf-8'))
With login Id and API key
Write the code same as in the first example but create the client with the following arguments:
client = Client(url='https://conjur.myorg.com',
account='default',
login_id='admin',
api_key='myapikey',
ca_bundle='/path/to/my/ca/bundle')
With .netrc
and .conjurrc
settings
Write the code same as in the first example but create the client with the following arguments:
client = Client()
Currently supported client methods:
get(variable_id)
Gets a variable value based on its ID. Variable is binary data
that should be decoded to your system's encoding (e.g.
get(variable_id).decode('utf-8')
.
get_many(variable_id[,variable_id...])
Gets multiple variable values based on their IDs. Variables are returned in a dictionary that maps the variable name to its value.
set(variable_id, value)
Sets a variable to a specific value based on its ID.
Note: Policy to create the variable must have been already loaded otherwise you will get a 404 error during invocation.
apply_policy_file(policy_name, policy_file)
Applies a file-based YAML to a named policy. This method only supports additive changes. Result is a dictionary object constructed from the returned JSON data.
replace_policy_file(policy_name, policy_file)
Replaces a named policy with one from the provided file. This is usually a destructive invocation. Result is a dictionary object constructed from the returned JSON data.
list()
Returns a Python list of all the available resources for the current account.
Contributing
We store instructions for development and guidelines for how to build and test this project in the CONTRIBUTING.md - please refer to that document if you would like to contribute.
License
This project is licensed under Apache License v2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file conjur-client-0.0.3.tar.gz
.
File metadata
- Download URL: conjur-client-0.0.3.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e07b4e7344543baa2f9cad77666dd39c3fe883b260574beee73e5596b4e0a98f |
|
MD5 | 2a4f327b5d98e49f403d55e65314f0ed |
|
BLAKE2b-256 | 1771fc7fa70a9b678440fbee106f22872f07adf9aea6dc3b18537dfc42cde867 |
Provenance
File details
Details for the file conjur_client-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: conjur_client-0.0.3-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3197eefdb321d4433331f25963a20d1133e63228f0ec8be1fba8eb94832b84f |
|
MD5 | 44d45034313c5a504e59d30efc466067 |
|
BLAKE2b-256 | ff6b216ba702bf4894b646afa1ab40b50c9c812c8f426432dc422073d9986f75 |