Package: conjur
conjur-api-python3This repository includes both the self-contained Conjur command-line tool (conjur) and the
Python3-based SDK for accessing the Conjur API to manage Conjur resources.Certificate levelConjur CLIThe Conjur CLI is aCertifiedlevel project. It's been reviewed by CyberArk to verify that it
will securely work with CyberArk Conjur Enterprise (previously known as DAP) as documented. In
addition, CyberArk offers Enterprise-level support for these features. For more detailed information
on our certification levels,
seeour community guidelines.Conjur Python SDKThe Conjur Python SDK is aCommunitylevel project. It's a community contributed project that **
is not reviewed or supported by CyberArk**. For more detailed information on our certification
levels,
seeour community guidelines.Using conjur-api-python3 with Conjur Open SourceAre you using this project withConjur Open Source? Then westronglyrecommend choosing the version of this project to use from the
latestConjur OSS suite release. Conjur maintainers perform additional testing on the suite release versions to ensure
compatibility. When possible, upgrade your Conjur Open Source version to match thelatest suite release. When using integrations, choose the latest suite release that matches your Conjur Open Source
version. For any questions, please contact us
onDiscourse.Supported ServicesConjur Open Source v1.2.0 or laterConjur Enterprise v11.2.1 (v5.6.3) or laterSypported PlatformsmacOS Catalina or laterWindows 10 or laterRed Hat Enterprise Linux 7, 8InstallationInstall the Conjur CLITo access the latest release of the Conjur CLI, go to
ourreleasepage. For instructions on how to set up and configure the CLI, see
ourofficial documentation.Install the SDKThe SDK can be installed via PyPI. Note that the SDK is aCommunitylevel project meaning that
the SDK is subject to alterations that may result in breaking change.To avoid unanticipated breaking changes, make sure that you stay up-to-date on our latest releases
and review the project'sCHANGELOG.md.pip3 install conjur

conjur --helpAlternatively, you can install the library from the source. Note that this will install the latest
work from the cloned source and not necessarily an official release.Clone the project and run:pip3 installUsageCLIFor more information on how to set up, configure, and start using the Conjur CLI, see
ourofficial documentation.SDKTo start using the SDK in your applications, create a Client instance and then invoke the API on it:With login ID and password#!/usr/bin/env python3fromconjurimportClientclient=Client(conjurrc_data=ConjurrcData(...),ssl_verification_mode=SslVerificationMode.TRUST_STORE,credentials_provider=FileCredentialsProvider(),debug=False)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'))Defining the Conjur server endpointA configuration file called.conjurrcis used to hold details required to communicate to the
Conjur server. You can provide these details needed to open a connection to the Conjur endpoint in
this file instead of passing them in (url,account, andca_bundle)during initialization of the Client.The.conjurrcfile should be saved to your home directory and should containconjur_url,conjur_account, andcert_file.# .conjurrc
---
cert_file: /Users/someuser/conjur-server.pem
conjur_account: someaccount
conjur_url: https://conjur-serverStoring credentialsWhen using the SDK, you can keep credentials in the system's native credential store instead of
passing them in during initialization of the Client. By default, the Client will favor saving
credentials (login ID and password) to the system's credential store. If the detected credential
store is not one we support or is not accessible, the credentials will be written to a configuration
file,.netrc, in plaintext.If written to the.netrc, it is strongly recommended that you log out when not using the Conjur
CLI. This removes the credentials from the.netrcfile.The.netrcfile or (_netrcfor Windows environments) contains credentials needed to log in to
the Conjur endpoint and should consist of 'machine', 'login', and 'password'.Note that if you choose to create this file yourself, ensure you follow least privilege, allowing
only the user who has created the file to have read/write permissions on it (chmod 700 .netrc).# .netrc / _netrc
machine https://conjur.myorg.com
login admin
password 1234....Supported Client methodsget(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 already been loaded otherwise you will get a 404 error
during invocation.load_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.update_policy_file(policy_name, policy_file)Modifies an existing Conjur policy. Data may be explicitly deleted using the!delete,!revoke,
and!denystatements. Unlike
"replace" mode, no data is ever implicitly deleted. Result is a dictionary object constructed from
the returned JSON data.list(list_constraints)Returns a list of all available resources for the current account.The 'list constraints' parameter is optional and should be provided as a dictionary.For example:client.list({'kind': 'user', 'inspect': True})List constraintsExplanationkindFilter resources by specified kind (user, host, layer, group, policy, variable, or webservice)limitLimit list of resources to specified numberoffsetSkip specified number of resourcesroleRetrieve list of resources that specified role is entitled to see (must specify role's full ID)searchSearch for resources based on specified queryinspectList the metadata for resourcesrotate_other_api_key(resource: Resource)Rotates another entity's API key and returns it as a string.Note: resource is of type Resource which should havetype(user / host) andnameattributes.rotate_personal_api_key(logged_in_user, current_password)Rotates the personal API key of the logged-in user and returns it as a string.change_personal_password(logged_in_user, current_password, new_password)Updates the current, logged-in user's password with the password parameter provided.Note: the new password must meet the Conjur password complexity constraints. It must contain at
least 12 characters: 2 uppercase, 2 lowercase, 1 digit, 1 special character.whoami()Note: This method requires Conjur v1.9+Returns a Python dictionary of information about the Client making an API request (such as its IP
address, user, account, token expiration date, etc).ContributingInstructions for how to deploy a deployment environment and run project tests can be found
inCONTRIBUTING.md.LicenseThis project islicensed under Apache License v2.0. Copyright (c) 2021 CyberArk
Software Ltd. All rights reserved.