happyDomain/storage/interface.go

195 lines
7.6 KiB
Go
Raw Normal View History

2020-05-04 14:58:02 +00:00
// Copyright or © or Copr. happyDNS (2020)
//
2022-01-10 13:06:19 +00:00
// contact@happydomain.org
2020-05-04 14:58:02 +00:00
//
// 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 (
2022-01-10 13:06:19 +00:00
"git.happydns.org/happydomain/model"
)
type Storage interface {
2020-07-28 15:34:55 +00:00
// DoMigration is the first function called.
DoMigration() error
2020-07-28 15:34:55 +00:00
// Tidy should optimize the database, looking for orphan records, ...
Tidy() error
2020-07-28 15:34:55 +00:00
// Close shutdown the connection with the database and releases all structure.
Close() error
// AUTH -------------------------------------------------------
// GetAuthUsers retrieves the list of known Users.
GetAuthUsers() (happydns.UserAuths, error)
// GetAuthUser retrieves the User with the given identifier.
2022-10-25 16:16:34 +00:00
GetAuthUser(id happydns.Identifier) (*happydns.UserAuth, error)
// GetAuthUserByEmail retrives the User with the given email address.
GetAuthUserByEmail(email string) (*happydns.UserAuth, error)
// AuthUserExists checks if the given email address is already associated to an User.
AuthUserExists(email string) bool
// CreateAuthUser creates a record in the database for the given User.
CreateAuthUser(user *happydns.UserAuth) error
// UpdateAuthUser updates the fields of the given User.
UpdateAuthUser(user *happydns.UserAuth) error
// DeleteAuthUser removes the given User from the database.
DeleteAuthUser(user *happydns.UserAuth) error
// ClearAuthUsers deletes all AuthUsers present in the database.
ClearAuthUsers() error
2020-07-28 15:34:55 +00:00
// DOMAINS ----------------------------------------------------
// GetDomains retrieves all Domains associated to the given User.
2020-04-22 08:17:16 +00:00
GetDomains(u *happydns.User) (happydns.Domains, error)
2020-07-28 15:34:55 +00:00
// GetDomain retrieves the Domain with the given id and owned by the given User.
2022-10-25 16:16:34 +00:00
GetDomain(u *happydns.User, id happydns.Identifier) (*happydns.Domain, error)
2020-07-28 15:34:55 +00:00
// GetDomainByDN is like GetDomain but look for the domain name instead of identifier.
2020-04-22 08:17:16 +00:00
GetDomainByDN(u *happydns.User, dn string) (*happydns.Domain, error)
2020-07-28 15:34:55 +00:00
// DomainExists looks if the given domain name alread exists in the database.
2020-04-22 08:17:16 +00:00
DomainExists(dn string) bool
2020-07-28 15:34:55 +00:00
// CreateDomain creates a record in the database for the given Domain.
2020-04-22 08:17:16 +00:00
CreateDomain(u *happydns.User, z *happydns.Domain) error
2020-07-28 15:34:55 +00:00
// UpdateDomain updates the fields of the given Domain.
2020-04-22 08:17:16 +00:00
UpdateDomain(z *happydns.Domain) error
2020-07-28 15:34:55 +00:00
// UpdateDomainOwner updates the owner of the given Domain.
2020-04-22 08:17:16 +00:00
UpdateDomainOwner(z *happydns.Domain, newOwner *happydns.User) error
2020-07-28 15:34:55 +00:00
// DeleteDomain removes the given Domain from the database.
2020-04-22 08:17:16 +00:00
DeleteDomain(z *happydns.Domain) error
2020-07-28 15:34:55 +00:00
// ClearDomains deletes all Domains present in the database.
2020-04-22 08:17:16 +00:00
ClearDomains() error
2021-07-05 15:11:17 +00:00
// PROVIDERS ----------------------------------------------------
// GetProviderMetas retrieves provider's metadatas of all providers own by the given User.
GetProviderMetas(u *happydns.User) ([]happydns.ProviderMeta, error)
// GetProviderMeta retrieves the metadatas for the Provider with the given identifier and owner.
2022-10-25 16:16:34 +00:00
GetProviderMeta(u *happydns.User, id happydns.Identifier) (*happydns.ProviderMeta, error)
2021-07-05 15:11:17 +00:00
// GetProvider retrieves the full Provider with the given identifier and owner.
2022-10-25 16:16:34 +00:00
GetProvider(u *happydns.User, id happydns.Identifier) (*happydns.ProviderCombined, error)
2021-07-05 15:11:17 +00:00
// CreateProvider creates a record in the database for the given Provider.
CreateProvider(u *happydns.User, s happydns.Provider, comment string) (*happydns.ProviderCombined, error)
// UpdateProvider updates the fields of the given Provider.
UpdateProvider(s *happydns.ProviderCombined) error
// UpdateProviderOwner updates the owner of the given Provider.
UpdateProviderOwner(s *happydns.ProviderCombined, newOwner *happydns.User) error
// DeleteProvider removes the given Provider from the database.
DeleteProvider(s *happydns.ProviderMeta) error
// ClearProviders deletes all Providers present in the database.
ClearProviders() error
2020-07-28 15:34:55 +00:00
// SESSIONS ---------------------------------------------------
// GetSession retrieves the Session with the given identifier.
2022-10-25 16:16:34 +00:00
GetSession(id happydns.Identifier) (*happydns.Session, error)
2020-07-28 15:34:55 +00:00
// GetAuthUserSessions retrieves all Session for the given AuthUser.
GetAuthUserSessions(user *happydns.UserAuth) ([]*happydns.Session, error)
// GetUserSessions retrieves all Session for the given User.
GetUserSessions(user *happydns.User) ([]*happydns.Session, error)
2020-07-28 15:34:55 +00:00
// CreateSession creates a record in the database for the given Session.
CreateSession(session *happydns.Session) error
2020-07-28 15:34:55 +00:00
// UpdateSession updates the fields of the given Session.
UpdateSession(session *happydns.Session) error
2020-07-28 15:34:55 +00:00
// DeleteSession removes the given Session from the database.
DeleteSession(session *happydns.Session) error
2020-07-28 15:34:55 +00:00
// ClearSessions deletes all Sessions present in the database.
2020-04-20 10:47:41 +00:00
ClearSessions() error
2020-07-28 15:34:55 +00:00
// USERS ------------------------------------------------------
// GetUsers retrieves the list of known Users.
GetUsers() (happydns.Users, error)
2020-07-28 15:34:55 +00:00
// GetUser retrieves the User with the given identifier.
2022-10-25 16:16:34 +00:00
GetUser(id happydns.Identifier) (*happydns.User, error)
2020-07-28 15:34:55 +00:00
// GetUserByEmail retrives the User with the given email address.
GetUserByEmail(email string) (*happydns.User, error)
2020-07-28 15:34:55 +00:00
// CreateUser creates a record in the database for the given User.
CreateUser(user *happydns.User) error
2020-07-28 15:34:55 +00:00
// UpdateUser updates the fields of the given User.
UpdateUser(user *happydns.User) error
2020-07-28 15:34:55 +00:00
// DeleteUser removes the given User from the database.
DeleteUser(user *happydns.User) error
2020-07-28 15:34:55 +00:00
// ClearUsers deletes all Users present in the database.
ClearUsers() error
2020-06-08 23:25:15 +00:00
2020-07-28 15:34:55 +00:00
// ZONES ------------------------------------------------------
// GetZoneMeta retrives metadatas of the Zone with the given identifier.
2022-10-25 16:16:34 +00:00
GetZoneMeta(id happydns.Identifier) (*happydns.ZoneMeta, error)
2020-07-28 15:34:55 +00:00
// GetZone retrieves the full Zone (including Services and metadatas) which have the given identifier.
2022-10-25 16:16:34 +00:00
GetZone(id happydns.Identifier) (*happydns.Zone, error)
2020-07-28 15:34:55 +00:00
// CreateZone creates a record in the database for the given Zone.
2020-06-08 23:25:15 +00:00
CreateZone(zone *happydns.Zone) error
2020-07-28 15:34:55 +00:00
// UpdateZone updates the fields of the given Zone.
2020-06-08 23:25:15 +00:00
UpdateZone(zone *happydns.Zone) error
2020-07-28 15:34:55 +00:00
// DeleteZone removes the given Zone from the database.
2020-06-08 23:25:15 +00:00
DeleteZone(zone *happydns.Zone) error
2020-07-28 15:34:55 +00:00
// ClearZones deletes all Zones present in the database.
2020-06-08 23:25:15 +00:00
ClearZones() error
}