models

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connection

func Connection() *gorm.DB

Types

type Contact

type Contact struct {
	gorm.Model

	Name           string
	EMail          string `gorm:"not null;unique"`
	PasswordDigest string
	Admin          bool
}

func AuthContactWithPassword

func AuthContactWithPassword(email, password string) (*Contact, string, error)

func AuthContactWithToken

func AuthContactWithToken(token string) (*Contact, error)

func CreateContact

func CreateContact(name, email, password string) (*Contact, string, error)

func FindContactByEmail added in v0.1.2

func FindContactByEmail(email string) (*Contact, error)

func (*Contact) DelToken added in v0.1.2

func (c *Contact) DelToken(token string)

func (*Contact) GenerateToken

func (c *Contact) GenerateToken() string

func (*Contact) Mirrors added in v0.1.3

func (c *Contact) Mirrors() *MirrorCollection

func (*Contact) ToProto

func (c *Contact) ToProto() *pb.Contact

func (*Contact) Update added in v0.1.2

func (c *Contact) Update(cpb *pb.Contact, token string) (*Contact, string)

type Mirror

type Mirror struct {
	gorm.Model

	ContactID        int32
	IPv4             string
	IPv6             string
	Domain           string
	LocalDestination string
	Name             string

	Traffic   int64
	Bandwidth int64
	Storage   int64

	ClientToken string

	ServiceEndpointID int32
	ServiceID         int32
}

func FindMirrorById added in v0.1.3

func FindMirrorById(id int32) (*Mirror, error)

func MirrorFromProto

func MirrorFromProto(p *pb.Mirror) *Mirror

func (*Mirror) BeforeCreate added in v0.1.3

func (m *Mirror) BeforeCreate()

func (*Mirror) FetchServices

func (m *Mirror) FetchServices() *ServiceCollection

func (*Mirror) Service added in v0.3.0

func (m *Mirror) Service() (*Service, error)

func (*Mirror) ServiceEndpoint added in v0.1.3

func (m *Mirror) ServiceEndpoint() *Mirror

func (*Mirror) ToProto

func (m *Mirror) ToProto(nested ...bool) *pb.Mirror

func (*Mirror) Update added in v0.1.3

func (m *Mirror) Update(request *pb.Mirror) error

type MirrorCollection

type MirrorCollection struct {
	Mirrors []*Mirror
}

func MirrorList

func MirrorList(limit int, offset int) *MirrorCollection

func (*MirrorCollection) ToProto

func (mc *MirrorCollection) ToProto() []*pb.Mirror

type Service

type Service struct {
	gorm.Model

	Name     string
	Storage  int64
	FileList string
}

func FindServiceById added in v0.2.0

func FindServiceById(id int32) (*Service, error)

func ServiceFromProto

func ServiceFromProto(s *pb.Service) *Service

func (*Service) Files added in v0.2.0

func (s *Service) Files() []string

func (*Service) ToProto

func (s *Service) ToProto() *pb.Service

type ServiceCollection

type ServiceCollection struct {
	Services []*Service
	Proto    []*pb.Service
}

func ServiceList added in v0.2.0

func ServiceList(limit int, offset int) *ServiceCollection

func (*ServiceCollection) ToProto

func (sc *ServiceCollection) ToProto() []*pb.Service

func (*ServiceCollection) ToServices

func (sc *ServiceCollection) ToServices() []*Service

Jump to

Keyboard shortcuts

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