model

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

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	ID        string         `gorm:"primarykey'not null" jsonapi:"primary,backends" json:"id,omitempty"`
	CreatedAt time.Time      `jsonapi:"attribute" json:"created_at,omitempty"`
	UpdatedAt time.Time      `jsonapi:"attribute" json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Name      string         `gorm:"uniqueIndex;not null" jsonapi:"attribute" json:"name"`
	Zones     []*Zone        `gorm:"many2many:backend_zones;" jsonapi:"relationship" json:"zones,omitempty"`
}

func (*Backend) AddZone

func (b *Backend) AddZone(db *gorm.DB, zone *Zone) (err error)

AddZone adds a zone to the backend

func (*Backend) BeforeCreate

func (b *Backend) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate generates a new ULID for the backend if needed

func (*Backend) Delete

func (b *Backend) Delete(db *gorm.DB) (err error)

Delete deletes the backend from the database

func (*Backend) Get

func (b *Backend) Get(db *gorm.DB, preload bool) (err error)

Get returns the backend with the given id

func (b *Backend) Link() *jsonapi.Link

Link returns the link to the backend

func (*Backend) LinkRelation

func (b *Backend) LinkRelation(relation string) *jsonapi.Link

LinkRelation returns the link to the relationship

func (*Backend) RemoveZone

func (b *Backend) RemoveZone(db *gorm.DB, zone *Zone) (err error)

RemoveZone removes a zone from the backend

func (*Backend) ReplaceZones

func (b *Backend) ReplaceZones(db *gorm.DB, zones []*Zone) (err error)

ReplaceZones replaces the zones of the backend

func (*Backend) Update

func (b *Backend) Update(db *gorm.DB, backend Backend) (err error)

Update a backend in the database

type Record

type Record struct {
	ID        string         `gorm:"primarykey;not null" jsonapi:"primary,records"`
	CreatedAt time.Time      `jsonapi:"attribute" json:"created_at,omitempty"`
	UpdatedAt time.Time      `jsonapi:"attribute" json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Name      string         `gorm:"uniqueIndex;not null" jsonapi:"attribute" json:"name"`
	TTL       int            `gorm:"not null;default:3600" jsonapi:"attribute" json:"ttl"`
	Type      string         `gorm:"not null" jsonapi:"attribute" json:"type"`
	Content   string         `gorm:"not null" jsonapi:"attribute" json:"content"`
	Zone      *Zone          `gorm:"-" jsonapi:"relationship" json:"zones"`
	ZoneID    string         `gorm:"foreignKey:ZoneID" json:"-"`
}

func (*Record) BeforeCreate

func (r *Record) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate generates a new ULID for the record if needed TOOO: Implement data validation for the record type and content

func (*Record) Delete

func (r *Record) Delete(db *gorm.DB) error

Delete the record

func (*Record) DeleteZone

func (r *Record) DeleteZone(db *gorm.DB) error

DeleteZone deletes the zone of the record

func (*Record) Get

func (r *Record) Get(db *gorm.DB, preload bool) error

Get the record

func (r *Record) Link() *jsonapi.Link

Link returns the link to the resource

func (*Record) LinkRelation

func (r *Record) LinkRelation(relation string) *jsonapi.Link

LinkRelation returns the link to the related resource

func (*Record) ReplaceZone

func (r *Record) ReplaceZone(db *gorm.DB, zone *Zone) error

ReplaceZone replaces the zone of the record

func (*Record) Update

func (r *Record) Update(db *gorm.DB, record Record) error

Update the record

type Zone

type Zone struct {
	ID        string         `gorm:"primarykey,not null" jsonapi:"primary,zones"`
	CreatedAt time.Time      `jsonapi:"attribute" json:"created_at,omitempty"`
	UpdatedAt time.Time      `jsonapi:"attribute" json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Name      string         `gorm:"uniqueIndex;not null" jsonapi:"attribute" json:"name"`
	TTL       int            `gorm:"default:3600" jsonapi:"attribute" json:"ttl"`
	MName     string         `gorm:"default:@;not null" jsonapi:"attribute" json:"mname"`
	RName     string         `gorm:"default:admin;not null" jsonapi:"attribute" json:"rname"`
	Serial    int            `gorm:"default:1" jsonapi:"attribute" json:"serial"`
	Refresh   int            `gorm:"default:3600" jsonapi:"attribute" json:"refresh"`
	Retry     int            `gorm:"default:600" jsonapi:"attribute" json:"retry"`
	Expire    int            `gorm:"default:604800" jsonapi:"attribute" json:"expire"`
	Minimum   int            `gorm:"default:3600" jsonapi:"attribute" json:"minimum"`
	Records   []*Record      `gorm:"foreignKey:ZoneID" jsonapi:"relationship" json:"records,omitempty"`
	Backends  []*Backend     `gorm:"many2many:backend_zones;" jsonapi:"relationship" json:"backends,omitempty"`
}

func (*Zone) AddBackend

func (z *Zone) AddBackend(db *gorm.DB, backend *Backend) (err error)

AddBackend adds a zone to the zone

func (*Zone) AddRecord

func (z *Zone) AddRecord(db *gorm.DB, record *Record) (err error)

AddRecord adds a record to the zone

func (*Zone) BeforeCreate

func (z *Zone) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate generates a new ULID for the zone if needed

func (*Zone) Delete

func (z *Zone) Delete(db *gorm.DB) (err error)

Delete a zone

func (*Zone) Get

func (z *Zone) Get(db *gorm.DB, preload bool) (err error)

Get a zone

func (z *Zone) Link() *jsonapi.Link

Link returns the link to the resource

func (*Zone) LinkRelation

func (z *Zone) LinkRelation(relation string) *jsonapi.Link

LinkRelation returns the link to the related resource

func (*Zone) RemoveBackend

func (z *Zone) RemoveBackend(db *gorm.DB, backend *Backend) (err error)

RemoveBackend removes a backend from the zone

func (*Zone) RemoveRecord

func (z *Zone) RemoveRecord(db *gorm.DB, record *Record) (err error)

RemoveRecord removes a record from the zone

func (*Zone) ReplaceBackends

func (z *Zone) ReplaceBackends(db *gorm.DB, backends []*Backend) (err error)

ReplaceBackends replaces all backends of the zone

func (*Zone) ReplaceRecords

func (z *Zone) ReplaceRecords(db *gorm.DB, records []*Record) (err error)

ReplaceRecords replaces all records of the zone

func (*Zone) Update

func (z *Zone) Update(db *gorm.DB, zone Zone) (err error)

Update a zone

Jump to

Keyboard shortcuts

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