Documentation
¶
Index ¶
- Constants
- Variables
- func APIErrorFactory(resp *http.Response, pipelineErr error) error
- func NewHTTPClient(options []middleware.MiddlewareOption) (*nethttp.Client, error)
- type APIError
- type Client
- type Config
- type IPRange
- type IPRanges
- type IPRangesResponse
- type JSONAPIError
- type Meta
- type OpenAPI
- type OpenAPIResponse
- type RetryHook
- type TFERequestAdapter
- type WithLastModified
Constants ¶
const ( DefaultAddress = "https://app.terraform.io" DefaultBasePath = "/api/v2" ContentTypeJSONAPI = "application/vnd.api+json" ContentTypeJSON = "application/json" )
Variables ¶
var ( // ErrUnauthorized, ErrNotFound, ErrInternalServer, ErrForbidden, ErrBadRequest, and // ErrUnprocessableEntity are common API errors that can be used with errors.Is for // easy comparison. ErrNotFound = &APIError{StatusCode: http.StatusNotFound, Message: http.StatusText(http.StatusNotFound)} ErrInternalServer = &APIError{StatusCode: http.StatusInternalServerError, Message: http.StatusText(http.StatusInternalServerError)} ErrForbidden = &APIError{StatusCode: http.StatusForbidden, Message: http.StatusText(http.StatusForbidden)} ErrBadRequest = &APIError{StatusCode: http.StatusBadRequest, Message: http.StatusText(http.StatusBadRequest)} ErrUnprocessableEntity = &APIError{StatusCode: http.StatusUnprocessableEntity, Message: http.StatusText(http.StatusUnprocessableEntity)} ErrTooManyRequests = &APIError{StatusCode: http.StatusTooManyRequests, Message: http.StatusText(http.StatusTooManyRequests)} )
Functions ¶
func APIErrorFactory ¶
APIErrorFactory is a function that takes an HTTP response and a pipeline error, and returns an APIError. The response must have a status code of 400 or above.
func NewHTTPClient ¶
func NewHTTPClient(options []middleware.MiddlewareOption) (*nethttp.Client, error)
Types ¶
type Client ¶
Client is the Terraform Enterprise API client. It provides the basic connectivity and configuration for accessing the TFE API
func (*Client) GetStream ¶
func (c *Client) GetStream(ctx context.Context, uriOrPath string, headers http.Header) (*http.Response, error)
GetStream sends a GET request using the client's configured middleware and authentication, returning the raw *http.Response without buffering the body. The caller is responsible for closing the response body. This method is useful for API endpoints that return large responses, such as log files or streaming data.
Usually, calling an endpoint using the API interface will return a deserialized struct or buffered []byte slice. However, for endpoints that return large responses, you can choose to use GetStream to get the raw *http.Response and stream the body directly without buffering it in memory.
type Config ¶
type Config struct {
// The address of the Terraform Enterprise API.
Address string
// The base path on which the API is served.
BasePath string
// API token used to access the Terraform Enterprise API.
Token string
// Headers that will be added to every request.
Headers http.Header
// RetryHook is invoked each time a request is retried.
RetryHook RetryHook
// Retry enables automatic retries for rate limited requests.
RetryRateLimited bool
// RetryServerErrors enables the retry logic in the client.
RetryServerErrors bool
// RetryMaxRetries sets the maximum number of retries for a request before giving up.
RetryMaxRetries int
}
Config provides configuration details to the API client.
type IPRange ¶
type IPRange struct {
// List of IP ranges in CIDR notation used for connections from user site to HCP Terraform APIs
API []string `json:"api,omitempty"`
// List of IP ranges in CIDR notation used for notifications
Notifications []string `json:"notifications,omitempty"`
// List of IP ranges in CIDR notation used for outbound requests from Sentinel policies
Sentinel []string `json:"sentinel,omitempty"`
// List of IP ranges in CIDR notation used for connecting to VCS providers
VCS []string `json:"vcs,omitempty"`
}
IPRange represents a list of HCP Terraform's IP ranges
type IPRanges ¶
type IPRanges interface {
// Retrieve HCP Terraform IP ranges. If `modifiedSince` is not nil
// then it will only return the IP ranges changes since that date.
// The format for `modifiedSince` can be found here:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
Read(ctx context.Context, modifiedSince *time.Time) (*IPRangesResponse, error)
}
IP Ranges provides a list of HCP Terraform or Terraform Enterprise's IP ranges.
TFE API docs: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/ip-ranges
type IPRangesResponse ¶
type IPRangesResponse struct {
WithLastModified
IPRange *IPRange
}
type JSONAPIError ¶
type OpenAPI ¶
type OpenAPI interface {
Read(ctx context.Context, prerelease bool, modifiedSince *time.Time) (*OpenAPIResponse, error)
}
OpenAPI provides access to the OpenAPI specification for HCP Terraform or Terraform Enterprise.
type OpenAPIResponse ¶
type OpenAPIResponse struct {
WithLastModified
Bytes []byte
}
OpenAPIResponse represents the response from reading the OpenAPI specification, including the raw bytes and the last modified time.
type RetryHook ¶
type RetryHook = middleware.RetryHookCallback
RetryHook allows a function to run before each retry.
type TFERequestAdapter ¶
type TFERequestAdapter struct {
khttp.NetHttpRequestAdapter
Client *nethttp.Client
}
DefaultRequestAdapter is the core service used by GraphServiceClient to make requests to Microsoft Graph.
func NewRequestAdapter ¶
func NewRequestAdapter(baseURL string, options []middleware.MiddlewareOption, authenticationProvider absauth.AuthenticationProvider) (*TFERequestAdapter, error)
NewRequestAdapter creates a new TFERequestAdapter with the given parameters
type WithLastModified ¶
WithLastModified represents a response that contains a last modified time.
func (*WithLastModified) IsNotModified ¶
func (o *WithLastModified) IsNotModified() bool
IsNotModified returns true if the response does not contain data or a last modified time.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package middleware contains the custom middleware used by the go-tfe SDK, as well as options for configuring the default middlewares.
|
Package middleware contains the custom middleware used by the go-tfe SDK, as well as options for configuring the default middlewares. |