Documentation
¶
Overview ¶
Package http provides an HTTP interface allowing HTTP clients to interact with OTF.
Index ¶
- func DecodeQuery(opts interface{}, query url.Values) error
- func MarshalPayload(w io.Writer, r *http.Request, models interface{}) error
- func NewRouter(server *Server) *negroni.Negroni
- func WithCode(code int) func(w http.ResponseWriter)
- func WriteError(w http.ResponseWriter, code int, err error)
- func WriteResponse(w http.ResponseWriter, r *http.Request, obj interface{}, ...)
- type Server
- func (s *Server) ApplyJSONAPIObject(a *otf.Apply) *tfe.Apply
- func (s *Server) ApplyRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) CancelRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) Close() error
- func (s *Server) ConfigurationVersionJSONAPIObject(cv *otf.ConfigurationVersion) *tfe.ConfigurationVersion
- func (s *Server) ConfigurationVersionListJSONAPIObject(cvl *otf.ConfigurationVersionList) *tfe.ConfigurationVersionList
- func (s *Server) CreateConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteWorkspaceByID(w http.ResponseWriter, r *http.Request)
- func (s *Server) DiscardRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) ForceCancelRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetApply(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetApplyLogs(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetPlan(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetPlanJSON(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetPlanLogs(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRunPlanJSON(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetURL(route WebRoute, param ...interface{}) string
- func (s *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetWorkspaceByID(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListConfigurationVersions(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListRuns(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)
- func (s *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) Open() (err error)
- func (s *Server) OrganizationJSONAPIObject(org *otf.Organization) *tfe.Organization
- func (s *Server) OrganizationListJSONAPIObject(cvl *otf.OrganizationList) *tfe.OrganizationList
- func (s *Server) PlanJSONAPIObject(p *otf.Plan) *tfe.Plan
- func (s *Server) Port() int
- func (s *Server) RunJSONAPIObject(r *otf.Run) *tfe.Run
- func (s *Server) RunListJSONAPIObject(cvl *otf.RunList) *tfe.RunList
- func (s *Server) StateVersionJSONAPIObject(r *otf.StateVersion) *tfe.StateVersion
- func (s *Server) StateVersionListJSONAPIObject(cvl *otf.StateVersionList) *tfe.StateVersionList
- func (s *Server) StateVersionOutputJSONAPIObject(svo *otf.StateVersionOutput) *tfe.StateVersionOutput
- func (s *Server) StateVersionOutputListJSONAPIObject(svol otf.StateVersionOutputList) []*tfe.StateVersionOutput
- func (s *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateWorkspaceByID(w http.ResponseWriter, r *http.Request)
- func (s *Server) UploadConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) UploadLogs(w http.ResponseWriter, r *http.Request)
- func (s *Server) Wait(ctx context.Context) error
- func (s *Server) WellKnown(w http.ResponseWriter, r *http.Request)
- func (s *Server) WorkspaceJSONAPIObject(ws *otf.Workspace) *tfe.Workspace
- func (s *Server) WorkspaceListJSONAPIObject(cvl *otf.WorkspaceList) *tfe.WorkspaceList
- type WebRoute
- type WellKnown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeQuery ¶
DecodeQuery unmarshals a query string (k1=v1&k2=v2...) into a struct.
func MarshalPayload ¶
MarshalPayload marshals the models object into a JSON-API response.
func WithCode ¶
func WithCode(code int) func(w http.ResponseWriter)
WithCode is a helper func for writing an HTTP status code to a response stream. For use with WriteResponse.
func WriteError ¶
func WriteError(w http.ResponseWriter, code int, err error)
WriteError writes an HTTP response with a JSON-API marshalled error obj.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, r *http.Request, obj interface{}, opts ...func(http.ResponseWriter))
WriteResponse writes an HTTP response with a JSON-API marshalled payload.
Types ¶
type Server ¶
type Server struct {
logr.Logger
SSL bool
CertFile, KeyFile string
// Listening Address in the form <ip>:<port>
Addr string
// Hostname, used within absolute URL links, defaults to localhost
Hostname string
OrganizationService otf.OrganizationService
WorkspaceService otf.WorkspaceService
StateVersionService otf.StateVersionService
ConfigurationVersionService otf.ConfigurationVersionService
RunService otf.RunService
PlanService otf.PlanService
ApplyService otf.ApplyService
// contains filtered or unexported fields
}
Server provides an HTTP/S server
func (*Server) ApplyJSONAPIObject ¶
ApplyJSONAPIObject converts a Apply to a struct that can be marshalled into a JSON-API object
func (*Server) ConfigurationVersionJSONAPIObject ¶
func (s *Server) ConfigurationVersionJSONAPIObject(cv *otf.ConfigurationVersion) *tfe.ConfigurationVersion
ConfigurationVersionJSONAPIObject converts a ConfigurationVersion to a struct that can be marshalled into a JSON-API object
func (*Server) ConfigurationVersionListJSONAPIObject ¶
func (s *Server) ConfigurationVersionListJSONAPIObject(cvl *otf.ConfigurationVersionList) *tfe.ConfigurationVersionList
ConfigurationVersionListJSONAPIObject converts a ConfigurationVersionList to a struct that can be marshalled into a JSON-API object
func (*Server) CreateConfigurationVersion ¶
func (s *Server) CreateConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) CreateOrganization ¶
func (s *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) CreateStateVersion ¶
func (s *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) CreateWorkspace ¶
func (s *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) CurrentStateVersion ¶
func (s *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteOrganization ¶
func (s *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteWorkspace ¶
func (s *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteWorkspaceByID ¶
func (s *Server) DeleteWorkspaceByID(w http.ResponseWriter, r *http.Request)
func (*Server) DiscardRun ¶
func (s *Server) DiscardRun(w http.ResponseWriter, r *http.Request)
func (*Server) DownloadStateVersion ¶
func (s *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) ForceCancelRun ¶
func (s *Server) ForceCancelRun(w http.ResponseWriter, r *http.Request)
func (*Server) GetApplyLogs ¶
func (s *Server) GetApplyLogs(w http.ResponseWriter, r *http.Request)
func (*Server) GetConfigurationVersion ¶
func (s *Server) GetConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) GetEntitlements ¶
func (s *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)
func (*Server) GetOrganization ¶
func (s *Server) GetOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) GetPlanJSON ¶
func (s *Server) GetPlanJSON(w http.ResponseWriter, r *http.Request)
func (*Server) GetPlanLogs ¶
func (s *Server) GetPlanLogs(w http.ResponseWriter, r *http.Request)
func (*Server) GetRunPlanJSON ¶
func (s *Server) GetRunPlanJSON(w http.ResponseWriter, r *http.Request)
func (*Server) GetStateVersion ¶
func (s *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) GetWorkspace ¶
func (s *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) GetWorkspaceByID ¶
func (s *Server) GetWorkspaceByID(w http.ResponseWriter, r *http.Request)
func (*Server) ListConfigurationVersions ¶
func (s *Server) ListConfigurationVersions(w http.ResponseWriter, r *http.Request)
func (*Server) ListOrganizations ¶
func (s *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)
func (*Server) ListStateVersions ¶
func (s *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)
func (*Server) ListWorkspaces ¶
func (s *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)
func (*Server) LockWorkspace ¶
func (s *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) OrganizationJSONAPIObject ¶
func (s *Server) OrganizationJSONAPIObject(org *otf.Organization) *tfe.Organization
OrganizationJSONAPIObject converts a Organization to a struct that can be marshalled into a JSON-API object
func (*Server) OrganizationListJSONAPIObject ¶
func (s *Server) OrganizationListJSONAPIObject(cvl *otf.OrganizationList) *tfe.OrganizationList
OrganizationListJSONAPIObject converts a OrganizationList to a struct that can be marshalled into a JSON-API object
func (*Server) PlanJSONAPIObject ¶
PlanJSONAPIObject converts a Plan to a struct that can be marshalled into a JSON-API object
func (*Server) Port ¶
Port returns the TCP port for the running server. This is useful in tests where we allocate a random port by using ":0".
func (*Server) RunJSONAPIObject ¶
RunJSONAPIObject converts a Run to a struct that can be marshalled into a JSON-API object
func (*Server) RunListJSONAPIObject ¶
RunListJSONAPIObject converts a RunList to a struct that can be marshalled into a JSON-API object
func (*Server) StateVersionJSONAPIObject ¶
func (s *Server) StateVersionJSONAPIObject(r *otf.StateVersion) *tfe.StateVersion
StateVersionJSONAPIObject converts a StateVersion to a struct that can be marshalled into a JSON-API object
func (*Server) StateVersionListJSONAPIObject ¶
func (s *Server) StateVersionListJSONAPIObject(cvl *otf.StateVersionList) *tfe.StateVersionList
StateVersionListJSONAPIObject converts a StateVersionList to a struct that can be marshalled into a JSON-API object
func (*Server) StateVersionOutputJSONAPIObject ¶
func (s *Server) StateVersionOutputJSONAPIObject(svo *otf.StateVersionOutput) *tfe.StateVersionOutput
StateVersionOutputJSONAPIObject converts a StateVersionOutput to a struct that can be marshalled into a JSON-API object
func (*Server) StateVersionOutputListJSONAPIObject ¶
func (s *Server) StateVersionOutputListJSONAPIObject(svol otf.StateVersionOutputList) []*tfe.StateVersionOutput
StateVersionOutputListJSONAPIObject converts a StateVersionOutputList to a struct that can be marshalled into a JSON-API object
func (*Server) UnlockWorkspace ¶
func (s *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateOrganization ¶
func (s *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateWorkspace ¶
func (s *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateWorkspaceByID ¶
func (s *Server) UpdateWorkspaceByID(w http.ResponseWriter, r *http.Request)
func (*Server) UploadConfigurationVersion ¶
func (s *Server) UploadConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) UploadLogs ¶
func (s *Server) UploadLogs(w http.ResponseWriter, r *http.Request)
func (*Server) WorkspaceJSONAPIObject ¶
WorkspaceJSONAPIObject converts a Workspace to a struct that can be marshalled into a JSON-API object
func (*Server) WorkspaceListJSONAPIObject ¶
func (s *Server) WorkspaceListJSONAPIObject(cvl *otf.WorkspaceList) *tfe.WorkspaceList
WorkspaceListJSONAPIObject converts a WorkspaceList to a struct that can be marshalled into a JSON-API object
type WebRoute ¶
type WebRoute string
const ( // ShutdownTimeout is the time given for outstanding requests to finish // before shutdown. ShutdownTimeout = 1 * time.Second UploadConfigurationVersionRoute WebRoute = "/configuration-versions/%v/upload" GetPlanLogsRoute WebRoute = "/plans/%v/logs" GetApplyLogsRoute WebRoute = "/applies/%v/logs" )