Help us shape the future of Go! Take the 2026 Go Developer Survey

aiven

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: MIT Imports: 9 Imported by: 1

README

Aiven

Aiven has a Python Client, but not a Go client. This is a Go SDK which enables you to use it with Terraform to automatically spin up services together with the rest of your architecture.

Development

This SDK is currently still under development. Only the bits that I currently need are sporadically added. If any new features are required, feel free to open an issue or a PR.

This has been developed purely for the goal of using this together with Terraform, but with general usage in mind. You can see the Terraform provider here

Testing

Currently, tests are only run in development and not through CI. This is due to the requirement of an actual credit card. In the future we'll look into enabling a mock for this so we can run unit tests on CI and do integration tests on our own.

Documentation

Index

Constants

View Source
const APIUrl = "https://api.aiven.io/v1beta/"

Variables

View Source
var (
	ErrNoResponseData = errors.New("No response data available")
	ErrInvalidHost    = errors.New("Host doesn't isn't in the correct format: `hostname:port`")
)

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Errors  []Error `json:"errors,omitempty"`
	Message string  `json:"message,omitempty"`
}

type Backup

type Backup struct {
}

type BillingHandler

type BillingHandler struct {
	Cards *CardsHandler
	// contains filtered or unexported fields
}

type Card

type Card struct {
	Brand        string   `json:"brand"`
	CardId       string   `json:"card_id"`
	Country      string   `json:"country"`
	CountryCode  string   `json:"country_code"`
	ExpMonth     int      `json:"exp_month"`
	ExpYear      int      `json:"exp_year"`
	Last4        string   `json:"last4"`
	Name         string   `json:"name"`
	ProjectNames []string `json:"projects"`
}

type CardListResponse

type CardListResponse struct {
	APIResponse
	Cards []*Card `json:"cards"`
}

type CardsHandler

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

func (*CardsHandler) List

func (h *CardsHandler) List() ([]*Card, error)

type Client

type Client struct {
	ApiKey string
	Client *http.Client

	Projects     *ProjectsHandler
	Services     *ServicesHandler
	Databases    *DatabasesHandler
	ServiceUsers *ServiceUsersHandler
	Billing      *BillingHandler
}

Client represents the instance that does all the calls to the Aiven API.

func NewTokenClient

func NewTokenClient(key string) (*Client, error)

NewTokenClient creates a new client based on a given token.

func NewUserClient

func NewUserClient(email, password string) (*Client, error)

NewUserClient creates a new client based on email and password.

func (*Client) Init

func (c *Client) Init()

Init initializes the client and sets up all the handlers.

type ConnectionPool

type ConnectionPool struct {
}

type CreateDatabaseRequest

type CreateDatabaseRequest struct {
	Database  string `json:"database"`
	LcCollate string `json:"lc_collate,omitempty"`
	LcType    string `json:"lc_type,omitempty"`
}

type CreateProjectRequest

type CreateProjectRequest struct {
	CardId  string `json:"card_id,omitempty"`
	Cloud   string `json:"cloud,omitempty"`
	Project string `json:"project"`
}

type CreateServiceRequest

type CreateServiceRequest struct {
	Cloud       string `json:"cloud,omitempty"`
	GroupName   string `json:"group_name,omitempty"`
	Plan        string `json:"plan,omitempty"`
	ServiceName string `json:"service_name"`
	ServiceType string `json:"service_type"`
}

type CreateServiceUserRequest

type CreateServiceUserRequest struct {
	Username string `json:"username"`
}

type Database

type Database struct {
	Database  string `json:"database"`
	LcCollate string `json:"lc_collate,omitempty"`
	LcType    string `json:"lc_type,omitempty"`
}

type DatabasesHandler

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

func (*DatabasesHandler) Create

func (h *DatabasesHandler) Create(project, service string, req CreateDatabaseRequest) (*Database, error)

func (*DatabasesHandler) Delete

func (h *DatabasesHandler) Delete(project, service, database string) error

type Error

type Error struct {
	Message  string `json:"message"`
	MoreInfo string `json:"more_info"`
	Status   int    `json:"status"`
}

Error represents an Aiven API Error.

func (Error) Error

func (e Error) Error() string

Error concatenates the Status, Message and MoreInfo values.

type Project

type Project struct {
	AvailableCredits string `json:"available_credits"`
	BillingAddress   string `json:"billing_address"`
	Card             Card   `json:"card_info"`
	Country          string `json:"country"`
	CountryCode      string `json:"country_code"`
	DefaultCloud     string `json:"default_cloud"`
	EstimatedBalance string `json:"estimated_balance"`
	PaymentMethod    string `json:"payment_method"`
	Name             string `json:"project_name"`
	VatId            string `json:"vat_id"`
}

type ProjectListResponse

type ProjectListResponse struct {
	APIResponse
	Projects []*Project `json:"projects"`
}

type ProjectResponse

type ProjectResponse struct {
	APIResponse
	Project *Project `json:"project"`
}

type ProjectsHandler

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

func (*ProjectsHandler) Create

func (*ProjectsHandler) Delete

func (h *ProjectsHandler) Delete(project string) error

func (*ProjectsHandler) Get

func (h *ProjectsHandler) Get(project string) (*Project, error)

func (*ProjectsHandler) List

func (h *ProjectsHandler) List() ([]*Project, error)

func (*ProjectsHandler) Update

func (h *ProjectsHandler) Update(project string, req UpdateProjectRequest) (*Project, error)

type Service

type Service struct {
	CloudName  string         `json:"cloud_name"`
	CreateTime string         `json:"create_time"`
	UpdateTime string         `json:"update_time"`
	GroupList  []string       `json:"group_list"`
	NodeCount  int            `json:"node_count"`
	Plan       string         `json:"plan"`
	Name       string         `json:"service_name"`
	Type       string         `json:"service_type"`
	Uri        string         `json:"service_uri"`
	State      string         `json:"state"`
	Metadata   interface{}    `json:"metadata"`
	Users      []*ServiceUser `json:"users"`
}

func (*Service) Hostname

func (s *Service) Hostname() (string, error)

Hostname parses the hostname out of the Service URI.

func (*Service) Port

func (s *Service) Port() (string, error)

Port parses the port out of the service URI.

type ServiceListResponse

type ServiceListResponse struct {
	APIResponse
	Services []*Service `json:"services"`
}

type ServiceResponse

type ServiceResponse struct {
	APIResponse
	Service *Service `json:"service"`
}

type ServiceUser

type ServiceUser struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Type     string `json:"type"`
}

type ServiceUserResponse

type ServiceUserResponse struct {
	APIResponse
	User *ServiceUser `json:"user"`
}

type ServiceUsersHandler

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

func (*ServiceUsersHandler) Create

func (h *ServiceUsersHandler) Create(project, service string, req CreateServiceUserRequest) (*ServiceUser, error)

func (*ServiceUsersHandler) Delete

func (h *ServiceUsersHandler) Delete(project, service, user string) error

type ServicesHandler

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

func (*ServicesHandler) Create

func (h *ServicesHandler) Create(project string, req CreateServiceRequest) (*Service, error)

func (*ServicesHandler) Delete

func (h *ServicesHandler) Delete(project, service string) error

func (*ServicesHandler) Get

func (h *ServicesHandler) Get(project, service string) (*Service, error)

func (*ServicesHandler) List

func (h *ServicesHandler) List(project string) ([]*Service, error)

func (*ServicesHandler) Update

func (h *ServicesHandler) Update(project, service string, req UpdateServiceRequest) (*Service, error)

type Token

type Token struct {
	Token string `json:"token"`
	State string `json:"state"`
}

Token represents a user token.

func UserToken

func UserToken(email, password string, client *http.Client) (*Token, error)

UserToken retrieves a User Auth Token for a given email/password pair.

type UpdateProjectRequest

type UpdateProjectRequest struct {
	CardId         string `json:"card_id,omitempty"`
	Cloud          string `json:"cloud,omitempty"`
	BillingAddress string `json:"billing_address"`
}

type UpdateServiceRequest

type UpdateServiceRequest struct {
	Cloud     string `json:"cloud,omitempty"`
	GroupName string `json:"group_name,omitempty"`
	Plan      string `json:"plan,omitempty"`
	Powered   bool   `json:"powered"` // TODO: figure out if we can overwrite the default?
}

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Type     string `json:"type"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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