Documentation ¶
Index ¶
- func CreateService(c *gin.Context)
- func CreateVersion(c *gin.Context)
- func GetService(c *gin.Context)
- func ListServices(c *gin.Context)
- func Login(c *gin.Context)
- func NewRouter() *gin.Engine
- func Register(c *gin.Context)
- func UpdateService(c *gin.Context)
- type CreateVersionOutput
- type GetServiceWithVersionsOutput
- type ListServicesOutput
- type LoginOutput
- type RegisterOutput
- type ServiceOutput
- type ServiceWithVersions
- type UserAuthInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateService ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 Register ¶
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 ¶
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 ¶
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 ¶
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 ¶
RegisterOutput represents the output returned after a user is registered successfully.
type ServiceOutput ¶
ServiceOutput represents the output returned when fetching/creating/updating a single Service.
type ServiceWithVersions ¶
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.