tfeapi

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MPL-2.0 Imports: 11 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

This section is empty.

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 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"
	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