tasks

package
v0.0.0-...-c40a820 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypeAssertionError is thrown when type an interface does not match the asserted type
	ErrTypeAssertionError = errors.New("unable to assert type")
)

Functions

func AssertApproverRequestRequired

func AssertApproverRequestRequired(obj ApproverRequest) error

AssertApproverRequestRequired checks if the required fields are not zero-ed

func AssertApproverResponseRequired

func AssertApproverResponseRequired(obj ApproverResponse) error

AssertApproverResponseRequired checks if the required fields are not zero-ed

func AssertGetApprovers200ResponseRequired

func AssertGetApprovers200ResponseRequired(obj GetApprovers200Response) error

AssertGetApprovers200ResponseRequired checks if the required fields are not zero-ed

func AssertGetTasks200ResponseRequired

func AssertGetTasks200ResponseRequired(obj GetTasks200Response) error

AssertGetTasks200ResponseRequired checks if the required fields are not zero-ed

func AssertGetTasksDefaultResponseRequired

func AssertGetTasksDefaultResponseRequired(obj GetTasksDefaultResponse) error

AssertGetTasksDefaultResponseRequired checks if the required fields are not zero-ed

func AssertRecurseApproverRequestRequired

func AssertRecurseApproverRequestRequired(objSlice interface{}) error

AssertRecurseApproverRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ApproverRequest (e.g. [][]ApproverRequest), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseApproverResponseRequired

func AssertRecurseApproverResponseRequired(objSlice interface{}) error

AssertRecurseApproverResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ApproverResponse (e.g. [][]ApproverResponse), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseGetApprovers200ResponseRequired

func AssertRecurseGetApprovers200ResponseRequired(objSlice interface{}) error

AssertRecurseGetApprovers200ResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of GetApprovers200Response (e.g. [][]GetApprovers200Response), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseGetTasks200ResponseRequired

func AssertRecurseGetTasks200ResponseRequired(objSlice interface{}) error

AssertRecurseGetTasks200ResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of GetTasks200Response (e.g. [][]GetTasks200Response), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseGetTasksDefaultResponseRequired

func AssertRecurseGetTasksDefaultResponseRequired(objSlice interface{}) error

AssertRecurseGetTasksDefaultResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of GetTasksDefaultResponse (e.g. [][]GetTasksDefaultResponse), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseInterfaceRequired

func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error

AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseTaskRequestRequired

func AssertRecurseTaskRequestRequired(objSlice interface{}) error

AssertRecurseTaskRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TaskRequest (e.g. [][]TaskRequest), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTaskResponseRequired

func AssertRecurseTaskResponseRequired(objSlice interface{}) error

AssertRecurseTaskResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TaskResponse (e.g. [][]TaskResponse), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseUpdateTask200ResponseRequired

func AssertRecurseUpdateTask200ResponseRequired(objSlice interface{}) error

AssertRecurseUpdateTask200ResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of UpdateTask200Response (e.g. [][]UpdateTask200Response), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseValueRequired

func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error

AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertTaskRequestRequired

func AssertTaskRequestRequired(obj TaskRequest) error

AssertTaskRequestRequired checks if the required fields are not zero-ed

func AssertTaskResponseRequired

func AssertTaskResponseRequired(obj TaskResponse) error

AssertTaskResponseRequired checks if the required fields are not zero-ed

func AssertUpdateTask200ResponseRequired

func AssertUpdateTask200ResponseRequired(obj UpdateTask200Response) error

AssertUpdateTask200ResponseRequired checks if the required fields are not zero-ed

func DefaultErrorHandler

func DefaultErrorHandler(w http.ResponseWriter, r *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 Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type ApproverRequest

type ApproverRequest struct {
	Name string `json:"name"`

	Email string `json:"email"`
}

type ApproverResponse

type ApproverResponse struct {
	Id int64 `json:"id"`

	Name string `json:"name"`

	Email string `json:"email"`
}

type ApproversApiController

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

ApproversApiController binds http requests to an api service and writes the service results to the http response

func (*ApproversApiController) AddApprover

func (c *ApproversApiController) AddApprover(w http.ResponseWriter, r *http.Request)

AddApprover - Add a new approver

func (*ApproversApiController) DeleteApprover

func (c *ApproversApiController) DeleteApprover(w http.ResponseWriter, r *http.Request)

DeleteApprover - Delete approver

func (*ApproversApiController) FindApproversByEmail

func (c *ApproversApiController) FindApproversByEmail(w http.ResponseWriter, r *http.Request)

FindApproversByEmail - Find approver by email

func (*ApproversApiController) GetApprovers

func (c *ApproversApiController) GetApprovers(w http.ResponseWriter, r *http.Request)

GetApprovers - Retrieve all approvers

func (*ApproversApiController) Routes

func (c *ApproversApiController) Routes() Routes

Routes returns all the api routes for the ApproversApiController

func (*ApproversApiController) UpdateApprover

func (c *ApproversApiController) UpdateApprover(w http.ResponseWriter, r *http.Request)

UpdateApprover - Updates an existing approver

type ApproversApiOption

type ApproversApiOption func(*ApproversApiController)

ApproversApiOption for how the controller is set up.

func WithApproversApiErrorHandler

func WithApproversApiErrorHandler(h ErrorHandler) ApproversApiOption

WithApproversApiErrorHandler inject ErrorHandler into controller

type ApproversApiRouter

type ApproversApiRouter interface {
	AddApprover(http.ResponseWriter, *http.Request)
	DeleteApprover(http.ResponseWriter, *http.Request)
	FindApproversByEmail(http.ResponseWriter, *http.Request)
	GetApprovers(http.ResponseWriter, *http.Request)
	UpdateApprover(http.ResponseWriter, *http.Request)
}

ApproversApiRouter defines the required methods for binding the api requests to a responses for the ApproversApi The ApproversApiRouter implementation should parse necessary information from the http request, pass the data to a ApproversApiServicer to perform the required actions, then write the service results to the http response.

type ApproversApiService

type ApproversApiService struct {
}

ApproversApiService is a service that implements the logic for the ApproversApiServicer This service should implement the business logic for every endpoint for the ApproversApi API. Include any external packages or services that will be required by this service.

func (*ApproversApiService) AddApprover

func (s *ApproversApiService) AddApprover(ctx context.Context, approverRequest ApproverRequest) (ImplResponse, error)

AddApprover - Add a new approver

func (*ApproversApiService) DeleteApprover

func (s *ApproversApiService) DeleteApprover(ctx context.Context, approverEmail string) (ImplResponse, error)

DeleteApprover - Delete approver

func (*ApproversApiService) FindApproversByEmail

func (s *ApproversApiService) FindApproversByEmail(ctx context.Context, email string) (ImplResponse, error)

FindApproversByEmail - Find approver by email

func (*ApproversApiService) GetApprovers

func (s *ApproversApiService) GetApprovers(ctx context.Context, page int32, size int32) (ImplResponse, error)

GetApprovers - Retrieve all approvers

func (*ApproversApiService) UpdateApprover

func (s *ApproversApiService) UpdateApprover(ctx context.Context, approverEmail string, approverRequest ApproverRequest) (ImplResponse, error)

UpdateApprover - Updates an existing approver

type ApproversApiServicer

type ApproversApiServicer interface {
	AddApprover(context.Context, ApproverRequest) (ImplResponse, error)
	DeleteApprover(context.Context, string) (ImplResponse, error)
	FindApproversByEmail(context.Context, string) (ImplResponse, error)
	GetApprovers(context.Context, int32, int32) (ImplResponse, error)
	UpdateApprover(context.Context, string, ApproverRequest) (ImplResponse, error)
}

ApproversApiServicer defines the api actions for the ApproversApi 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.

func NewApproversApiService

func NewApproversApiService() ApproversApiServicer

NewApproversApiService creates a default api service

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 GetApprovers200Response

type GetApprovers200Response struct {
	Tasks []ApproverResponse `json:"tasks,omitempty"`
}

type GetTasks200Response

type GetTasks200Response struct {
	Tasks []TaskResponse `json:"tasks,omitempty"`
}

type GetTasksDefaultResponse

type GetTasksDefaultResponse struct {
	Message string `json:"message,omitempty"`

	ErrorCode string `json:"errorCode,omitempty"`
}

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

ImplResponse response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type ParsingError

type ParsingError struct {
	Err error
}

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 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 {
	Name        string
	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

func NewApproversApiController

func NewApproversApiController(s ApproversApiServicer, opts ...ApproversApiOption) Router

NewApproversApiController creates a default api controller

func NewTasksApiController

func NewTasksApiController(s TasksApiServicer, opts ...TasksApiOption) Router

NewTasksApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type TaskRequest

type TaskRequest struct {
	Title string `json:"title"`

	Description string `json:"description"`

	Approvers []ApproverRequest `json:"approvers,omitempty"`
}

type TaskResponse

type TaskResponse struct {
	Id int64 `json:"id,omitempty"`

	Title string `json:"title"`

	Description string `json:"description"`

	Approvers []ApproverRequest `json:"approvers,omitempty"`
}

type TasksApiController

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

TasksApiController binds http requests to an api service and writes the service results to the http response

func (*TasksApiController) AddTask

AddTask - Add a new task

func (*TasksApiController) DeleteTask

func (c *TasksApiController) DeleteTask(w http.ResponseWriter, r *http.Request)

DeleteTask - Deletes a task

func (*TasksApiController) FindTasksByStatus

func (c *TasksApiController) FindTasksByStatus(w http.ResponseWriter, r *http.Request)

FindTasksByStatus - Find tasks by status

func (*TasksApiController) GetTaskById

func (c *TasksApiController) GetTaskById(w http.ResponseWriter, r *http.Request)

GetTaskById - Find task by ID

func (*TasksApiController) GetTasks

func (c *TasksApiController) GetTasks(w http.ResponseWriter, r *http.Request)

GetTasks - Retrieves all tasks

func (*TasksApiController) Routes

func (c *TasksApiController) Routes() Routes

Routes returns all the api routes for the TasksApiController

func (*TasksApiController) UpdateTask

func (c *TasksApiController) UpdateTask(w http.ResponseWriter, r *http.Request)

UpdateTask - Updates an existing task

type TasksApiOption

type TasksApiOption func(*TasksApiController)

TasksApiOption for how the controller is set up.

func WithTasksApiErrorHandler

func WithTasksApiErrorHandler(h ErrorHandler) TasksApiOption

WithTasksApiErrorHandler inject ErrorHandler into controller

type TasksApiRouter

type TasksApiRouter interface {
	AddTask(http.ResponseWriter, *http.Request)
	DeleteTask(http.ResponseWriter, *http.Request)
	FindTasksByStatus(http.ResponseWriter, *http.Request)
	GetTaskById(http.ResponseWriter, *http.Request)
	GetTasks(http.ResponseWriter, *http.Request)
	UpdateTask(http.ResponseWriter, *http.Request)
}

TasksApiRouter defines the required methods for binding the api requests to a responses for the TasksApi The TasksApiRouter implementation should parse necessary information from the http request, pass the data to a TasksApiServicer to perform the required actions, then write the service results to the http response.

type TasksApiService

type TasksApiService struct {
}

TasksApiService is a service that implements the logic for the TasksApiServicer This service should implement the business logic for every endpoint for the TasksApi API. Include any external packages or services that will be required by this service.

func (*TasksApiService) AddTask

func (s *TasksApiService) AddTask(ctx context.Context, taskRequest TaskRequest) (ImplResponse, error)

AddTask - Add a new task

func (*TasksApiService) DeleteTask

func (s *TasksApiService) DeleteTask(ctx context.Context, taskId int64) (ImplResponse, error)

DeleteTask - Deletes a task

func (*TasksApiService) FindTasksByStatus

func (s *TasksApiService) FindTasksByStatus(ctx context.Context, status string) (ImplResponse, error)

FindTasksByStatus - Find tasks by status

func (*TasksApiService) GetTaskById

func (s *TasksApiService) GetTaskById(ctx context.Context, taskId int64) (ImplResponse, error)

GetTaskById - Find task by ID

func (*TasksApiService) GetTasks

func (s *TasksApiService) GetTasks(ctx context.Context, page int32, size int32) (ImplResponse, error)

GetTasks - Retrieves all tasks

func (*TasksApiService) UpdateTask

func (s *TasksApiService) UpdateTask(ctx context.Context, taskId int64, taskRequest TaskRequest) (ImplResponse, error)

UpdateTask - Updates an existing task

type TasksApiServicer

type TasksApiServicer interface {
	AddTask(context.Context, TaskRequest) (ImplResponse, error)
	DeleteTask(context.Context, int64) (ImplResponse, error)
	FindTasksByStatus(context.Context, string) (ImplResponse, error)
	GetTaskById(context.Context, int64) (ImplResponse, error)
	GetTasks(context.Context, int32, int32) (ImplResponse, error)
	UpdateTask(context.Context, int64, TaskRequest) (ImplResponse, error)
}

TasksApiServicer defines the api actions for the TasksApi 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.

func NewTasksApiService

func NewTasksApiService() TasksApiServicer

NewTasksApiService creates a default api service

type UpdateTask200Response

type UpdateTask200Response struct {
	Message string `json:"message,omitempty"`
}

Jump to

Keyboard shortcuts

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