Documentation
¶
Index ¶
- Variables
- func AssertErrorConstraints(obj Error) error
- func AssertErrorRequired(obj Error) error
- func AssertGetTaskV1ResponseConstraints(obj GetTaskV1Response) error
- func AssertGetTaskV1ResponseRequired(obj GetTaskV1Response) error
- func AssertGetWorkV1ResponseConstraints(obj GetWorkV1Response) error
- func AssertGetWorkV1ResponseRequired(obj GetWorkV1Response) error
- func AssertGetWorkV1TaskConstraints(obj GetWorkV1Task) error
- func AssertGetWorkV1TaskRequired(obj GetWorkV1Task) error
- func AssertListTasksV1ResponseConstraints(obj ListTasksV1Response) error
- func AssertListTasksV1ResponseRequired(obj ListTasksV1Response) error
- func AssertRecurseInterfaceRequired[T any](obj interface{}, callback func(T) error) error
- func AssertRecurseValueRequired[T any](value reflect.Value, callback func(T) error) error
- func AssertReportWorkV1RequestConstraints(obj ReportWorkV1Request) error
- func AssertReportWorkV1RequestRequired(obj ReportWorkV1Request) error
- func AssertReportWorkV1ResponseConstraints(obj ReportWorkV1Response) error
- func AssertReportWorkV1ResponseRequired(obj ReportWorkV1Response) error
- func AssertReportWorkV1TaskResultConstraints(obj ReportWorkV1TaskResult) error
- func AssertReportWorkV1TaskResultRequired(obj ReportWorkV1TaskResult) error
- func AssertScheduleRunV1RequestConstraints(obj ScheduleRunV1Request) error
- func AssertScheduleRunV1RequestRequired(obj ScheduleRunV1Request) error
- func AssertScheduleRunV1ResponseConstraints(obj ScheduleRunV1Response) error
- func AssertScheduleRunV1ResponseRequired(obj ScheduleRunV1Response) error
- func DefaultErrorHandler(w http.ResponseWriter, _ *http.Request, err error, result *ImplResponse)
- func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
- func IsZeroValue(val interface{}) bool
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(routers ...Router) chi.Router
- func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)
- func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)
- type Constraint
- type Error
- type ErrorHandler
- type GetTaskV1Response
- type GetWorkV1Response
- type GetWorkV1Task
- type ImplResponse
- type ListTasksV1Response
- type Number
- type Operation
- type ParseString
- type ParsingError
- type ReportWorkV1Request
- type ReportWorkV1Response
- type ReportWorkV1TaskResult
- type RequiredError
- type Route
- type Router
- type Routes
- type ScheduleRunV1Request
- type ScheduleRunV1Response
- type TaskAPIController
- type TaskAPIOption
- type TaskAPIRouter
- type TaskAPIServicer
- type WorkerAPIController
- type WorkerAPIOption
- type WorkerAPIRouter
- type WorkerAPIServicer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTypeAssertionError is thrown when type an interface does not match the asserted type ErrTypeAssertionError = errors.New("unable to assert type") )
Functions ¶
func AssertErrorConstraints ¶
AssertErrorConstraints checks if the values respects the defined constraints
func AssertErrorRequired ¶
AssertErrorRequired checks if the required fields are not zero-ed
func AssertGetTaskV1ResponseConstraints ¶
func AssertGetTaskV1ResponseConstraints(obj GetTaskV1Response) error
AssertGetTaskV1ResponseConstraints checks if the values respects the defined constraints
func AssertGetTaskV1ResponseRequired ¶
func AssertGetTaskV1ResponseRequired(obj GetTaskV1Response) error
AssertGetTaskV1ResponseRequired checks if the required fields are not zero-ed
func AssertGetWorkV1ResponseConstraints ¶
func AssertGetWorkV1ResponseConstraints(obj GetWorkV1Response) error
AssertGetWorkV1ResponseConstraints checks if the values respects the defined constraints
func AssertGetWorkV1ResponseRequired ¶
func AssertGetWorkV1ResponseRequired(obj GetWorkV1Response) error
AssertGetWorkV1ResponseRequired checks if the required fields are not zero-ed
func AssertGetWorkV1TaskConstraints ¶
func AssertGetWorkV1TaskConstraints(obj GetWorkV1Task) error
AssertGetWorkV1TaskConstraints checks if the values respects the defined constraints
func AssertGetWorkV1TaskRequired ¶
func AssertGetWorkV1TaskRequired(obj GetWorkV1Task) error
AssertGetWorkV1TaskRequired checks if the required fields are not zero-ed
func AssertListTasksV1ResponseConstraints ¶
func AssertListTasksV1ResponseConstraints(obj ListTasksV1Response) error
AssertListTasksV1ResponseConstraints checks if the values respects the defined constraints
func AssertListTasksV1ResponseRequired ¶
func AssertListTasksV1ResponseRequired(obj ListTasksV1Response) error
AssertListTasksV1ResponseRequired checks if the required fields are not zero-ed
func AssertRecurseInterfaceRequired ¶
AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired ¶
AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion. ErrTypeAssertionError is thrown if the underlying struct does not match type T.
func AssertReportWorkV1RequestConstraints ¶
func AssertReportWorkV1RequestConstraints(obj ReportWorkV1Request) error
AssertReportWorkV1RequestConstraints checks if the values respects the defined constraints
func AssertReportWorkV1RequestRequired ¶
func AssertReportWorkV1RequestRequired(obj ReportWorkV1Request) error
AssertReportWorkV1RequestRequired checks if the required fields are not zero-ed
func AssertReportWorkV1ResponseConstraints ¶
func AssertReportWorkV1ResponseConstraints(obj ReportWorkV1Response) error
AssertReportWorkV1ResponseConstraints checks if the values respects the defined constraints
func AssertReportWorkV1ResponseRequired ¶
func AssertReportWorkV1ResponseRequired(obj ReportWorkV1Response) error
AssertReportWorkV1ResponseRequired checks if the required fields are not zero-ed
func AssertReportWorkV1TaskResultConstraints ¶
func AssertReportWorkV1TaskResultConstraints(obj ReportWorkV1TaskResult) error
AssertReportWorkV1TaskResultConstraints checks if the values respects the defined constraints
func AssertReportWorkV1TaskResultRequired ¶
func AssertReportWorkV1TaskResultRequired(obj ReportWorkV1TaskResult) error
AssertReportWorkV1TaskResultRequired checks if the required fields are not zero-ed
func AssertScheduleRunV1RequestConstraints ¶
func AssertScheduleRunV1RequestConstraints(obj ScheduleRunV1Request) error
AssertScheduleRunV1RequestConstraints checks if the values respects the defined constraints
func AssertScheduleRunV1RequestRequired ¶
func AssertScheduleRunV1RequestRequired(obj ScheduleRunV1Request) error
AssertScheduleRunV1RequestRequired checks if the required fields are not zero-ed
func AssertScheduleRunV1ResponseConstraints ¶
func AssertScheduleRunV1ResponseConstraints(obj ScheduleRunV1Response) error
AssertScheduleRunV1ResponseConstraints checks if the values respects the defined constraints
func AssertScheduleRunV1ResponseRequired ¶
func AssertScheduleRunV1ResponseRequired(obj ScheduleRunV1Response) error
AssertScheduleRunV1ResponseRequired checks if the required fields are not zero-ed
func DefaultErrorHandler ¶
func DefaultErrorHandler(w http.ResponseWriter, _ *http.Request, err error, result *ImplResponse)
DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing request params will return a StatusBadRequest. Otherwise, the error code originating from the servicer will be used.
func EncodeJSONResponse ¶
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
func IsZeroValue ¶
func IsZeroValue(val interface{}) bool
IsZeroValue checks if the val is the zero-ed value.
func NewRouter ¶
func NewRouter(routers ...Router) chi.Router
NewRouter creates a new router for any number of api routers
func ReadFormFileToTempFile ¶
ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
Types ¶
type Constraint ¶
func WithMaximum ¶
func WithMaximum[T Number](expected T) Constraint[T]
func WithMinimum ¶
func WithMinimum[T Number](expected T) Constraint[T]
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if you would like errors to be handled differently from the DefaultErrorHandler
type GetTaskV1Response ¶
type GetWorkV1Response ¶
type GetWorkV1Response struct { // Internal identifier of the unit of work. RunID int32 `json:"runID"` // Repository for which to apply the tasks. Repository string `json:"repository,omitempty"` // Names of the tasks to execute. Tasks []GetWorkV1Task `json:"tasks"` }
type GetWorkV1Task ¶
type ImplResponse ¶
type ImplResponse struct { Code int Body interface{} }
ImplResponse defines an implementation response with error code and the associated body
func Response ¶
func Response(code int, body interface{}) ImplResponse
Response return a ImplResponse struct filled
type ListTasksV1Response ¶
type ListTasksV1Response struct { // Names of registered tasks. Tasks []string `json:"tasks"` }
type Operation ¶
func WithDefaultOrParse ¶
func WithDefaultOrParse[T Number | string | bool](def T, parse ParseString[T]) Operation[T]
func WithRequire ¶
func WithRequire[T Number | string | bool](parse ParseString[T]) Operation[T]
type ParsingError ¶
ParsingError indicates that an error has occurred when parsing request parameters
func (*ParsingError) Error ¶
func (e *ParsingError) Error() string
func (*ParsingError) Unwrap ¶
func (e *ParsingError) Unwrap() error
type ReportWorkV1Request ¶
type ReportWorkV1Request struct { // General that occurred during the run, if any. Error string `json:"error,omitempty"` // Internal identifier of the unit of work. RunID int32 `json:"runID"` // Results of each task. TaskResults []ReportWorkV1TaskResult `json:"taskResults,omitempty"` }
type ReportWorkV1Response ¶
type ReportWorkV1Response struct { // Indicator of the result of the operation. Result string `json:"result"` }
type ReportWorkV1TaskResult ¶
type ReportWorkV1TaskResult struct { // Error encountered during the run, if any. Error string `json:"error,omitempty"` // Name of the repository. RepositoryName string `json:"repositoryName"` // Identifier of the result. Result int32 `json:"result,omitempty"` // Name of the task. TaskName string `json:"taskName"` }
ReportWorkV1TaskResult - Result of the run of a task.
type RequiredError ¶
type RequiredError struct {
Field string
}
RequiredError indicates that an error has occurred when parsing request parameters
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
type Route ¶
type Route struct { Method string Pattern string HandlerFunc http.HandlerFunc }
A Route defines the parameters for an api endpoint
type Router ¶
type Router interface {
Routes() Routes
}
Router defines the required methods for retrieving api routes
type ScheduleRunV1Request ¶
type ScheduleRunV1Request struct { // Name of the repository for which to add a run. If empty, the run uses the filters of the task. RepositoryName string `json:"repositoryName,omitempty"` // Schedule the run after the given time. If empty, then the current time is used. ScheduleAfter time.Time `json:"scheduleAfter,omitempty"` // Name of the task for which to add a run. TaskName string `json:"taskName"` RunData map[string]string `json:"runData,omitempty"` }
type ScheduleRunV1Response ¶
type ScheduleRunV1Response struct { // Identifier of the newly scheduled run. RunID int32 `json:"runID"` }
type TaskAPIController ¶
type TaskAPIController struct {
// contains filtered or unexported fields
}
TaskAPIController binds http requests to an api service and writes the service results to the http response
func NewTaskAPIController ¶
func NewTaskAPIController(s TaskAPIServicer, opts ...TaskAPIOption) *TaskAPIController
NewTaskAPIController creates a default api controller
func (*TaskAPIController) GetTaskV1 ¶
func (c *TaskAPIController) GetTaskV1(w http.ResponseWriter, r *http.Request)
GetTaskV1 - Get information about a task.
func (*TaskAPIController) ListTasksV1 ¶
func (c *TaskAPIController) ListTasksV1(w http.ResponseWriter, r *http.Request)
ListTasksV1 - List tasks.
func (*TaskAPIController) Routes ¶
func (c *TaskAPIController) Routes() Routes
Routes returns all the api routes for the TaskAPIController
type TaskAPIOption ¶
type TaskAPIOption func(*TaskAPIController)
TaskAPIOption for how the controller is set up.
func WithTaskAPIErrorHandler ¶
func WithTaskAPIErrorHandler(h ErrorHandler) TaskAPIOption
WithTaskAPIErrorHandler inject ErrorHandler into controller
type TaskAPIRouter ¶
type TaskAPIRouter interface { GetTaskV1(http.ResponseWriter, *http.Request) ListTasksV1(http.ResponseWriter, *http.Request) }
TaskAPIRouter defines the required methods for binding the api requests to a responses for the TaskAPI The TaskAPIRouter implementation should parse necessary information from the http request, pass the data to a TaskAPIServicer to perform the required actions, then write the service results to the http response.
type TaskAPIServicer ¶
type TaskAPIServicer interface { GetTaskV1(context.Context, string) (ImplResponse, error) ListTasksV1(context.Context) (ImplResponse, error) }
TaskAPIServicer defines the api actions for the TaskAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
type WorkerAPIController ¶
type WorkerAPIController struct {
// contains filtered or unexported fields
}
WorkerAPIController binds http requests to an api service and writes the service results to the http response
func NewWorkerAPIController ¶
func NewWorkerAPIController(s WorkerAPIServicer, opts ...WorkerAPIOption) *WorkerAPIController
NewWorkerAPIController creates a default api controller
func (*WorkerAPIController) GetWorkV1 ¶
func (c *WorkerAPIController) GetWorkV1(w http.ResponseWriter, r *http.Request)
GetWorkV1 - Get a unit of work.
func (*WorkerAPIController) ReportWorkV1 ¶
func (c *WorkerAPIController) ReportWorkV1(w http.ResponseWriter, r *http.Request)
ReportWorkV1 - Report the result of a unit of work
func (*WorkerAPIController) Routes ¶
func (c *WorkerAPIController) Routes() Routes
Routes returns all the api routes for the WorkerAPIController
func (*WorkerAPIController) ScheduleRunV1 ¶
func (c *WorkerAPIController) ScheduleRunV1(w http.ResponseWriter, r *http.Request)
ScheduleRunV1 - Schedule a run.
type WorkerAPIOption ¶
type WorkerAPIOption func(*WorkerAPIController)
WorkerAPIOption for how the controller is set up.
func WithWorkerAPIErrorHandler ¶
func WithWorkerAPIErrorHandler(h ErrorHandler) WorkerAPIOption
WithWorkerAPIErrorHandler inject ErrorHandler into controller
type WorkerAPIRouter ¶
type WorkerAPIRouter interface { GetWorkV1(http.ResponseWriter, *http.Request) ReportWorkV1(http.ResponseWriter, *http.Request) ScheduleRunV1(http.ResponseWriter, *http.Request) }
WorkerAPIRouter defines the required methods for binding the api requests to a responses for the WorkerAPI The WorkerAPIRouter implementation should parse necessary information from the http request, pass the data to a WorkerAPIServicer to perform the required actions, then write the service results to the http response.
type WorkerAPIServicer ¶
type WorkerAPIServicer interface { GetWorkV1(context.Context) (ImplResponse, error) ReportWorkV1(context.Context, ReportWorkV1Request) (ImplResponse, error) ScheduleRunV1(context.Context, ScheduleRunV1Request) (ImplResponse, error) }
WorkerAPIServicer defines the api actions for the WorkerAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
Source Files
¶
- api.go
- api_task.go
- api_worker.go
- error.go
- helpers.go
- impl.go
- logger.go
- model_error.go
- model_get_task_v1_response.go
- model_get_work_v1_response.go
- model_get_work_v1_task.go
- model_list_tasks_v1_response.go
- model_report_work_v1_request.go
- model_report_work_v1_response.go
- model_report_work_v1_task_result.go
- model_schedule_run_v1_request.go
- model_schedule_run_v1_response.go
- routers.go