reago

package module
v0.0.0-...-712628d Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 17 Imported by: 0

README

REAGO

Build Status Coverage Status

A Rackspace Email API client for Go.

Based on the API published by rackspace. The API is not complete. It currently does only the things I needed it to do for another utility I was writing.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func DoRequest

func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error)

DoRequest submits an HTTP request.

func DoRequestWithClient

func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)

DoRequestWithClient submits an HTTP request using the specified client.

func SetBaseURL

func SetBaseURL(bu string) func(*Client) error

SetBaseURL is a client option for setting the base URL.

func SetDebugHTTP

func SetDebugHTTP() func(*Client) error

SetDebugHTTP is a client option for setting debugging for HTTP calls.

func SetGetLimiter

func SetGetLimiter(rps float64, burst int) func(*Client) error

SetGetLimiter is a client option for setting the ratelimiter for GET requests. rps is the requests per second and burst is the number of burst requests allowed.

func SetPostLimiter

func SetPostLimiter(rps float64, burst int) func(*Client) error

SetPostLimiter is a client option for setting the ratelimiter for POST requests. rps is the requests per second and burst is the number of burst requests allowed.

func SetSecretKey

func SetSecretKey(sk string) func(*Client) error

SetSecretKey is a client option for setting the secret key.

func SetUserAgent

func SetUserAgent(ua string) func(*Client) error

SetUserAgent is a client option for setting the user agent.

func SetUserKey

func SetUserKey(uk string) func(*Client) error

SetUserKey is a client option for setting the user key.

Types

type ArgError

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

ArgError is an error that represents an error with an input to reago. It identifies the argument and the cause (if possible).

func NewArgError

func NewArgError(arg, reason string) *ArgError

NewArgError creates an ArgError.

func (*ArgError) Error

func (e *ArgError) Error() string

Error stringifies an ArgError.

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	RackspaceEmailAliases RackspaceEmailAliasesService
	Domains               DomainsService
	// contains filtered or unexported fields
}

Client manages communication with Rackspace Email v1 API

func New

func New(httpClient *http.Client, options ...func(*Client) error) (*Client, error)

New returns a new API client instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a Rackspace Email API client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body map[string]string) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the map body is rendered as application/x-www-form-urlencoded.

type Domain

type Domain struct {
	Name                           string `json:"name"`
	AccountNumber                  string `json:"accountNumber"`
	ServiceType                    string `json:"serviceType"`
	ActiveSyncLicenses             int    `json:"activeSyncLicenses"`
	ActiveSyncMobileServiceEnabled bool   `json:"activeSyncMobileServiceEnabled"`
	ArchivingServiceEnabled        bool   `json:"archivingServiceEnabled"`
	BlackBerryLicenses             int    `json:"blackBerryLicenses"`
	BlackBerryMobileServiceEnabled bool   `json:"blackBerryMobileServiceEnabled"`
	ExchangeExtraStorage           int    `json:"exchangeExtraStorage"`
	ExchangeMaxNumMailboxes        int    `json:"exchangeMaxNumMailboxes"`
	ExchangeUsedStorage            int    `json:"exchangeUsedStorage"`
	RSEmailBaseMailboxSize         int    `json:"rsEmailBaseMailboxSize"`
	RSEmailExtraStorage            int    `json:"rsEmailExtraStorage"`
	RSEmailMaxNumberMailboxes      int    `json:"rsEmailMaxNumberMailboxes"`
	RSEmailUsedStorage             int    `json:"rsEmailUsedStorage"`
}

Domain represents a Rackspace Email API domain

type DomainsService

type DomainsService interface {
	Index(context.Context, *PageOptions) ([]Domain, *Response, error)
	Show(context.Context, string) (*Domain, *Response, error)
}

DomainsService is an interface for managing DNS with the Rackspace Email API.

See: http://api-wiki.apps.rackspace.com/api-wiki/index.php?title=Domain_(Rest_API)

type DomainsServiceOp

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

DomainsServiceOp handles communication with the domain related methods of the Rackspace Email API.

func (DomainsServiceOp) Index

func (s DomainsServiceOp) Index(ctx context.Context, opt *PageOptions) ([]Domain, *Response, error)

Index lists all domains

func (DomainsServiceOp) Show

func (s DomainsServiceOp) Show(ctx context.Context, name string) (*Domain, *Response, error)

Show gets details of a domain and requires a non-empty domain name

type EmailAddress

type EmailAddress struct {
	Addresses []string `json:"emailAddress"`
}

EmailAddress represents an array of email addresses that iare tied to a Rackspace Email alias.

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message
	Message string `json:"message"`

	// RequestID returned from the API, useful to contact support.
	RequestID string `json:"request_id"`
}

ErrorResponse returns the information from an API error

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error returns a string representation of an API error

type PageOptions

type PageOptions struct {
	Offset int `url:"offset,omitempty"`
	Size   int `url:"size,omitempty"`
}

PageOptions specifies the request pagination options

type RackspaceEmailAlias

type RackspaceEmailAlias struct {
	Name            string `json:"name"`
	NumberOfMembers int    `json:"numberOfMembers"`
}

RackspaceEmailAlias represents a Rackspace Email API alias from the Index method.

type RackspaceEmailAliasShow

type RackspaceEmailAliasShow struct {
	Name             string       `json:"name"`
	EmailAddressList EmailAddress `json:"emailAddressList"`
}

RackspaceEmailAliasShow represents the response from the Show method.

type RackspaceEmailAliasesService

RackspaceEmailAliasesService is an interface for managing Rackspace Email aliases with the Rackspace Email API.

See: http://api-wiki.apps.rackspace.com/api-wiki/index.php?title=Rackspace_Alias(Rest_API)

type RackspaceEmailAliasesServiceOp

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

RackspaceEmailAliasesServiceOp handles communication with the rackspace email alias related methods of the Rackspace Email API.

func (*RackspaceEmailAliasesServiceOp) Add

func (s *RackspaceEmailAliasesServiceOp) Add(ctx context.Context, domain, alias string, emailAddresses []string) (*Response, error)

Add adds a new Rackspace Email alias and requires a non-empty domain name and a non-empty alias and a slice of email addresses.

func (*RackspaceEmailAliasesServiceOp) Delete

func (s *RackspaceEmailAliasesServiceOp) Delete(ctx context.Context, domain, alias string) (*Response, error)

Delete removes a Rackspace Email alias and requires a non-empty domain name and a non-empty alias.

func (RackspaceEmailAliasesServiceOp) Index

Index lists all Rackspace Email aliases

func (*RackspaceEmailAliasesServiceOp) Show

Show gets details of a Rackspace Email alias and requires a non-empty domain name and a non-empty alias.

type Response

type Response struct {
	*http.Response
}

Response is a Rackspace Email API response. This wraps the standard http.Response returned from Rackspace.

Jump to

Keyboard shortcuts

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