ycsdk

package module
v0.0.0-...-417428f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 58 Imported by: 0

README

Yandex.Cloud Go SDK

GoDoc CircleCI

Go SDK for Yandex.Cloud services.

NOTE: SDK is under development, and may make backwards-incompatible changes.

Installation

go get github.com/fedorpatlin/go-sdk

Example usages

Initializing SDK
sdk, err := ycsdk.Build(ctx, ycsdk.Config{
	Credentials: ycsdk.OAuthToken(token),
})
if err != nil {
	log.Fatal(err)
}
More examples

More examples can be found in examples dir.

Documentation

Index

Constants

View Source
const (
	CertificateManagerID     = "certificate-manager"
	CertificateManagerDataID = "certificate-manager-data"
)
View Source
const (
	KMSServiceID       = "kms"
	KMSCryptoServiceID = "kms-crypto"
)
View Source
const (
	DefaultPageSize int64 = 1000

	ComputeServiceID            Endpoint = "compute"
	IAMServiceID                Endpoint = "iam"
	OperationServiceID          Endpoint = "operation"
	ResourceManagementServiceID Endpoint = "resource-manager"
	StorageServiceID            Endpoint = "storage"
	SerialSSHServiceID          Endpoint = "serialssh"
	// revive:disable:var-naming
	ApiEndpointServiceID Endpoint = "endpoint"
	// revive:enable:var-naming
	VpcServiceID        Endpoint = "vpc"
	KubernetesServiceID Endpoint = "managed-kubernetes"
)
View Source
const DataProcServiceID = "dataproc"
View Source
const InstanceMetadataAddr = "169.254.169.254"

InstanceMetadata is address at the metadata server is accessible from inside the virtual machine. See doc for details: https://cloud.yandex.com/docs/compute/operations/vm-info/get-info#inside-instance

Variables

This section is empty.

Functions

This section is empty.

Types

type AI

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

func (*AI) STT

func (m *AI) STT() *stt.STT

func (*AI) Translate

func (m *AI) Translate() *translate.Translate

func (*AI) Vision

func (m *AI) Vision() *vision.Vision

type Config

type Config struct {
	// Credentials are used to authenticate the client. See Credentials for more info.
	Credentials Credentials
	// DialContextTimeout specifies timeout of dial on API endpoint that
	// is used when building an SDK instance.
	DialContextTimeout time.Duration
	// TLSConfig is optional tls.Config that one can use in order to tune TLS options.
	TLSConfig *tls.Config

	// Endpoint is an API endpoint of Yandex.Cloud against which the SDK is used.
	// Most users won't need to explicitly set it.
	Endpoint  string
	Plaintext bool
}

Config is a config that is used to create SDK instance.

type Credentials

type Credentials interface {
	// YandexCloudAPICredentials is a marker method. All compatible Credentials implementations have it
	YandexCloudAPICredentials()
}

Credentials is an abstraction of API authorization credentials. See https://cloud.yandex.ru/docs/iam/concepts/authorization/authorization for details. Note that functions that return Credentials may return different Credentials implementation in next SDK version, and this is not considered breaking change.

func OAuthToken

func OAuthToken(token string) Credentials

OAuthToken returns API credentials for user Yandex Passport OAuth token, that can be received on page https://oauth.yandex.ru/authorize?response_type=token&client_id=1a6990aa636648e9b2ef855fa7bec2fb See https://cloud.yandex.ru/docs/iam/concepts/authorization/oauth-token for details.

func ServiceAccountKey

func ServiceAccountKey(key *iamkey.Key) (Credentials, error)

ServiceAccountKey returns credentials for the given IAM Key. The key is used to sign JWT tokens. JWT tokens are exchanged for IAM Tokens used to authorize API calls. This authorization method is not supported for IAM Keys issued for User Accounts.

type Endpoint

type Endpoint string
const (
	AITranslate Endpoint = "ai-translate"
	AIVision    Endpoint = "ai-vision"
	AISTT       Endpoint = "ai-stt"
)
const (
	MDBMongoDBServiceID    Endpoint = "managed-mongodb"
	MDBClickhouseServiceID Endpoint = "managed-clickhouse"
	MDBPostgreSQLServiceID Endpoint = "managed-postgresql"
	MDBRedisServiceID      Endpoint = "managed-redis"
	MDBMySQLServiceID      Endpoint = "managed-mysql"
)
const (
	FunctionServiceID Endpoint = "serverless-functions"
	TriggerServiceID  Endpoint = "serverless-triggers"
)
const (
	ContainerRegistryServiceID Endpoint = "container-registry"
)
const InstancegroupServiceID Endpoint = "compute"
const (
	IoTDevicesServiceID Endpoint = "iot-devices"
)
const (
	LoadBalancerServiceID Endpoint = "load-balancer"
)
const (
	MarketplaceMeteringServiceID Endpoint = "marketplace"
)

type ExchangeableCredentials

type ExchangeableCredentials interface {
	Credentials
	// IAMTokenRequest returns request for fresh IAM token or error.
	IAMTokenRequest() (*iampb.CreateIamTokenRequest, error)
}

ExchangeableCredentials can be exchanged for IAM Token in IAM Token Service, that can be used to authorize API calls. See https://cloud.yandex.ru/docs/iam/concepts/authorization/iam-token for details.

type IAMTokenCredentials

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

IAMTokenCredentials implements Credentials with IAM token as-is

func (IAMTokenCredentials) IAMToken

func (IAMTokenCredentials) YandexCloudAPICredentials

func (creds IAMTokenCredentials) YandexCloudAPICredentials()

type IoT

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

func (*IoT) Devices

func (m *IoT) Devices() *devices.Devices

type MDB

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

func (*MDB) Clickhouse

func (m *MDB) Clickhouse() *clickhouse.Clickhouse

func (*MDB) MongoDB

func (m *MDB) MongoDB() *mongodb.MongoDB

func (*MDB) MySQL

func (m *MDB) MySQL() *mysql.MySQL

func (*MDB) PostgreSQL

func (m *MDB) PostgreSQL() *postgresql.PostgreSQL

func (*MDB) Redis

func (m *MDB) Redis() *redis.Redis

type Marketplace

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

func (*Marketplace) Metering

func (m *Marketplace) Metering() *metering.Metering

type NoCredentials

type NoCredentials struct{}

NoCredentials implements Credentials, it allows to create unauthenticated connections

func (NoCredentials) IAMToken

IAMToken always returns gRPC error with status UNAUTHENTICATED

func (NoCredentials) YandexCloudAPICredentials

func (creds NoCredentials) YandexCloudAPICredentials()

type NonExchangeableCredentials

type NonExchangeableCredentials interface {
	Credentials
	// IAMToken returns IAM Token.
	IAMToken(ctx context.Context) (*iampb.CreateIamTokenResponse, error)
}

NonExchangeableCredentials allows to get IAM Token without calling IAM Token Service.

func InstanceServiceAccount

func InstanceServiceAccount() NonExchangeableCredentials

InstanceServiceAccount returns credentials for Compute Instance Service Account. That is, for SDK build with InstanceServiceAccount credentials and used on Compute Instance created with yandex.cloud.compute.v1.CreateInstanceRequest.service_account_id, API calls will be authenticated with this ServiceAccount ID. TODO(skipor): doc link

func NewIAMTokenCredentials

func NewIAMTokenCredentials(iamToken string) NonExchangeableCredentials

type Resolver

type Resolver interface {
	ID() string
	Err() error

	Run(context.Context, *SDK, ...grpc.CallOption) error
}

type SDK

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

SDK is a Yandex.Cloud SDK

func Build

func Build(ctx context.Context, conf Config, customOpts ...grpc.DialOption) (*SDK, error)

Build creates an SDK instance

func (*SDK) AI

func (sdk *SDK) AI() *AI

AI returns AI object that is used to do AI stuff.

func (*SDK) ApiEndpoint

func (sdk *SDK) ApiEndpoint() *apiendpoint.APIEndpoint

ApiEndpoint gets ApiEndpointService client

func (*SDK) Certificates

func (sdk *SDK) Certificates() *certificatemanager.CertificateManager

func (*SDK) CertificatesData

func (sdk *SDK) CertificatesData() *certificatemanagerdata.CertificateManagerData

func (*SDK) Compute

func (sdk *SDK) Compute() *compute.Compute

Compute returns Compute object that is used to operate on Yandex Compute Cloud

func (*SDK) ContainerRegistry

func (sdk *SDK) ContainerRegistry() *containerregistry.ContainerRegistry

ContainerRegistry returns ContainerRegistry object that is used to operate on Yandex Container Registry

func (*SDK) CreateIAMToken

func (sdk *SDK) CreateIAMToken(ctx context.Context) (*iampb.CreateIamTokenResponse, error)

func (*SDK) Dataproc

func (sdk *SDK) Dataproc() *dataproc.Dataproc

func (*SDK) Endpoint

func (sdk *SDK) Endpoint(endpointName Endpoint) (ep *endpoint.ApiEndpoint, exist bool)

func (*SDK) IAM

func (sdk *SDK) IAM() *iam.IAM

IAM returns IAM object that is used to operate on Yandex Cloud Identity and Access Manager

func (*SDK) InitErr

func (sdk *SDK) InitErr() error

func (*SDK) InstanceGroup

func (sdk *SDK) InstanceGroup() *instancegroup.InstanceGroup

InstanceGroup returns InstanceGroup object that is used to operate on Yandex Compute InstanceGroup

func (*SDK) IoT

func (sdk *SDK) IoT() *IoT

func (*SDK) KMS

func (sdk *SDK) KMS() *kms.KMS

func (*SDK) KMSCrypto

func (sdk *SDK) KMSCrypto() *kmscrypto.KMSCrypto

func (*SDK) KnownServices

func (sdk *SDK) KnownServices() []string

func (*SDK) Kubernetes

func (sdk *SDK) Kubernetes() *k8s.Kubernetes

Kubernetes returns Kubernetes object that is used to operate on Yandex Managed Kubernetes

func (*SDK) LoadBalancer

func (sdk *SDK) LoadBalancer() *loadbalancer.LoadBalancer

LoadBalancer returns LoadBalancer object that is used to operate on load balancers

func (*SDK) MDB

func (sdk *SDK) MDB() *MDB

MDB returns MDB object that is used to operate on Yandex Managed Databases

func (*SDK) Marketplace

func (sdk *SDK) Marketplace() *Marketplace

func (*SDK) Operation

func (sdk *SDK) Operation() *gen_operation.OperationServiceClient

Operation gets OperationService client

func (*SDK) Resolve

func (sdk *SDK) Resolve(ctx context.Context, r ...Resolver) error

func (*SDK) ResourceManager

func (sdk *SDK) ResourceManager() *resourcemanager.ResourceManager

ResourceManager returns ResourceManager object that is used to operate on Folders and Clouds

func (*SDK) Serverless

func (sdk *SDK) Serverless() *Serverless

func (*SDK) Shutdown

func (sdk *SDK) Shutdown(ctx context.Context) error

Shutdown shutdowns SDK and closes all open connections.

func (*SDK) VPC

func (sdk *SDK) VPC() *vpc.VPC

VPC returns VPC object that is used to operate on Yandex Virtual Private Cloud

func (*SDK) WrapOperation

func (sdk *SDK) WrapOperation(op *operation.Operation, err error) (*sdk_operation.Operation, error)

WrapOperation wraps operation proto message to

type Serverless

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

func (*Serverless) Functions

func (s *Serverless) Functions() *functions.Function

func (*Serverless) Triggers

func (s *Serverless) Triggers() *triggers.Trigger

Directories

Path Synopsis
examples
gen
ai/stt
nolint
nolint
ai/translate
nolint
nolint
ai/vision
nolint
nolint
apiendpoint
nolint
nolint
nolint
nolint
compute
nolint nolint nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint nolint nolint
nolint
containerregistry
nolint nolint nolint nolint
nolint nolint nolint nolint
dataproc
nolint nolint nolint nolint
nolint nolint nolint nolint
functions
nolint
nolint
iam
nolint nolint nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint nolint nolint
nolint
iot/devices
nolint nolint
nolint nolint
kms
nolint
nolint
kmscrypto
nolint
nolint
kubernetes
nolint nolint nolint
nolint nolint nolint
loadbalancer
nolint nolint
nolint nolint
nolint
mdb/clickhouse
nolint nolint nolint nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint nolint nolint nolint
mdb/mongodb
nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint
mdb/mysql
nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint
mdb/postgresql
nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint
mdb/redis
nolint nolint nolint
nolint nolint nolint
operation
nolint
nolint
resourcemanager
nolint nolint
nolint nolint
triggers
nolint
nolint
vpc
nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint
pkg
singleflight
Package singleflight based on github.com/golang/groupcache/singleflight
Package singleflight based on github.com/golang/groupcache/singleflight

Jump to

Keyboard shortcuts

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