Documentation ¶
Overview ¶
Package goprsc is the Postfix REST Server API client for GO.
Index ¶
- Variables
- type Account
- type AccountService
- func (s *AccountService) Create(domain, username, password string) error
- func (s *AccountService) Delete(domain, username string) error
- func (s *AccountService) Get(domain, username string) (*Account, error)
- func (s *AccountService) List(domain string) ([]Account, error)
- func (s *AccountService) Update(domain, username string, updateRequest *AccountUpdateRequest) error
- type AccountUpdateRequest
- type Alias
- type AliasService
- func (s *AliasService) Create(domain, alias, email string) error
- func (s *AliasService) Delete(domain, alias, email string) error
- func (s *AliasService) Get(domain, alias string) ([]Alias, error)
- func (s *AliasService) GetForEmail(domain, alias, email string) (*Alias, error)
- func (s *AliasService) List(domain string) ([]Alias, error)
- func (s *AliasService) Update(domain, alias, email string, ur *AliasUpdateRequest) error
- type AliasUpdateRequest
- type AuthResponse
- type AuthService
- type Bcc
- type BccService
- type BccUpdateRequest
- type Client
- type ClientOption
- type DateTime
- type Domain
- type DomainService
- type DomainUpdateRequest
- type ErrorResponse
- type IncomingBccService
- type LoginRequest
- type LogoutRequest
- type OutgoingBccService
- type RefreshTokenRequest
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = NewClient(nil)
DefaultClient is the default Client that works with the default HTTP client and connects to port 8080 on localhost. Use this one if you don't need specific http.Client implementation, protocol, host/IP or port number.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID int `json:"id"` Username string `json:"username"` Domain string `json:"domain"` DomainID int `json:"domainId"` Enabled bool `json:"enabled"` Created DateTime `json:"created"` Updated DateTime `json:"updated"` }
Account is an instance of a account (an email address)
type AccountService ¶
type AccountService service
AccountService handles communication with the account APIs in the Postfix REST Server.
func (*AccountService) Create ¶
func (s *AccountService) Create(domain, username, password string) error
Create creates a new account with the given username in the given domain.
func (*AccountService) Delete ¶
func (s *AccountService) Delete(domain, username string) error
Delete removes the account specified with the given domain and username
func (*AccountService) Get ¶
func (s *AccountService) Get(domain, username string) (*Account, error)
Get returns the account with the given username on the given domain.
func (*AccountService) List ¶
func (s *AccountService) List(domain string) ([]Account, error)
List makes a GET request for all registered accounts in the specified domain.
func (*AccountService) Update ¶
func (s *AccountService) Update(domain, username string, updateRequest *AccountUpdateRequest) error
Update updates the specified account.
type AccountUpdateRequest ¶
type AccountUpdateRequest struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` ConfirmPassword string `json:"confirmPassword,omitempty"` Enabled bool `json:"enabled"` }
AccountUpdateRequest is a data structure that carries account update information
type Alias ¶
type Alias struct { ID int `json:"id"` Name string `json:"name"` Email string `json:"email"` Enabled bool `json:"enabled"` Created DateTime `json:"created"` Updated DateTime `json:"updated"` }
Alias is an email address alias.
type AliasService ¶
type AliasService service
AliasService handles communication with the alias APIs in the Postfix REST Server.
func (*AliasService) Create ¶
func (s *AliasService) Create(domain, alias, email string) error
Create makes a POST request to create a new alias.
func (*AliasService) Delete ¶
func (s *AliasService) Delete(domain, alias, email string) error
Delete removes an alias.
func (*AliasService) Get ¶
func (s *AliasService) Get(domain, alias string) ([]Alias, error)
Get retrieves information for an alias.
func (*AliasService) GetForEmail ¶
func (s *AliasService) GetForEmail(domain, alias, email string) (*Alias, error)
GetForEmail retrieves an alias for specific account and target email.
func (*AliasService) List ¶
func (s *AliasService) List(domain string) ([]Alias, error)
List makes a GET request for all aliases for the given domain.
func (*AliasService) Update ¶
func (s *AliasService) Update(domain, alias, email string, ur *AliasUpdateRequest) error
Update makes a PUT request and updates the specified alias.
type AliasUpdateRequest ¶
type AliasUpdateRequest struct { Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` Enabled bool `json:"enabled"` }
AliasUpdateRequest carries alias update information.
type AuthResponse ¶
type AuthResponse struct { AuthToken string `json:"token"` RefreshToken string `json:"refreshToken"` }
AuthResponse represents a successfull authentication response
type AuthService ¶
type AuthService service
AuthService handles communication with the authentication APIs in the Postfix Rest Server.
func (*AuthService) Login ¶
func (s *AuthService) Login(login, password string) (*AuthResponse, error)
Login makes a post request to the API for logging in
func (*AuthService) Logout ¶
func (s *AuthService) Logout(login, refreshToken string) error
Logout makes a post request to the API for logging out
type Bcc ¶
type Bcc struct { ID int `json:"id"` AccountID int `json:"accountId"` Email string `json:"email"` Enabled bool `json:"enabled"` Created DateTime `json:"created"` Updated DateTime `json:"updated"` }
Bcc is a blind carbon copy for specific account
type BccService ¶
type BccService interface { // Get makes a GET request and fetches the specified BCC. Get(domain, account string) (*Bcc, error) // Create makes a POST request to create a new BCC. Create(domain, account, email string) error // Update makes a PUT request to update the specified BCC. Update(domain, account string, ur *BccUpdateRequest) error // Delete removes a BCC. Delete(domain, account string) error }
type BccUpdateRequest ¶
type BccUpdateRequest struct { Email string `json:"email,omitempty"` Enabled bool `json:"enabled"` }
BccUpdateRequest carrires BCC update information.
type Client ¶
type Client struct { // The protocol used for API requests (defaults to http). Protocol string // The host to connect to (defaults to localhost). Host string // The port on which the client should connect to the server (defaults to 8080). Port string // UserAgent is the client user agent UserAgent string // Login represents the username of the logged in user Login string // The authentication token AuthToken string // The refresh token for retrieving new authentication token RefreshToken string // Auth is the service used for communication with the authentication API. Auth *AuthService // Domains is the service used for communication with the domains API. Domains *DomainService // Accounts is the service used for communication with the accounts API. Accounts *AccountService // Aliases is the service used for communication with the aliases API. Aliases *AliasService // OutputBccs is the service used for communication with the output BCC API. OutputBccs *OutgoingBccService // InputBccs is the service used for communication with the input BCC API. InputBccs *IncomingBccService // contains filtered or unexported fields }
Client manages communication with the Postfix REST Server API.
func NewClientWithOptions ¶
func NewClientWithOptions(httpClient *http.Client, options ...ClientOption) (*Client, error)
NewClientWithOptions returns a new client with the given ClientOptions applied.
type ClientOption ¶
ClientOption is an option to the client that can be passed to NewClientWithOptions().
func AuthOption ¶
func AuthOption(login, authToken, refreshToken string) ClientOption
AuthOption is a client option for setting the authentication tokens.
func HTTPSProtocolOption ¶
func HTTPSProtocolOption() ClientOption
HTTPSProtocolOption is a client option for using the HTTPS protocol.
func HostOption ¶
func HostOption(host string) ClientOption
HostOption is a client option for setting the hostname or IP address of the server.
func PortOption ¶
func PortOption(port string) ClientOption
PortOption is a client option for setting the port number on which the server is listening.
func UserAgentOption ¶
func UserAgentOption(userAgent string) ClientOption
UserAgentOption is a client option for setting the user agent.
type DateTime ¶
DateTime represents a time that can be unmarshaled from a JSON string formatted as "yyyy-mm-ddThh:mm:ss+|-hhmm" (e.g. '2017-01-02T15:47:59+0100'). All exported methods of time.Time can be called on DateTime.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Domain ¶
type Domain struct { ID int `json:"id"` Name string `json:"name"` Enabled bool `json:"enabled"` Created DateTime `json:"created"` Updated DateTime `json:"updated"` }
Domain represents a domain (e.g. example.com)
type DomainService ¶
type DomainService service
DomainService handles communiation with the domain APIs in the Postfix REST Server.
func (*DomainService) Create ¶
func (s *DomainService) Create(domain string) error
Create makes a POST request to the API to create a new domain.
func (*DomainService) Delete ¶
func (s *DomainService) Delete(name string) error
Delete makes a DELETE request to the API to delete the specified domain
func (*DomainService) Get ¶
func (s *DomainService) Get(domain string) (*Domain, error)
Get makes a GET request for a specific domain specified with the domain parameter.
func (*DomainService) List ¶
func (s *DomainService) List() ([]Domain, error)
List makes a GET request for all registered domains.
func (*DomainService) Update ¶
func (s *DomainService) Update(name string, updateRequest *DomainUpdateRequest) error
Update makes a PUT request to update domain parameters
type DomainUpdateRequest ¶
type DomainUpdateRequest struct { Name string `json:"name,omitempty"` Enabled bool `json:"enabled"` }
DomainUpdateRequest represents a request for domain update
type ErrorResponse ¶
type ErrorResponse struct { // The HTTP response Response *http.Response // Message is the error message received as response to the API request. Message string `json:"message"` // Path is the URL of the request. Path string `json:"path"` // Method is the HTTP method of the request. Method string `json:"method"` }
ErrorResponse represents an error caused by an API request.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type IncomingBccService ¶
type IncomingBccService struct {
// contains filtered or unexported fields
}
IncomingBccService handles communication with the incoming BCC APIs in the Postfix REST Server.
func NewIncomingBccService ¶
func NewIncomingBccService(c *Client) *IncomingBccService
NewIncomingBccService creates a new IncomingBccService instance.
func (IncomingBccService) Update ¶
func (s IncomingBccService) Update(domain, account string, ur *BccUpdateRequest) error
Update makes a PUT request to update the specified BCC.
type LoginRequest ¶
LoginRequest represents a request for logging in
type LogoutRequest ¶
LogoutRequest representes a request for logging out
type OutgoingBccService ¶
type OutgoingBccService struct {
// contains filtered or unexported fields
}
OutgoingBccService handles communication with the outgoing BCC APIs in the Postfix REST Server.
func NewOutgoingBccService ¶
func NewOutgoingBccService(c *Client) *OutgoingBccService
NewOutgoingBccService creates a new OutgoingBccService instance.
func (OutgoingBccService) Update ¶
func (s OutgoingBccService) Update(domain, account string, ur *BccUpdateRequest) error
Update makes a PUT request to update the specified BCC.
type RefreshTokenRequest ¶
type RefreshTokenRequest struct { Login string `json:"login"` RefreshToken string `json:"refreshToken"` }
RefreshTokenRequest represents a request for retrieving a new access token