forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all TODOs, add examples and update README
- Loading branch information
Sander van Harmelen
committed
Jun 28, 2018
1 parent
3a424de
commit 310afc2
Showing
28 changed files
with
424 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,117 @@ | ||
Terraform Enterprise Go Client | ||
============================== | ||
|
||
This is an API client for [Terraform Enterprise][tfe]. | ||
This is an API client for [Terraform Enterprise](https://www.hashicorp.com/products/terraform). | ||
|
||
[tfe]: https://www.hashicorp.com/products/terraform | ||
[![Build Status](https://travis-ci.org/hashicorp/go-tfe.svg?branch=master)](https://travis-ci.org/hashicorp/go-tfe) | ||
[![GitHub license](https://img.shields.io/github/license/hashicorp/go-tfe.svg)](https://github.com/hashicorp/go-tfe/blob/master/LICENSE) | ||
[![GoDoc](https://godoc.org/github.com/hashicorp/go-tfe?status.svg)](https://godoc.org/github.com/hashicorp/go-tfe) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/hashicorp/go-tfe)](https://goreportcard.com/report/github.com/hashicorp/go-tfe) | ||
[![GitHub issues](https://img.shields.io/github/issues/hashicorp/go-tfe.svg)](https://github.com/hashicorp/go-tfe/issues) | ||
|
||
## NOTE | ||
|
||
The Terraform Enterprise API endpoints are in beta and are subject to change! | ||
So that means this API client is also in beta and is also subject to change. We | ||
will indicate any breaking changes by releasing new versions. Until the release | ||
of v1.0, any minor version changes will indicate possible breaking changes. Patch | ||
version changes will be used for both bugfixes and non-breaking changes. | ||
|
||
## Coverage | ||
|
||
Currently the following endpoints are supported: | ||
|
||
- [x] [Accounts](https://www.terraform.io/docs/enterprise/api/account.html) | ||
- [x] [Configuration Versions](https://www.terraform.io/docs/enterprise/api/configuration-versions.html) | ||
- [x] [OAuth Clients](https://www.terraform.io/docs/enterprise/api/oauth-clients.html) | ||
- [x] [OAuth Tokens](https://www.terraform.io/docs/enterprise/api/oauth-tokens.html) | ||
- [x] [Organizations](https://www.terraform.io/docs/enterprise/api/organizations.html) | ||
- [x] [Organization Tokens](https://www.terraform.io/docs/enterprise/api/organization-tokens.html) | ||
- [x] [Policies](https://www.terraform.io/docs/enterprise/api/policies.html) | ||
- [x] [Policy Checks](https://www.terraform.io/docs/enterprise/api/policy-checks.html) | ||
- [ ] [Registry Modules](https://www.terraform.io/docs/enterprise/api/modules.html) | ||
- [x] [Runs](https://www.terraform.io/docs/enterprise/api/run.html) | ||
- [x] [SSH Keys](https://www.terraform.io/docs/enterprise/api/ssh-keys.html) | ||
- [x] [Team Access](https://www.terraform.io/docs/enterprise/api/team-access.html) | ||
- [x] [Team Memberships](https://www.terraform.io/docs/enterprise/api/team-members.html) | ||
- [x] [Team Tokens](https://www.terraform.io/docs/enterprise/api/team-tokens.html) | ||
- [x] [Teams](https://www.terraform.io/docs/enterprise/api/teams.html) | ||
- [x] [Variables](https://www.terraform.io/docs/enterprise/api/variables.html) | ||
- [x] [Workspaces](https://www.terraform.io/docs/enterprise/api/workspaces.html) | ||
- [ ] [Admin](https://www.terraform.io/docs/enterprise/api/admin/index.html) | ||
|
||
## Installation | ||
|
||
``` | ||
go get -u github.com/hashicorp/go-tfe | ||
``` | ||
|
||
## Usage | ||
|
||
```go | ||
import tfe "github.com/hashicorp/go-tfe" | ||
``` | ||
|
||
Construct a new TFE client, then use the various endpoints on the client to | ||
access different parts of the Terraform Enterprise API. For example, to list | ||
all organizations: | ||
|
||
```go | ||
config := &tfe.Config{ | ||
Token: "UXsybZKSz07IEw.tfev2.FajRykbzcnG9ESrhBjBMLNUSsPp69qLyzclIskE", | ||
} | ||
|
||
client, err := tfe.NewClient(config) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
orgs, err := client.Organizations.List(OrganizationListOptions{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
``` | ||
|
||
### Examples | ||
|
||
The [examples](https://github.com/hashicorp/go-tfe/tree/master/examples) directory | ||
contains a couple of examples. One of which is listed here as well: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
tfe "github.com/hashicorp/go-tfe" | ||
) | ||
|
||
func main() { | ||
config := &tfe.Config{ | ||
Token: "UXsybZKSz07IEw.tfev2.FajRykbzcnG9ESrhBjBMLNUSsPp69qLyzclIskE", | ||
} | ||
|
||
client, err := tfe.NewClient(config) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Create a new organization | ||
options := tfe.OrganizationCreateOptions{ | ||
Name: tfe.String("example"), | ||
Email: tfe.String("[email protected]"), | ||
} | ||
org, err := client.Organizations.Create(options) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Delete an organization | ||
err = client.Organizations.Delete(org.Name) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
``` | ||
|
||
For complete usage of the API client, see the full [package docs](https://godoc.org/github.com/hashicorp/go-tfe). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.