models

package
v0.0.0-...-30a92e5 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUUID

func CreateUUID(scope *gorm.Scope)

CreateUUID creates the UUID of a model.

Types

type AuthenticationProvider

type AuthenticationProvider struct {
	// Inherit properties from base model.
	Model

	Name         string `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug         string `json:"slug,omitempty" validate:"required,min=1,max=200,printascii" gorm:"size:200;unique_index"`
	ClientKey    string `json:"client_key,omitempty" validate:"required,min=1,max=200" gorm:"size:200"`
	ClientSecret string `json:"client_secret,omitempty" validate:"required,min=1,max=200" gorm:"size:200"`
	Provider     string `json:"provider,omitempty" validate:"required,max=200,oneof=gitlab google" gorm:"size:200"`
	Global       bool   `json:"global,omitempty"`
}

AuthenticationProvider represents an OAuth 2.0 or OpenID Connect provider, such as Azure AD, GitLab or Google.

func (*AuthenticationProvider) BeforeCreate

func (a *AuthenticationProvider) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*AuthenticationProvider) BeforeSave

func (a *AuthenticationProvider) BeforeSave(scope *gorm.Scope) error

BeforeSave will sanitize fields to remove potentially dangerous characters.

type AuthenticationProviderPayload

type AuthenticationProviderPayload struct {
	Name         string `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug         string `json:"slug,omitempty" validate:"required,min=1,max=200,printascii" gorm:"size:200;unique_index"`
	ClientKey    string `json:"client_key,omitempty" validate:"required,min=1,max=200" gorm:"size:200"`
	ClientSecret string `json:"client_secret,omitempty" validate:"required,min=1,max=200" gorm:"size:200"`
	Provider     string `json:"provider,omitempty" validate:"required,max=200,oneof=gitlab google" gorm:"size:200"`
	Global       bool   `json:"global,omitempty"`
}

AuthenticationProviderPayload is the data that is accessible via the request body.

type Model

type Model struct {
	ID        string     `json:"id" validate:"-" gorm:"primary_key"`
	CreatedAt time.Time  `json:"created_at" validate:"-" gorm:"index"`
	UpdatedAt time.Time  `json:"updated_at" validate:"-" gorm:"index"`
	DeletedAt *time.Time `json:"deleted_at,omitempty" validate:"-" gorm:"index"`
}

Model is the base model which includes all shared properties.

type Organisation

type Organisation struct {
	// Inherit properties from base model.
	Model

	Name        string    `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug        string    `json:"slug,omitempty" validate:"required,min=1,max=200,printascii,ne=guest,ne=global" gorm:"size:200;unique_index"`
	Description string    `json:"description,omitempty" validate:"omitempty,max=1000" gorm:"size:1000"`
	AvatarURL   string    `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
	Projects    []Project `json:"-"`
}

Organisation can be a company, a group or a legal entity.

func (*Organisation) BeforeCreate

func (o *Organisation) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*Organisation) BeforeSave

func (o *Organisation) BeforeSave(scope *gorm.Scope) error

BeforeSave will sanitize fields to remove potentially dangerous characters.

type OrganisationPayload

type OrganisationPayload struct {
	Name        string `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug        string `json:"slug,omitempty" validate:"required,min=1,max=200,printascii,ne=guest,ne=global" gorm:"size:200;unique_index"`
	Description string `json:"description,omitempty" validate:"omitempty,max=1000" gorm:"size:1000"`
	AvatarURL   string `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
}

OrganisationPayload is the data that is accessible via the request body.

type Project

type Project struct {
	// Inherit properties from base model.
	Model

	Name           string `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug           string `json:"slug,omitempty" validate:"required,min=1,max=200,printascii" gorm:"size:200;unique_index"`
	Description    string `json:"description,omitempty" validate:"omitempty,max=1000" gorm:"size:1000"`
	AvatarURL      string `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
	OrganisationID string `json:"organisation_id,omitempty" validate:"required,uuid4"`
}

Project groups assets within an organisation.

func (*Project) BeforeCreate

func (p *Project) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*Project) BeforeSave

func (p *Project) BeforeSave(scope *gorm.Scope) error

BeforeSave will sanitize fields to remove potentially dangerous characters.

type ProjectPayload

type ProjectPayload struct {
	Name           string `json:"name,omitempty" validate:"required,min=1,max=200" gorm:"size:200;unique_index"`
	Slug           string `json:"slug,omitempty" validate:"required,min=1,max=200,printascii" gorm:"size:200;unique_index"`
	Description    string `json:"description,omitempty" validate:"omitempty,max=1000" gorm:"size:1000"`
	AvatarURL      string `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
	OrganisationID string `json:"organisation_id,omitempty" validate:"required,uuid4"`
}

ProjectPayload is the data that is accessible via the request body.

type User

type User struct {
	// Inherit properties from base model.
	Model

	FirstName string `json:"first_name,omitempty" validate:"required,min=2,max=200" gorm:"size:200"`
	LastName  string `json:"last_name,omitempty" validate:"required,min=2,max=200" gorm:"size:200"`
	Email     string `json:"email,omitempty" validate:"required,max=200,email" gorm:"size:200;unique_index"`
	AvatarURL string `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
}

User is an application user.

func (*User) BeforeCreate

func (u *User) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*User) BeforeSave

func (u *User) BeforeSave(scope *gorm.Scope) error

BeforeSave will sanitize fields to remove potentially dangerous characters.

type UserPayload

type UserPayload struct {
	FirstName string `json:"first_name,omitempty" validate:"required,min=2,max=200" gorm:"size:200"`
	LastName  string `json:"last_name,omitempty" validate:"required,min=2,max=200" gorm:"size:200"`
	Email     string `json:"email,omitempty" validate:"required,max=200,email" gorm:"size:200;unique_index"`
	AvatarURL string `json:"avatar_url,omitempty" validate:"omitempty,max=500,url" gorm:"size:500"`
}

UserPayload is the data that is accessible via the request body.

Jump to

Keyboard shortcuts

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