cloud

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cloud — вызовы API cloud.ru поверх клиентов internal/gen. Запрос собирает сгенерированный клиент; ответ 2xx отдаётся телом как есть — вывод --json без потерь полей, которых нет в спецификации; не 2xx — *APIError.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotUUID    = i18n.Sentinel("cloud.err.not_uuid")
	ErrBadID      = i18n.Sentinel("cloud.err.bad_id")
	ErrBadExpires = i18n.Sentinel("cloud.err.bad_expires")
)

Ошибки ввода, отказанные до запроса; текст для человека — в обёртке.

View Source
var ErrList = i18n.Sentinel("cloud.err.list")

ErrList — ответ списка, который нельзя склеить: null, нет поля, токен по кругу, предел.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound — ответ API 404.

func ParseOperation

func ParseOperation(raw []byte) (op operation.Operation, ok bool)

ParseOperation разбирает ответ DBaaS в операцию; ok — в теле операция с id.

func ParseVPCOperation

func ParseVPCOperation(raw []byte) (op operation.Operation, ok bool)

ParseVPCOperation разбирает операцию VPC; ok — в теле операция с id.

func PollError

func PollError(err error) error

PollError — ошибка опроса (операции, ресурса): сбой сети, 429, 5xx и сбой проверки доступа — временные, опрос — GET, повтор безопасен. Остальные 4xx — ошибка запроса, повтор не поможет.

Types

type APIError

type APIError struct {
	Status  int
	Message string
}

APIError — ответ API не 2xx.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) ExitCode

func (e *APIError) ExitCode() int

ExitCode — 4 на отказ в доступе. Сбой проверки доступа (flakyAccess) — не отказ, код 1.

type ClickHouse

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

ClickHouse — Public API Managed ClickHouse.

func NewClickHouse

func NewClickHouse(server string, o Options) (*ClickHouse, error)

NewClickHouse — клиент API ClickHouse по адресу server.

func (*ClickHouse) Cluster

func (h *ClickHouse) Cluster(ctx context.Context, id string) ([]byte, error)

func (*ClickHouse) ClusterOperations

func (h *ClickHouse) ClusterOperations(ctx context.Context, id string) ([]byte, error)

ClusterOperations — все операции кластера: {"operations": [...]}.

func (*ClickHouse) Clusters

func (h *ClickHouse) Clusters(ctx context.Context, project string) ([]byte, error)

Clusters — все кластеры проекта: {"clusters": [...]} со всех страниц. page_size не отправляем: ClickHouse отвечает и без него.

func (*ClickHouse) CreateCluster

func (h *ClickHouse) CreateCluster(ctx context.Context, c ClickHouseClusterCreate) ([]byte, error)

CreateCluster возвращает операцию создания.

func (*ClickHouse) CreateDatabase

func (h *ClickHouse) CreateDatabase(ctx context.Context, cluster, name string) ([]byte, error)

func (*ClickHouse) CreateUser

func (h *ClickHouse) CreateUser(ctx context.Context, cluster, name, password string, roles []string) ([]byte, error)

CreateUser — пустой roles: поле не отправляется.

func (*ClickHouse) Database

func (h *ClickHouse) Database(ctx context.Context, cluster, name string) ([]byte, error)

func (*ClickHouse) Databases

func (h *ClickHouse) Databases(ctx context.Context, cluster string) ([]byte, error)

func (*ClickHouse) DeleteCluster

func (h *ClickHouse) DeleteCluster(ctx context.Context, id string) ([]byte, error)

DeleteCluster возвращает операцию удаления.

func (*ClickHouse) DeleteDatabase

func (h *ClickHouse) DeleteDatabase(ctx context.Context, cluster, name string) ([]byte, error)

func (*ClickHouse) DeleteUser

func (h *ClickHouse) DeleteUser(ctx context.Context, cluster, name string) ([]byte, error)

func (*ClickHouse) GrantRole

func (h *ClickHouse) GrantRole(ctx context.Context, cluster, name, role string) ([]byte, error)

func (*ClickHouse) Operation

func (h *ClickHouse) Operation(ctx context.Context, id string) ([]byte, error)

func (*ClickHouse) Operations

func (h *ClickHouse) Operations() operation.Getter

Operations — опрос операций ClickHouse для operation.Waiter.

func (*ClickHouse) ProbeProject

func (h *ClickHouse) ProbeProject(ctx context.Context, project string) ([]byte, error)

ProbeProject — первая страница из одного кластера: проверка доступа к проекту.

func (*ClickHouse) RevokeRole

func (h *ClickHouse) RevokeRole(ctx context.Context, cluster, name, role string) ([]byte, error)

func (*ClickHouse) Roles

func (h *ClickHouse) Roles(ctx context.Context, cluster string) ([]byte, error)

func (*ClickHouse) Specs

func (h *ClickHouse) Specs(ctx context.Context, version, zone, role string) ([]byte, error)

Specs — спецификации; role — server | keeper | "" (не отправлять).

func (*ClickHouse) UpdateCluster

func (h *ClickHouse) UpdateCluster(ctx context.Context, id string, u ClickHouseClusterUpdate) ([]byte, error)

UpdateCluster возвращает операцию изменения.

func (*ClickHouse) UpdateUser

func (h *ClickHouse) UpdateUser(ctx context.Context, cluster, name string, password *string, roles []string) ([]byte, error)

UpdateUser — nil password: не менять, пустой roles: не менять.

func (*ClickHouse) User

func (h *ClickHouse) User(ctx context.Context, cluster, name string) ([]byte, error)

func (*ClickHouse) Users

func (h *ClickHouse) Users(ctx context.Context, cluster string) ([]byte, error)

func (*ClickHouse) Versions

func (h *ClickHouse) Versions(ctx context.Context) ([]byte, error)

type ClickHouseClusterCreate

type ClickHouseClusterCreate struct {
	Project, Name, Description, Version, Spec, KeeperMode string
	Shards, Replicas, StorageGiB                          int32
	Subnets                                               []string
	Keeper                                                ClickHouseKeeper
	Config                                                *ClickHouseConfig
	Logging                                               Logging
	Body                                                  []byte
}

ClickHouseClusterCreate — новый кластер; KeeperMode — embedded | standalone | "" (legacy). Body — сырой JSON поверх собранного: ключи верхнего уровня заменяют поля.

type ClickHouseClusterUpdate

type ClickHouseClusterUpdate struct {
	Spec       string
	StorageGiB int32
	Keeper     ClickHouseKeeper
	Config     *ClickHouseConfig
	Body       []byte
}

ClickHouseClusterUpdate — изменение кластера; нулевые поля не отправляются.

type ClickHouseConfig

ClickHouseConfig — серверные параметры кластера.

func ParseClickHouseConfig

func ParseClickHouseConfig(flag string, kvs map[string]string) (*ClickHouseConfig, error)

ParseClickHouseConfig — --config ключ=число. Неизвестный ключ отклоняется по полям структуры, а не молча теряется.

type ClickHouseKeeper

type ClickHouseKeeper struct {
	Spec       string
	StorageGiB int32
}

ClickHouseKeeper — выделенный Keeper (standalone_keeper); пустой — поле не отправляется.

type Compute

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

Compute — API виртуальных машин: подсети и зоны. Идентификаторы в нём — UUID, не UUID отказываем до запроса.

func NewCompute

func NewCompute(server string, o Options) (*Compute, error)

NewCompute — клиент API виртуальных машин по адресу server.

func (*Compute) CreateSubnet

func (c *Compute) CreateSubnet(ctx context.Context, s SubnetCreate) ([]byte, error)

CreateSubnet создаёт подсеть. Зона — только id: availability_zone_name в спецификации есть, но API его отвергает (422 extra_forbidden, 14.10). Зона и VPC в теле — строки по спецификации, их формат проверяет API; UUID — только там, где его требует сгенерированный клиент (проект, путь, фильтр списка).

func (*Compute) DeleteSubnet

func (c *Compute) DeleteSubnet(ctx context.Context, id string) ([]byte, error)

func (*Compute) Subnet

func (c *Compute) Subnet(ctx context.Context, id string) ([]byte, error)

func (*Compute) Subnets

func (c *Compute) Subnets(ctx context.Context, f SubnetFilter) ([]byte, error)

Subnets — подсети, все страницы: {"items": [...], "total": N}.

func (*Compute) Zones

func (c *Compute) Zones(ctx context.Context) ([]byte, error)

Zones — зоны доступности: в API Redis и Kafka их списка нет, а спецификации без зоны не отдаются.

type IAM

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

IAM — сервисные аккаунты, их ключи доступа и роли в проекте. Отвечает snake_case, хотя в спецификации camelCase, — тела ответов не разбираем сгенерированными типами (docs/api-coverage.md, «Расхождения»).

func NewIAM

func NewIAM(server string, o Options) (*IAM, error)

NewIAM — клиент IAM API по адресу server.

func (*IAM) AccessKey

func (s *IAM) AccessKey(ctx context.Context, account, id string) ([]byte, error)

func (*IAM) AccessKeys

func (s *IAM) AccessKeys(ctx context.Context, account string) ([]byte, error)

func (*IAM) CreateAccessKey

func (s *IAM) CreateAccessKey(ctx context.Context, account, description, ttl string) ([]byte, error)

CreateAccessKey выпускает ключ; секрет — в ответе, один раз. Пустые description и ttl не отправляются.

func (*IAM) CreateServiceAccount

func (s *IAM) CreateServiceAccount(ctx context.Context, project, name, description string) ([]byte, error)

CreateServiceAccount — аккаунт name в проекте project; description "" — без описания.

func (*IAM) DeleteAccessKey

func (s *IAM) DeleteAccessKey(ctx context.Context, account, id string) ([]byte, error)

func (*IAM) DeleteServiceAccount

func (s *IAM) DeleteServiceAccount(ctx context.Context, id string) ([]byte, error)

func (*IAM) Grant

func (s *IAM) Grant(ctx context.Context, project, subject, role, expires string) ([]byte, error)

Grant выдаёт роль role субъекту subject в проекте project; expires — RFC 3339 или "" (бессрочно).

func (*IAM) Permission

func (s *IAM) Permission(ctx context.Context, id string) ([]byte, error)

func (*IAM) Permissions

func (s *IAM) Permissions(ctx context.Context, filter string) ([]byte, error)

Permissions — выданные роли по фильтру IAM, все страницы.

func (*IAM) Revoke

func (s *IAM) Revoke(ctx context.Context, id string) ([]byte, error)

func (*IAM) ServiceAccount

func (s *IAM) ServiceAccount(ctx context.Context, id string) ([]byte, error)

func (*IAM) ServiceAccounts

func (s *IAM) ServiceAccounts(ctx context.Context, project string) ([]byte, error)

ServiceAccounts — сервисные аккаунты проекта, все страницы.

type Kafka

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

Kafka — Public API Managed Kafka.

func NewKafka

func NewKafka(server string, o Options) (*Kafka, error)

NewKafka — клиент API Kafka по адресу server.

func (*Kafka) Cluster

func (k *Kafka) Cluster(ctx context.Context, id string) ([]byte, error)

func (*Kafka) ClusterOperations

func (k *Kafka) ClusterOperations(ctx context.Context, id string) ([]byte, error)

ClusterOperations — все операции кластера: {"operations": [...]}.

func (*Kafka) Clusters

func (k *Kafka) Clusters(ctx context.Context, project string) ([]byte, error)

Clusters — все кластеры проекта: {"clusters": [...]} со всех страниц.

func (*Kafka) CreateCluster

func (k *Kafka) CreateCluster(ctx context.Context, c KafkaClusterCreate) ([]byte, error)

CreateCluster возвращает операцию создания.

func (*Kafka) CreateTopic

func (k *Kafka) CreateTopic(ctx context.Context, cluster, name string, partitions, replication int32, params map[string]string) ([]byte, error)

CreateTopic возвращает операцию; params уходят всегда, пустые — «{}» (поле обязательно).

func (*Kafka) CreateUser

func (k *Kafka) CreateUser(ctx context.Context, cluster, name, password string, roles []string) ([]byte, error)

CreateUser возвращает операцию; пустой roles — поле не отправляется.

func (*Kafka) DeleteCluster

func (k *Kafka) DeleteCluster(ctx context.Context, id string) ([]byte, error)

DeleteCluster возвращает операцию удаления.

func (*Kafka) DeleteTopic

func (k *Kafka) DeleteTopic(ctx context.Context, cluster, name string) ([]byte, error)

func (*Kafka) DeleteUser

func (k *Kafka) DeleteUser(ctx context.Context, cluster, name string) ([]byte, error)

func (*Kafka) Operation

func (k *Kafka) Operation(ctx context.Context, id string) ([]byte, error)

func (*Kafka) Operations

func (k *Kafka) Operations() operation.Getter

Operations — опрос операций Kafka для operation.Waiter.

func (*Kafka) Roles

func (k *Kafka) Roles(ctx context.Context, cluster string) ([]byte, error)

func (*Kafka) Specs

func (k *Kafka) Specs(ctx context.Context, f KafkaSpecFilter) ([]byte, error)

func (*Kafka) Topic

func (k *Kafka) Topic(ctx context.Context, cluster, name string) ([]byte, error)

func (*Kafka) Topics

func (k *Kafka) Topics(ctx context.Context, cluster, filter string) ([]byte, error)

Topics — все топики кластера: {"topics": [...]}; filter — часть имени.

func (*Kafka) UpdateCluster

func (k *Kafka) UpdateCluster(ctx context.Context, id string, u KafkaClusterUpdate) ([]byte, error)

UpdateCluster возвращает операцию изменения.

func (*Kafka) UpdateTopic

func (k *Kafka) UpdateTopic(ctx context.Context, cluster, name string, u KafkaTopicUpdate) ([]byte, error)

UpdateTopic возвращает операцию изменения.

func (*Kafka) UpdateUser

func (k *Kafka) UpdateUser(ctx context.Context, cluster, name string, password *string, roles []string) ([]byte, error)

UpdateUser возвращает операцию: nil password — не менять, пустой roles — не менять.

func (*Kafka) User

func (k *Kafka) User(ctx context.Context, cluster, name string) ([]byte, error)

func (*Kafka) Users

func (k *Kafka) Users(ctx context.Context, cluster string) ([]byte, error)

func (*Kafka) Versions

func (k *Kafka) Versions(ctx context.Context) ([]byte, error)

type KafkaClusterCreate

type KafkaClusterCreate struct {
	Project, Name, Description, Version, Spec, Subnet string
	Brokers, StorageGiB                               int32
	UI, CruiseControl, AutoRebalance                  bool
	Params                                            map[string]string
	Logging                                           Logging
	Body                                              []byte
}

KafkaClusterCreate — новый кластер. Body — сырой JSON поверх собранного: ключи верхнего уровня заменяют поля.

type KafkaClusterUpdate

type KafkaClusterUpdate struct {
	Spec       string
	StorageGiB int32
	Params     map[string]string
	Body       []byte
}

KafkaClusterUpdate — изменение кластера; нулевые поля не отправляются.

type KafkaSpecFilter

type KafkaSpecFilter struct {
	Version, Zone, Cluster string
}

KafkaSpecFilter — отбор спецификаций: версия и зона или кластер (для resize).

type KafkaTopicUpdate

type KafkaTopicUpdate struct {
	Partitions, Replication int32
	Params                  map[string]string
}

KafkaTopicUpdate — изменение топика; нулевые поля не отправляются.

type Logging

type Logging struct {
	Enabled bool
	GroupID string
}

Logging — интеграция с Клиентским логированием; без Enabled поле не отправляется, пустая группа — по умолчанию.

type Options

type Options struct {
	HTTPClient *http.Client
	// Auth ставит токен в запрос.
	Auth func(ctx context.Context, req *http.Request) error
}

Options — общее для клиентов всех API.

type Redis

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

Redis — Public API Managed Redis.

func NewRedis

func NewRedis(server string, o Options) (*Redis, error)

NewRedis — клиент API Redis по адресу server.

func (*Redis) Cluster

func (r *Redis) Cluster(ctx context.Context, id string) ([]byte, error)

func (*Redis) ClusterOperations

func (r *Redis) ClusterOperations(ctx context.Context, id string) ([]byte, error)

ClusterOperations — все операции кластера: {"operations": [...]}.

func (*Redis) Clusters

func (r *Redis) Clusters(ctx context.Context, project string) ([]byte, error)

Clusters — все кластеры проекта: {"clusters": [...]} со всех страниц.

func (*Redis) CreateCluster

func (r *Redis) CreateCluster(ctx context.Context, c RedisClusterCreate) ([]byte, error)

CreateCluster возвращает операцию создания.

func (*Redis) CreateUser

func (r *Redis) CreateUser(ctx context.Context, cluster, name, password string, roles []string) ([]byte, error)

CreateUser возвращает операцию; пустой roles — поле не отправляется.

func (*Redis) DeleteCluster

func (r *Redis) DeleteCluster(ctx context.Context, id string) ([]byte, error)

DeleteCluster возвращает операцию удаления.

func (*Redis) DeleteUser

func (r *Redis) DeleteUser(ctx context.Context, cluster, name string) ([]byte, error)

func (*Redis) Operation

func (r *Redis) Operation(ctx context.Context, id string) ([]byte, error)

func (*Redis) Operations

func (r *Redis) Operations() operation.Getter

Operations — опрос операций Redis для operation.Waiter.

func (*Redis) Roles

func (r *Redis) Roles(ctx context.Context, cluster string) ([]byte, error)

func (*Redis) Specs

func (r *Redis) Specs(ctx context.Context, f RedisSpecFilter) ([]byte, error)

func (*Redis) UpdateCluster

func (r *Redis) UpdateCluster(ctx context.Context, id string, u RedisClusterUpdate) ([]byte, error)

UpdateCluster возвращает операцию изменения.

func (*Redis) UpdateUser

func (r *Redis) UpdateUser(ctx context.Context, cluster, name string, password *string, roles []string) ([]byte, error)

UpdateUser заменяет пользователя целиком (PUT): nil password — не менять.

func (*Redis) User

func (r *Redis) User(ctx context.Context, cluster, name string) ([]byte, error)

Пустое тело не подменяется на «{}»: user update перенёс бы пустой список ролей и обнулил права.

func (*Redis) Users

func (r *Redis) Users(ctx context.Context, cluster string) ([]byte, error)

func (*Redis) Versions

func (r *Redis) Versions(ctx context.Context) ([]byte, error)

type RedisClusterCreate

type RedisClusterCreate struct {
	Project, Name, Description, Version, Spec, Type string
	Shards, Replicas, StorageGiB                    int32
	Subnets                                         []string
	Params                                          map[string]string
	Logging                                         Logging
	Body                                            []byte
}

RedisClusterCreate — новый кластер. Type — standalone | master-replica. Body — сырой JSON поверх собранного: ключи верхнего уровня заменяют поля.

type RedisClusterUpdate

type RedisClusterUpdate struct {
	Spec       string
	StorageGiB int32
	Params     map[string]string
	Body       []byte
}

RedisClusterUpdate — изменение кластера; нулевые поля не отправляются.

type RedisSpecFilter

type RedisSpecFilter struct {
	Version, Zone, Cluster string
}

RedisSpecFilter — отбор спецификаций: версия и зона или кластер (для resize).

type SubnetCreate

type SubnetCreate struct {
	Project, Name, Zone, CIDR, VPC, Description, Gateway string
	DNS                                                  []string
	Isolated                                             bool
}

SubnetCreate — новая подсеть; пустые необязательные поля не отправляются.

type SubnetFilter

type SubnetFilter struct {
	Project, Zone, VPC, Name string
}

SubnetFilter — отбор подсетей; пустые поля не отправляются.

type VPC

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

VPC — Evolution VPC API: сети проекта и их операции.

func NewVPC

func NewVPC(server string, o Options) (*VPC, error)

NewVPC — клиент VPC API по адресу server.

func (*VPC) Create

func (v *VPC) Create(ctx context.Context, req VPCCreate) ([]byte, error)

Create возвращает операцию создания.

func (*VPC) Delete

func (v *VPC) Delete(ctx context.Context, id string) ([]byte, error)

Delete возвращает операцию удаления.

func (*VPC) Get

func (v *VPC) Get(ctx context.Context, id string) ([]byte, error)

func (*VPC) List

func (v *VPC) List(ctx context.Context, project string) ([]byte, error)

List — VPC проекта, все страницы.

func (*VPC) Operation

func (v *VPC) Operation(ctx context.Context, id string) ([]byte, error)

func (*VPC) Operations

func (v *VPC) Operations() operation.Getter

Operations — опрос операций VPC для operation.Waiter.

type VPCCreate

type VPCCreate struct {
	Project, Name, Description string
}

VPCCreate — новая VPC; пустое описание не отправляется.

Jump to

Keyboard shortcuts

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