restapi

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MPL-2.0-no-copyleft-exception Imports: 20 Imported by: 0

Documentation

Overview

Package restapi uisvc API for the user interface service; the service that is directly responsible for presenting data to users. This service typically runs at the border, and leverages session cookies or authentication tokens that we generate for users. It also is responsible for handling the act of oauth and user creation through its login hooks. uisvc typically talks to the datasvc and other services to accomplish its goal, it does not save anything locally or carry state.

Schemes:
  http
Host: localhost
BasePath: /
Version: 1.0.0

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

View Source
var (
	// SwaggerJSON embedded version of the swagger document used at generation time
	SwaggerJSON json.RawMessage
	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
	FlatSwaggerJSON json.RawMessage
)

Functions

func AddCapability

func AddCapability(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

AddCapability adds a capability for a user.

func AddRepositorySubscription

func AddRepositorySubscription(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

AddRepositorySubscription adds a subscription for the user to the repo

func AddRepositoryToCI

func AddRepositoryToCI(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

AddRepositoryToCI adds the repository to CI and subscribes the user to it.

func CancelRun

func CancelRun(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CancelRun cancels a run by id.

func CancelSubmission

func CancelSubmission(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CancelSubmission cancels a submission by ID.

func CancelTask

func CancelTask(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CancelTask cancels a task by ID.

func CountRuns

func CountRuns(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CountRuns returns a count of the queue items by asking the datasvc for it.

func CountRunsForTask

func CountRunsForTask(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CountRunsForTask counts all the runs by task ID.

func CountSubmissions

func CountSubmissions(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CountSubmissions counts the submissions with optional repository/sha filtering.

func CountTasks

func CountTasks(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

CountTasks counts the task list with the supplied repo/sha filtering.

func DeleteRepositoryFromCI

func DeleteRepositoryFromCI(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

DeleteRepositoryFromCI removes the repository from CI. that's it.

func DeleteRepositorySubscription

func DeleteRepositorySubscription(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

DeleteRepositorySubscription removes the subscription to the repository from the user account.

func DeleteToken

func DeleteToken(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

DeleteToken removes the existing token for the user.

func Errors

func Errors(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

Errors processes the /errors GET endpoint

func GetRun

func GetRun(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetRun retrieves a run by id.

func GetRunsForTask

func GetRunsForTask(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetRunsForTask retrieves all the runs by task id. Pagination rules are in effect.

func GetSubmission

func GetSubmission(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetSubmission retrieves a submission by id

func GetSubmissionRuns

func GetSubmissionRuns(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetSubmissionRuns retrieves a submission's runs from the submission id

func GetSubmissionTasks

func GetSubmissionTasks(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetSubmissionTasks retrieves a submission's task from the submission id

func GetToken

func GetToken(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetToken obtains a new token from the db. If one is already set, you must delete it before this will return a new one.

func GetUserProperties

func GetUserProperties(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

GetUserProperties gives an object containing information about the user.

func ListRepositoriesMy

func ListRepositoriesMy(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListRepositoriesMy lists the repositories the user can modify.

func ListRepositoriesSubscribed

func ListRepositoriesSubscribed(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListRepositoriesSubscribed lists all subscribed repos as JSON.

func ListRepositoriesVisible

func ListRepositoriesVisible(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListRepositoriesVisible returns all the repos the user can see.

func ListRuns

func ListRuns(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListRuns lists all the runs that were requested by the page/perPage parameters.

func ListSubmissions

func ListSubmissions(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListSubmissions lists the submissions with optional repository/sha filtering and pagination.

func ListSubscribedTasksForUser

func ListSubscribedTasksForUser(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListSubscribedTasksForUser lists only the tasks for the repositories the user is subscribed to.

func ListTasks

func ListTasks(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ListTasks retrieves the task list.

func LogAttach

func LogAttach(pCtx context.Context, h *handlers.H, ctx *gin.Context, conn *websocket.Conn) error

LogAttach connects to a running logging process and outputs the return data as it arrives.

func LoggedIn

func LoggedIn(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

LoggedIn handles the process of signaling javascript whether or not to login.

func Login

func Login(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

Login processes the oauth response and optionally redirects the user if not logged in already.

func Logout

func Logout(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

Logout logs the user out of the tinyCI system.

func MakeUIServer

func MakeUIServer(client github.Client) (*handlers.H, chan struct{}, *tinyci.Client, *tinyci.Client, error)

MakeUIServer makes a uisvc.

func RemoveCapability

func RemoveCapability(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

RemoveCapability removes a capability from a user.

func ScanRepositories

func ScanRepositories(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

ScanRepositories scans for owned and managed repositories for Add-to-CI operations.

func Submit

func Submit(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

Submit powers a manual submission to the queuesvc.

func Upgrade

func Upgrade(pCtx context.Context, h *handlers.H, ctx *gin.Context) (interface{}, int, error)

Upgrade upgrades the user's api keys.

Types

type HandlerConfig

type HandlerConfig struct{}

HandlerConfig is for on-disk configuration of the service. It will be parsed on boot and passed into each HandlerFunc.

func MakeHandlerConfig

func MakeHandlerConfig(sc config.ServiceConfig) *HandlerConfig

MakeHandlerConfig takes a handlers.ServiceConfig and spits out a HandlerConfig.

func (HandlerConfig) Configure

func (hc HandlerConfig) Configure(router handlers.Routes) error

Configure allows you to configure the routes, in particular. Setting the processing functions here will be a big part of your day job.

func (HandlerConfig) CustomInit

func (hc HandlerConfig) CustomInit(h *handlers.H) error

CustomInit allows you to perform any final magic before boot.

func (HandlerConfig) DBConfigure

func (hc HandlerConfig) DBConfigure(h *handlers.H) error

DBConfigure configures the database if necessary.

func (HandlerConfig) SetRoutes

func (hc HandlerConfig) SetRoutes(h *handlers.H)

SetRoutes sets the routes in the handler so gin can execute them.

func (HandlerConfig) Validate

func (hc HandlerConfig) Validate(h *handlers.H) error

Validate allows you to perform your own custom validations on the configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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