Documentation
¶
Index ¶
- Constants
- Variables
- func CheckResp(resp *http.Response, err error) (*http.Response, error)
- type Client
- func (c *Client) CreateOrganization(org *Organization) (*Organization, error)
- func (c *Client) CreateTeam(org string, t *Team) (*Team, error)
- func (c *Client) CreateTeamAccess(ta *TeamAccess) (*TeamAccess, error)
- func (c *Client) CreateVariable(organization string, workspace string, variable *Variable) (*Variable, error)
- func (c *Client) CreateWorkspace(organization string, workspace *Workspace) (*Workspace, error)
- func (c *Client) DeleteOrganization(id string) error
- func (c *Client) DeleteTeam(id string) error
- func (c *Client) DeleteTeamAccess(id string) error
- func (c *Client) DeleteVariable(id string) error
- func (c *Client) DeleteWorkspace(organization string, workspaceName string) error
- func (c *Client) GetOrganizationByID(id string) (*Organization, error)
- func (c *Client) GetTeamAccessByID(id string) (*TeamAccess, error)
- func (c *Client) GetTeamByID(id string) (*Team, error)
- func (c *Client) GetVariableByID(organization string, workspace string, id string) (*Variable, error)
- func (c *Client) GetVariableByKey(organization string, workspace string, key string) (*Variable, error)
- func (c *Client) GetWorkspaceByID(organization string, workspaceId string) (*Workspace, error)
- func (c *Client) GetWorkspaceByName(organization string, workspaceName string) (*Workspace, error)
- func (c *Client) ListLinkableRepos(oauthTokenID string) ([]*LinkableRepo, error)
- func (c *Client) ListOAuthTokens(organization string) ([]*OAuthToken, error)
- func (c *Client) ListTeams(organization string) ([]*Team, error)
- func (c *Client) ListVariables(organization string, workspace string) ([]*Variable, error)
- func (c *Client) NewRequest(verb, spath string, ro *RequestOptions) (*Request, error)
- func (c *Client) UpdateVariable(variable *Variable) (*Variable, error)
- func (c *Client) UpdateWorkspace(organization string, w *Workspace) (*Workspace, error)
- type ClientOptions
- type LinkableRepo
- type OAuthClientT
- type OAuthToken
- type Organization
- type Request
- type RequestOptions
- type Team
- type TeamAccess
- type VCSRepoT
- type Variable
- type Workspace
Constants ¶
const ( AccessRead = "read" AccessWrite = "write" AccessAdmin = "admin" )
const (
TrialVersion = "trial"
)
Variables ¶
var ErrAuth = fmt.Errorf("authentication failed")
ErrAuth is the error returned if a 401 is returned by an API request.
var ErrNotFound = fmt.Errorf("resource not found")
ErrNotFound is the error returned if a 404 is returned by an API request.
Functions ¶
Types ¶
type Client ¶
type Client struct { // URL is the API endpoint URL *url.URL // HTTPClient is the underlying http client with which to make requests. HTTPClient *retryablehttp.Client // DefaultHeaders is a set of headers that will be added to every request. // This minimally includes the atlas user-agent string. DefaultHeader http.Header }
func NewClient ¶
func NewClient(opts *ClientOptions) (*Client, error)
func (*Client) CreateOrganization ¶
func (c *Client) CreateOrganization(org *Organization) (*Organization, error)
func (*Client) CreateTeamAccess ¶
func (c *Client) CreateTeamAccess(ta *TeamAccess) (*TeamAccess, error)
func (*Client) CreateVariable ¶
func (*Client) CreateWorkspace ¶
CreateWorkspace creates a workspace.
func (*Client) DeleteOrganization ¶
func (*Client) DeleteTeam ¶
func (*Client) DeleteTeamAccess ¶
func (*Client) DeleteVariable ¶
func (*Client) DeleteWorkspace ¶
func (*Client) GetOrganizationByID ¶
func (c *Client) GetOrganizationByID(id string) (*Organization, error)
func (*Client) GetTeamAccessByID ¶
func (c *Client) GetTeamAccessByID(id string) (*TeamAccess, error)
func (*Client) GetVariableByID ¶
func (*Client) GetVariableByKey ¶
func (*Client) GetWorkspaceByID ¶
func (*Client) GetWorkspaceByName ¶
func (*Client) ListLinkableRepos ¶
func (c *Client) ListLinkableRepos(oauthTokenID string) ([]*LinkableRepo, error)
func (*Client) ListOAuthTokens ¶
func (c *Client) ListOAuthTokens(organization string) ([]*OAuthToken, error)
func (*Client) ListVariables ¶
func (*Client) NewRequest ¶
func (c *Client) NewRequest(verb, spath string, ro *RequestOptions) (*Request, error)
Request creates a new HTTP request using the given verb and sub path.
func (*Client) UpdateVariable ¶
type ClientOptions ¶
type ClientOptions struct { BaseURL string DefaultHeader http.Header NoVerifyTLS bool CAPath string CAFile string }
func DefaultClientOptions ¶
func DefaultClientOptions() *ClientOptions
func (*ClientOptions) SetToken ¶
func (c *ClientOptions) SetToken(token string)
type LinkableRepo ¶
type LinkableRepo struct { // ID is a string identifying the repo. It appears to be the // name of the repo according to the repo hosting provider, // i.e. Grab/SecretProject for github.com/Grab/SecretProject. ID string `jsonapi:"primary,authorized-repos"` }
LinkableRepo represents a linkable repository, i.e. a repository hosted on a VCS hosting system like GitHub, Bitbucket, Gitlab, etc.
type OAuthClientT ¶
type OAuthClientT struct {
ID string `jsonapi:"primary,oauth-clients"`
}
OauthClientT represents an OAuth Client. This is not directly manipulatable in the API, but it is used as part of the OAuthToken type.
type OAuthToken ¶
type OAuthToken struct { ID string `jsonapi:"primary,oauth-tokens"` CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` ServiceProviderUser string `jsonapi:"attr,service-provider-user"` HasSSHKey bool `jsonapi:"attr,has-ssh-key"` OAuthClient OAuthClientT `jsonapi:"relation,oauth-client` }
OAuthToken represents the OAuth Token associated with an OAuth Client.
type Organization ¶
type Organization struct { ID string `jsonapi:"primary,organizations"` Name string `jsonapi:"attr,name"` Email string `jsonapi:"attr,email"` EnterprisePlan string `jsonapi:"attr,enterprise-plan"` }
Organization represents an organization in Terraform Enterprise. The API to manipulate organizations is undocumented.
type RequestOptions ¶
type RequestOptions struct { // Params is a map of key-value pairs that will be added to the Request. Params map[string]string // Headers is a map of key-value pairs that will be added to the Request. Headers map[string]string // Body is a bytes.Buffer object that will be streamed or uploaded with the // Request. BodyLength is the final size of the Body. Body *bytes.Buffer BodyLength int64 }
RequestOptions is the list of options to pass to the request.
type Team ¶
type Team struct { ID string `jsonapi:"primary,teams"` Name string `jsonapi:"attr,name"` UsersCount int `jsonapi:"attr,users-count,omitempty"` }
Team is a collection of users that may be granted permissions. https://www.terraform.io/docs/enterprise/api/teams.html
type TeamAccess ¶
type TeamAccess struct { ID string `jsonapi:"primary,team-workspaces"` // Access should be "read", "write" or "admin" Access string `jsonapi:"attr,access"` Team *Team `jsonapi:"relation,team"` Workspace *Workspace `jsonapi:"relation,workspace"` }
TeamAccess represents a permission for a given Team to access a given Workspace. https://www.terraform.io/docs/enterprise/api/team-access.html
type VCSRepoT ¶
type VCSRepoT struct { // LinkableRepiID is the name of the repository this workspace // is linked to. If you're using Github or Bitbucket this is // in the format "$user/$repo". LinkableRepoID string `json:"identifier"` // OAuthTokenID is the ID of a previously registered OAuth // token for Terraform to connect to your VCS system (Github, // Bitbucket, Gitlab...). OAuthTokenID string `json:"oauth-token-id"` Branch string `json:"branch"` DefaultBranch bool `json:"default-branch"` IngressSubmodules bool `json:"ingress-submodules"` }
type Variable ¶
type Variable struct { ID string `jsonapi:"primary,vars"` Key string `jsonapi:"attr,key"` Value string `jsonapi:"attr,value"` Sensitive bool `jsonapi:"attr,sensitive"` Category string `jsonapi:"attr,category"` HCL bool `jsonapi:"attr,hcl"` Workspace *Workspace `jsonapi:"relation,configurable"` // contains filtered or unexported fields }
Variable represents a workspace variable. https://www.terraform.io/docs/enterprise/api/variables.html
func (*Variable) JSONAPIFilter ¶
This is a mild hack: because TFE's API expects the workspace and organization to be passed as a "filter" object (similar to a "meta" or "links", except it's not standard JSONAPI behavior), we use a forked version of google/jsonapi that supports these objects. To add this object, we implement the method below.
type Workspace ¶
type Workspace struct { // ID is the ID of the workspace. Generated server-side. ID string `jsonapi:"primary,workspaces"` // Name is the human-friendly name of the workspace. Name string `jsonapi:"attr,name,omitempty"` // TODO what's that Environment string `jsonapi:"attr,environment,omitempty"` // AutoApply is whether changes get applied without human // approval AutoApply bool `jsonapi:"attr,auto-apply,omitempty"` // Locked is a read-only attribute that indicates whether the // workspace is locked. Locked bool `jsonapi:"attr,locked,omitempty"` // CreatedAt is the timestamp of this workspace's creation CreatedAt time.Time `jsonapi:"attr,created-at,iso8601,omitempty"` // WorkingDirectory is the working directory within the VCS // repository used to run Terraform for this workspace. WorkingDirectory string `jsonapi:"attr,working-directory"` // TerraformVersion is the version of Terraform in use in this // workspace. TerraformVersion string `jsonapi:"attr,terraform-version,omitempty"` // CanQueueDestroyPlan indicates whether the workspace allows // creating a destroy plan. CanQueueDestroyPlan bool `jsonapi:"attr,can-queue-destroy-plan,omitempty"` // IngressTriggerAttributes is the settings struct for VCS // integration VCSRepo VCSRepoT `jsonapi:"attr,vcs-repo,omitempty"` }
Workspace represents a workspace in Terraform Enterprise. To create a Workspace with a VCS connection, use CompoundWorkspace instead. https://www.terraform.io/docs/enterprise/api/workspaces.html