A small client library for the Terraform Enterprise REST API.
Project description
Pyterprise
This is a small Python client library for Terraform Enterprise with helper functions to abstract usage of the HTTP API - this is a work in progress and likely not all functionality of the API has (or will) be ported over - but most common uses will attempted to be covered here.
The methods used are straightforward and relatively self documenting so I won't have too much uses covered here.
Usage:
First import the module and authenticate using the init method, you can retrieve a token from the terraform enterprise UI.
import pyterprise
tfe_token = 'TOKENHERE'
client = pyterprise.TerraformAPI()
# Supply your token as a parameter and the url for the terraform enterprise server.
client.init(token=tfe_token, url='Endpoint for TFE')
Once initialized, you should be able to run various methods for accessing the API, most of the methods are basic python implementations of http requests that will simply return the json response content as a string. Here is some example usage that you can combine with the authentication example below:
# returns a list of all workspace IDs for a given organization
client.list_workspace_ids(organization='<org-name>')
# returns the most current statefile of a given workspace
client.get_workspace_current_statefile(workspace_id='example')
# run the terraform in a given workspace
client.run_terraform_workspace(workspace_id='<workspace id>', message='test of api client')
# get terraform plan information for a given workspace
client.get_terraform_plan(plan_id='test_id')
Please read the main code here for more methods to use for the API.
Project details
Release history Release notifications | RSS feed
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
Hashes for pyterprise-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e06dd85c92731f73f59bbd22345a2351801c8e67468d9a776ab6847c6c4c934e |
|
MD5 | 5c0bfbcc09fa19d22a4b24d60b98194c |
|
BLAKE2b-256 | edb302d621fc389e4fd884e48655ed7165273e90c0d11aed173841fb373120fe |