rest

package
v0.0.0-...-42c0c98 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const REFRESH_TOKEN_COOKIE = "refresh-token"
View Source
const REFRESH_TOKEN_PATH = "/api/rest/token/refresh"

Variables

This section is empty.

Functions

func CreateCompetition

func CreateCompetition(client *ent.Client) gin.HandlerFunc

CreateCompetition godoc

@Security		ServiceAuth
@Summary		Create a Competition
@Schemes		http https
@Description	Create a Competition
@Tags			Service API
@Param			competition	body	rest.CompetitionInput	true	"The competition to create"
@Produce		json
@Success		201	{object}	rest.CompetitionModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/competition [post]

func CreateProvider

func CreateProvider(client *ent.Client) gin.HandlerFunc

CreateProvider godoc

@Security		ServiceAuth
@Summary		Create a Provider
@Schemes		http https
@Description	Create a Provider
@Tags			Service API
@Param			provider	body	rest.ProviderInput	true	"The provider to create"
@Produce		json
@Success		201	{object}	rest.ProviderModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/provider [post]

func CreateTeam

func CreateTeam(client *ent.Client) gin.HandlerFunc

CreateTeam godoc

@Security		ServiceAuth
@Summary		Create a Team
@Schemes		http https
@Description	Create a Team
@Tags			Service API
@Param			team	body	rest.TeamInput	true	"The team to create"
@Produce		json
@Success		201	{object}	rest.TeamModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/team [post]

func CreateUser

func CreateUser(client *ent.Client) gin.HandlerFunc

CreateUser godoc

@Security		ServiceAuth
@Summary		Create a User
@Schemes		http https
@Description	Create a User
@Tags			Service API
@Param			user	body	rest.UserInput	true	"The user to create"
@Produce		json
@Success		201	{object}	rest.UserModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/user [post]

func CreateVMObject

func CreateVMObject(client *ent.Client) gin.HandlerFunc

CreateVMObject godoc

@Security		ServiceAuth
@Summary		Create a VM Object
@Schemes		http https
@Description	Create a VM Object
@Tags			Service API
@Param			vm_object	body	rest.VmObjectInput	true	"The vm object to create"
@Produce		json
@Success		201	{object}	rest.VmObjectModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object [post]

func DeleteCompetition

func DeleteCompetition(client *ent.Client) gin.HandlerFunc

DeleteCompetition godoc

@Security		ServiceAuth
@Summary		Delete a Competition
@Schemes		http https
@Description	Delete a Competition
@Tags			Service API
@Param			id	path	string	true	"The id of the competition"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		204
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/competition/{id} [delete]

func DeleteProvider

func DeleteProvider(client *ent.Client) gin.HandlerFunc

DeleteProvider godoc

@Security		ServiceAuth
@Summary		Delete a Provider
@Schemes		http https
@Description	Delete a Provider
@Tags			Service API
@Param			id	path	string	true	"The id of the provider"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		204
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/provider/{id} [delete]

func DeleteTeam

func DeleteTeam(client *ent.Client) gin.HandlerFunc

DeleteTeam godoc

@Security		ServiceAuth
@Summary		Delete a Team
@Schemes		http https
@Description	Delete a Team
@Tags			Service API
@Param			id	path	string	true	"The id of the team"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		204
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/team/{id} [delete]

func DeleteUser

func DeleteUser(client *ent.Client) gin.HandlerFunc

DeleteUser godoc

@Security		ServiceAuth
@Summary		Delete a User
@Schemes		http https
@Description	Delete a User
@Tags			Service API
@Param			id	path	string	true	"The id of the user"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		204
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/user/{id} [delete]

func DeleteVMObject

func DeleteVMObject(client *ent.Client) gin.HandlerFunc

DeleteVMObject godoc

@Security		ServiceAuth
@Summary		Delete a VM Object
@Schemes		http https
@Description	Delete a VM Object
@Tags			Service API
@Param			id	path	string	true	"The id of the vm object"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		204
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object/{id} [delete]

func GetCompetition

func GetCompetition(client *ent.Client) gin.HandlerFunc

GetCompetition godoc

@Security		ServiceAuth
@Summary		Get a Competition
@Schemes		http https
@Description	Get a Competition
@Tags			Service API
@Param			id	path	string	true	"The id of the competition"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		200	{object}	rest.CompetitionModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/competition/{id} [get]

func GetProvider

func GetProvider(client *ent.Client) gin.HandlerFunc

GetProvider godoc

@Security		ServiceAuth
@Summary		Get a provider
@Schemes		http https
@Description	Get a provider
@Tags			Service API
@Param			id	path	string	true	"The id of the provider"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		200	{object}	rest.ProviderModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/provider/{id} [get]

func GetTeam

func GetTeam(client *ent.Client) gin.HandlerFunc

GetTeam godoc

@Security		ServiceAuth
@Summary		Get a Team
@Schemes		http https
@Description	Get a Team
@Tags			Service API
@Param			id	path	string	true	"The id of the team"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		200	{object}	rest.TeamModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/team/{id} [get]

func GetUser

func GetUser(client *ent.Client) gin.HandlerFunc

GetUser godoc

@Security		ServiceAuth
@Summary		Get a User
@Schemes		http https
@Description	Get a User
@Tags			Service API
@Param			id	path	string	true	"The id of the user"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		200	{object}	rest.UserModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/user/{id} [get]

func GetVMObject

func GetVMObject(client *ent.Client) gin.HandlerFunc

GetVMObject godoc

@Security		ServiceAuth
@Summary		Get a VM Object
@Schemes		http https
@Description	Get a VM Object
@Tags			Service API
@Param			id	path	string	true	"The id of the vm object"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Produce		json
@Success		200	{object}	rest.VmObjectModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object/{id} [get]

func ListCompetitions

func ListCompetitions(client *ent.Client) gin.HandlerFunc

ListCompetitions godoc

@Security		ServiceAuth
@Summary		List all Competitions
@Schemes		http https
@Description	List all Competitions
@Tags			Service API
@Param			field	query	string	false	"Field to search by (optional)"	Enums(name)	validate(optional)
@Param			q		query	string	false	"Search text (optional)"		validate(optional)
@Produce		json
@Success		200	{array}		rest.CompetitionModel
@Failure		500	{object}	api.APIError
@Router			/rest/competition [get]

func ListProviders

func ListProviders(client *ent.Client) gin.HandlerFunc

ListProviders godoc

@Security		ServiceAuth
@Summary		List all Providers
@Schemes		http https
@Description	List all Providers
@Tags			Service API
@Param			field	query	string	false	"Field to search by (optional)"	Enums(name)	validate(optional)
@Param			q		query	string	false	"Search text (optional)"		validate(optional)
@Produce		json
@Success		200	{array}		rest.ProviderModel
@Failure		500	{object}	api.APIError
@Router			/rest/provider [get]

func ListTeams

func ListTeams(client *ent.Client) gin.HandlerFunc

ListTeams godoc

@Security		ServiceAuth
@Summary		List all Teams
@Schemes		http https
@Description	List all Teams
@Tags			Service API
@Param			field	query	string	false	"Field to search by (optional)"	Enums(name,number)	validate(optional)
@Param			q		query	string	false	"Search text (optional)"		validate(optional)
@Produce		json
@Success		200	{array}		rest.TeamModel
@Failure		500	{object}	api.APIError
@Router			/rest/team [get]

func ListUsers

func ListUsers(client *ent.Client) gin.HandlerFunc

ListUsers godoc

@Security		ServiceAuth
@Summary		List all Users
@Schemes		http https
@Description	List all Users
@Tags			Service API
@Param			field	query	string	false	"Field to search by (optional)"	Enums(username,first_name,last_name)	validate(optional)
@Param			q		query	string	false	"Search text (optional)"		validate(optional)
@Produce		json
@Success		200	{array}		rest.UserModel
@Failure		500	{object}	api.APIError
@Router			/rest/user [get]

func ListVmObjects

func ListVmObjects(client *ent.Client) gin.HandlerFunc

ListVmObjects godoc

@Security		ServiceAuth
@Summary		List all VM Objects
@Schemes		http https
@Description	List all VM Objects
@Tags			Service API
@Param			field	query	string	false	"Field to search by (optional)"	Enums(identifier,name)	validate(optional)
@Param			q		query	string	false	"Search text (optional)"		validate(optional)
@Produce		json
@Success		200	{array}		rest.VmObjectModel
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object [get]

func RegisterRESTEndpoints

func RegisterRESTEndpoints(client *ent.Client, r *gin.RouterGroup)

func ServiceLogin

func ServiceLogin(client *ent.Client) gin.HandlerFunc

ServiceLogin godoc

@Summary		Login with a service account and get a session token
@Schemes		http https
@Description	Login with a service account and get a session token. The refresh token is set as a cookie in the response and can be used to refresh a session without re-authenticating.
@Tags			Auth API
@Accept			json,mpfd
@Param			login	body	ServiceLoginVals	true	"Service account details"
@Produce		json
@Success		200	{object}	ServiceLoginResult
@Failure		401	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/token [post]

ServiceLogin handles login of service accounts and packs the session into context

func ServiceTokenRefresh

func ServiceTokenRefresh(client *ent.Client) gin.HandlerFunc

ServiceTokenRefresh godoc

@Summary		Refresh a service account session without re-authenticating
@Schemes		http https
@Description	Refresh a service account session without re-authenticating
@Tags			Auth API
@Param			Cookie	header	string	false	"refresh-token"	default(refresh-token=xxx)
@Produce		json
@Success		200	{object}	ServiceLoginResult
@Failure		401	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/token/refresh [post]

ServiceTokenRefresh handles refreshing sessions automatically

func UpdateCompetition

func UpdateCompetition(client *ent.Client) gin.HandlerFunc

UpdateCompetition godoc

@Security		ServiceAuth
@Summary		Update a Competition
@Schemes		http https
@Description	Update a Competition
@Tags			Service API
@Param			id			path	string					true	"The id of the competition"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			competition	body	rest.CompetitionInput	true	"The updated competition"
@Produce		json
@Success		201	{object}	rest.CompetitionModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/competition/{id} [put]

func UpdateProvider

func UpdateProvider(client *ent.Client) gin.HandlerFunc

UpdateProvider godoc

@Security		ServiceAuth
@Summary		Update a Provider
@Schemes		http https
@Description	Update a Provider
@Tags			Service API
@Param			id			path	string				true	"The id of the provider"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			provider	body	rest.ProviderInput	true	"The updated provider"
@Produce		json
@Success		201	{object}	rest.ProviderModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/provider/{id} [put]

func UpdateTeam

func UpdateTeam(client *ent.Client) gin.HandlerFunc

UpdateTeam godoc

@Security		ServiceAuth
@Summary		Update a Team
@Schemes		http https
@Description	Update a Team
@Tags			Service API
@Param			id		path	string			true	"The id of the team"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			team	body	rest.TeamInput	true	"The updated team"
@Produce		json
@Success		201	{object}	rest.TeamModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/team/{id} [put]

func UpdateUser

func UpdateUser(client *ent.Client) gin.HandlerFunc

UpdateUser godoc

@Security		ServiceAuth
@Summary		Update a User
@Schemes		http https
@Description	Update a User
@Tags			Service API
@Param			id		path	string			true	"The id of the user"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			user	body	rest.UserInput	true	"The updated user"
@Produce		json
@Success		201	{object}	rest.UserModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/user/{id} [put]

func UpdateVMObject

func UpdateVMObject(client *ent.Client) gin.HandlerFunc

UpdateVMObject godoc

@Security		ServiceAuth
@Summary		Update a VM Object
@Schemes		http https
@Description	Update a VM Object
@Tags			Service API
@Param			id			path	string				true	"The id of the vm object"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			vm_object	body	rest.VmObjectInput	true	"The updated vm object"
@Produce		json
@Success		201	{object}	rest.VmObjectModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object/{id} [put]

func UpdateVMObjectIdentifier

func UpdateVMObjectIdentifier(client *ent.Client) gin.HandlerFunc

UpdateVMObjectIdentifier godoc

@Security		ServiceAuth
@Summary		Update the Identifier of a VM Object
@Schemes		http https
@Description	Update the Identifier of a VM Object
@Tags			Service API
@Param			id			path	string							true	"The id of the vm object"	format(uuid)	example(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
@Param			identifier	body	rest.VmObjectIdentifierInput	true	"The updated vm object identifier"
@Produce		json
@Success		201	{object}	rest.VmObjectModel
@Failure		422	{object}	api.APIError
@Failure		404	{object}	api.APIError
@Failure		500	{object}	api.APIError
@Router			/rest/vm-object/{id}/identifier [put]

Types

type CompetitionEdge

type CompetitionEdge struct {
	// Fields
	ID   uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Name string    `json:"name" example:"Test Competition"`                   // [REQUIRED] The unique name (aka. slug) for the competition.
}

CompetitionEdge model info

@Description	Used for Competition in edges

type CompetitionInput

type CompetitionInput struct {
	Name                  string `json:"name" form:"name" binding:"required" example:"ISTS 'XX"`
	CompetitionToProvider string `` /* 127-byte string literal not displayed */
}

CompetitionInput model info

@Description	Used as an input model for creating/updating Competitions

type CompetitionModel

type CompetitionModel struct {
	// Fields
	ID   uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Name string    `json:"name" example:"Test Competition"`                   // [REQUIRED] The unique name (aka. slug) for the competition.
	// Edges
	CompetitionToTeams    []*TeamEdge  `json:"competition_to_teams"`
	CompetitionToProvider ProviderEdge `json:"competition_to_provider"`
}

CompetitionModel model info

@Description	Used for Competition endpoints

func CompetitionEntToModel

func CompetitionEntToModel(entCompetition *ent.Competition) CompetitionModel

CompetitionEntToModel converts the result of a Competition ENT query into a CompetitionModel for API responses

type ProviderEdge

type ProviderEdge struct {
	// Fields
	ID     uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Name   string    `json:"name" example:"Local Openstack"`                    // [REQUIRED] The unique name (aka. slug) for the provider.
	Type   string    `json:"type" example:"OPENSTACK"`                          // [REQUIRED] The type of provider this is (must match a registered one in https://github.com/BradHacker/compsole/tree/main/compsole/providers)
	Config string    `json:"config" example:"{...}"`                            // [REQUIRED] This is the JSON configuration for the provider.
}

ProviderEdge model info

@Description	Used for Provider in edges

type ProviderInput

type ProviderInput struct {
	Name   string `json:"name" form:"name" binding:"required" example:"RITSEC Openstack"`
	Type   string `json:"type" form:"type" binding:"required" example:"OPENSTACK" enums:"OPENSTACK"`
	Config string `` // See https://github.com/BradHacker/compsole/tree/main/configs for examples
	/* 130-byte string literal not displayed */
}

ProviderInput model info

@Description	Used as an input model for creating/updating Providers

type ProviderModel

type ProviderModel struct {
	// Fields
	ID     uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Name   string    `json:"name" example:"Local Openstack"`                    // [REQUIRED] The unique name (aka. slug) for the provider.
	Type   string    `json:"type" example:"OPENSTACK"`                          // [REQUIRED] The type of provider this is (must match a registered one in https://github.com/BradHacker/compsole/tree/main/compsole/providers)
	Config string    `json:"config" example:"{...}"`                            // [REQUIRED] This is the JSON configuration for the provider.
	// Edges
	ProviderToCompetitions []CompetitionEdge `json:"provider_to_competitions"`
}

ProviderModel model info

@Description	Used for Provider endpoints

func ProviderEntToModel

func ProviderEntToModel(entProvider *ent.Provider) ProviderModel

ProviderEntToModel converts the result of a Provider ENT query into a ProviderModel for API responses

type ServiceLoginResult

type ServiceLoginResult struct {
	Token     string `json:"token"`
	ExpiresAt int64  `json:"token_expires_at"`
}

type ServiceLoginVals

type ServiceLoginVals struct {
	ApiKey    string `form:"api_key" json:"api_key" binding:"required"`
	ApiSecret string `form:"api_secret" json:"api_secret" binding:"required"`
}

type TeamEdge

type TeamEdge struct {
	// Fields
	ID         uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	TeamNumber int       `json:"team_number" example:"1"`                           // [REQUIRED] The team number.
	Name       string    `json:"name" example:"Team 1"`                             // [OPTIONAL] The display name for the team.
}

TeamEdge model info

@Description	Used for Team in edges

type TeamInput

type TeamInput struct {
	Name              string `json:"name" form:"name" binding:"required" example:"ISTS 'XX"`
	TeamNumber        int    `json:"team_number" form:"team_number" binding:"required" example:"1"`
	TeamToCompetition string `json:"team_to_competition" form:"team_to_competition" binding:"required" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
}

TeamInput model info

@Description	Used as an input model for creating/updating Teams

type TeamModel

type TeamModel struct {
	// Fields
	ID         uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	TeamNumber int       `json:"team_number" example:"1"`                           // [REQUIRED] The team number.
	Name       string    `json:"name" example:"Team 1"`                             // [OPTIONAL] The display name for the team.
	// Edges
	TeamToCompetition CompetitionEdge `json:"team_to_competition"`
	TeamToVmObjects   []VmObjectEdge  `json:"team_to_vm_objects"`
	TeamToUsers       []UserEdge      `json:"team_to_users"`
}

TeamModel model info

@Description	Used for Team endpoints

func TeamEntToModel

func TeamEntToModel(entTeam *ent.Team) TeamModel

TeamEntToModel converts the result of a Team ENT query into a TeamModel for API responses

type UserEdge

type UserEdge struct {
	// Fields
	ID        uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Username  string    `json:"username" example:"compsole"`                       // [REQUIRED] The username for the user.
	FirstName string    `json:"first_name" example:"Default"`                      // [OPTIONAL] The display first name for the user.
	LastName  string    `json:"last_name" example:"User"`                          // [OPTIONAL] The display last name for the user.
	Role      user.Role `json:"role" example:"USER"`                               // [REQUIRED] The role of the user. Admins have full access.
}

UserEdge model info

@Description	Used for User in edges

type UserInput

type UserInput struct {
	Username   string  `json:"username" form:"username" binding:"required" example:"compsole"`
	FirstName  string  `json:"first_name" form:"first_name" binding:"required" example:"John"`
	LastName   string  `json:"last_name" form:"last_name" binding:"required" example:"Doe"`
	Role       string  `json:"role" form:"role" binding:"required" example:"USER" enums:"USER,ADMIN"`
	UserToTeam *string `json:"user_to_team,omitempty" form:"user_to_team" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
}

UserInput model info

@Description	Used as an input model for creating/updating Users

type UserModel

type UserModel struct {
	// Fields
	ID        uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Username  string    `json:"username" example:"compsole"`                       // [REQUIRED] The username for the user.
	FirstName string    `json:"first_name" example:"Default"`                      // [OPTIONAL] The display first name for the user.
	LastName  string    `json:"last_name" example:"User"`                          // [OPTIONAL] The display last name for the user.
	Role      user.Role `json:"role" example:"USER"`                               // [REQUIRED] The role of the user. Admins have full access.
	// Edges
	UserToTeam *TeamEdge `json:"user_to_team"`
}

UserModel model info

@Description	Used for User endpoints

func UserEntToModel

func UserEntToModel(entUser *ent.User) UserModel

UserEntToModel converts the result of a User ENT query into a UserModel for API responses

type VmObjectEdge

type VmObjectEdge struct {
	//Fields
	ID          uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`         // Compsole ID
	Name        string    `json:"name" example:"team01.dc.comp.co"`                          // [REQUIRED] A user-friendly name for the VM. This will be provider-specific.
	Identifier  string    `json:"identifier" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // [REQUIRED] The identifier of the VM. This will be provider-specific.
	IpAddresses []string  `json:"ip_addresses" example:"10.0.0.1,100.64.0.1"`                // [OPTIONAL] IP addresses of the VM. This will be displayed to the user.
	Locked      bool      `json:"locked" example:"false"`                                    // [REQUIRED] (default is false) If a vm is locked, standard users will not be able to access this VM.
}

VmObjectModel model info

@Description	Used for VM Object in edges

type VmObjectIdentifierInput

type VmObjectIdentifierInput struct {
	Identifier string `json:"identifier" form:"identifier" binding:"required" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
}

VmObjectInput model info

@Description	Used as an input model for updating VM Object identifiers

type VmObjectInput

type VmObjectInput struct {
	Name           string   `json:"name" form:"name" binding:"required" example:"team01.dc.comp.co"`
	Identifier     string   `json:"identifier" form:"identifier" binding:"required" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
	IpAddresses    []string `json:"ip_addresses" form:"ip_addresses" binding:"required" example:"10.0.0.1,100.64.0.1"`
	VmObjectToTeam string   `json:"vm_object_to_team" form:"vm_object_to_team" binding:"required" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
}

VmObjectInput model info

@Description	Used as an input model for creating/updating VM Objects

type VmObjectModel

type VmObjectModel struct {
	//Fields
	ID          uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`         // Compsole ID
	Name        string    `json:"name" example:"team01.dc.comp.co"`                          // [REQUIRED] A user-friendly name for the VM. This will be provider-specific.
	Identifier  string    `json:"identifier" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // [REQUIRED] The identifier of the VM. This will be provider-specific.
	IpAddresses []string  `json:"ip_addresses" example:"10.0.0.1,100.64.0.1"`                // [OPTIONAL] IP addresses of the VM. This will be displayed to the user.
	Locked      bool      `json:"locked" example:"false"`                                    // [REQUIRED] (default is false) If a vm is locked, standard users will not be able to access this VM.
	// Edges
	VmObjectToTeam *TeamEdge `json:"vm_object_to_team"`
}

VmObjectModel model info

@Description	Used for VM Object endpoints

func VmObjectEntToModel

func VmObjectEntToModel(entVmObject *ent.VmObject) VmObjectModel

VmObjectEntToModel converts the result of a VM Object ENT query into a VmObjectModel for API responses

Jump to

Keyboard shortcuts

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