postgres

package
v0.0.0-...-c9063be Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFilterType = errors.New("invalid filter type")
)

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB) error

func CreateDB

func CreateDB(dbUser, dbPass, dbHost, dbName, dbPort string) error

func FromDBContact

func FromDBContact(c *Contact) *entities.Contact

FromDBContact converts a database Contact to a domain entities.Contact

func FromDBRegistrar

func FromDBRegistrar(dbr *Registrar) *entities.Registrar

func FromDBTLD

func FromDBTLD(dbtld *TLD) *entities.TLD

FromDBTLD converts a DBTLD struct to a TLD struct

func NewConnection

func NewConnection(cfg Config) (*gorm.DB, error)

func ToDomain

func ToDomain(dbDom *Domain) *entities.Domain

ToDomain converts a Domain to a domain model *entities.Domain

func ToHost

func ToHost(dbHost *Host) *entities.Host

ToHost converts a postgres.Host to an entities.Host

func ToHostAddress

func ToHostAddress(dbHostAddress *HostAddress) netip.Addr

ToHostAddress converts a postgres.HostAddress to an netip.Addr

func ToIanaRegistrar

func ToIanaRegistrar(dbRegistrar *IANARegistrar) *entities.IANARegistrar

ToIanaRegistrar converts a DB IANARegistrar to a domain IANARegistrar

func ToSpec5Label

func ToSpec5Label(label *Spec5Label) *entities.Spec5Label

ToSpec5Label converts a DBSpec5Label struct to a Spec5Label struct

Types

type AAAARecordData

type AAAARecordData struct {
	Address string `json:"address"`
}

AAAARecordData represents the data for an AAAA record use it to marshal/unmarshal the data field in DNSRecord

type ARecordData

type ARecordData struct {
	Address string `json:"address"`
}

ARecordData represents the data for an A record use it to marshal/unmarshal the data field in DNSRecord

type AccreditationRepository

type AccreditationRepository struct {
	// contains filtered or unexported fields
}

AccreditationRepository implements the AccreditationRepository interface

func NewAccreditationRepository

func NewAccreditationRepository(db *gorm.DB) *AccreditationRepository

NewAccreditationRepository creates a new AccreditationRepository

func (*AccreditationRepository) CreateAccreditation

func (r *AccreditationRepository) CreateAccreditation(ctx context.Context, tldName, rarClID string) error

CreateAccreditation creates a new accreditation

func (*AccreditationRepository) DeleteAccreditation

func (r *AccreditationRepository) DeleteAccreditation(ctx context.Context, tldName, rarClID string) error

DeleteAccreditation deletes an accreditation

func (*AccreditationRepository) ListRegistrarTLDs

func (r *AccreditationRepository) ListRegistrarTLDs(ctx context.Context, pageSize int, cursor string, rarClID string) ([]*entities.TLD, error)

ListRegistrarTLDs lists TLDs for a registrar

func (*AccreditationRepository) ListTLDRegistrars

func (r *AccreditationRepository) ListTLDRegistrars(ctx context.Context, pageSize int, cursor string, tldName string) ([]*entities.Registrar, error)

ListTLDRegistrars lists registrars for a TLD

type ActiveDomainQueryResult

type ActiveDomainQueryResult struct {
	Domain string
	Host   string
}

GetHostsForDomain retrieves the hosts associated with an active domain

type CNAMERecordData

type CNAMERecordData struct {
	Target string `json:"target"`
}

CNAMERecordData represents the data for a CNAME record use it to marshal/unmarshal the data field in DNSRecord

type Config

type Config struct {
	User        string
	Pass        string
	Host        string
	Port        string
	DBName      string
	SSLmode     string
	AutoMigrate bool
}

type Contact

type Contact struct {
	// ID is the ID of the contact as provided by the registrar.
	ID                       string `gorm:"primaryKey"`
	RoID                     int64  `gorm:"uniqueIndex;not null"` // we use the int64 representation of our roid to allow time based sorting using roid
	Voice                    string
	Fax                      string
	Email                    string
	ClID                     string
	CrRr                     *string
	UpRr                     *string
	AuthInfo                 string `gorm:"not null"`
	CreatedAt                time.Time
	UpdatedAt                time.Time
	NameInt                  string
	OrgInt                   string
	Street1Int               string
	Street2Int               string
	Street3Int               string
	CityInt                  string
	SPInt                    string `gorm:"column:sp_int"`
	PCInt                    string `gorm:"column:pc_int"`
	CCInt                    string `gorm:"column:cc_int"`
	NameLoc                  string
	OrgLoc                   string
	Street1Loc               string
	Street2Loc               string
	Street3Loc               string
	CityLoc                  string
	SPLoc                    string `gorm:"column:sp_loc"`
	PCLoc                    string `gorm:"column:pc_loc"`
	CCLoc                    string `gorm:"column:cc_loc"`
	entities.ContactStatus   `gorm:"embedded"`
	entities.ContactDisclose `gorm:"embedded"`

	// FK relationships with domains
	DomsWhereRegistrant []*Domain `gorm:"foreignKey:RegistrantID"`
	DomsWhereAdmin      []*Domain `gorm:"foreignKey:AdminID"`
	DomsWhereTech       []*Domain `gorm:"foreignKey:TechID"`
	DomsWhereBilling    []*Domain `gorm:"foreignKey:BillingID"`
}

Contact is the Gorm model for the Contact entity.

func ToDBContact

func ToDBContact(c *entities.Contact) *Contact

ToDBContact converts a domain entities.Contact to a database Contact

func (*Contact) TableName

func (r *Contact) TableName() string

TableName specifies the table name for contacts

type ContactRepository

type ContactRepository struct {
	// contains filtered or unexported fields
}

ContactRepository implements the ContactRepository interface

func NewContactRepository

func NewContactRepository(db *gorm.DB) *ContactRepository

NewContactRepository creates a new ContactRepository

func (*ContactRepository) BulkCreate

func (r *ContactRepository) BulkCreate(ctx context.Context, contacts []*entities.Contact) error

BulkCreate creates multiple contacts at once

func (*ContactRepository) CreateContact

func (r *ContactRepository) CreateContact(ctx context.Context, c *entities.Contact) (*entities.Contact, error)

CreateContact creates a new contact

func (*ContactRepository) DeleteContactByID

func (r *ContactRepository) DeleteContactByID(ctx context.Context, id string) error

DeleteContactByID deletes a contact from the database

func (*ContactRepository) GetContactByID

func (r *ContactRepository) GetContactByID(ctx context.Context, id string) (*entities.Contact, error)

GetContactByID retrieves a contact from the database by its ID

func (*ContactRepository) ListContacts

func (r *ContactRepository) ListContacts(ctx context.Context, params queries.ListItemsQuery) ([]*entities.Contact, string, error)

ListContacts returns a list of contacts

func (*ContactRepository) UpdateContact

func (r *ContactRepository) UpdateContact(ctx context.Context, c *entities.Contact) (*entities.Contact, error)

UpdateContact updates a contact in the database

type DNSKEYRecordData

type DNSKEYRecordData struct {
	Flags     uint16 `json:"flags"`
	Protocol  uint8  `json:"protocol"`
	Algorithm uint8  `json:"algorithm"`
	PublicKey string `json:"publicKey"`
}

DNSKEYRecordData represents the data for a DNSKEY record use it to marshal/unmarshal the data field in DNSRecord

type DNSRecordRepository

type DNSRecordRepository struct {
	// contains filtered or unexported fields
}

DNSRecordRepository implements the DNSRecordRepository interface

func NewGormDNSRecordRepository

func NewGormDNSRecordRepository(db *gorm.DB) *DNSRecordRepository

NewGormDNSRecordRepository returns a new DNSRecordRepository using Gorm

func (*DNSRecordRepository) Create

func (r *DNSRecordRepository) Create(ctx context.Context, record *TLDDNSRecord) (*TLDDNSRecord, error)

Create creates a new DNS record in the database

func (*DNSRecordRepository) Delete

func (r *DNSRecordRepository) Delete(ctx context.Context, id int) error

Delete deletes a DNS record from the database

func (*DNSRecordRepository) GetByZone

func (r *DNSRecordRepository) GetByZone(ctx context.Context, zone string) ([]*TLDDNSRecord, error)

GetByZone returns all DNS records for a given zone

type DSRecordData

type DSRecordData struct {
	KeyTag     uint16 `json:"keyTag"`
	Algorithm  uint8  `json:"algorithm"`
	DigestType uint8  `json:"digestType"`
	Digest     string `json:"digest"`
}

DSRecordData represents the data for a DS record use it to marshal/unmarshal the data field in DNSRecord

type Domain

type Domain struct {
	RoID                          int64  `gorm:"primaryKey"`
	Name                          string `gorm:"uniqueIndex;not null"`
	OriginalName                  string
	UName                         string
	RegistrantID                  *string // These are optional, prohibited or mandatory based on ContactDataPolicy
	AdminID                       *string // These are optional, prohibited or mandatory based on ContactDataPolicy
	TechID                        *string // These are optional, prohibited or mandatory based on ContactDataPolicy
	BillingID                     *string // These are optional, prohibited or mandatory based on ContactDataPolicy
	ClID                          string
	CrRr                          *string
	UpRr                          *string
	TLDName                       string `gorm:"not null;foreignKey"`
	TLD                           TLD
	ExpiryDate                    time.Time `gorm:"not null;index"`
	DropCatch                     bool
	RenewedYears                  int
	AuthInfo                      string `gorm:"not null"`
	CreatedAt                     time.Time
	UpdatedAt                     time.Time
	entities.DomainStatus         `gorm:"embedded"`
	entities.DomainRGPStatus      `gorm:"embedded"`
	entities.DomainGrandFathering `gorm:"embedded"`
	Hosts                         []Host `gorm:"many2many:domain_hosts;"`
}

Domain is the GORM model for the Domain entity

func ToDBDomain

func ToDBDomain(d *entities.Domain) *Domain

FromDomain converts a domain model *entities.Domain to a Domain

func (Domain) TableName

func (Domain) TableName() string

TableName returns the table name for the Domain model

type DomainRepository

type DomainRepository struct {
	// contains filtered or unexported fields
}

DomainRepository is the postgres implementation of the DomainRepository Interface

func NewDomainRepository

func NewDomainRepository(db *gorm.DB) *DomainRepository

NewDomainRepository creates a new DomainRepository

func (*DomainRepository) AddHostToDomain

func (dr *DomainRepository) AddHostToDomain(ctx context.Context, domRoID int64, hostRoid int64) error

AddHostToDomain adds a domain_hosts association to the database

func (*DomainRepository) BulkCreate

func (r *DomainRepository) BulkCreate(ctx context.Context, doms []*entities.Domain) error

Bulk Create Creates multiple domains in the repository, useful when importing data. Does not persist Hosts if present

func (*DomainRepository) Count

Count returns the number of domains in the database

func (*DomainRepository) CountExpiringDomains

func (dr *DomainRepository) CountExpiringDomains(ctx context.Context, before time.Time, clid, tld string) (int64, error)

CountExiringDomains returns the number of domains that are expiring within the given number of days

func (*DomainRepository) CountPurgeableDomains

func (dr *DomainRepository) CountPurgeableDomains(ctx context.Context, after time.Time, clid, tld string) (int64, error)

CountPurgeableDomains returns the number of domains that are pending deletion and have passed the grace period

func (*DomainRepository) CountRestoredDomains

func (dr *DomainRepository) CountRestoredDomains(ctx context.Context, clid, tld string) (int64, error)

CountRestoredDomains returns the number of domains that are in pendingRestore state (have been restored using the Domain.Restore() function)

func (*DomainRepository) Create

Create creates a new domain in the database

func (*DomainRepository) DeleteDomainByID

func (dr *DomainRepository) DeleteDomainByID(ctx context.Context, id int64) error

DeleteDomain deletes a domain from the database by its id

func (*DomainRepository) DeleteDomainByName

func (dr *DomainRepository) DeleteDomainByName(ctx context.Context, name string) error

DeleteDomain deletes a domain from the database by its name

func (*DomainRepository) GetActiveDomainGlue

func (dr *DomainRepository) GetActiveDomainGlue(ctx context.Context, tld string) ([]dns.RR, error)

GetActiveDomainGlue gets the glue records for a given TLD

func (*DomainRepository) GetActiveDomainsWithHosts

func (dr *DomainRepository) GetActiveDomainsWithHosts(ctx context.Context, params queries.ActiveDomainsWithHostsQuery) ([]dns.RR, error)

GetActiveDomainsWithHosts gets the domains that are flagged as active and their associated hosts This data is used to build the NS records for a given TLD

func (*DomainRepository) GetDomainByID

func (dr *DomainRepository) GetDomainByID(ctx context.Context, id int64, preloadHosts bool) (*entities.Domain, error)

GetDomainByID retrieves a domain from the database by its ID

func (*DomainRepository) GetDomainByName

func (dr *DomainRepository) GetDomainByName(ctx context.Context, name string, preloadHosts bool) (*entities.Domain, error)

GetDomainByName retrieves a domain from the database by its name it returns ErrDomainNotFound if the domain does not exist

func (*DomainRepository) ListDomains

func (dr *DomainRepository) ListDomains(ctx context.Context, params queries.ListItemsQuery) ([]*entities.Domain, string, error)

ListDomains retrieves domains from the database applying optional filters and cursor-based pagination. It constructs a query that orders domain records by their primary key (ro_id) in ascending order. It supports filtering by various domain attributes such as client ID, TLD name, domain name (both exact and partial matches), ROID, and by creation or expiry dates (before/after).

If a page cursor is provided, the query starts after the given ro_id. The query limits the results to (PageSize + 1) records to determine if there is an additional page. If more results exist than PageSize, a new cursor is set to the ro_id of the last returned domain, enabling further pagination.

func (*DomainRepository) ListExpiringDomains

func (dr *DomainRepository) ListExpiringDomains(ctx context.Context, before time.Time, pagesize int, clid, tld, cursor string) ([]*entities.Domain, error)

ListExpiringDomains returns a list of domains that are expiring before the given time. These domain objects have minimal properties filled: RoID, Name and ExpiryDate

func (*DomainRepository) ListPurgeableDomains

func (dr *DomainRepository) ListPurgeableDomains(ctx context.Context, after time.Time, pagesize int, clid, cursor, tld string) ([]*entities.Domain, error)

ListPurgeableDomains returns a list of domains that are pending deletion and have passed the grace period

func (*DomainRepository) ListRestoredDomains

func (dr *DomainRepository) ListRestoredDomains(ctx context.Context, pagesize int, clid, tld, cursor string) ([]*entities.Domain, error)

ListRestoredDomains returns a list of domains that are in pendingRestore state (have been restored using the Domain.Restore() function)

func (*DomainRepository) RemoveHostFromDomain

func (dr *DomainRepository) RemoveHostFromDomain(ctx context.Context, domRoID int64, hostRoid int64) error

RemoveHostFromDomain removes a domain_hosts association from the database

func (*DomainRepository) UpdateDomain

func (dr *DomainRepository) UpdateDomain(ctx context.Context, d *entities.Domain) (*entities.Domain, error)

UpdateDomain updates a domain in the database

type FX

type FX struct {
	Date      time.Time `gorm:"primaryKey"`
	Base      string    `gorm:"primaryKey"`
	Target    string    `gorm:"primaryKey"`
	Rate      float64
	CreatedAt time.Time
	UpdatedAt time.Time
}

FX represents a foreign exchange rate in the database

func (*FX) FromEntity

func (fx *FX) FromEntity(entity *entities.FX)

FromEntity converts an entities.FX struct to an FX struct

func (FX) TableName

func (FX) TableName() string

TableName returns the table name for the FX model

func (*FX) ToEntity

func (fx *FX) ToEntity() *entities.FX

ToEntity converts the FX struct to an entities.FX struct

type FXRepository

type FXRepository struct {
	// contains filtered or unexported fields
}

FXRepository is the GORM implementation of the FXRepository

func NewFXRepository

func NewFXRepository(db *gorm.DB) *FXRepository

NewFXRepository creates a new FXRepository instance

func (*FXRepository) GetByBaseAndTargetCurrency

func (r *FXRepository) GetByBaseAndTargetCurrency(ctx context.Context, baseCurrency, targetCurrency string) (*entities.FX, error)

GetByBaseAndTargetCurrency gets the exchange rate for a base and target currency

func (*FXRepository) ListByBaseCurrency

func (r *FXRepository) ListByBaseCurrency(ctx context.Context, baseCurrency string) ([]*entities.FX, error)

ListByBaseCurrency lists all exchange rates by base currency

func (*FXRepository) UpdateAll

func (r *FXRepository) UpdateAll(ctx context.Context, fxs []*FX) error

UpdateAll updates all exchange rates in the database

type Fee

type Fee struct {
	Currency   string `gorm:"primaryKey"`
	Name       string `gorm:"primaryKey"`
	Amount     uint64
	Refundable *bool
	PhaseID    int64 `gorm:"primaryKey"`
	Phase      Phase
}

Fee is the GORM model for the phase_fee table. Uses a composite primary key to ensure that a fee with the same currency and name is not inserted twice in a phase

func (*Fee) FromEntity

func (f *Fee) FromEntity(entity *entities.Fee)

FromEntity converts a Fee entity to a Fee model

func (Fee) TableName

func (Fee) TableName() string

TableName returns the table name for the PhaseFee model

func (*Fee) ToEntity

func (f *Fee) ToEntity() *entities.Fee

ToEntity converts a Fee model to a Fee entity

type FeeRepository

type FeeRepository struct {
	DB *gorm.DB
}

FeeRepository is the GORM implementation of the FeeRepository

func NewFeeRepository

func NewFeeRepository(db *gorm.DB) *FeeRepository

NewPhaseFeeRepository creates a new PhaseFeeRepository instance

func (*FeeRepository) CreateFee

func (r *FeeRepository) CreateFee(ctx context.Context, fee *entities.Fee) (*entities.Fee, error)

CreateFee creates a new phase fee in the database

func (*FeeRepository) DeleteFee

func (r *FeeRepository) DeleteFee(ctx context.Context, phaseID int64, name, currency string) error

DeleteFee deletes a phase fee from the database

func (*FeeRepository) GetFee

func (r *FeeRepository) GetFee(ctx context.Context, phaseID int64, name, currency string) (*entities.Fee, error)

GetFee retrieves a phase fee from the database

type GlueQueryResult

type GlueQueryResult struct {
	Host    string
	Address string
	Version int
}

GlueQueryResult is a struct to hold the results of a query for glue records This is used to build the A or AAAA records (GLUE) for a given TLD These records are needed for in-bailiwick NS records

type GormNNDNRepository

type GormNNDNRepository struct {
	// contains filtered or unexported fields
}

GormNNDNRepository implements the Repo interface

func NewGormNNDNRepository

func NewGormNNDNRepository(db *gorm.DB) *GormNNDNRepository

NewGormNNDNRepository returns a new GormNNDNRepository

func (*GormNNDNRepository) Count

func (*GormNNDNRepository) CreateNNDN

func (r *GormNNDNRepository) CreateNNDN(ctx context.Context, nndn *entities.NNDN) (*entities.NNDN, error)

func (*GormNNDNRepository) DeleteNNDN

func (r *GormNNDNRepository) DeleteNNDN(ctx context.Context, name string) error

func (*GormNNDNRepository) GetNNDN

func (r *GormNNDNRepository) GetNNDN(ctx context.Context, name string) (*entities.NNDN, error)

func (*GormNNDNRepository) ListNNDNs

func (*GormNNDNRepository) UpdateNNDN

func (r *GormNNDNRepository) UpdateNNDN(ctx context.Context, nndn *entities.NNDN) (*entities.NNDN, error)

type GormRegistrarRepository

type GormRegistrarRepository struct {
	// contains filtered or unexported fields
}

GormRegistrarRepository implements the RegistrarRepository interface

func NewGormRegistrarRepository

func NewGormRegistrarRepository(db *gorm.DB) *GormRegistrarRepository

NewGormRegistrarRepository returns a new GormRegistrarRepository

func (*GormRegistrarRepository) BulkCreate

func (r *GormRegistrarRepository) BulkCreate(ctx context.Context, rars []*entities.Registrar) error

Bulk Create Creates multiple registrars in the repository

func (*GormRegistrarRepository) Count

Count returns the total number of registrars in the repository

func (*GormRegistrarRepository) Create

Create Creates a new Registrar in the repository

func (*GormRegistrarRepository) Delete

func (r *GormRegistrarRepository) Delete(ctx context.Context, clid string) error

Delete Deletes a registrar from the repository

func (*GormRegistrarRepository) GetByClID

func (r *GormRegistrarRepository) GetByClID(ctx context.Context, clid string, preloadTLDs bool) (*entities.Registrar, error)

GetByClID looks up a Regsitrar by ite ClID and returns it

func (*GormRegistrarRepository) GetByGurID

func (r *GormRegistrarRepository) GetByGurID(ctx context.Context, gurID int) (*entities.Registrar, error)

GetByGurID looks up a Registrar by its GurID and returns it TODO: FIXME: This may retrun multiple results (e.g. 9999), so we need to handle this like a list endpoint

func (*GormRegistrarRepository) IsRegistrarAccreditedForTLD

func (r *GormRegistrarRepository) IsRegistrarAccreditedForTLD(ctx context.Context, tldName, rarClID string) (bool, error)

IsRegistrarAccreditedForTLD checks whether the specified registrar is accredited for a particular top-level domain (TLD). It queries the underlying database to match the provided registrar ID and TLD name, returning true if accreditation is confirmed, and false otherwise. Any query error is also returned.

func (*GormRegistrarRepository) List

List returns a list of registrars

func (*GormRegistrarRepository) Update

Update Updates a registrar in the repository

type GormTLDRepository

type GormTLDRepository struct {
	// contains filtered or unexported fields
}

GormTLDRepository implements the TLDRepo interface

func NewGormTLDRepo

func NewGormTLDRepo(db *gorm.DB) *GormTLDRepository

NewGormTLDRepo returns a new GormTLDRepo

func (*GormTLDRepository) Count

func (repo *GormTLDRepository) Count(ctx context.Context, filter queries.ListTldsFilter) (int64, error)

Count returns the total number of TLDs in the database TODO: add a filter to count only TLDs that match a certain criteria

func (*GormTLDRepository) Create

func (repo *GormTLDRepository) Create(ctx context.Context, tld *entities.TLD) error

Create creates a new TLD in the database

func (*GormTLDRepository) DeleteByName

func (repo *GormTLDRepository) DeleteByName(ctx context.Context, name string) error

Delete deletes a TLD from the database

func (*GormTLDRepository) GetByName

func (repo *GormTLDRepository) GetByName(ctx context.Context, name string, preloadAll bool) (*entities.TLD, error)

GetByName retrieves a TLD by the specified name from the repository. If preloadAll is true, it preloads additional associated phase and pricing and fee details. If no record is found, it returns entities.ErrTLDNotFound; otherwise, it returns any encountered error.

func (*GormTLDRepository) List

List returns a list of all TLDs. TLDs are ordered alphabetically by name and user pagination is supported by pagesize and cursor(name)

func (*GormTLDRepository) Update

func (repo *GormTLDRepository) Update(ctx context.Context, tld *entities.TLD) error

Update updates a TLD in the database

type Host

type Host struct {
	RoID                int64  `gorm:"primaryKey"`
	Name                string `gorm:"uniqueIndex:idx_uniq_name_clid;not null"`
	ClID                string `gorm:"uniqueIndex:idx_uniq_name_clid;not null"`
	CrRr                *string
	UpRr                *string
	InBailiwick         bool
	CreatedAt           time.Time
	UpdatedAt           time.Time
	entities.HostStatus `gorm:"embedded"`
	Addresses           []HostAddress `gorm:"foreignKey:HostRoID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // When the parent host is deleted, delete the addresses
}

Host is the GORM model for the host table

func ToDBHost

func ToDBHost(host *entities.Host) *Host

ToDBHost converts an entities.Host to a postgres.Host

func (Host) TableName

func (Host) TableName() string

TableName returns the table name for the Host model

type HostAddress

type HostAddress struct {
	HostRoID int64  `gorm:"primaryKey"`
	Address  string `gorm:"primaryKey"`
	Version  int
}

HostAddress is the GORM model for the host_address table

func ToDBHostAddress

func ToDBHostAddress(addr netip.Addr, hostRoID int64) *HostAddress

ToDBHostAddress converts a netip.Addr to a postgres.HostAddress

func (HostAddress) TableName

func (HostAddress) TableName() string

TableName returns the table name for the HostAddress model

type HostAddressRepository

type HostAddressRepository struct {
	// contains filtered or unexported fields
}

HostAddressRepository is the postgres implementation of the HostAddressRepository

func NewGormHostAddressRepository

func NewGormHostAddressRepository(db *gorm.DB) *HostAddressRepository

NewGormHostAddressRepository creates a new instance of HostAddressRepository

func (*HostAddressRepository) CreateHostAddress

func (r *HostAddressRepository) CreateHostAddress(ctx context.Context, hostRoid int64, addr *netip.Addr) (*netip.Addr, error)

CreateHostAddress creates a new host address

func (*HostAddressRepository) DeleteHostAddressByHostRoidAndAddress

func (r *HostAddressRepository) DeleteHostAddressByHostRoidAndAddress(ctx context.Context, hostRoid int64, addr *netip.Addr) error

DeleteHostAddressByHostRoidAndAddress deletes a host address by the host roid and address

func (*HostAddressRepository) GetHostAddressesByHostRoid

func (r *HostAddressRepository) GetHostAddressesByHostRoid(ctx context.Context, hostRoid int64) ([]netip.Addr, error)

GetHostAddressesByHostRoid gets all host addresses by the host roid

type HostRepository

type HostRepository struct {
	// contains filtered or unexported fields
}

HostRepository is the postgres implementation of the HostRepository

func NewGormHostRepository

func NewGormHostRepository(db *gorm.DB) *HostRepository

NewGormHostRepository creates a new instance of HostRepository

func (*HostRepository) BulkCreate

func (r *HostRepository) BulkCreate(ctx context.Context, hosts []*entities.Host) error

BulkCreate creates multiple hosts in a single transaction. If addresses are provided, they will be created as well Should one of the hosts fail to be created, the operation fails and no hosts are created, the error will be returned

func (*HostRepository) CreateHost

func (r *HostRepository) CreateHost(ctx context.Context, host *entities.Host) (*entities.Host, error)

CreateHost creates a new host and does NOT create the addresses

func (*HostRepository) DeleteHostByRoid

func (r *HostRepository) DeleteHostByRoid(ctx context.Context, roid int64) error

DeleteHostByRoid deletes a host by its roid

func (*HostRepository) GetHostAssociationCount

func (r *HostRepository) GetHostAssociationCount(ctx context.Context, roid int64) (int64, error)

GetHostAssociationCount returns the number of domains a host is associated with. This can be used to determine if a host needs the linked flag to be unset

func (*HostRepository) GetHostByNameAndClID

func (r *HostRepository) GetHostByNameAndClID(ctx context.Context, name string, clid string) (*entities.Host, error)

GetHostByNameAndClID gets a host by its name and clid

func (*HostRepository) GetHostByRoid

func (r *HostRepository) GetHostByRoid(ctx context.Context, roid int64) (*entities.Host, error)

GetHostByRoid gets a host by its roid

func (*HostRepository) ListHosts

func (r *HostRepository) ListHosts(ctx context.Context, params queries.ListItemsQuery) ([]*entities.Host, string, error)

ListHosts lists hosts

func (*HostRepository) UpdateHost

func (r *HostRepository) UpdateHost(ctx context.Context, host *entities.Host) (*entities.Host, error)

UpdateHost updates a host

type IANARegistrar

type IANARegistrar struct {
	GurID     int `gorm:"primary_key;auto_increment:false"`
	Name      string
	Status    string
	RdapURL   string
	CreatedAt time.Time
}

IANARegistrar is a struct representing an IANA Registrar in the database

func ToDBIANARegistrar

func ToDBIANARegistrar(registrar *entities.IANARegistrar) *IANARegistrar

ToDBIANARegistrar converts a domain IANARegistrar to a DB IANARegistrar

func (IANARegistrar) TableName

func (IANARegistrar) TableName() string

type IANARegistrarRepository

type IANARegistrarRepository struct {
	// contains filtered or unexported fields
}

IANARegistrarRepository implements the IANARegistrarRepository interface

func NewIANARegistrarRepository

func NewIANARegistrarRepository(db *gorm.DB) *IANARegistrarRepository

NewIANARegistrarRepository returns a new IANARegistrarRepository

func (*IANARegistrarRepository) Count

func (r *IANARegistrarRepository) Count(ctx context.Context) (int, error)

Count returns the number of IANARegistrars in the database

func (*IANARegistrarRepository) GetByGurID

func (r *IANARegistrarRepository) GetByGurID(ctx context.Context, gurID int) (*entities.IANARegistrar, error)

GetByGurID Retrieves gets a IANARegistrar by GurID

func (*IANARegistrarRepository) List

func (r *IANARegistrarRepository) List(ctx context.Context, pageSize int, pageCursor, nameSearchString, status string) ([]*entities.IANARegistrar, error)

ListAll returns all IANARegistrars in the database

func (*IANARegistrarRepository) UpdateAll

func (r *IANARegistrarRepository) UpdateAll(ctx context.Context, registrars []*entities.IANARegistrar) error

UpdateAll updates all IANARegistrars in the database

type MXRecordData

type MXRecordData struct {
	Preference uint16 `json:"preference"`
	Exchange   string `json:"exchange"`
}

MXRecordData represents the data for an MX record use it to marshal/unmarshal the data field in DNSRecord

type NNDN

type NNDN struct {
	Name      string `gorm:"primaryKey"` // ASCII Name as primary key
	UName     string // Unicode Name, should only be populated if the blocked string is an IDN
	TLDName   string `gorm:"not null;foreignKey"` // TLD Name as a foreign key
	TLD       TLD
	NameState string `gorm:"not null"` // State of the NNDN, not null
	Reason    string // Reason for the NNDN being blocked
	CreatedAt time.Time
	UpdatedAt time.Time
}

NNDN is the GORM representation of an NNDN object for database interaction.

func (NNDN) TableName

func (NNDN) TableName() string

TableName specifies the table Name for NNDN.

type NSRecordData

type NSRecordData struct {
	Ns string `json:"ns"`
}

NSRecordData represents the data for an NS record use it to marshal/unmarshal the data field in DNSRecord

type PTRRecordData

type PTRRecordData struct {
	Ptr string `json:"ptr"`
}

PTRRecordData represents the data for a PTR record use it to marshal/unmarshal the data field in DNSRecord

type Phase

type Phase struct {
	ID              int64  `gorm:"primaryKey"`
	Name            string `gorm:"uniqueIndex:idx_unq_name_tld,not null"`
	Type            string `gorm:"index"`
	Starts          time.Time
	Ends            *time.Time
	Prices          []Price `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Fees            []Fee   `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	PremiumListName *string
	PremiumList     *PremiumList
	CreatedAt       time.Time
	UpdatedAt       time.Time
	TLDName         string `gorm:"uniqueIndex:idx_unq_name_tld,not null"`
	// TLD                  TLD    // This creates the foreign key relationship
	entities.PhasePolicy `gorm:"embedded"`
}

Phase GORM entity. ID is the primary key and we add a composite unique index ond tldname+name to facilitate human friendly queries

func (*Phase) FromEntity

func (p *Phase) FromEntity(phase *entities.Phase)

FromEntity converts a domain model *entities.Phase to a Phase

func (Phase) TableName

func (Phase) TableName() string

TableName returns the table name for the Phase model

func (*Phase) ToEntity

func (p *Phase) ToEntity() *entities.Phase

ToEntity converts a Phase to a domain model *entities.Phase

type PhaseRepository

type PhaseRepository struct {
	// contains filtered or unexported fields
}

PhaseRepository is the GORM postgres implementation of the PhaseRepository interface

func NewGormPhaseRepository

func NewGormPhaseRepository(db *gorm.DB) *PhaseRepository

NewGormPhaseRepository creates a new instance of PhaseRepository

func (*PhaseRepository) CreatePhase

func (r *PhaseRepository) CreatePhase(ctx context.Context, phase *entities.Phase) (*entities.Phase, error)

CreatePhase creates a new phase

func (*PhaseRepository) DeletePhaseByTLDAndName

func (r *PhaseRepository) DeletePhaseByTLDAndName(ctx context.Context, tld, name string) error

DeletePhaseByName deletes a phase by its name

func (*PhaseRepository) GetPhaseByTLDAndName

func (r *PhaseRepository) GetPhaseByTLDAndName(ctx context.Context, tld, name string) (*entities.Phase, error)

GetPhaseByTLDAndName gets a phase by its name

func (*PhaseRepository) ListActiveGAPhases

func (r *PhaseRepository) ListActiveGAPhases(ctx context.Context, pageSize int, pageCursor string) ([]*entities.Phase, error)

ListActiveGAPhases lists all active phases for all TLDs

func (*PhaseRepository) ListPhasesByTLD

func (r *PhaseRepository) ListPhasesByTLD(ctx context.Context, tld string, pageSize int, pageCursor string) ([]*entities.Phase, error)

ListPhasesByTLD lists all phases for a TLD

func (*PhaseRepository) UpdatePhase

func (r *PhaseRepository) UpdatePhase(ctx context.Context, phase *entities.Phase) (*entities.Phase, error)

UpdatePhase updates a phase. It will Omit Price and Fee updates. Use specific prices and fees repository for that

type PremiumLabel

type PremiumLabel struct {
	ID                 int64  `gorm:"primaryKey"`
	Label              string `gorm:"uniqueIndex:idx_uniq_label_list_cur;not null"`
	PremiumListName    string `gorm:"uniqueIndex:idx_uniq_label_list_cur;not null"`
	RegistrationAmount uint64
	RenewalAmount      uint64
	TransferAmount     uint64
	RestoreAmount      uint64
	Currency           string `gorm:"uniqueIndex:idx_uniq_label_list_cur;not null"`
	Class              string
}

PremiumLabel represents a premium label in our repository

func FromEntity

func FromEntity(pl *entities.PremiumLabel) *PremiumLabel

FromEntity converts the domain entity to a PremiumLabel

func (PremiumLabel) TableName

func (PremiumLabel) TableName() string

TableName returns the table name for the PremiumLabel model

func (*PremiumLabel) ToEntity

func (pl *PremiumLabel) ToEntity() *entities.PremiumLabel

ToEntity converts the PremiumLabel to a domain entity

type PremiumLabelRepository

type PremiumLabelRepository struct {
	// contains filtered or unexported fields
}

PremiumListRepository implements the PremiumListRepository interface

func NewGORMPremiumLabelRepository

func NewGORMPremiumLabelRepository(db *gorm.DB) *PremiumLabelRepository

NewPremiumListRepository creates a new PremiumListRepository instance

func (*PremiumLabelRepository) Create

Create creates a new premium list in the database

func (*PremiumLabelRepository) DeleteByLabelListAndCurrency

func (plr *PremiumLabelRepository) DeleteByLabelListAndCurrency(ctx context.Context, label, list, currency string) error

DeleteByLabelListAndCurrency deletes a premium label by label, list, and currency

func (*PremiumLabelRepository) GetByLabelListAndCurrency

func (plr *PremiumLabelRepository) GetByLabelListAndCurrency(ctx context.Context, label, list, currency string) (*entities.PremiumLabel, error)

GetByLabelListAndCurrency retrieves a premium label by label, list, and currency

func (*PremiumLabelRepository) List

List retrieves a list of premium labels

type PremiumList

type PremiumList struct {
	Name          string `gorm:"primaryKey"`
	RyID          string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	PremiumLabels []PremiumLabel `gorm:"foreignKey:PremiumListName;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

PremiumList represents a premium list in our repository

func (*PremiumList) FromEntity

func (pl *PremiumList) FromEntity(premiumList *entities.PremiumList)

FromEntity converts a domain entity to a PremiumList

func (*PremiumList) TableName

func (pl *PremiumList) TableName() string

TableName returns the table name for the PremiumList model

func (*PremiumList) ToEntity

func (pl *PremiumList) ToEntity() *entities.PremiumList

ToEntity converts a PremiumList to a domain entity

type PremiumListRepository

type PremiumListRepository struct {
	// contains filtered or unexported fields
}

PremiumListRepository implements the PremiumListRepository interface

func NewGORMPremiumListRepository

func NewGORMPremiumListRepository(db *gorm.DB) *PremiumListRepository

NewPremiumListRepository creates a new PremiumListRepository instance

func (*PremiumListRepository) Create

Create creates a new premium list in the database

func (*PremiumListRepository) DeleteByName

func (plr *PremiumListRepository) DeleteByName(ctx context.Context, name string) error

DeleteByName deletes a premium list by name

func (*PremiumListRepository) GetByName

func (plr *PremiumListRepository) GetByName(ctx context.Context, name string) (*entities.PremiumList, error)

GetByName retrieves a premium list by name

func (*PremiumListRepository) List

List retrieves premium lists

type Price

type Price struct {
	Currency           string `gorm:"primaryKey"`
	RegistrationAmount uint64
	RenewalAmount      uint64
	TransferAmount     uint64
	RestoreAmount      uint64
	PhaseID            int64 `gorm:"primaryKey"`
	Phase              Phase
}

Price is the GORM model for the phase_price table. We use a composite primary key to ensure that a price with the same currency is not inserted twice in the same phase

func (*Price) FromEntity

func (pp *Price) FromEntity(ppEntity *entities.Price)

FromEntitye converst an entities.PhasePrice to a postgres.PhasePrice

func (Price) TableName

func (Price) TableName() string

TableName returns the table name for the PhasePrice model

func (*Price) ToEntity

func (pp *Price) ToEntity() *entities.Price

ToEntity converts a postgres.PhasePrice to an entities.PhasePrice

type PriceRepository

type PriceRepository struct {
	// contains filtered or unexported fields
}

PriceRepository is the GORM implementation of the PriceRepository

func NewGormPriceRepository

func NewGormPriceRepository(db *gorm.DB) *PriceRepository

NewGormPriceRepository creates a new GormPriceRepository

func (*PriceRepository) CreatePrice

func (r *PriceRepository) CreatePrice(ctx context.Context, price *entities.Price) (*entities.Price, error)

CreatePrice creates a new price in the database

func (*PriceRepository) DeletePrice

func (r *PriceRepository) DeletePrice(ctx context.Context, phaseID int64, currency string) error

DeletePrice deletes a price from the database

func (*PriceRepository) GetPrice

func (r *PriceRepository) GetPrice(ctx context.Context, phaseID int64, currency string) (*entities.Price, error)

GetPrice retrieves a price from the database

type Registrar

type Registrar struct {
	ClID        string `gorm:"primary_key"`
	Name        string `gorm:"unique;not null"`
	NickName    string `gorm:"unique;not null"`
	GurID       int
	Email       string
	Status      string `gorm:"not null"`
	IANAStatus  string
	Autorenew   bool
	Street1Int  string
	Street2Int  string
	Street3Int  string
	CityInt     string
	SPInt       string `gorm:"column:sp_int"`
	PCInt       string `gorm:"column:pc_int"`
	CCInt       string `gorm:"column:cc_int"`
	Street1Loc  string
	Street2Loc  string
	Street3Loc  string
	CityLoc     string
	SPLoc       string `gorm:"column:sp_loc"`
	PCLoc       string `gorm:"column:pc_loc"`
	CCLoc       string `gorm:"column:cc_loc"`
	Voice       string
	Fax         string
	URL         string
	Whois43     string
	Whois80     string
	RdapBaseUrl string
	CreatedAt   time.Time
	UpdatedAt   time.Time

	// FK relationships with contacts
	Contacts        []*Contact `gorm:"foreignKey:ClID"`
	ContactsCreated []*Contact `gorm:"foreignKey:CrRr"`
	ContactsUpdated []*Contact `gorm:"foreignKey:UpRr"`

	// FK relationships with hosts
	Hosts        []*Host `gorm:"foreignKey:ClID"`
	HostsCreated []*Host `gorm:"foreignKey:CrRr"`
	HostsUpdated []*Host `gorm:"foreignKey:UpRr"`

	// FK relationships with domains
	Domains        []*Domain `gorm:"foreignKey:ClID"`
	DomainsCreated []*Domain `gorm:"foreignKey:CrRr"`
	DomainsUpdated []*Domain `gorm:"foreignKey:UpRr"`

	// Many to Many relationship with TLDs
	TLDs []TLD `gorm:"many2many:accreditations;"`
}

Registrar is the GORM representation of a Registrar

func ToDBRegistrar

func ToDBRegistrar(r *entities.Registrar) *Registrar

func (Registrar) TableName

func (Registrar) TableName() string

type RegistryOperator

type RegistryOperator struct {
	RyID         string `gorm:"primary_key"`
	Name         string `gorm:"unique;not null"`
	URL          string
	Email        string `gorm:"not null"`
	Voice        string
	Fax          string
	CreatedAt    time.Time
	UpdatedAt    time.Time
	TLDs         []*TLD         `gorm:"foreignKey:RyID"`
	PremiumLists []*PremiumList `gorm:"foreignKey:RyID"`
}

RegistryOperator represents a registry Operator Entity in our repository

func (*RegistryOperator) FromEntity

func (ro *RegistryOperator) FromEntity(e *entities.RegistryOperator)

FromEntity converts the entity to a RegistryOperator

func (RegistryOperator) TableName

func (RegistryOperator) TableName() string

TableName returns the table name for the RegistryOperator entity

func (*RegistryOperator) ToEntity

func (ro *RegistryOperator) ToEntity() *entities.RegistryOperator

ToEntity converts the RegistryOperator to an entity

type RegistryOperatorRepository

type RegistryOperatorRepository struct {
	// contains filtered or unexported fields
}

RegistryOperatorRepository implements the RegistryOperatorRepository interface

func NewGORMRegistryOperatorRepository

func NewGORMRegistryOperatorRepository(db *gorm.DB) *RegistryOperatorRepository

NewGORMRegistryOperatorRepository creates a new RegistryOperatorRepository

func (*RegistryOperatorRepository) Count

func (*RegistryOperatorRepository) Create

Create creates a new RegistryOperator in the database

func (*RegistryOperatorRepository) DeleteByRyID

func (r *RegistryOperatorRepository) DeleteByRyID(ctx context.Context, ryID string) error

DeleteByRyID deletes a RegistryOperator by its RyID

func (*RegistryOperatorRepository) GetByRyID

GetByRyID retrieves a RegistryOperator by its RyID

func (*RegistryOperatorRepository) List

List retrieves RegistryOperators from the database

func (*RegistryOperatorRepository) Update

Update updates a RegistryOperator in the database

type SOARecordData

type SOARecordData struct {
	Ns      string `json:"ns"`
	Mbox    string `json:"mbox"`
	Serial  uint32 `json:"serial"`
	Refresh uint32 `json:"refresh"`
	Retry   uint32 `json:"retry"`
	Expire  uint32 `json:"expire"`
	Minttl  uint32 `json:"minttl"`
}

SOARecordData represents the data for a SOA record use it to marshal/unmarshal the data field in DNSRecord

type SRVRecordData

type SRVRecordData struct {
	Priority uint16 `json:"priority"`
	Weight   uint16 `json:"weight"`
	Port     uint16 `json:"port"`
	Target   string `json:"target"`
}

SRVRecordData represents the data for an SRV record use it to marshal/unmarshal the data field in DNSRecord

type Spec5Label

type Spec5Label struct {
	Label     string `gorm:"primary_key"`
	Type      string
	CreatedAt time.Time
}

Spec5Label is a struct representing an label blocked by RA Specification 5 in the database

func ToDBSpec5Label

func ToDBSpec5Label(label *entities.Spec5Label) *Spec5Label

ToDBSpec5Label converts a Spec5Label struct to a DBSpec5Label struct

func (Spec5Label) TableName

func (Spec5Label) TableName() string

type Spec5Repository

type Spec5Repository struct {
	// contains filtered or unexported fields
}

Spec5Repository implements the Spec5Repository interface

func NewSpec5Repository

func NewSpec5Repository(db *gorm.DB) *Spec5Repository

NewSpec5Repository returns a new Spec5Repository

func (*Spec5Repository) List

ListAll returns all Spec5Labels in the database

func (*Spec5Repository) UpdateAll

func (r *Spec5Repository) UpdateAll(ctx context.Context, labels []*entities.Spec5Label) error

UpdateAll updates all Spec5Labels in the database

type TLD

type TLD struct {
	Name              string `gorm:"primary_key"`
	Type              string `gorm:"index"`
	UName             string
	AllowEscrowImport bool
	EnableDNS         bool
	// One to Many relationship with Phases
	Phases []Phase `gorm:"foreignKey:TLDName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// FK relationship with RegistryOperator
	RyID      string
	CreatedAt time.Time
	UpdatedAt time.Time
	// Many to Many relationship with Registrars (AKA accreditations)
	Registrars []Registrar `gorm:"many2many:accreditations;"`
	// FK relationships with domains
	DNSRecord []*TLDDNSRecord `gorm:"foreignKey:Zone"`
}

TLD is a GORM struct representing a TLD in the database

func ToDBTLD

func ToDBTLD(tld *entities.TLD) *TLD

ToDBTLD converts a TLD struct to a DBTLD struct

type TLDDNSRecord

type TLDDNSRecord struct {
	ID        int       `json:"id"`
	Zone      string    `json:"zone" gorm:"index"`
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	TTL       uint32    `json:"ttl"`
	Data      string    `json:"data"` // JSON serialized data
	Priority  *uint16   `json:"priority,omitempty"`
	Weight    *uint16   `json:"weight,omitempty"`
	Port      *uint16   `json:"port,omitempty"`
	Target    *string   `json:"target,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

TLDDNSRecord represents a DNS record in the database

func ConvertRRToDNSRecord

func ConvertRRToDNSRecord(rr dns.RR) (*TLDDNSRecord, error)

ConvertRRToDNSRecord converts a dns.RR to a DNSRecord

func (TLDDNSRecord) TableName

func (TLDDNSRecord) TableName() string

TableName returns the table name for the DNSRecord model

func (*TLDDNSRecord) ToRR

func (record *TLDDNSRecord) ToRR() (dns.RR, error)

Convert DNSRecord to dns.RR

type TXTRecordData

type TXTRecordData struct {
	Text string `json:"text"`
}

TXTRecordData represents the data for a TXT record use it to marshal/unmarshal the data field in DNSRecord

Jump to

Keyboard shortcuts

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