terraformenterpriserestapi的小型客户端库。
pyterprise的Python项目详细描述
曲解
这是Terraform Enterprise的一个非常简单的Python客户机库,它带有帮助函数来抽象HTTP的使用 并以规范化的方式处理错误。 根据函数命名约定,此库中包含的方法通常将1映射到1 terraform enterprise documentation,如果您不确定这个库的用法,请查看可用的方法。
安装:
这个模块可以通过pip3安装,这个库是兼容的,可以与python2一起使用,但是对于2.7版本的pypa是不可用的。
pip3 install --user pyterprise
用法:
首先导入模块并使用init方法进行身份验证,您可以从terraform enterprise UI检索令牌
importpyterprisetfe_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')
一旦初始化,您应该能够运行各种方法来访问api,大多数方法都是基本的python实现 简单地将json响应内容作为字符串返回的http请求。
示例:
# Get all most recent workspace statefiles to stdout.workspaces=client.list_workspace_ids('awesome-organization')forworkspaceinworkspaces:print(client.get_workspace_current_statefile(workspace_id=workspace))# Create a workspace.client.create_workspace(organization='test-org',workspace_name='test-workspace')# Update Workspace: Include any params to update, exclude any to not change.update_params={"name":"test-workspace","terraform_version":"0.12.1","working-directory":"test/awesome-directory","vcs-repo":{"identifier":"github/Terraform-Testing","branch":"test","ingress-submodules":False,"oauth-token-id":"ot-XXXXXXXXX"}}client.update_workspace(organization='test-org',update_params=update_params)# Set a workspace environmental variable in a given workspace id.client.create_workspace_variable('test-workspace',key='TF_LOG',value='DEBUG')# Remove the created and modified workspace.client.delete_workspace(organization='test-org',workspace_name='test-workspace')
请参阅模块内容或terraform enterprise api documentation了解 此模块中应涵盖大多数可用方法,并且与 其余文件。
api覆盖率/助手方法
Workspaces
- [x]列出工作区
- [x]创建工作区
- [X]删除工作区
- [x]列出工作区ID
- [X]获取未确认运行的工作区
- [X]获取工作区当前状态文件
- [X]显示工作区
- [X]更新工作区
Runs
- [X]应用TerraForm Run
- [X]强制执行运行
- [X]运行TerraForm工作区(包括销毁选项)
- [X]获取工作区运行
- [X]放弃运行
- [X]取消跑步
Teams
- [X]显示用户
- [X]组建团队
- [X]创建团队
- [X]显示团队信息
- [X]删除团队
Variables
- [x]创建工作区变量
- [X]列出变量
- [X]删除工作区变量
其他
- [x]获取地形平面图
- [X]列出组织
- [X]显示组织
- [X]更新组织
- [X]摧毁组织
- [X]创建组织
贡献
非常感谢您的贡献!请随时这样做,以改善这个客户库。我创建了这个库 当时还没有一个简单的python库来执行terraform enterprise中的基本管理任务。
disclaimer:由于单元测试尚未实现,此客户端库此时被认为处于“alpha”状态。请自行承担使用风险
推荐PyPI第三方库