api

package
v0.0.0-...-c123614 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package api Golang bindings for Baruwa REST API

Usage:

import "github.com/baruwa-enterprise/baruwa-go/api"

Create a new Baruwa API client, then use the various methods on the client to access different parts of the Baruwa REST API. For example:

import (
	"fmt"
	"log"
	"os"

	"github.com/baruwa-enterprise/baruwa-go/api"
	prettyjson "github.com/hokaccha/go-prettyjson"
)

func main() {
	var (
		err                 error
		c                   *api.Client
		u                   *api.UserList
		opts                *api.ListOptions
		serverURL, apiToken string
	)

	serverURL = os.Getenv("BARUWA_API_SERVER")
	apiToken = os.Getenv("BARUWA_API_TOKEN")

	if c, err = api.New(serverURL, apiToken, nil); err != nil {
		log.Fatal(err)
	}

	// page through users
	for {
		if u, err = c.GetUsers(opts); err != nil {
			log.Fatal(err)
		}

		if len(u.Items) == 0 {
			fmt.Println()
			break
		}

		if b, err = prettyjson.Marshal(u); err != nil {
			log.Fatal(err)
		}

		fmt.Printf("%s\n", b)

		if u.Links.Pages.Next == "" {
			break
		}

		opts = &api.ListOptions{
			Page: u.Links.Pages.Next,
		}
	}
}

Refer to the https://github.com/baruwa-enterprise/baruwactl for a full application built using this api for further usage information.

Index

Constants

View Source
const (
	// APIVersion of Baruwa API
	APIVersion = "v1"
	// Version of this library
	Version = "0.0.1"

	// UserListURL - users list paging url fmt string
	UserListURL = "%s/api/%s/users?page=%d"
	// OrgListURL - organization list paging url fmt string
	OrgListURL = "%s/api/%s/organizations?page=%d"
	// OrgSMListURL - organization smarthosts list paging url fmt string
	OrgSMListURL = "%s/api/%s/organizations/smarthosts/%d?page=%d"
	// OrgFSListURL - fallback servers list paging url fmt string
	OrgFSListURL = "%s/api/%s/failbackservers/%d?page=%d"
	// DomainListURL - domains list paging url fmt string
	DomainListURL = "%s/api/%s/domains?page=%d"
	// UDSListURL - user delivery servers list paging url fmt string
	UDSListURL = "%s/api/%s/userdeliveryservers/%d?page=%d"
	// DSMListURL - domain smarthosts list paging url fmt string
	DSMListURL = "%s/api/%s/domains/smarthosts/%d?page=%d"
	// DDSListURL - delivery servers list paging url fmt string
	DDSListURL = "%s/api/%s/deliveryservers/%d?page=%d"
	// DASListURL - domain smarthosts list paging url fmt string
	DASListURL = "%s/api/%s/authservers/%d?page=%d"
	// DAliasListURL - domain aliases list paging url fmt string
	DAliasListURL = "%s/api/%s/domainaliases/%d?page=%d"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliasAddress

type AliasAddress struct {
	ID      int    `json:"id,omitempty" url:"id,omitempty"`
	Address string `json:"address" url:"address"`
	Enabled bool   `json:"enabled" url:"enabled"`
}

AliasAddress hosts alias addresses

Baruwa API Docs: https://www.baruwa.com/docs/api/#alias-addresses

type AliasDomain

type AliasDomain struct {
	ID   int    `json:"id" url:"id"`
	Name string `json:"name" url:"name"`
}

AliasDomain hold alias domain entries

type AuthServer

type AuthServer struct {
	ID              int    `json:"id,omitempty" url:"id,omitempty"`
	Address         string `json:"address" url:"address"`
	Port            int    `json:"port" url:"port"`
	Protocol        int    `json:"protocol" url:"protocol"`
	Enabled         bool   `json:"enabled" url:"enabled"`
	SplitAddress    bool   `json:"split_address" url:"split_address"`
	UserMapTemplate string `json:"user_map_template" url:"user_map_template"`
}

AuthServer holds an authentication server

type AuthServerList

type AuthServerList struct {
	Items []AuthServer `json:"items"`
	Links Links        `json:"links"`
	Meta  Meta         `json:"meta"`
}

AuthServerList holds authentication servers

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

Client represents the Baruwa API client

func New

func New(endpoint, token string, options *Options) (c *Client, err error)

New creates a new Baruwa API client.Options are optional and can be nil.

func (*Client) ChangeUserPassword

func (c *Client) ChangeUserPassword(userID int, form *PasswordForm) (err error)

ChangeUserPassword changes a users account password

Baruwa API Docs: https://www.baruwa.com/docs/api/#change-a-password

func (*Client) CreateAliasAddress

func (c *Client) CreateAliasAddress(userID int, alias *AliasAddress) (err error)

CreateAliasAddress creates an alias address

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-an-alias-address

func (*Client) CreateAuthServer

func (c *Client) CreateAuthServer(domainID int, server *AuthServer) (err error)

CreateAuthServer creates an authentication server

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-authentication-settings

func (*Client) CreateDomain

func (c *Client) CreateDomain(domain *Domain) (err error)

CreateDomain creates a domain

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-new-domain

func (*Client) CreateDomainAlias

func (c *Client) CreateDomainAlias(domainID int, form *DomainAliasForm) (alias *DomainAlias, err error)

CreateDomainAlias creates a domain alias

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-domain-alias

func (*Client) CreateDomainDeliveryServer

func (c *Client) CreateDomainDeliveryServer(domainID int, form *DomainDeliveryServerForm) (server *DomainDeliveryServer, err error)

CreateDomainDeliveryServer creates a domain delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-delivery-server

func (*Client) CreateDomainSmartHost

func (c *Client) CreateDomainSmartHost(domainID int, server *DomainSmartHost) (err error)

CreateDomainSmartHost creates a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-domain-smarthost

func (*Client) CreateFallBackServer

func (c *Client) CreateFallBackServer(organizationID int, server *FallBackServer) (err error)

CreateFallBackServer creates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-fallback-server

func (*Client) CreateLDAPSettings

func (c *Client) CreateLDAPSettings(domainID, serverID int, settings *LDAPSettings) (err error)

CreateLDAPSettings creates a domain LDAP settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-ad-ldap-settings

func (*Client) CreateOrgSmartHost

func (c *Client) CreateOrgSmartHost(organizationID int, server *OrgSmartHost) (err error)

CreateOrgSmartHost creates a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-an-organization-smarthost

func (*Client) CreateOrganization

func (c *Client) CreateOrganization(form *OrganizationForm) (org *Organization, err error)

CreateOrganization creates an organization

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-an-organization

func (*Client) CreateRadiusSettings

func (c *Client) CreateRadiusSettings(domainID, serverID int, settings *RadiusSettings) (err error)

CreateRadiusSettings creates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-radius-settings

func (*Client) CreateRelaySetting

func (c *Client) CreateRelaySetting(organizationID int, server *RelaySetting) (err error)

CreateRelaySetting creates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-relay-settings

func (*Client) CreateUser

func (c *Client) CreateUser(user *UserForm) (u *User, err error)

CreateUser creates a user account

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-new-account

func (*Client) CreateUserDeliveryServer

func (c *Client) CreateUserDeliveryServer(domainID int, form *UserDeliveryServerForm) (server *UserDeliveryServer, err error)

CreateUserDeliveryServer creates a user delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#create-a-user-delivery-server

func (*Client) DeleteAliasAddress

func (c *Client) DeleteAliasAddress(alias *AliasAddress) (err error)

DeleteAliasAddress deletes an alias address

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-an-alias-address

func (*Client) DeleteAuthServer

func (c *Client) DeleteAuthServer(domainID int, server *AuthServer) (err error)

DeleteAuthServer deletes an authentication server

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-authentication-settings

func (*Client) DeleteDomain

func (c *Client) DeleteDomain(domainID int) (err error)

DeleteDomain deletes a domain

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-domain

func (*Client) DeleteDomainAlias

func (c *Client) DeleteDomainAlias(domainID int, form *DomainAliasForm) (err error)

DeleteDomainAlias deletes an domain alias

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-domain-alias

func (*Client) DeleteDomainDeliveryServer

func (c *Client) DeleteDomainDeliveryServer(domainID int, form *DomainDeliveryServerForm) (err error)

DeleteDomainDeliveryServer deletes a domain delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-delivery-server

func (*Client) DeleteDomainSmartHost

func (c *Client) DeleteDomainSmartHost(domainID int, server *DomainSmartHost) (err error)

DeleteDomainSmartHost deletes a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-domain-smarthost

func (*Client) DeleteFallBackServer

func (c *Client) DeleteFallBackServer(server *FallBackServer) (err error)

DeleteFallBackServer deletes radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-fallback-server

func (*Client) DeleteLDAPSettings

func (c *Client) DeleteLDAPSettings(domainID, serverID int, settings *LDAPSettings) (err error)

DeleteLDAPSettings deletes a domain LDAP settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-ad-ldap-settings

func (*Client) DeleteOrgSmartHost

func (c *Client) DeleteOrgSmartHost(organizationID int, server *OrgSmartHost) (err error)

DeleteOrgSmartHost deletes a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-system-status

func (*Client) DeleteOrganization

func (c *Client) DeleteOrganization(organizationID int) (err error)

DeleteOrganization deletes an organization

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-an-organization

func (*Client) DeleteRadiusSettings

func (c *Client) DeleteRadiusSettings(domainID, serverID int, settings *RadiusSettings) (err error)

DeleteRadiusSettings deletes radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-radius-settings

func (*Client) DeleteRelaySetting

func (c *Client) DeleteRelaySetting(server *RelaySetting) (err error)

DeleteRelaySetting deletes radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-relay-settings

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID int) (err error)

DeleteUser deletes a user account

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-an-account

func (*Client) DeleteUserDeliveryServer

func (c *Client) DeleteUserDeliveryServer(domainID int, form *UserDeliveryServerForm) (err error)

DeleteUserDeliveryServer deletes a user delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#delete-a-user-delivery-server

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(clientID, secret string) (token *TokenResponse, err error)

GetAccessToken returns a token

func (*Client) GetAliasAddress

func (c *Client) GetAliasAddress(aliasID int) (alias *AliasAddress, err error)

GetAliasAddress returns an alias address

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-an-existing-alias-address

func (*Client) GetAuthServer

func (c *Client) GetAuthServer(domainID, serverID int) (server *AuthServer, err error)

GetAuthServer returns an authentication server

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-authentication-settings

func (*Client) GetAuthServers

func (c *Client) GetAuthServers(domainID int, opts *ListOptions) (l *AuthServerList, err error)

GetAuthServers returns a AuthServerList object This contains a paginated list of authentication servers and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-authentication-settings

func (*Client) GetDomain

func (c *Client) GetDomain(domainID int) (domain *Domain, err error)

GetDomain returns a domain

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-domain

func (*Client) GetDomainAlias

func (c *Client) GetDomainAlias(domainID, aliasID int) (alias *DomainAlias, err error)

GetDomainAlias returns a domain alias

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-domain-alias

func (*Client) GetDomainAliases

func (c *Client) GetDomainAliases(domainID int, opts *ListOptions) (l *DomainAliasList, err error)

GetDomainAliases returns a DomainList object This contains a paginated list of domain aliases and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#domain-aliases

func (*Client) GetDomainByName

func (c *Client) GetDomainByName(domainName string) (domain *Domain, err error)

GetDomainByName returns a domain

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-domain-by-name

func (*Client) GetDomainDeliveryServer

func (c *Client) GetDomainDeliveryServer(domainID, serverID int) (server *DomainDeliveryServer, err error)

GetDomainDeliveryServer returns a domain delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-delivery-server

func (*Client) GetDomainDeliveryServers

func (c *Client) GetDomainDeliveryServers(domainID int, opts *ListOptions) (l *DomainDeliveryServerList, err error)

GetDomainDeliveryServers returns a DomainDeliveryServerList object This contains a paginated list of domain delivery servers and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-delivery-servers

func (*Client) GetDomainSmartHost

func (c *Client) GetDomainSmartHost(domainID, serverID int) (server *DomainSmartHost, err error)

GetDomainSmartHost returns a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-domain-smarthost

func (*Client) GetDomainSmartHosts

func (c *Client) GetDomainSmartHosts(domainID int, opts *ListOptions) (l *DomainSmartHostList, err error)

GetDomainSmartHosts returns a DomainSmartHostList object This contains a paginated list of domain smarthosts and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-domain-smarthosts

func (*Client) GetDomains

func (c *Client) GetDomains(opts *ListOptions) (l *DomainList, err error)

GetDomains returns a DomainList object This contains a paginated list of domains and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#list-all-domains

func (*Client) GetFallBackServer

func (c *Client) GetFallBackServer(serverID int) (server *FallBackServer, err error)

GetFallBackServer returns radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-fallback-server

func (*Client) GetFallBackServers

func (c *Client) GetFallBackServers(organizationID int, opts *ListOptions) (l *FallBackServerList, err error)

GetFallBackServers returns a FallBackServerList object This contains a paginated list of fallback servers and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#fallback-servers

func (*Client) GetLDAPSettings

func (c *Client) GetLDAPSettings(domainID, serverID, settingsID int) (settings *LDAPSettings, err error)

GetLDAPSettings returns a domain LDAP settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-ad-ldap-settings

func (*Client) GetOrgSmartHost

func (c *Client) GetOrgSmartHost(organizationID, serverID int) (server *OrgSmartHost, err error)

GetOrgSmartHost returns a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-organization-smarthost

func (*Client) GetOrgSmartHosts

func (c *Client) GetOrgSmartHosts(organizationID int, opts *ListOptions) (l *OrgSmartHostList, err error)

GetOrgSmartHosts returns a OrgSmartHostList object This contains a paginated list of Organization smarthosts and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-organization-smarthosts

func (*Client) GetOrganization

func (c *Client) GetOrganization(organizationID int) (org *Organization, err error)

GetOrganization returns an organization

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-an-existing-organization

func (*Client) GetOrganizations

func (c *Client) GetOrganizations(opts *ListOptions) (l *OrganizationList, err error)

GetOrganizations returns a OrganizationList object This contains a paginated list of Organizations and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-all-organizations

func (*Client) GetRadiusSettings

func (c *Client) GetRadiusSettings(domainID, serverID, settingsID int) (settings *RadiusSettings, err error)

GetRadiusSettings returns radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-radius-settings

func (*Client) GetRelaySetting

func (c *Client) GetRelaySetting(relayID int) (server *RelaySetting, err error)

GetRelaySetting returns radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-relay-settings

func (*Client) GetSystemStatus

func (c *Client) GetSystemStatus() (status *SystemStatus, err error)

GetSystemStatus returns radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-system-status

func (*Client) GetUser

func (c *Client) GetUser(userID int) (user *User, err error)

GetUser returns a user account

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-an-existing-account

func (*Client) GetUserDeliveryServer

func (c *Client) GetUserDeliveryServer(domainID, serverID int) (server *UserDeliveryServer, err error)

GetUserDeliveryServer returns a user delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#retrieve-a-user-delivery-server

func (*Client) GetUserDeliveryServers

func (c *Client) GetUserDeliveryServers(domainID int, opts *ListOptions) (l *UserDeliveryServerList, err error)

GetUserDeliveryServers returns a UserDeliveryServerList object This contains a paginated list of domain delivery servers and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#listing-user-delivery-servers

func (*Client) GetUsers

func (c *Client) GetUsers(opts *ListOptions) (l *UserList, err error)

GetUsers returns a UserList object This contains a paginated list of user accounts and links to the neighbouring pages.

Baruwa API Docs: https://www.baruwa.com/docs/api/#list-all-accounts

func (*Client) UpdateAliasAddress

func (c *Client) UpdateAliasAddress(alias *AliasAddress) (err error)

UpdateAliasAddress updates an alias address

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-an-alias-address

func (*Client) UpdateAuthServer

func (c *Client) UpdateAuthServer(domainID int, server *AuthServer) (err error)

UpdateAuthServer updates an authentication server

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-authentication-settings

func (*Client) UpdateDomain

func (c *Client) UpdateDomain(domain *Domain) (err error)

UpdateDomain updates a domain

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-domain

func (*Client) UpdateDomainAlias

func (c *Client) UpdateDomainAlias(domainID int, form *DomainAliasForm) (err error)

UpdateDomainAlias updates a domain alias

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-domain-alias

func (*Client) UpdateDomainDeliveryServer

func (c *Client) UpdateDomainDeliveryServer(domainID int, form *DomainDeliveryServerForm) (err error)

UpdateDomainDeliveryServer updates a domain delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-delivery-server

func (*Client) UpdateDomainSmartHost

func (c *Client) UpdateDomainSmartHost(domainID int, server *DomainSmartHost) (err error)

UpdateDomainSmartHost updates a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-domain-smarthost

func (*Client) UpdateFallBackServer

func (c *Client) UpdateFallBackServer(server *FallBackServer) (err error)

UpdateFallBackServer updates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-fallback-server

func (*Client) UpdateLDAPSettings

func (c *Client) UpdateLDAPSettings(domainID, serverID int, settings *LDAPSettings) (err error)

UpdateLDAPSettings updates a domain LDAP settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-ad-ldap-settings

func (*Client) UpdateOrgSmartHost

func (c *Client) UpdateOrgSmartHost(organizationID int, server *OrgSmartHost) (err error)

UpdateOrgSmartHost updates a domain smarthost

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-organization-smarthost

func (*Client) UpdateOrganization

func (c *Client) UpdateOrganization(form *OrganizationForm, org *Organization) (err error)

UpdateOrganization updates an organization

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-an-organization

func (*Client) UpdateRadiusSettings

func (c *Client) UpdateRadiusSettings(domainID, serverID int, settings *RadiusSettings) (err error)

UpdateRadiusSettings updates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-radius-settings

func (*Client) UpdateRelaySetting

func (c *Client) UpdateRelaySetting(server *RelaySetting) (err error)

UpdateRelaySetting updates radius settings

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-relay-settings

func (*Client) UpdateUser

func (c *Client) UpdateUser(user *UserForm) (err error)

UpdateUser updates a user account

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-an-account

func (*Client) UpdateUserDeliveryServer

func (c *Client) UpdateUserDeliveryServer(domainID int, form *UserDeliveryServerForm) (err error)

UpdateUserDeliveryServer updates a user delivery server

Baruwa API Docs: https://www.baruwa.com/docs/api/#update-a-user-delivery-server

type Domain

type Domain struct {
	ID                int          `json:"id,omitempty" url:"id,omitempty"`
	Name              string       `json:"name" url:"name"`
	SiteURL           string       `json:"site_url" url:"site_url"`
	Enabled           bool         `json:"status" url:"status"`
	AcceptInbound     bool         `json:"accept_inbound" url:"accept_inbound"`
	DiscardMail       bool         `json:"discard_mail" url:"discard_mail"`
	SMTPCallout       bool         `json:"smtp_callout" url:"smtp_callout"`
	LdapCallout       bool         `json:"ldap_callout" url:"ldap_callout"`
	VirusChecks       bool         `json:"virus_checks" url:"virus_checks"`
	VirusChecksAtSMTP bool         `json:"virus_checks_at_smtp" url:"virus_checks_at_smtp"`
	BlockMacros       bool         `json:"block_macros" url:"block_macros"`
	SpamChecks        bool         `json:"spam_checks" url:"spam_checks"`
	SpamActions       int          `json:"spam_actions" url:"spam_actions"`
	HighspamActions   int          `json:"highspam_actions" url:"highspam_actions"`
	VirusActions      int          `json:"virus_actions" url:"virus_actions"`
	LowScore          LocalFloat64 `json:"low_score" url:"low_score"`
	HighScore         LocalFloat64 `json:"high_score" url:"high_score"`
	MessageSize       string       `json:"message_size" url:"message_size"`
	DeliveryMode      int          `json:"delivery_mode" url:"delivery_mode"`
	Language          string       `json:"language" url:"language"`
	Timezone          string       `json:"timezone" url:"timezone"`
	ReportEvery       int          `json:"report_every" url:"report_every"`
	Organizations     []int        `json:"organizations,omitempty" url:"organizations,omitempty"`
}

Domain holds domains

type DomainAlias

type DomainAlias struct {
	ID            int          `json:"id,omitempty" url:"id,omitempty"`
	Name          string       `json:"name" url:"name"`
	Enabled       bool         `json:"status" url:"status"`
	AcceptInbound bool         `json:"accept_inbound" url:"accept_inbound"`
	Domain        *AliasDomain `json:"domain,omitempty" url:"domain,omitempty"`
}

DomainAlias holds domain aliases

type DomainAliasForm

type DomainAliasForm struct {
	ID            int    `json:"id,omitempty" url:"id,omitempty"`
	Name          string `json:"name" url:"name"`
	Enabled       bool   `json:"status" url:"status"`
	AcceptInbound bool   `json:"accept_inbound" url:"accept_inbound"`
	Domain        int    `json:"domain,omitempty" url:"domain,omitempty"`
}

DomainAliasForm holds domain aliases

type DomainAliasList

type DomainAliasList struct {
	Items []DomainAlias `json:"items"`
	Links Links         `json:"links"`
	Meta  Meta          `json:"meta"`
}

DomainAliasList holds domain smarthosts

type DomainDeliveryServer

type DomainDeliveryServer struct {
	ID               int          `json:"id,omitempty" url:"id,omitempty"`
	Address          string       `json:"address" url:"address"`
	Protocol         int          `json:"protocol" url:"protocol"`
	Port             int          `json:"port" url:"port"`
	RequireTLS       bool         `json:"require_tls" url:"require_tls"`
	VerificationOnly bool         `json:"verification_only" url:"verification_only"`
	Enabled          bool         `json:"enabled" url:"enabled"`
	Domain           *AliasDomain `json:"domain,omitempty" url:"domain,omitempty"`
}

DomainDeliveryServer holds domain delivery servers

type DomainDeliveryServerForm

type DomainDeliveryServerForm struct {
	ID               int    `json:"id,omitempty" url:"id,omitempty"`
	Address          string `json:"address" url:"address"`
	Protocol         int    `json:"protocol" url:"protocol"`
	Port             int    `json:"port" url:"port"`
	RequireTLS       bool   `json:"require_tls" url:"require_tls"`
	VerificationOnly bool   `json:"verification_only" url:"verification_only"`
	Enabled          bool   `json:"enabled" url:"enabled"`
	Domain           int    `json:"domain,omitempty" url:"domain,omitempty"`
}

DomainDeliveryServerForm holds domain delivery servers

type DomainDeliveryServerList

type DomainDeliveryServerList struct {
	Items []DomainDeliveryServer `json:"items"`
	Links Links                  `json:"links"`
	Meta  Meta                   `json:"meta"`
}

DomainDeliveryServerList holds domain delivery servers

type DomainList

type DomainList struct {
	Items []Domain `json:"items"`
	Links Links    `json:"links"`
	Meta  Meta     `json:"meta"`
}

DomainList holds domain smarthosts

type DomainSmartHost

type DomainSmartHost struct {
	ID          int    `json:"id,omitempty" url:"id,omitempty"`
	Address     string `json:"address" url:"address"`
	Username    string `json:"username" url:"username"`
	Password    string `json:"password,omitempty" url:"password,omitempty"`
	Port        int    `json:"port" url:"port"`
	RequireTLS  bool   `json:"require_tls" url:"require_tls"`
	Enabled     bool   `json:"enabled" url:"enabled"`
	Description string `json:"description" url:"description"`
}

DomainSmartHost holds domain smarthosts

type DomainSmartHostList

type DomainSmartHostList struct {
	Items []DomainSmartHost `json:"items"`
	Links Links             `json:"links"`
	Meta  Meta              `json:"meta"`
}

DomainSmartHostList holds domain smarthosts

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response `json:"-"`
	Message  string         `json:"error,omitempty"`
	Code     int            `json:"code,omitempty"`
}

ErrorResponse https://www.baruwa.com/docs/api/#errors

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error method implementation for ErrorResponse struct

type FallBackServer

type FallBackServer struct {
	ID               int                `json:"id,omitempty" url:"id,omitempty"`
	Address          string             `json:"address" url:"address"`
	Protocol         int                `json:"protocol" url:"protocol"`
	Port             int                `json:"port" url:"port"`
	RequireTLS       bool               `json:"require_tls" url:"require_tls"`
	VerificationOnly bool               `json:"verification_only" url:"verification_only"`
	Enabled          bool               `json:"enabled" url:"enabled"`
	Organization     *FallBackServerOrg `json:"organization" url:"organization"`
}

FallBackServer holds organization fallback servers

type FallBackServerList

type FallBackServerList struct {
	Items []FallBackServer `json:"items"`
	Links Links            `json:"links"`
	Meta  Meta             `json:"meta"`
}

FallBackServerList holds users

type FallBackServerOrg

type FallBackServerOrg struct {
	ID   int    `json:"id" url:"id"`
	Name string `json:"name" url:"name"`
}

FallBackServerOrg holds fallback server organization

type LDAPSettings

type LDAPSettings struct {
	ID                int        `json:"id,omitempty" url:"id,omitempty"`
	Basedn            string     `json:"basedn" url:"basedn"`
	NameAttribute     string     `json:"nameattribute" url:"nameattribute"`
	EmailAttribute    string     `json:"emailattribute" url:"emailattribute"`
	BindDN            string     `json:"binddn" url:"binddn"`
	BindPw            string     `json:"bindpw,omitempty" url:"bindpw,omitempty"`
	UseTLS            bool       `json:"usetls" url:"usetls"`
	UseSearch         bool       `json:"usesearch" url:"usesearch"`
	SearchFilter      string     `json:"searchfilter" url:"searchfilter"`
	SearchScope       string     `json:"search_scope" url:"search_scope"`
	EmailSearchFilter string     `json:"emailsearchfilter" url:"emailsearchfilter"`
	EmailSearchScope  string     `json:"emailsearch_scope" url:"emailsearch_scope"`
	AuthServer        SettingsAS `json:"authserver,omitempty" url:"authserver,omitempty"`
}

LDAPSettings holds Domain LDAP settings

type Links struct {
	Pages Pages `json:"pages"`
}

Links holds links

type ListOptions

type ListOptions struct {
	Page string
}

ListOptions holds list options

type LocalFloat64

type LocalFloat64 float64

LocalFloat64 allow for overriding in cli

func (*LocalFloat64) Set

func (f *LocalFloat64) Set(v string) (err error)

Set is required by cli

func (*LocalFloat64) String

func (f *LocalFloat64) String() string

type Meta

type Meta struct {
	Total int `json:"total"`
}

Meta holds meta

type MyTime

type MyTime struct {
	time.Time
}

MyTime custom date formater

func (*MyTime) MarshalJSON

func (mt *MyTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals the custom date

func (*MyTime) UnmarshalJSON

func (mt *MyTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals the custom date

type Options

type Options struct {
	// HTTP client for communication with the Baruwa API
	HTTPClient *http.Client
	// User agent for HTTP client
	UserAgent string
}

Options represents optional settings and flags that can be passed to New

type OrgDomain

type OrgDomain struct {
	ID   int    `json:"id" url:"id"`
	Name string `json:"name" url:"name"`
}

OrgDomain hold alias domain entries

type OrgSmartHost

type OrgSmartHost struct {
	ID          int    `json:"id,omitempty" url:"id,omitempty"`
	Address     string `json:"address" url:"address"`
	Username    string `json:"username" url:"username"`
	Password    string `json:"password,omitempty" url:"password,omitempty"`
	Port        int    `json:"port" url:"port"`
	RequireTLS  bool   `json:"require_tls" url:"require_tls"`
	Enabled     bool   `json:"enabled" url:"enabled"`
	Description string `json:"description" url:"description"`
}

OrgSmartHost holds domain smarthosts

type OrgSmartHostList

type OrgSmartHostList struct {
	Items []OrgSmartHost `json:"items"`
	Links Links          `json:"links"`
	Meta  Meta           `json:"meta"`
}

OrgSmartHostList holds domain smarthosts

type Organization

type Organization struct {
	ID      int         `json:"id,omitempty" url:"id,omitempty"`
	Name    string      `json:"name" url:"name"`
	Domains []OrgDomain `json:"domains,omitempty" url:"domains,omitempty"`
}

Organization holds organizations

type OrganizationForm

type OrganizationForm struct {
	ID      int    `json:"id,omitempty" url:"id,omitempty"`
	Name    string `json:"name" url:"name"`
	Domains []int  `json:"domains,omitempty" url:"domains,omitempty"`
	Admins  []int  `json:"admins,omitempty" url:"admins,omitempty"`
}

OrganizationForm used for creation and update of organizations

type OrganizationList

type OrganizationList struct {
	Items []Organization `json:"items"`
	Links Links          `json:"links"`
	Meta  Meta           `json:"meta"`
}

OrganizationList holds domain smarthosts

type Pages

type Pages struct {
	First    string `json:"first"`
	Last     string `json:"last"`
	Previous string `json:"prev"`
	Next     string `json:"next"`
}

Pages holds pages

type PasswordForm

type PasswordForm struct {
	Password1 string `json:"password1" url:"password1"`
	Password2 string `json:"password2" url:"password2"`
}

PasswordForm sends password update

type RadiusSettings

type RadiusSettings struct {
	ID         int         `json:"id,omitempty" url:"id,omitempty"`
	Secret     string      `json:"secret" url:"secret"`
	Timeout    int         `json:"timeout" url:"timeout"`
	AuthServer *SettingsAS `json:"authserver,omitempty" url:"authserver,omitempty"`
}

RadiusSettings holds domain radius settings

type RelaySetting

type RelaySetting struct {
	ID              int          `json:"id,omitempty" url:"id,omitempty"`
	Address         string       `json:"address" url:"address"`
	Username        string       `json:"username" url:"username"`
	Enabled         bool         `json:"enabled" url:"enabled"`
	RequireTLS      bool         `json:"require_tls" url:"require_tls"`
	Password1       string       `json:"password1,omitempty" url:"password1,omitempty"`
	Password2       string       `json:"password2,omitempty" url:"password2,omitempty"`
	Description     string       `json:"description" url:"description"`
	LowScore        LocalFloat64 `json:"low_score" url:"low_score"`
	HighScore       LocalFloat64 `json:"high_score" url:"high_score"`
	SpamActions     int          `json:"spam_actions" url:"spam_actions"`
	HighSpamActions int          `json:"highspam_actions" url:"highspam_actions"`
	BlockMacros     bool         `json:"block_macros" url:"block_macros"`
	RateLimit       int          `json:"ratelimit" url:"ratelimit"`
	AllowAllSenders bool         `json:"allow_allsenders" url:"allow_allsenders"`
}

RelaySetting holds relay settings

type SettingsAS

type SettingsAS struct {
	ID int `json:"id"`
}

SettingsAS hold the authentication server id

type SystemStatus

type SystemStatus struct {
	Inbound  int         `json:"inbound" url:"inbound"`
	Status   bool        `json:"status" url:"status"`
	Total    SystemTotal `json:"total" url:"total"`
	Outbound int         `json:"outbound" url:"outbound"`
}

SystemStatus holds system status

type SystemTotal

type SystemTotal struct {
	Spam     int `json:"spam" url:"spam"`
	HighSpam int `json:"highspam" url:"highspam"`
	LowSpam  int `json:"lowspam" url:"lowspam"`
	Infected int `json:"infected" url:"infected"`
	Clean    int `json:"clean" url:"clean"`
	Total    int `json:"total" url:"total"`
	Virii    int `json:"virii" url:"virii"`
}

SystemTotal holds totals

type TokenResponse

type TokenResponse struct {
	RefreshToken string         `json:"refresh_token"`
	Token        string         `json:"access_token"`
	Type         string         `json:"token_type"`
	Scope        string         `json:"score"`
	ExpiresIn    expirationTime `json:"expires_in"`
}

TokenResponse is for API response for the /oauth2/token endpoint

type User

type User struct {
	ID            int                `json:"id,omitempty" url:"id,omitempty"`
	Username      string             `json:"username" url:"username"`
	Firstname     string             `json:"firstname" url:"firstname"`
	Lastname      string             `json:"lastname" url:"lastname"`
	Email         string             `json:"email" url:"email"`
	Timezone      string             `json:"timezone" url:"timezone"`
	AccountType   int                `json:"account_type" url:"account_type"`
	Enabled       bool               `json:"active" url:"active"`
	SendReport    bool               `json:"send_report" url:"send_report"`
	SpamChecks    bool               `json:"spam_checks" url:"spam_checks"`
	LowScore      LocalFloat64       `json:"low_score" url:"low_score"`
	HighScore     LocalFloat64       `json:"high_score" url:"high_score"`
	BlockMacros   bool               `json:"block_macros" url:"block_macros"`
	CreatedOn     MyTime             `json:"created_on" url:"created_on"`
	LastLogin     MyTime             `json:"last_login" url:"last_login"`
	Domains       []UserDomain       `json:"domains,omitempty" url:"domains,omitempty"`
	Organizations []UserOrganization `json:"organizations,omitempty" url:"organizations,omitempty"`
}

User holds users

type UserAddress

type UserAddress struct {
}

UserAddress addresses

type UserDeliveryServer

type UserDeliveryServer struct {
	ID               int          `json:"id,omitempty" url:"id,omitempty"`
	Address          string       `json:"address" url:"address"`
	Protocol         int          `json:"protocol" url:"protocol"`
	Port             int          `json:"port" url:"port"`
	RequireTLS       bool         `json:"require_tls" url:"require_tls"`
	VerificationOnly bool         `json:"verification_only" url:"verification_only"`
	Enabled          bool         `json:"enabled" url:"enabled"`
	Domain           *AliasDomain `json:"domain,omitempty" url:"domain,omitempty"`
}

UserDeliveryServer holds user delivery servers

type UserDeliveryServerForm

type UserDeliveryServerForm struct {
	ID               int    `json:"id,omitempty" url:"id,omitempty"`
	Address          string `json:"address" url:"address"`
	Protocol         int    `json:"protocol" url:"protocol"`
	Port             int    `json:"port" url:"port"`
	RequireTLS       bool   `json:"require_tls" url:"require_tls"`
	VerificationOnly bool   `json:"verification_only" url:"verification_only"`
	Enabled          bool   `json:"enabled" url:"enabled"`
	Domain           int    `json:"domain,omitempty" url:"domain,omitempty"`
}

UserDeliveryServerForm holds user delivery servers

type UserDeliveryServerList

type UserDeliveryServerList struct {
	Items []UserDeliveryServer `json:"items"`
	Links Links                `json:"links"`
	Meta  Meta                 `json:"meta"`
}

UserDeliveryServerList holds user delivery servers

type UserDomain

type UserDomain struct {
	ID   int    `json:"id" url:"id"`
	Name string `json:"name" url:"name"`
}

UserDomain holds user domains

type UserForm

type UserForm struct {
	ID            *int          `json:"id,omitempty" url:"id,omitempty"`
	Username      *string       `json:"username" url:"username,omitempty"`
	Firstname     *string       `json:"firstname" url:"firstname,omitempty"`
	Lastname      *string       `json:"lastname" url:"lastname,omitempty"`
	Password1     *string       `json:"password1" url:"password1,omitempty"`
	Password2     *string       `json:"password2" url:"password2,omitempty"`
	Email         *string       `json:"email" url:"email,omitempty"`
	Timezone      *string       `json:"timezone" url:"timezone,omitempty"`
	AccountType   *int          `json:"account_type" url:"account_type,omitempty"`
	Enabled       *bool         `json:"active" url:"active,omitempty"`
	SendReport    *bool         `json:"send_report" url:"send_report,omitempty"`
	SpamChecks    *bool         `json:"spam_checks" url:"spam_checks,omitempty"`
	LowScore      *LocalFloat64 `json:"low_score" url:"low_score,omitempty,omitempty"`
	HighScore     *LocalFloat64 `json:"high_score" url:"high_score,omitempty"`
	BlockMacros   *bool         `json:"block_macros" url:"block_macros,omitempty"`
	Domains       []int         `json:"domains,omitempty" url:"domains,omitempty"`
	Organizations []int         `json:"organizations,omitempty" url:"organizations,omitempty"`
}

UserForm holds users

type UserList

type UserList struct {
	Items []User `json:"items"`
	Links Links  `json:"links"`
	Meta  Meta   `json:"meta"`
}

UserList holds users

type UserOrganization

type UserOrganization struct {
	ID   int    `json:"id" url:"id"`
	Name string `json:"name" url:"name"`
}

UserOrganization holds user organizations

Jump to

Keyboard shortcuts

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