Documentation
¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT.
Index ¶
- Constants
- Variables
- func Handler(si ServerInterface) http.Handler
- func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
- func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
- func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
- type API
- func (a *API) GetEnvs(w http.ResponseWriter, _ *http.Request)
- func (a *API) GetFiles(w http.ResponseWriter, r *http.Request, params GetFilesParams)
- func (a *API) GetHealth(w http.ResponseWriter, r *http.Request)
- func (a *API) GetMetrics(w http.ResponseWriter, r *http.Request)
- func (a *API) PostFiles(w http.ResponseWriter, r *http.Request, params PostFilesParams)
- func (a *API) PostInit(w http.ResponseWriter, r *http.Request)
- func (a *API) SetData(ctx context.Context, logger zerolog.Logger, data PostInitJSONBody) error
- func (a *API) SetupHyperloop(address string)
- func (a *API) WithAuthorization(handler http.Handler) http.Handler
- type ChiServerOptions
- type DefaultMMDSClient
- type EntryInfo
- type EntryInfoType
- type EnvVars
- type Error
- type FileNotFound
- type FilePath
- type GetFilesParams
- type InternalServerError
- type InvalidParamFormatError
- type InvalidPath
- type InvalidUser
- type MMDSClient
- type Metrics
- type MiddlewareFunc
- type NotEnoughDiskSpace
- type PostFilesMultipartBody
- type PostFilesMultipartRequestBody
- type PostFilesParams
- type PostInitJSONBody
- type PostInitJSONRequestBody
- type RequiredHeaderError
- type RequiredParamError
- type SecureToken
- func (s *SecureToken) Bytes() ([]byte, error)
- func (s *SecureToken) Destroy()
- func (s *SecureToken) Equals(token string) bool
- func (s *SecureToken) EqualsSecure(other *SecureToken) bool
- func (s *SecureToken) IsSet() bool
- func (s *SecureToken) Set(token []byte) error
- func (s *SecureToken) TakeFrom(src *SecureToken)
- func (s *SecureToken) UnmarshalJSON(data []byte) error
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) GetEnvs(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetFiles(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetHealth(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetMetrics(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostFiles(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostInit(w http.ResponseWriter, r *http.Request)
- type Signature
- type SignatureExpiration
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type Unimplemented
- func (_ Unimplemented) GetEnvs(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetFiles(w http.ResponseWriter, r *http.Request, params GetFilesParams)
- func (_ Unimplemented) GetHealth(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetMetrics(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostFiles(w http.ResponseWriter, r *http.Request, params PostFilesParams)
- func (_ Unimplemented) PostInit(w http.ResponseWriter, r *http.Request)
- type UnmarshalingParamError
- type UploadSuccess
- type User
- type VolumeMount
Constants ¶
const ( SigningReadOperation = "read" SigningWriteOperation = "write" )
const ( // EncodingGzip is the gzip content encoding. EncodingGzip = "gzip" // EncodingIdentity means no encoding (passthrough). EncodingIdentity = "identity" // EncodingWildcard means any encoding is acceptable. EncodingWildcard = "*" )
const (
AccessTokenAuthScopes = "AccessTokenAuth.Scopes"
)
Variables ¶
var ( ErrAccessTokenMismatch = errors.New("access token validation failed") ErrAccessTokenResetNotAuthorized = errors.New("access token reset not authorized") )
var ( ErrInvalidAddress = errors.New("invalid IP address") ErrUnknownAddressFormat = errors.New("unknown IP address format") )
var ( ErrTokenNotSet = errors.New("access token not set") ErrTokenEmpty = errors.New("empty token not allowed") )
var ErrNoDiskSpace = fmt.Errorf("not enough disk space available")
var SupportedEncodings = []string{ EncodingGzip, }
SupportedEncodings lists the content encodings supported for file transfer. The order matters - encodings are checked in order of preference.
Functions ¶
func Handler ¶
func Handler(si ServerInterface) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func HandlerFromMux ¶
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerWithOptions ¶
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
HandlerWithOptions creates http.Handler with additional options
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) GetFiles ¶
func (a *API) GetFiles(w http.ResponseWriter, r *http.Request, params GetFilesParams)
func (*API) GetMetrics ¶
func (a *API) GetMetrics(w http.ResponseWriter, r *http.Request)
func (*API) PostFiles ¶
func (a *API) PostFiles(w http.ResponseWriter, r *http.Request, params PostFilesParams)
func (*API) SetupHyperloop ¶
type ChiServerOptions ¶
type ChiServerOptions struct {
BaseURL string
BaseRouter chi.Router
Middlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
type DefaultMMDSClient ¶
type DefaultMMDSClient struct{}
DefaultMMDSClient is the production implementation that calls the real MMDS endpoint.
func (*DefaultMMDSClient) GetAccessTokenHash ¶
func (c *DefaultMMDSClient) GetAccessTokenHash(ctx context.Context) (string, error)
type EntryInfo ¶
type EntryInfo struct {
// Name Name of the file
Name string `json:"name"`
// Path Path to the file
Path string `json:"path"`
// Type Type of the file
Type EntryInfoType `json:"type"`
}
EntryInfo defines model for EntryInfo.
type EntryInfoType ¶
type EntryInfoType string
EntryInfoType Type of the file
const (
File EntryInfoType = "file"
)
Defines values for EntryInfoType.
type Error ¶
type Error struct {
// Code Error code
Code int `json:"code"`
// Message Error message
Message string `json:"message"`
}
Error defines model for Error.
type GetFilesParams ¶
type GetFilesParams struct {
// Path Path to the file, URL encoded. Can be relative to user's home directory.
Path *FilePath `form:"path,omitempty" json:"path,omitempty"`
// Username User used for setting the owner, or resolving relative paths.
Username *User `form:"username,omitempty" json:"username,omitempty"`
// Signature Signature used for file access permission verification.
Signature *Signature `form:"signature,omitempty" json:"signature,omitempty"`
// SignatureExpiration Signature expiration used for defining the expiration time of the signature.
SignatureExpiration *SignatureExpiration `form:"signature_expiration,omitempty" json:"signature_expiration,omitempty"`
}
GetFilesParams defines parameters for GetFiles.
type InternalServerError ¶
type InternalServerError = Error
InternalServerError defines model for InternalServerError.
type InvalidParamFormatError ¶
func (*InvalidParamFormatError) Error ¶
func (e *InvalidParamFormatError) Error() string
func (*InvalidParamFormatError) Unwrap ¶
func (e *InvalidParamFormatError) Unwrap() error
type MMDSClient ¶
MMDSClient provides access to MMDS metadata.
type Metrics ¶
type Metrics struct {
// CpuCount Number of CPU cores
CpuCount *int `json:"cpu_count,omitempty"`
// CpuUsedPct CPU usage percentage
CpuUsedPct *float32 `json:"cpu_used_pct,omitempty"`
// DiskTotal Total disk space in bytes
DiskTotal *int `json:"disk_total,omitempty"`
// DiskUsed Used disk space in bytes
DiskUsed *int `json:"disk_used,omitempty"`
// MemTotal Total virtual memory in bytes
MemTotal *int `json:"mem_total,omitempty"`
// MemUsed Used virtual memory in bytes
MemUsed *int `json:"mem_used,omitempty"`
// Ts Unix timestamp in UTC for current sandbox time
Ts *int64 `json:"ts,omitempty"`
}
Metrics Resource usage metrics
type NotEnoughDiskSpace ¶
type NotEnoughDiskSpace = Error
NotEnoughDiskSpace defines model for NotEnoughDiskSpace.
type PostFilesMultipartBody ¶
type PostFilesMultipartBody struct {
File *openapi_types.File `json:"file,omitempty"`
}
PostFilesMultipartBody defines parameters for PostFiles.
type PostFilesMultipartRequestBody ¶
type PostFilesMultipartRequestBody PostFilesMultipartBody
PostFilesMultipartRequestBody defines body for PostFiles for multipart/form-data ContentType.
type PostFilesParams ¶
type PostFilesParams struct {
// Path Path to the file, URL encoded. Can be relative to user's home directory.
Path *FilePath `form:"path,omitempty" json:"path,omitempty"`
// Username User used for setting the owner, or resolving relative paths.
Username *User `form:"username,omitempty" json:"username,omitempty"`
// Signature Signature used for file access permission verification.
Signature *Signature `form:"signature,omitempty" json:"signature,omitempty"`
// SignatureExpiration Signature expiration used for defining the expiration time of the signature.
SignatureExpiration *SignatureExpiration `form:"signature_expiration,omitempty" json:"signature_expiration,omitempty"`
}
PostFilesParams defines parameters for PostFiles.
type PostInitJSONBody ¶
type PostInitJSONBody struct {
// AccessToken Access token for secure access to envd service
AccessToken *SecureToken `json:"accessToken,omitempty"`
// DefaultUser The default user to use for operations
DefaultUser *string `json:"defaultUser,omitempty"`
// DefaultWorkdir The default working directory to use for operations
DefaultWorkdir *string `json:"defaultWorkdir,omitempty"`
// EnvVars Environment variables to set
EnvVars *EnvVars `json:"envVars,omitempty"`
// HyperloopIP IP address of the hyperloop server to connect to
HyperloopIP *string `json:"hyperloopIP,omitempty"`
// Timestamp The current timestamp in RFC3339 format
Timestamp *time.Time `json:"timestamp,omitempty"`
VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"`
}
PostInitJSONBody defines parameters for PostInit.
type PostInitJSONRequestBody ¶
type PostInitJSONRequestBody PostInitJSONBody
PostInitJSONRequestBody defines body for PostInit for application/json ContentType.
type RequiredHeaderError ¶
func (*RequiredHeaderError) Error ¶
func (e *RequiredHeaderError) Error() string
func (*RequiredHeaderError) Unwrap ¶
func (e *RequiredHeaderError) Unwrap() error
type RequiredParamError ¶
type RequiredParamError struct {
ParamName string
}
func (*RequiredParamError) Error ¶
func (e *RequiredParamError) Error() string
type SecureToken ¶
type SecureToken struct {
// contains filtered or unexported fields
}
SecureToken wraps memguard for secure token storage. It uses LockedBuffer which provides memory locking, guard pages, and secure zeroing on destroy.
func (*SecureToken) Bytes ¶
func (s *SecureToken) Bytes() ([]byte, error)
Bytes returns a copy of the token bytes (for signature generation). The caller should zero the returned slice after use. Returns ErrTokenNotSet if the receiver is nil.
func (*SecureToken) Destroy ¶
func (s *SecureToken) Destroy()
Destroy securely wipes the token from memory. No-op if the receiver is nil.
func (*SecureToken) Equals ¶
func (s *SecureToken) Equals(token string) bool
Equals checks if token matches using constant-time comparison. Returns false if the receiver is nil.
func (*SecureToken) EqualsSecure ¶
func (s *SecureToken) EqualsSecure(other *SecureToken) bool
EqualsSecure compares this token with another SecureToken using constant-time comparison. Returns false if either receiver or other is nil.
func (*SecureToken) IsSet ¶
func (s *SecureToken) IsSet() bool
IsSet returns true if a token is stored. Returns false if the receiver is nil.
func (*SecureToken) Set ¶
func (s *SecureToken) Set(token []byte) error
Set securely replaces the token, destroying the old one first. The old token memory is zeroed before the new token is stored. The input byte slice is wiped after copying to secure memory. Returns ErrTokenEmpty if token is empty - use Destroy() to clear the token instead.
func (*SecureToken) TakeFrom ¶
func (s *SecureToken) TakeFrom(src *SecureToken)
TakeFrom transfers the token from src to this SecureToken, destroying any existing token. The source token is cleared after transfer. This avoids copying the underlying bytes.
func (*SecureToken) UnmarshalJSON ¶
func (s *SecureToken) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler to securely parse a JSON string directly into memguard, wiping the input bytes after copying.
Access tokens are hex-encoded HMAC-SHA256 hashes (64 chars of [0-9a-f]), so they never contain JSON escape sequences.
type ServerInterface ¶
type ServerInterface interface {
// Get the environment variables
// (GET /envs)
GetEnvs(w http.ResponseWriter, r *http.Request)
// Download a file
// (GET /files)
GetFiles(w http.ResponseWriter, r *http.Request, params GetFilesParams)
// Upload a file and ensure the parent directories exist. If the file exists, it will be overwritten.
// (POST /files)
PostFiles(w http.ResponseWriter, r *http.Request, params PostFilesParams)
// Check the health of the service
// (GET /health)
GetHealth(w http.ResponseWriter, r *http.Request)
// Set initial vars, ensure the time and metadata is synced with the host
// (POST /init)
PostInit(w http.ResponseWriter, r *http.Request)
// Get the stats of the service
// (GET /metrics)
GetMetrics(w http.ResponseWriter, r *http.Request)
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) GetEnvs ¶
func (siw *ServerInterfaceWrapper) GetEnvs(w http.ResponseWriter, r *http.Request)
GetEnvs operation middleware
func (*ServerInterfaceWrapper) GetFiles ¶
func (siw *ServerInterfaceWrapper) GetFiles(w http.ResponseWriter, r *http.Request)
GetFiles operation middleware
func (*ServerInterfaceWrapper) GetHealth ¶
func (siw *ServerInterfaceWrapper) GetHealth(w http.ResponseWriter, r *http.Request)
GetHealth operation middleware
func (*ServerInterfaceWrapper) GetMetrics ¶
func (siw *ServerInterfaceWrapper) GetMetrics(w http.ResponseWriter, r *http.Request)
GetMetrics operation middleware
func (*ServerInterfaceWrapper) PostFiles ¶
func (siw *ServerInterfaceWrapper) PostFiles(w http.ResponseWriter, r *http.Request)
PostFiles operation middleware
func (*ServerInterfaceWrapper) PostInit ¶
func (siw *ServerInterfaceWrapper) PostInit(w http.ResponseWriter, r *http.Request)
PostInit operation middleware
type SignatureExpiration ¶
type SignatureExpiration = int
SignatureExpiration defines model for SignatureExpiration.
type TooManyValuesForParamError ¶
func (*TooManyValuesForParamError) Error ¶
func (e *TooManyValuesForParamError) Error() string
type UnescapedCookieParamError ¶
func (*UnescapedCookieParamError) Error ¶
func (e *UnescapedCookieParamError) Error() string
func (*UnescapedCookieParamError) Unwrap ¶
func (e *UnescapedCookieParamError) Unwrap() error
type Unimplemented ¶
type Unimplemented struct{}
func (Unimplemented) GetEnvs ¶
func (_ Unimplemented) GetEnvs(w http.ResponseWriter, r *http.Request)
Get the environment variables (GET /envs)
func (Unimplemented) GetFiles ¶
func (_ Unimplemented) GetFiles(w http.ResponseWriter, r *http.Request, params GetFilesParams)
Download a file (GET /files)
func (Unimplemented) GetHealth ¶
func (_ Unimplemented) GetHealth(w http.ResponseWriter, r *http.Request)
Check the health of the service (GET /health)
func (Unimplemented) GetMetrics ¶
func (_ Unimplemented) GetMetrics(w http.ResponseWriter, r *http.Request)
Get the stats of the service (GET /metrics)
func (Unimplemented) PostFiles ¶
func (_ Unimplemented) PostFiles(w http.ResponseWriter, r *http.Request, params PostFilesParams)
Upload a file and ensure the parent directories exist. If the file exists, it will be overwritten. (POST /files)
func (Unimplemented) PostInit ¶
func (_ Unimplemented) PostInit(w http.ResponseWriter, r *http.Request)
Set initial vars, ensure the time and metadata is synced with the host (POST /init)
type UnmarshalingParamError ¶
func (*UnmarshalingParamError) Error ¶
func (e *UnmarshalingParamError) Error() string
func (*UnmarshalingParamError) Unwrap ¶
func (e *UnmarshalingParamError) Unwrap() error
type UploadSuccess ¶
type UploadSuccess = []EntryInfo
UploadSuccess defines model for UploadSuccess.
type VolumeMount ¶
VolumeMount Volume