Skip to main content

A small client library for the Terraform Enterprise REST API.

Project description

Pyterprise

This is a simple Python client library for Terraform Enterprise with helper functions to abstract usage of the HTTP API. The methods included in this library generally map 1 to 1 in terms of function naming conventions to terraform enterprise documentation. Methods generally will return the json response of the given endpoint.

Installation:

This module can be found and installed on pip3, although the library is compatible with python 2.7 as well.

pip3 install --user pyterprise

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.Client()

# Supply your token as a parameter and the url for the terraform enterprise server.
client.init(token=tfe_token, url='https://example-host.com')

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.

Examples:

# Get all most recent workspace statefiles to stdout.
workspaces = client.list_workspace_ids('quantcast')
for workspace in workspaces:
    print(client.get_workspace_current_statefile(workspace_id=workspace))

# Deleting and creating workspaces.
client.create_workspace(organization='test-org', workspace_name='test-workspace')
client.delete_workspace(organization='test-org', workspace_name='test-workspace')

# Set a workspace environmental variable in a given workspace id.
client.create_workspace_variable('test-workspace', key='TF_LOG', value='DEBUG')

Please consult module contents or terraform enterprise api documentation for available methods.

Contributions

Contributions are more than welcome, please feel free to do so to improve this client library. I originally created this library because, while it seemed there were good client libaries for Golang and Ruby, it seemed there were not any decent community client libraries for Python for the Terraform Enterprise API.

As of writing this I am still actively working on this library to include the remaining API methods and include unit testing for methods.

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

pyterprise-0.0.7.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file pyterprise-0.0.7.tar.gz.

File metadata

  • Download URL: pyterprise-0.0.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for pyterprise-0.0.7.tar.gz
Algorithm Hash digest
SHA256 03ae49674c954f9772676ba55f0cc3f54951500e5382e806297c831473c665e3
MD5 5d752cd4d8a734ee8d046222b9f7dfd9
BLAKE2b-256 92d654d1f8a8524fc1902ba6ae157f881757987bec0ab3f16991c4b509e67e12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page