api

package
v0.0.0-...-8d09c37 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateService

func CreateService(c *gin.Context)

CreateService godoc @Summary Create a service. @Accept json @Produce json @Param Authorization header string true "Bearer token" @Param service body models.CreateServiceInput true "Service JSON" @Success 201 {object} ServiceOutput @Router /service [post]

CreateService creates a Service for the authenticated user. The request body must contain a name and an optional description.

func CreateVersion

func CreateVersion(c *gin.Context)

CreateVersion godoc @Summary Create a version for a service @Accept json @Produce json @Param Authorization header string true "Bearer token" @Param version body models.CreateVersionInput true "Version JSON" @Success 201 {object} CreateVersionOutput @Router /service/{id}/version [post]

CreateVersion creates a new Version for the provided Service. The Service must exist in the database. The request body must contain the service id and a unique version string.

func GetService

func GetService(c *gin.Context)

GetService godoc @Summary Get requested service. @Description If the 'versions' query param is absent/false, versions is omitted from the response. @Produce json @Param Authorization header string true "Bearer token" @Param versions query bool false "Return related versions" @Success 200 {object} ServiceOutput @Success 200 {object} GetServiceWithVersionsOutput @Router /service/{id} [get]

GetService returns the requested Service based on the 'id' query parameter. If the 'versions' query parameter is present and set to 'true', the Version objects for that Service are also present in the response.

func ListServices

func ListServices(c *gin.Context)

ListServices godoc @Summary List all services for the authenticated user. @Produce json @Param Authorization header string true "Bearer token" @Param limit query int false "Limit results" @Param offset query int false "Query offset" @Param sortKey query string false "Key to sort records by" @Param descending query bool false "Sort records in descending order" @Param name query string false "Search records by name" @Success 200 {object} ListServicesOutput @Router /services [get]

ListServices returns a list of services for the authenticated user based on the following query parameters:

func Login

func Login(c *gin.Context)

Login godoc @Summary Login a user @Accept json @Produce json @Param creds body UserAuthInput true "Auth creds JSON" @Success 200 {object} LoginOutput @Router /auth/login [post]

Login returns an access token for the user, if found.

func NewRouter

func NewRouter() *gin.Engine

NewRouter returns a Gin router configured with all endpoints and middleware.

func Register

func Register(c *gin.Context)

Register godoc @Summary Register a user @Accept json @Produce json @Param creds body UserAuthInput true "Auth creds JSON" @Success 201 {object} RegisterOutput @Router /auth/register [post]

Register registers a new user.

func UpdateService

func UpdateService(c *gin.Context)

UpdateService godoc @Summary Update a service @Accept json @Produce json @Param Authorization header string true "Bearer token" @Param version body models.UpdateServiceInput true "Service update JSON" @Success 201 {object} ServiceOutput @Router /service/{id} [patch]

UpdateService updates the Service according to the provided input.

Types

type CreateVersionOutput

type CreateVersionOutput struct {
	Data models.Version `json:"data"`
}

CreateVersionOutput represnets the output returned after creating a Version object.

type GetServiceWithVersionsOutput

type GetServiceWithVersionsOutput struct {
	Data ServiceWithVersions `json:"data"`
}

GetServiceWithVersionsOutput represents the output returned when fetching a Service along with its related Version objects.

type ListServicesOutput

type ListServicesOutput struct {
	Data []models.Service `json:"data"`
}

ListServicesOutput represents the output returned when fetching a list of Services.

type LoginOutput

type LoginOutput struct {
	AccessToken string `json:"accessToken"`
}

LoginOutput represents the output returned after a user logs in successfully.

type RegisterOutput

type RegisterOutput struct {
	Data models.User `json:"data"`
}

RegisterOutput represents the output returned after a user is registered successfully.

type ServiceOutput

type ServiceOutput struct {
	Data models.Service `json:"data"`
}

ServiceOutput represents the output returned when fetching/creating/updating a single Service.

type ServiceWithVersions

type ServiceWithVersions struct {
	models.Service
	Versions []models.Version `json:"versions"`
}

ServiceWithVersions represents a Service with its related Versions.

type UserAuthInput

type UserAuthInput struct {
	Username string `json:"username" binding:"required,max=20"`
	Password string `json:"password" binding:"required,max=20"`
}

UserAuthInput represents the user authentication credentials.

Jump to

Keyboard shortcuts

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