Documentation
¶
Index ¶
- Variables
- func CustomErrorToHTTPStatusCode(err error) int
- func GormToCustomError(err error) error
- func MapRecordToRecordAdded(record Record) events.RecordAdded
- func MapRecordToRecordUpdated(record Record) events.RecordUpdated
- func MapToRecordDeleted(zoneID uuid.UUID, recordID uuid.UUID) events.RecordDeleted
- func MapToZoneDeleted(zoneID uuid.UUID) events.ZoneDeleted
- func MapZoneToZoneCreated(zone Zone) events.ZoneCreated
- func MustString(data any) string
- func String(data any) (string, error)
- type ManagementService
- func (m *ManagementService) AddRecord(record Record) (Record, error)
- func (m *ManagementService) CreateZone(zone Zone) (Zone, error)
- func (m *ManagementService) DeleteRecord(zoneID uuid.UUID, recordID uuid.UUID) error
- func (m *ManagementService) DeleteZone(zoneID uuid.UUID) error
- func (m *ManagementService) GetRecord(zoneID uuid.UUID, recordID uuid.UUID) (Record, error)
- func (m *ManagementService) GetRecords(zoneID uuid.UUID) ([]Record, error)
- func (m *ManagementService) GetZone(zoneID uuid.UUID) (Zone, error)
- func (m *ManagementService) GetZones() ([]Zone, error)
- func (m *ManagementService) UpdateRecord(zoneID uuid.UUID, recordID uuid.UUID, record Record) (Record, error)
- type Record
- type RecordType
- type Repository
- type Zone
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GormToCustomError ¶
func MapRecordToRecordAdded ¶
func MapRecordToRecordAdded(record Record) events.RecordAdded
func MapRecordToRecordUpdated ¶
func MapRecordToRecordUpdated(record Record) events.RecordUpdated
func MapToRecordDeleted ¶
func MapToZoneDeleted ¶
func MapToZoneDeleted(zoneID uuid.UUID) events.ZoneDeleted
func MapZoneToZoneCreated ¶
func MapZoneToZoneCreated(zone Zone) events.ZoneCreated
func MustString ¶
Types ¶
type ManagementService ¶
type ManagementService struct {
// contains filtered or unexported fields
}
func NewManagementService ¶
func NewManagementService(repo Repository, mq mq.MessageQueue) *ManagementService
func (*ManagementService) AddRecord ¶
func (m *ManagementService) AddRecord(record Record) (Record, error)
func (*ManagementService) CreateZone ¶
func (m *ManagementService) CreateZone(zone Zone) (Zone, error)
func (*ManagementService) DeleteRecord ¶
func (*ManagementService) DeleteZone ¶
func (m *ManagementService) DeleteZone(zoneID uuid.UUID) error
func (*ManagementService) GetRecords ¶
func (m *ManagementService) GetRecords(zoneID uuid.UUID) ([]Record, error)
func (*ManagementService) GetZone ¶
func (m *ManagementService) GetZone(zoneID uuid.UUID) (Zone, error)
func (*ManagementService) GetZones ¶
func (m *ManagementService) GetZones() ([]Zone, error)
func (*ManagementService) UpdateRecord ¶
type Record ¶
type Record struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()" json:"id"` ZoneID uuid.UUID `gorm:"type:uuid" json:"zone_id"` Name string `gorm:"type:varchar(255);unique;not null" json:"name"` Type RecordType `gorm:"type:varchar(7);not null" json:"type"` // not using enums due to further update that might support other record types TTL uint32 `gorm:"type:integer;check:ttl >= 0;not null" json:"ttl"` Value pgtype.JSONB `gorm:"type:jsonb;not null" json:"value"` Zone Zone `gorm:"foreignKey:ZoneID;constraint:OnDelete:CASCADE" json:"-"` }
type RecordType ¶
type RecordType string
const ( A RecordType = "A" AAAA RecordType = "AAAA" MX RecordType = "MX" NS RecordType = "NS" TXT RecordType = "TXT" CNAME RecordType = "CNAME" PTR RecordType = "PTR" )
type Repository ¶
type Repository interface { SaveZone(zone Zone) (Zone, error) FindZones() ([]Zone, error) FindZoneByID(zoneID uuid.UUID) (Zone, error) DeleteZoneByID(zoneID uuid.UUID) error SaveZoneRecord(record Record) (Record, error) FindZoneRecords(zoneID uuid.UUID) ([]Record, error) FindZoneRecordByID(zoneID uuid.UUID, recordID uuid.UUID) (Record, error) UpdateZoneRecordByID(zoneID uuid.UUID, recordID uuid.UUID, record Record) (Record, error) DeleteZoneRecordByID(zoneID uuid.UUID, recordID uuid.UUID) error }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.