166 lines
6.4 KiB
Go
166 lines
6.4 KiB
Go
// Copyright or © or Copr. happyDNS (2020)
|
|
//
|
|
// contact@happydns.org
|
|
//
|
|
// This software is a computer program whose purpose is to provide a modern
|
|
// interface to interact with DNS systems.
|
|
//
|
|
// This software is governed by the CeCILL license under French law and abiding
|
|
// by the rules of distribution of free software. You can use, modify and/or
|
|
// redistribute the software under the terms of the CeCILL license as
|
|
// circulated by CEA, CNRS and INRIA at the following URL
|
|
// "http://www.cecill.info".
|
|
//
|
|
// As a counterpart to the access to the source code and rights to copy, modify
|
|
// and redistribute granted by the license, users are provided only with a
|
|
// limited warranty and the software's author, the holder of the economic
|
|
// rights, and the successive licensors have only limited liability.
|
|
//
|
|
// In this respect, the user's attention is drawn to the risks associated with
|
|
// loading, using, modifying and/or developing or reproducing the software by
|
|
// the user in light of its specific status of free software, that may mean
|
|
// that it is complicated to manipulate, and that also therefore means that it
|
|
// is reserved for developers and experienced professionals having in-depth
|
|
// computer knowledge. Users are therefore encouraged to load and test the
|
|
// software's suitability as regards their requirements in conditions enabling
|
|
// the security of their systems and/or data to be ensured and, more generally,
|
|
// to use and operate it in the same conditions as regards security.
|
|
//
|
|
// The fact that you are presently reading this means that you have had
|
|
// knowledge of the CeCILL license and that you accept its terms.
|
|
|
|
package storage // import "happydns.org/storage"
|
|
|
|
import (
|
|
"git.happydns.org/happydns/model"
|
|
)
|
|
|
|
type Storage interface {
|
|
// DoMigration is the first function called.
|
|
DoMigration() error
|
|
|
|
// Tidy should optimize the database, looking for orphan records, ...
|
|
Tidy() error
|
|
|
|
// Close shutdown the connection with the database and releases all structure.
|
|
Close() error
|
|
|
|
// DOMAINS ----------------------------------------------------
|
|
|
|
// GetDomains retrieves all Domains associated to the given User.
|
|
GetDomains(u *happydns.User) (happydns.Domains, error)
|
|
|
|
// GetDomain retrieves the Domain with the given id and owned by the given User.
|
|
GetDomain(u *happydns.User, id int64) (*happydns.Domain, error)
|
|
|
|
// GetDomainByDN is like GetDomain but look for the domain name instead of identifier.
|
|
GetDomainByDN(u *happydns.User, dn string) (*happydns.Domain, error)
|
|
|
|
// DomainExists looks if the given domain name alread exists in the database.
|
|
DomainExists(dn string) bool
|
|
|
|
// CreateDomain creates a record in the database for the given Domain.
|
|
CreateDomain(u *happydns.User, z *happydns.Domain) error
|
|
|
|
// UpdateDomain updates the fields of the given Domain.
|
|
UpdateDomain(z *happydns.Domain) error
|
|
|
|
// UpdateDomainOwner updates the owner of the given Domain.
|
|
UpdateDomainOwner(z *happydns.Domain, newOwner *happydns.User) error
|
|
|
|
// DeleteDomain removes the given Domain from the database.
|
|
DeleteDomain(z *happydns.Domain) error
|
|
|
|
// ClearDomains deletes all Domains present in the database.
|
|
ClearDomains() error
|
|
|
|
// SESSIONS ---------------------------------------------------
|
|
|
|
// GetSession retrieves the Session with the given identifier.
|
|
GetSession(id []byte) (*happydns.Session, error)
|
|
|
|
// CreateSession creates a record in the database for the given Session.
|
|
CreateSession(session *happydns.Session) error
|
|
|
|
// UpdateSession updates the fields of the given Session.
|
|
UpdateSession(session *happydns.Session) error
|
|
|
|
// DeleteSession removes the given Session from the database.
|
|
DeleteSession(session *happydns.Session) error
|
|
|
|
// ClearSessions deletes all Sessions present in the database.
|
|
ClearSessions() error
|
|
|
|
// SOURCES ----------------------------------------------------
|
|
|
|
// GetSourceMetas retrieves source's metadatas of all sources own by the given User.
|
|
GetSourceMetas(u *happydns.User) ([]happydns.SourceMeta, error)
|
|
|
|
// GetSourceMeta retrieves the metadatas for the Source with the given identifier and owner.
|
|
GetSourceMeta(u *happydns.User, id int64) (*happydns.SourceMeta, error)
|
|
|
|
// GetSource retrieves the full Source with the given identifier and owner.
|
|
GetSource(u *happydns.User, id int64) (*happydns.SourceCombined, error)
|
|
|
|
// CreateSource creates a record in the database for the given Source.
|
|
CreateSource(u *happydns.User, s happydns.Source, comment string) (*happydns.SourceCombined, error)
|
|
|
|
// UpdateSource updates the fields of the given Source.
|
|
UpdateSource(s *happydns.SourceCombined) error
|
|
|
|
// UpdateSourceOwner updates the owner of the given Source.
|
|
UpdateSourceOwner(s *happydns.SourceCombined, newOwner *happydns.User) error
|
|
|
|
// DeleteSource removes the given Source from the database.
|
|
DeleteSource(s *happydns.SourceMeta) error
|
|
|
|
// ClearSources deletes all Sources present in the database.
|
|
ClearSources() error
|
|
|
|
// USERS ------------------------------------------------------
|
|
|
|
// GetUsers retrieves the list of known Users.
|
|
GetUsers() (happydns.Users, error)
|
|
|
|
// GetUser retrieves the User with the given identifier.
|
|
GetUser(id int64) (*happydns.User, error)
|
|
|
|
// GetUserByEmail retrives the User with the given email address.
|
|
GetUserByEmail(email string) (*happydns.User, error)
|
|
|
|
// UserExists checks if the given email address is already associated to an User.
|
|
UserExists(email string) bool
|
|
|
|
// CreateUser creates a record in the database for the given User.
|
|
CreateUser(user *happydns.User) error
|
|
|
|
// UpdateUser updates the fields of the given User.
|
|
UpdateUser(user *happydns.User) error
|
|
|
|
// DeleteUser removes the given User from the database.
|
|
DeleteUser(user *happydns.User) error
|
|
|
|
// ClearUsers deletes all Users present in the database.
|
|
ClearUsers() error
|
|
|
|
// ZONES ------------------------------------------------------
|
|
|
|
// GetZoneMeta retrives metadatas of the Zone with the given identifier.
|
|
GetZoneMeta(id int64) (*happydns.ZoneMeta, error)
|
|
|
|
// GetZone retrieves the full Zone (including Services and metadatas) which have the given identifier.
|
|
GetZone(id int64) (*happydns.Zone, error)
|
|
|
|
// CreateZone creates a record in the database for the given Zone.
|
|
CreateZone(zone *happydns.Zone) error
|
|
|
|
// UpdateZone updates the fields of the given Zone.
|
|
UpdateZone(zone *happydns.Zone) error
|
|
|
|
// DeleteZone removes the given Zone from the database.
|
|
DeleteZone(zone *happydns.Zone) error
|
|
|
|
// ClearZones deletes all Zones present in the database.
|
|
ClearZones() error
|
|
}
|