tfeapi

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tfeapi provides common functionality useful for implementation of the Hashicorp TFE/TFC API, which uses the json:api encoding

Index

Constants

View Source
const (
	// APIPrefixV2 is the URL path prefix for TFE API endpoints
	APIPrefixV2 = "/api/v2/"
	// ModuleV1Prefix is the URL path prefix for module registry endpoints
	ModuleV1Prefix = "/v1/modules/"
)

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error)

Error writes an HTTP response with a JSON-API encoded error.

func IsTerraformCLI

func IsTerraformCLI(r *http.Request) bool

func Unmarshal

func Unmarshal(r io.Reader, v any) error

Types

type Handlers added in v0.1.15

type Handlers struct{}

func (*Handlers) AddHandlers added in v0.1.15

func (h *Handlers) AddHandlers(r *mux.Router)

type IncludeFunc

type IncludeFunc func(context.Context, any) ([]any, error)

IncludeFunc retrieves the resource for inclusion

type IncludeName

type IncludeName string

IncludeName is the name used in the query parameter to request a resource be included, i.e. /?include=<IncludeName>

const (
	IncludeOrganization IncludeName = "organization"
	IncludeWorkspace    IncludeName = "workspace"
	IncludeWorkspaces   IncludeName = "workspaces"
	IncludeCurrentRun   IncludeName = "current_run"
	IncludeConfig       IncludeName = "configuration_version"
	IncludeIngress      IncludeName = "ingress_attributes"
	IncludeUsers        IncludeName = "users"
	IncludeCreatedBy    IncludeName = "created_by"
	IncludeOutputs      IncludeName = "outputs"
)

type Responder

type Responder struct {
	// contains filtered or unexported fields
}

Responder handles responding to API requests.

func NewResponder

func NewResponder() *Responder

func (Responder) Register

func (i Responder) Register(name IncludeName, f IncludeFunc)

Register registers an IncludeFunc to be called whenever IncludeName is specified in an API query.

func (*Responder) Respond

func (res *Responder) Respond(w http.ResponseWriter, r *http.Request, payload any, status int, opts ...jsonapi.MarshalOption)

func (*Responder) RespondWithPage

func (res *Responder) RespondWithPage(w http.ResponseWriter, r *http.Request, items any, pagination *resource.Pagination)

Directories

Path Synopsis
Package types provides structs suitable for marshaling to/from json:api
Package types provides structs suitable for marshaling to/from json:api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL