Skip to content

A library to interface with a DirectAdmin installation's API

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
license.go
Notifications You must be signed in to change notification settings

levelzerotechnology/directadmin-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A library to interface with a DirectAdmin installation's API

Topics

Resources

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
license.go

Stars

Watchers

Forks

Packages

No packages published

Languages