directadmin

package module
v0.0.0-...-3d9538d Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

README

DirectAdmin Go SDK

Interface with a DirectAdmin installation using Go.

This library supports both the legacy/default DirectAdmin API, as well as their new modern API that's still in active development.

Note: This is in an experimental state. While it's being used in production, the library is very likely to change (especially in-line with DA's own changes). DA features are being added as needed on our end, but PRs are always welcome!

If you wonder why something has been handled in an unusual way, it's most likely a workaround required by one of DA's many quirks.

Login as Admin / Reseller / User

To open a session as an admin/reseller/user, follow the following code block:

package main

import (
	"time"
	
	"github.com/goccy/go-json"
	"github.com/levelzerotechnology/directadmin-go"
)

func main() {
	api, err := directadmin.New("https://your.da.address:2222", 5*time.Second)
	if err != nil {
		panic(err)
	}

	userCtx, err := api.LoginAsUser("your_username", "some_password_or_key")
	if err != nil {
		panic(err)
	}

	usage, err := userCtx.GetMyUserUsage()
	if err != nil {
		panic(err)
	}

	userCtx.User.Usage = *usage
}

From here, you can call user functions via userCtx.

For example, if you wanted to print each of your databases to your terminal:

dbs, err := userCtx.GetDatabases()
if err != nil {
	log.Fatalln(err)
}

for _, db := range dbs {
	fmt.Println(db.Name)
}

Roadmap

  • Cleanup repo structure (e.g. redis actions being within admin.go could go into a dedicated redis.go file perhaps)
  • Explore DA's new API's update versions of old functions (e.g. user config/usage)
  • Implement testing for all functions
  • Reach stable v1.0

License

BSD licensed. See the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	DatabaseFormatGz  = DatabaseFormat("gz")
	DatabaseFormatSql = DatabaseFormat("sql")
)
View Source
const (
	AccountRoleAdmin    = "Admin"
	AccountRoleReseller = "Reseller"
	AccountRoleUser     = "User"
)
View Source
const Unlimited int = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func New

func New(serverUrl string, timeout time.Duration, cacheEnabled bool, debug bool) (*API, error)

func (*API) GetURL

func (a *API) GetURL() string

func (*API) LoginAsAdmin

func (a *API) LoginAsAdmin(username string, passkey string) (*AdminContext, error)

LoginAsAdmin verifies the provided credentials against the DA API, then returns an admin-level context. The passkey can either be the user's password, or a login key

func (*API) LoginAsReseller

func (a *API) LoginAsReseller(username string, passkey string) (*ResellerContext, error)

LoginAsReseller verifies the provided credentials against the DA API, then returns a reseller-level context. The passkey can either be the user's password, or a login key

func (*API) LoginAsUser

func (a *API) LoginAsUser(username string, passkey string) (*UserContext, error)

LoginAsUser verifies the provided credentials against the DA API, then returns a user-level context. The passkey can either be the user's password, or a login key

type Admin

type Admin struct {
	Reseller
}

Admin inherits Reseller which inherits User

type AdminContext

type AdminContext struct {
	ResellerContext
}

func (*AdminContext) ConvertResellerToUser

func (c *AdminContext) ConvertResellerToUser(username string, reseller string) error

func (*AdminContext) ConvertUserToReseller

func (c *AdminContext) ConvertUserToReseller(username string) error

func (*AdminContext) CreateResellerPackage

func (c *AdminContext) CreateResellerPackage(pack ResellerPackage) error

CreateResellerPackage (admin) creates the provided package

func (*AdminContext) DeleteResellerPackages

func (c *AdminContext) DeleteResellerPackages(packs ...string) error

DeleteResellerPackages (admin) deletes all the specified packs for the session user

func (*AdminContext) DisableRedis

func (c *AdminContext) DisableRedis() error

func (*AdminContext) EnableRedis

func (c *AdminContext) EnableRedis() error

func (*AdminContext) GetAllUsers

func (c *AdminContext) GetAllUsers() ([]string, error)

GetAllUsers (admin) returns an array of all users

func (*AdminContext) GetLicense

func (c *AdminContext) GetLicense() (*License, error)

func (*AdminContext) GetLoginHistory

func (c *AdminContext) GetLoginHistory() ([]*LoginHistory, error)

func (*AdminContext) GetResellerPackage

func (c *AdminContext) GetResellerPackage(packageName string) (ResellerPackage, error)

GetResellerPackage (admin) returns the single specified package

func (*AdminContext) GetResellerPackages

func (c *AdminContext) GetResellerPackages() ([]ResellerPackage, error)

GetResellerPackages (admin) returns all packages belonging to the session user

func (*AdminContext) GetResellers

func (c *AdminContext) GetResellers() ([]string, error)

GetResellers (admin) returns an array of all resellers

func (*AdminContext) GetResellersWithUsage

func (c *AdminContext) GetResellersWithUsage() ([]string, error)

TODO: finish implementation

func (*AdminContext) LoginAsMyReseller

func (c *AdminContext) LoginAsMyReseller(username string) (*ResellerContext, error)

func (*AdminContext) MoveUserToReseller

func (c *AdminContext) MoveUserToReseller(username string, reseller string) error

func (*AdminContext) RenameResellerPackage

func (c *AdminContext) RenameResellerPackage(oldPackName string, newPackName string) error

RenameResellerPackage (admin) renames the provided package

func (*AdminContext) RestartDirectAdmin

func (c *AdminContext) RestartDirectAdmin() error

func (*AdminContext) UpdateDirectAdmin

func (c *AdminContext) UpdateDirectAdmin() error

func (*AdminContext) UpdateResellerPackage

func (c *AdminContext) UpdateResellerPackage(pack ResellerPackage) error

UpdateResellerPackage (admin) accepts a Package object and updates the version on DA with it

type BasicSysInfo

type BasicSysInfo struct {
	AllowPasswordReset bool      `json:"allowPasswordReset"`
	Hostname           string    `json:"hostname"`
	Languages          []string  `json:"languages"`
	LicenseError       string    `json:"licenseError"`
	LicenseTrial       bool      `json:"licenseTrial"`
	LicenseValid       bool      `json:"licenseValid"`
	OtpTrustDays       int       `json:"otpTrustDays"`
	Time               time.Time `json:"time"`
}

type DNSRecord

type DNSRecord struct {
	Name  string `json:"name"`
	Ttl   int    `json:"ttl"`
	Type  string `json:"type"`
	Value string `json:"value"`
}

type Database

type Database struct {
	Name             string `json:"database"`
	DefaultCharset   string `json:"defaultCharset"`
	DefaultCollation string `json:"defaultCollation"`
	DefinerIssues    int    `json:"definerIssues"`
	EventCount       int    `json:"eventCount"`
	RoutineCount     int    `json:"routineCount"`
	SizeBytes        int    `json:"sizeBytes"`
	TableCount       int    `json:"tableCount"`
	TriggerCount     int    `json:"triggerCount"`
	UserCount        int    `json:"userCount"`
	ViewCount        int    `json:"viewCount"`
}

type DatabaseFormat

type DatabaseFormat string

type DatabaseProcess

type DatabaseProcess struct {
	Command  string `json:"command"`
	Database string `json:"database"`
	Host     string `json:"host"`
	Id       int    `json:"id"`
	Info     string `json:"info"`
	State    string `json:"state"`
	Time     int    `json:"time"`
	User     string `json:"user"`
}

type DatabaseUser

type DatabaseUser struct {
	HostPatterns []string `json:"hostPatterns"`
	Password     string   `json:"password"`
	User         string   `json:"dbuser"`
}

type DatabaseWithUser

type DatabaseWithUser struct {
	Database
	Password string `json:"password"`
	User     string `json:"dbuser"`
}

type Domain

type Domain struct {
	Active             bool     `json:"active" yaml:"active"`
	BandwidthQuota     int      `json:"bandwidthQuota" yaml:"bandwidthQuota"`
	BandwidthUsage     int      `json:"bandwidthUsage" yaml:"bandwidthUsage"`
	CgiEnabled         bool     `json:"cgiEnabled" yaml:"cgiEnabled"`
	DefaultDomain      bool     `json:"defaultDomain" yaml:"defaultDomain"`
	DiskQuota          int      `json:"diskQuota" yaml:"diskQuota"`
	DiskUsage          int      `json:"diskUsage" yaml:"diskUsage"`
	Domain             string   `json:"domain" yaml:"domain"`
	IpAddresses        []string `json:"ipAddresses" yaml:"ipAddresses"`
	ModSecurityEnabled bool     `json:"modSecurityEnabled" yaml:"modSecurityEnabled"`
	OpenBaseDirEnabled bool     `json:"openBaseDirEnabled" yaml:"openBaseDirEnabled"`
	PhpEnabled         bool     `json:"phpEnabled" yaml:"phpEnabled"`
	PhpSelectorEnabled bool     `json:"phpSelectorEnabled" yaml:"phpSelectorEnabled"`
	PhpVersion         string   `json:"phpVersion" yaml:"phpVersion"`
	SafeMode           bool     `json:"safeMode" yaml:"safeMode"`
	SslEnabled         bool     `json:"sslEnabled" yaml:"sslEnabled"`
	Subdomains         []string `json:"subdomains" yaml:"subdomains"`
	SubdomainUsage     int      `json:"subdomainUsage" yaml:"subdomainUsage"`
	Suspended          bool     `json:"suspended" yaml:"suspended"`
	Username           string   `json:"username" yaml:"username"`
}

type EmailAccount

type EmailAccount struct {
	DiskQuota int    `json:"diskQuota" yaml:"diskQuota"`
	DiskUsage int    `json:"diskUsage" yaml:"diskUsage"`
	Domain    string `json:"domain" yaml:"domain"`
	Password  string `json:"password" yaml:"password"`
	SendQuota int    `json:"sendQuota" yaml:"sendQuota"`
	SendUsage int    `json:"sendUsage" yaml:"sendUsage"`
	Suspended bool   `json:"suspended" yaml:"suspended"`
	Username  string `json:"username" yaml:"username"`
}

type License

type License struct {
	Expires time.Time `json:"expires"`
	Lid     int       `json:"lid"`
	Limits  struct {
		Legacy               bool `json:"legacy"`
		MaxAdminsOrResellers int  `json:"maxAdminsOrResellers"`
		MaxDomains           int  `json:"maxDomains"`
		MaxUsers             int  `json:"maxUsers"`
		OnlyVPS              bool `json:"onlyVPS"`
		ProPack              bool `json:"proPack"`
		Trial                bool `json:"trial"`
	} `json:"limits"`
	Name  string `json:"name"`
	Pid   int    `json:"pid"`
	Type  string `json:"type"`
	Uid   int    `json:"uid"`
	Usage struct {
		AdminsOrResellers int `json:"adminsOrResellers"`
		Domains           int `json:"domains"`
		Users             int `json:"users"`
	} `json:"usage"`
}

type LoginHistory

type LoginHistory struct {
	Attempts  int       `json:"attempts"`
	Host      string    `json:"host"`
	Timestamp time.Time `json:"timestamp"`
}

type LoginKeyURL

type LoginKeyURL struct {
	AllowNetworks []string  `json:"allowNetworks"`
	Created       time.Time `json:"created"`
	CreatedBy     string    `json:"createdBy"`
	Expires       time.Time `json:"expires"`
	Id            string    `json:"id"`
	RedirectURL   string    `json:"redirectURL"`
	URL           string    `json:"url"`
}

type Package

type Package struct {
	AnonymousFtpEnabled     bool   `json:"anonymousFtpEnabled" yaml:"anonymousFtpEnabled"`
	BandwidthQuota          int    `json:"bandwidthQuota" yaml:"bandwidthQuota"`
	CpuQuota                int    `json:"cpuQuota" yaml:"cpuQuota"`
	CatchallEnabled         bool   `json:"catchallEnabled" yaml:"catchallEnabled"`
	CgiEnabled              bool   `json:"cgiEnabled" yaml:"cgiEnabled"`
	CronEnabled             bool   `json:"cronEnabled" yaml:"cronEnabled"`
	DNSControlEnabled       bool   `json:"dnsControlEnabled" yaml:"dnsControlEnabled"`
	DomainPointerQuota      int    `json:"domainPointerQuota" yaml:"domainPointerQuota"`
	DomainQuota             int    `json:"domainQuota" yaml:"domainQuota"`
	EmailAutoresponderQuota int    `json:"emailAutoresponderQuota" yaml:"emailAutoresponderQuota"`
	EmailForwarderQuota     int    `json:"emailForwarderQuota" yaml:"emailForwarderQuota"`
	EmailMailingListQuota   int    `json:"emailMailingListQuota" yaml:"emailMailingListQuota"`
	EmailQuota              int    `json:"emailQuota" yaml:"emailQuota"`
	FtpQuota                int    `json:"ftp" yaml:"ftpQuota"`
	GitEnabled              bool   `json:"gitEnabled" yaml:"gitEnabled"`
	IoReadBandwidthMax      int    `json:"ioReadBandwidthMax" yaml:"ioReadBandwidthMax"`
	IoReadIopsMax           int    `json:"ioReadIopsMax" yaml:"ioReadIopsMax"`
	IoWriteBandwidthMax     int    `json:"ioWriteBandwidthMax" yaml:"ioWriteBandwidthMax"`
	IoWriteIopsMax          int    `json:"ioWriteIopsMax" yaml:"ioWriteIopsMax"`
	InodeQuota              int    `json:"inodeQuota" yaml:"inodeQuota"`
	JailEnabled             bool   `json:"jailEnabled" yaml:"jailEnabled"`
	Language                string `json:"language" yaml:"language"`
	LoginKeysEnabled        bool   `json:"loginKeysEnabled" yaml:"loginKeysEnabled"`
	MemoryHigh              int    `json:"memoryHigh" yaml:"memoryHigh"`
	MemoryMax               int    `json:"memoryMax" yaml:"memoryMax"`
	MysqlQuota              int    `json:"mysqlQuota" yaml:"mysqlQuota"`
	Name                    string `json:"name" yaml:"name"`
	NginxEnabled            bool   `json:"nginxEnabled" yaml:"nginxEnabled"`
	PhpEnabled              bool   `json:"phpEnabled" yaml:"phpEnabled"`
	Quota                   int    `json:"quota" yaml:"quota"`
	RedisEnabled            bool   `json:"redisEnabled" yaml:"redisEnabled"`
	SshEnabled              bool   `json:"sshEnabled" yaml:"sshEnabled"`
	Skin                    string `json:"skin" yaml:"skin"`
	SpamAssassinEnabled     bool   `json:"spamAssassinEnabled" yaml:"spamAssassinEnabled"`
	SslEnabled              bool   `json:"sslEnabled" yaml:"sslEnabled"`
	SubdomainQuota          int    `json:"subdomainQuota" yaml:"subdomainQuota"`
	SuspendAtLimitEnabled   bool   `json:"suspendAtLimitEnabled" yaml:"suspendAtLimitEnabled"`
	SysInfoEnabled          bool   `json:"sysInfoEnabled" yaml:"sysInfoEnabled"`
	TasksMax                int    `json:"tasksMax" yaml:"tasksMax"`
	WordpressEnabled        bool   `json:"wordpressEnabled" yaml:"wordpressEnabled"`
}

type Reseller

type Reseller struct {
	User
}

Reseller inherits User

type ResellerContext

type ResellerContext struct {
	UserContext
}

func (*ResellerContext) CheckUserExists

func (c *ResellerContext) CheckUserExists(username string) error

CheckUserExists (reseller) checks if the given user exists

func (*ResellerContext) CreatePackage

func (c *ResellerContext) CreatePackage(pack Package) error

CreatePackage (reseller) creates the provided package

func (*ResellerContext) CreateUser

func (c *ResellerContext) CreateUser(user UserConfig, password string, emailUser bool, customPackage *Package) error

CreateUser (reseller) create a user.

The following fields must be populated: Domain, Email, IpAddresses, Package, Username

func (*ResellerContext) DeletePackages

func (c *ResellerContext) DeletePackages(packs ...string) error

DeletePackages (reseller) deletes all the specified packs for the session user

func (*ResellerContext) DeleteUsers

func (c *ResellerContext) DeleteUsers(usernames ...string) error

DeleteUsers (reseller) deletes all the users associated with the given usernames

func (*ResellerContext) GetMyUsers

func (c *ResellerContext) GetMyUsers() ([]string, error)

GetMyUsers (reseller) returns all users belonging to the session user

func (*ResellerContext) GetMyUsersWithUsage

func (c *ResellerContext) GetMyUsersWithUsage() ([]User, error)

GetMyUsersWithUsage (reseller) returns all users belonging to the session user, along with their UserConfig and UserUsage data

func (*ResellerContext) GetPackage

func (c *ResellerContext) GetPackage(packageName string) (Package, error)

GetPackage (reseller) returns the single specified package

func (*ResellerContext) GetPackages

func (c *ResellerContext) GetPackages() ([]Package, error)

GetPackages (reseller) returns all packages belonging to the session user

func (*ResellerContext) GetUserConfig

func (c *ResellerContext) GetUserConfig(username string) (*UserConfig, error)

GetUserConfig (reseller) returns the given user's config

func (*ResellerContext) GetUserUsage

func (c *ResellerContext) GetUserUsage(username string) (*UserUsage, error)

GetUserUsage (reseller) returns the given user's usage.

func (*ResellerContext) LoginAsMyUser

func (c *ResellerContext) LoginAsMyUser(username string) (*UserContext, error)

func (*ResellerContext) RenamePackage

func (c *ResellerContext) RenamePackage(oldPackName string, newPackName string) error

RenamePackage (reseller) renames the provided package

func (*ResellerContext) SuspendUser

func (c *ResellerContext) SuspendUser(username string) error

func (*ResellerContext) SuspendUsers

func (c *ResellerContext) SuspendUsers(usernames ...string) error

func (*ResellerContext) UnsuspendUser

func (c *ResellerContext) UnsuspendUser(username string) error

func (*ResellerContext) UnsuspendUsers

func (c *ResellerContext) UnsuspendUsers(usernames ...string) error

func (*ResellerContext) UpdatePackage

func (c *ResellerContext) UpdatePackage(pack Package) error

UpdatePackage (reseller) accepts a Package object and updates the version on DA with it

type ResellerPackage

type ResellerPackage struct {
	Package
	OversellEnabled bool `json:"oversellEnabled" url:"oversellEnabled"`
	UserQuota       int  `json:"userQuota" url:"userQuota"`
}

type Subdomain

type Subdomain struct {
	Domain     string `json:"domain" yaml:"domain"`
	PhpVersion string `json:"phpVersion" yaml:"phpVersion"`
	PublicHtml string `json:"publicHtml" yaml:"publicHtml"`
	Subdomain  string `json:"subdomain" yaml:"subdomain"`
}

type SysInfo

type SysInfo struct {
	CpuCount int `json:"cpuCount" yaml:"cpuCount"`
	Cpus     map[string]struct {
		MHz    float64 `json:"mhz"`
		Model  string  `json:"model"`
		Vendor string  `json:"vendor"`
	}
	SystemLoad struct {
		Last1Minute   string `json:"last1Minute"`
		Last5Minutes  string `json:"last5Minutes"`
		Last15Minutes string `json:"last15Minutes"`
	} `json:"systemLoad"`
	MemInfo struct {
		Active            int `json:"active"`
		ActiveAnon        int `json:"activeAnon"`
		ActiveFile        int `json:"activeFile"`
		AnonHugePages     int `json:"anonHugePages"`
		AnonPages         int `json:"anonPages"`
		Bounce            int `json:"bounce"`
		Buffers           int `json:"buffers"`
		Cached            int `json:"cached"`
		CommitLimit       int `json:"commitLimit"`
		CommittedAS       int `json:"committedAs"`
		DirectMap1G       int `json:"directMap1G"`
		DirectMap2M       int `json:"directMap2M"`
		DirectMap4K       int `json:"directMap4K"`
		Dirty             int `json:"Dirty"`
		FileHugePages     int `json:"fileHugePages"`
		FilePmdMapped     int `json:"filePmdMapped"`
		HardwareCorrupted int `json:"hardwareCorrupted"`
		HugePagesFree     int `json:"hugePagesFree"`
		HugePagesRsvd     int `json:"hugePagesRsvd"`
		HugePagesSurp     int `json:"hugePagesSurp"`
		HugePagesTotal    int `json:"hugePagesTotal"`
		HugePageSize      int `json:"hugePageSize"`
		HugeTlb           int `json:"hugeTlb"`
		Inactive          int `json:"inactive"`
		InactiveAnon      int `json:"inactiveAnon"`
		InactiveFile      int `json:"inactiveFile"`
		KReclaimable      int `json:"kReclaimable"`
		KernelStack       int `json:"kernelStack"`
		Mapped            int `json:"mapped"`
		MemAvailable      int `json:"memAvailable"`
		MemFree           int `json:"memFree"`
		MemTotal          int `json:"memTotal"`
		MLocked           int `json:"mLocked"`
		NfsUnstable       int `json:"nfsUnstable"`
		PageTables        int `json:"pageTables"`
		PerCpu            int `json:"perCpu"`
		SReclaimable      int `json:"sReclaimable"`
		SUnreclaim        int `json:"sUnreclaim"`
		Shmem             int `json:"shmem"`
		ShmemHugePages    int `json:"shmemHugePages"`
		ShmemPmdMapped    int `json:"shmemPmdMapped"`
		Slab              int `json:"slab"`
		SwapCached        int `json:"swapCached"`
		SwapFree          int `json:"swapFree"`
		SwapTotal         int `json:"swapTotal"`
		Unevictable       int `json:"snevictable"`
		VmallocChunk      int `json:"vmallocChunk"`
		VmallocTotal      int `json:"vmallocTotal"`
		VmallocUsed       int `json:"vmallocUsed"`
		Writeback         int `json:"writeback"`
		WritebackTmp      int `json:"writebackTmp"`
	} `json:"memory"`
	Services map[string]struct {
		Name    string `json:"name"`
		Status  string `json:"status"`
		Version string `json:"version"`
	} `json:"services"`
	Uptime struct {
		Days         string `json:"days"`
		Hours        string `json:"hours"`
		Minutes      string `json:"minutes"`
		TotalSeconds string `json:"totalSeconds"`
		Uptime       string `json:"uptime"`
	} `json:"uptime"`
}

type User

type User struct {
	Config UserConfig `json:"config"`
	Usage  UserUsage  `json:"usage"`
}

type UserConfig

type UserConfig struct {
	AftpEnabled                    bool      `json:"aftpEnabled" yaml:"aftpEnabled"`
	ApiAccessWithPasswordEnabled   bool      `json:"apiAccessWithPasswordEnabled" yaml:"apiAccessWithPasswordEnabled"`
	CatchAllEnabled                bool      `json:"catchAllEnabled" yaml:"catchAllEnabled"`
	CgiEnabled                     bool      `json:"cgiEnabled" yaml:"cgiEnabled"`
	ClamAvEnabled                  bool      `json:"clamAvEnabled" yaml:"clamAvEnabled"`
	Created                        time.Time `json:"created" yaml:"created"`
	Creator                        string    `json:"creator" yaml:"creator"`
	CronEnabled                    bool      `json:"cronEnabled" yaml:"cronEnabled"`
	Domain                         string    `json:"domain" yaml:"domain"`
	DNSEnabled                     bool      `json:"dnsEnabled" yaml:"dnsEnabled"`
	Email                          string    `json:"email" yaml:"email"`
	GitEnabled                     bool      `json:"gitEnabled" yaml:"gitEnabled"`
	IpAddresses                    []string  `json:"ipAddresses" yaml:"ipAddresses"`
	JailEnabled                    bool      `json:"jailEnabled" yaml:"jailEnabled"`
	Language                       string    `json:"language" yaml:"language"`
	LoginKeysEnabled               bool      `json:"loginKeysEnabled" yaml:"loginKeysEnabled"`
	NginxEnabled                   bool      `json:"nginxEnabled" yaml:"nginxEnabled"`
	NotifyOnQuestionFailures       bool      `json:"notifyOnQuestionFailures" yaml:"notifyOnQuestionFailures"`
	NotifyOnTwoFactorFailures      bool      `json:"notifyOnTwoFactorFailures" yaml:"notifyOnTwoFactorFailures"`
	Ns1                            string    `json:"ns1" yaml:"ns1"`
	Ns2                            string    `json:"ns2" yaml:"ns2"`
	Package                        string    `json:"package" yaml:"package"`
	PhpEnabled                     bool      `json:"phpEnabled" yaml:"phpEnabled"`
	RedisEnabled                   bool      `json:"redisEnabled" yaml:"redisEnabled"`
	SecurityQuestionsEnabled       bool      `json:"securityQuestionsEnabled" yaml:"securityQuestionsEnabled"`
	Skin                           string    `json:"skin" yaml:"skin"`
	SpamEnabled                    bool      `json:"spamEnabled" yaml:"spamEnabled"`
	SshEnabled                     bool      `json:"sshEnabled" yaml:"sshEnabled"`
	SslEnabled                     bool      `json:"sslEnabled" yaml:"sslEnabled"`
	Suspended                      bool      `json:"suspended" yaml:"suspended"`
	SuspendAtLimitEnabled          bool      `json:"suspendAtLimitEnabled" yaml:"suspendAtLimitEnabled"`
	SysInfoEnabled                 bool      `json:"sysInfoEnabled" yaml:"sysInfoEnabled"`
	TwoFactorAuthenticationEnabled bool      `json:"twoFactorAuthenticationEnabled" yaml:"twoFactorAuthenticationEnabled"`
	Username                       string    `json:"username" yaml:"username"`
	UserType                       string    `json:"userType" yaml:"userType"`
	WordPressToolkitEnabled        bool      `json:"wordPressToolkitEnabled" yaml:"wordPressToolkitEnabled"`
}

type UserContext

type UserContext struct {
	User User
	// contains filtered or unexported fields
}

func (*UserContext) ChangeWordPressUserPassword

func (c *UserContext) ChangeWordPressUserPassword(locationId string, userId int, password string) error

ChangeWordPressUserPassword (user) changes the password of the given wordpress user.

func (*UserContext) CheckDNSRecordExists

func (c *UserContext) CheckDNSRecordExists(checkField string, domain string, dnsRecord DNSRecord) error

CheckDNSRecordExists (user) checks if the given dns record exists on the server

checkField can be either "name" or "value"

func (*UserContext) CheckDomainExists

func (c *UserContext) CheckDomainExists(domain string) error

CheckDomainExists (user) checks if the given domain exists on the server

func (*UserContext) CheckFileExists

func (c *UserContext) CheckFileExists(filePath string) error

CheckFileExists (user) checks if the given file exists on the server

func (*UserContext) CreateDNSRecord

func (c *UserContext) CreateDNSRecord(domain string, dnsRecord DNSRecord) error

CreateDNSRecord (user) creates the provided dns record for the given domain

func (*UserContext) CreateDatabase

func (c *UserContext) CreateDatabase(database *Database) error

func (*UserContext) CreateDatabaseUser

func (c *UserContext) CreateDatabaseUser(databaseUser *DatabaseUser) error

func (*UserContext) CreateDatabaseWithUser

func (c *UserContext) CreateDatabaseWithUser(database *DatabaseWithUser) error

func (*UserContext) CreateDomain

func (c *UserContext) CreateDomain(domain Domain) error

CreateDomain (user) creates the provided domain for the session user

func (*UserContext) CreateEmailAccount

func (c *UserContext) CreateEmailAccount(emailAccount EmailAccount) error

func (*UserContext) CreateEmailForwarder

func (c *UserContext) CreateEmailForwarder(domain string, user string, emails ...string) error

func (*UserContext) CreateFile

func (c *UserContext) CreateFile(uploadToPath string, filePath string) error

CreateFile (user) creates the provided file for the session user

func (*UserContext) CreateFiles

func (c *UserContext) CreateFiles(uploadToPath string, filePaths ...string) error

CreateFiles (user) creates the provided files for the session user

func (*UserContext) CreateLoginURL

func (c *UserContext) CreateLoginURL(loginKeyURL *LoginKeyURL) (*LoginKeyURL, error)

func (*UserContext) CreateSubdomain

func (c *UserContext) CreateSubdomain(subdomain Subdomain) error

CreateSubdomain (user) creates the provided subdomain for the session user. This automatically gets called if subdomains are included in the CreateDomain call. You cannot specify a custom directory here

func (*UserContext) CreateWordPressInstall

func (c *UserContext) CreateWordPressInstall(install WordPressInstall, createDatabase bool) error

func (*UserContext) CreateWordPressInstallQuick

func (c *UserContext) CreateWordPressInstallQuick(install WordPressInstallQuick) error

CreateWordPressInstallQuick (user) creates a new wordpress install and automatically creates a database

func (*UserContext) DeleteDNSRecords

func (c *UserContext) DeleteDNSRecords(dnsRecords ...DNSRecord) error

DeleteDNSRecords (user) deletes all the specified dnss for the session user

func (*UserContext) DeleteDatabase

func (c *UserContext) DeleteDatabase(databaseName string) error

func (*UserContext) DeleteDomains

func (c *UserContext) DeleteDomains(deleteData bool, domains ...string) error

DeleteDomains (user) deletes all the specified domains for the session user

func (*UserContext) DeleteEmailAccount

func (c *UserContext) DeleteEmailAccount(domain string, name string) error

func (*UserContext) DeleteEmailForwarders

func (c *UserContext) DeleteEmailForwarders(domain string, names ...string) error

func (*UserContext) DeleteFiles

func (c *UserContext) DeleteFiles(skipTrash bool, files ...string) error

DeleteFiles (user) deletes all the specified files for the session user

func (*UserContext) DeleteSubdomains

func (c *UserContext) DeleteSubdomains(deleteData bool, domain string, subdomains ...string) error

DeleteSubdomains (user) deletes all the specified subdomain for the session user

func (*UserContext) DeleteWordPressInstall

func (c *UserContext) DeleteWordPressInstall(id string) error

func (*UserContext) DownloadDatabase

func (c *UserContext) DownloadDatabase(name string, format DatabaseFormat, filePath string) error

func (*UserContext) ExportDatabase

func (c *UserContext) ExportDatabase(databaseName string, gzip bool) ([]byte, error)

ExportDatabase (user) returns an export of the given database

func (*UserContext) ExtractFile

func (c *UserContext) ExtractFile(filePath string, file string) error

func (*UserContext) GetBasicSysInfo

func (c *UserContext) GetBasicSysInfo() (*BasicSysInfo, error)

func (*UserContext) GetDNSRecords

func (c *UserContext) GetDNSRecords(domain string) ([]DNSRecord, error)

GetDNSRecords (user) returns the given domain's dns records

func (*UserContext) GetDatabase

func (c *UserContext) GetDatabase(databaseName string) (*Database, error)

GetDatabase (user) returns the given database

func (*UserContext) GetDatabaseProcesses

func (c *UserContext) GetDatabaseProcesses() ([]*DatabaseProcess, error)

GetDatabaseProcesses (admin) returns an array of current database processes

func (*UserContext) GetDatabases

func (c *UserContext) GetDatabases() ([]*Database, error)

GetDatabases (user) returns an array of the session user's databases

func (*UserContext) GetDomain

func (c *UserContext) GetDomain(domainName string) (Domain, error)

GetDomain (user) returns the single specified domain

func (*UserContext) GetDomains

func (c *UserContext) GetDomains() ([]Domain, error)

GetDomains (user) returns the session user's domains

func (*UserContext) GetEmailAccounts

func (c *UserContext) GetEmailAccounts(domain string) ([]EmailAccount, error)

GetEmailAccounts (user) returns an array of email accounts belonging to the provided domain

func (*UserContext) GetEmailForwarders

func (c *UserContext) GetEmailForwarders(domain string) (map[string][]string, error)

GetEmailForwarders (user) returns an array of email forwarders belonging to the provided domain

func (*UserContext) GetLoginURLs

func (c *UserContext) GetLoginURLs() ([]*LoginKeyURL, error)

func (*UserContext) GetMyUserConfig

func (c *UserContext) GetMyUserConfig() (*UserConfig, error)

GetMyUserConfig (user) returns the session user's config

func (*UserContext) GetMyUserUsage

func (c *UserContext) GetMyUserUsage() (*UserUsage, error)

GetMyUserUsage (user) returns the session user's usage

func (*UserContext) GetMyUsername

func (c *UserContext) GetMyUsername() string

GetMyUsername returns the current user's username. This is particularly useful when logging in as another user, as it trims the admin/reseller username automatically

func (*UserContext) GetSysInfo

func (c *UserContext) GetSysInfo() (*SysInfo, error)

func (*UserContext) GetWordPressInstalls

func (c *UserContext) GetWordPressInstalls() ([]*WordPressLocation, error)
func (c *UserContext) GetWordPressSSOLink(locationId string, userId int) (string, error)

func (*UserContext) GetWordPressUsers

func (c *UserContext) GetWordPressUsers(locationId string) ([]*WordPressUser, error)

func (*UserContext) ImportDatabase

func (c *UserContext) ImportDatabase(databaseName string, emptyExistingDatabase bool, sql []byte) error

ImportDatabase (user) imports the given database export into the given database

func (*UserContext) IssueSSL

func (c *UserContext) IssueSSL(domain string, hostnamesToCertify ...string) error

IssueSSL (user) requests a lets encrypt certificate for the given hostnames

func (*UserContext) ListDomains

func (c *UserContext) ListDomains() (domainList []string, err error)

ListDomains (user) returns an array of all domains for the session user

func (*UserContext) ListSubdomains

func (c *UserContext) ListSubdomains(domain string) (subdomainList []string, err error)

ListSubdomains (user) returns an array of all subdomains for the given domain

func (*UserContext) Login

func (c *UserContext) Login() error

func (*UserContext) SetDefaultDomain

func (c *UserContext) SetDefaultDomain(domain string) error

SetDefaultDomain (user) sets the default domain for the session user

func (*UserContext) UpdateDNSRecord

func (c *UserContext) UpdateDNSRecord(domain string, originalDNSRecord DNSRecord, updatedDNSRecord DNSRecord) error

UpdateDNSRecord (user) updates the given dns record for the given domain

func (*UserContext) UpdateDatabaseUserHosts

func (c *UserContext) UpdateDatabaseUserHosts(username string, hosts []string) error

UpdateDatabaseUserHosts (user) updates the given database user's hosts

func (*UserContext) UpdateDatabaseUserPassword

func (c *UserContext) UpdateDatabaseUserPassword(username string, password string) error

UpdateDatabaseUserPassword (user) updates the given database user's password

func (*UserContext) UpdateDomain

func (c *UserContext) UpdateDomain(domain Domain) error

UpdateDomain (user) accepts a Domain object and updates the version on DA with it

func (*UserContext) UpdateEmailAccount

func (c *UserContext) UpdateEmailAccount(emailAccount EmailAccount) error

func (*UserContext) UpdateEmailForwarder

func (c *UserContext) UpdateEmailForwarder(domain string, user string, emails ...string) error

func (*UserContext) UpdateSubdomainRoot

func (c *UserContext) UpdateSubdomainRoot(subdomain Subdomain) error

func (*UserContext) VerifyEmailAccount

func (c *UserContext) VerifyEmailAccount(address string, password string) error

VerifyEmailAccount (user) accepts the full email address as well as the password for the account. If the credentials aren't correct, an error will be returned.

type UserUsage

type UserUsage struct {
	BandwidthQuota        int           `json:"bandwidthQuota" yaml:"bandwidthQuota"`
	BandwidthUsage        int           `json:"bandwidthUsage" yaml:"bandwidthUsage"`
	DbQuota               int           `json:"dbQuota" yaml:"dbQuota"`
	DbUsage               int           `json:"dbUsage" yaml:"dbUsage"`
	DiskQuota             int           `json:"diskQuota" yaml:"diskQuota"`
	DiskUsage             int           `json:"diskUsage" yaml:"diskUsage"`
	Domains               []domainUsage `json:"domains" yaml:"domains"`
	DomainPointersQuota   int           `json:"domainPointersQuota" yaml:"domainPointersQuota"`
	DomainPointersUsage   int           `json:"domainPointersUsage" yaml:"domainPointersUsage"`
	DomainQuota           int           `json:"domainQuota" yaml:"domainQuota"`
	DomainUsage           int           `json:"domainUsage" yaml:"domainUsage"`
	EmailQuota            int           `json:"emailQuota" yaml:"emailQuota"`
	EmailUsage            int           `json:"emailUsage" yaml:"emailUsage"`
	EmailForwardersQuota  int           `json:"emailForwardersQuota" yaml:"emailForwardersQuota"`
	EmailForwardersUsage  int           `json:"emailForwardersUsage" yaml:"emailForwardersUsage"`
	EmailMailingListQuota int           `json:"emailMailingListQuota" yaml:"emailMailingListQuota"`
	EmailMailingListUsage int           `json:"emailMailingListUsage" yaml:"emailMailingListUsage"`
	FtpQuota              int           `json:"ftpQuota" yaml:"ftpQuota"`
	FtpUsage              int           `json:"ftpUsed" yaml:"ftpUsed"`
	InodeQuota            int           `json:"inodeQuota" yaml:"inodeQuota"`
	InodeUsage            int           `json:"inodeUsage" yaml:"inodeUsage"`
	SubdomainQuota        int           `json:"subdomainQuota" yaml:"subdomainQuota"`
	SubdomainUsage        int           `json:"subdomainUsage" yaml:"subdomainUsage"`
}

type WordPressInstall

type WordPressInstall struct {
	AdminEmail string `json:"adminEmail" yaml:"adminEmail"`
	AdminName  string `json:"adminName" yaml:"adminName"`
	AdminPass  string `json:"adminPass" yaml:"adminPass"`
	DbName     string `json:"dbName" yaml:"dbName"`
	DbPass     string `json:"dbPass" yaml:"dbPass"`
	DbPrefix   string `json:"dbPrefix" yaml:"dbPrefix"`
	DbUser     string `json:"dbUser" yaml:"dbUser"`
	FilePath   string `json:"filePath" yaml:"filePath"`
	Title      string `json:"title" yaml:"title"`
}

type WordPressInstallQuick

type WordPressInstallQuick struct {
	AdminEmail string `json:"adminEmail" yaml:"adminEmail"`
	FilePath   string `json:"filePath" yaml:"filePath"`
	Title      string `json:"title" yaml:"title"`
}

type WordPressLocation

type WordPressLocation struct {
	FilePath  string `json:"filePath"`
	Host      string `json:"host"`
	Id        string `json:"id"`
	WebPath   string `json:"webPath"`
	Wordpress struct {
		AutoUpdateMajor bool   `json:"autoUpdateMajor"`
		AutoUpdateMinor bool   `json:"autoUpdateMinor"`
		Error           string `json:"error"`
		SiteURL         string `json:"siteURL"`
		Template        string `json:"template"`
		Title           string `json:"title"`
		Version         string `json:"version"`
	} `json:"wordpress"`
}

type WordPressUser

type WordPressUser struct {
	Id          int       `json:"id"`
	DisplayName string    `json:"displayName"`
	Email       string    `json:"email"`
	Login       string    `json:"login"`
	Registered  time.Time `json:"registered"`
	Roles       []string  `json:"roles"`
}

Jump to

Keyboard shortcuts

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