ycsdk

package module
v0.0.0-...-dfa5032 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 99 Imported by: 69

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/yandex-cloud/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"
	KMSAsymmetricEncryptionServiceID       = "kms"
	KMSAsymmetricEncryptionCryptoServiceID = "kms-crypto"
	KMSAsymmetricSignatureServiceID        = "kms"
	KMSAsymmetricSignatureCryptoServiceID  = "kms-crypto"
)
View Source
const (
	LoadtestingServiceID      = "loadtesting"
	LoadtestingAgentServiceID = "loadtesting/agent-api"
)
View Source
const (
	LockboxSecretServiceID  = "lockbox"
	LockboxPayloadServiceID = "lockbox-payload"
)
View Source
const (
	MarketplaceServiceID               Endpoint = "marketplace"
	MarketplaceMeteringServiceID                = MarketplaceServiceID
	MarketplaceLicenseManagerServiceID          = MarketplaceServiceID
)
View Source
const (
	DefaultPageSize int64 = 1000

	ComputeServiceID                Endpoint = "compute"
	IAMServiceID                    Endpoint = "iam"
	OperationServiceID              Endpoint = "operation"
	OrganizationManagementServiceID Endpoint = "organization-manager"
	ResourceManagementServiceID     Endpoint = "resource-manager"
	StorageServiceID                Endpoint = "storage"
	StorageAPIServiceID             Endpoint = "storage-api"
	MonitoringServiceID             Endpoint = "monitoring"
	SerialSSHServiceID              Endpoint = "serialssh"
	// revive:disable:var-naming
	ApiEndpointServiceID Endpoint = "endpoint"
	// revive:enable:var-naming
	VpcServiceID         Endpoint = "vpc"
	KubernetesServiceID  Endpoint = "managed-kubernetes"
	DNSServiceID         Endpoint = "dns"
	YDBServiceID         Endpoint = "ydb"
	BackupServiceID      Endpoint = "backup"
	AuditTrailsServiceID Endpoint = "audittrails"
)
View Source
const (
	CDNID = "cdn"
)
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

func WithAuthAsServiceAccount

func WithAuthAsServiceAccount(serviceAccountID string) grpc.CallOption

func WithAuthAsServiceAccounts

func WithAuthAsServiceAccounts(saGetter SAGetter) grpc.CallOption

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 Authenticator

type Authenticator interface {
	CreateIAMToken(ctx context.Context) (*iam.CreateIamTokenResponse, error)
	CreateIAMTokenForServiceAccount(ctx context.Context, serviceAccountID string) (*iam.CreateIamTokenResponse, error)
}

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/ 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.

func UserAccountKey

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

UserAccountKey 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.

WARN: user account keys are not supported, and won't be supported for most users.

type Endpoint

type Endpoint string
const (
	AITranslate Endpoint = "ai-translate"
	AIVision    Endpoint = "ai-vision"
	AISTT       Endpoint = "ai-stt"
)
const (
	IoTDevicesServiceID    Endpoint = "iot-devices"
	IoTDataServiceID       Endpoint = "iot-data"
	IoTBrokerServiceID     Endpoint = "iot-broker"
	IoTBrokerDataServiceID Endpoint = "broker-data"
)
const (
	LoggingServiceID      Endpoint = "logging"
	LogReadingServiceID   Endpoint = "log-reading"
	LogIngestionServiceID Endpoint = "log-ingestion"
)
const (
	MDBMongoDBServiceID    Endpoint = "managed-mongodb"
	MDBClickhouseServiceID Endpoint = "managed-clickhouse"
	MDBPostgreSQLServiceID Endpoint = "managed-postgresql"
	MDBRedisServiceID      Endpoint = "managed-redis"
	MDBMySQLServiceID      Endpoint = "managed-mysql"
	MDBKafkaServiceID      Endpoint = "managed-kafka"
	MDBSQLServerServiceID  Endpoint = "managed-sqlserver"
	MDBGreenplumServiceID  Endpoint = "managed-greenplum"
	MDBElasticSearchID     Endpoint = "managed-elasticsearch"
	MDBOpenSearchID        Endpoint = "managed-opensearch"
)
const (
	FunctionServiceID             Endpoint = "serverless-functions"
	TriggerServiceID              Endpoint = "serverless-triggers"
	APIGatewayServiceID           Endpoint = "serverless-apigateway"
	MDBProxyServiceID             Endpoint = "mdbproxy"
	ServerlessContainersServiceID Endpoint = "serverless-containers"
	APIGatewayWebsocketServiceID  Endpoint = "apigateway-connections"
)
const (
	ApplicationLoadBalancerServiceID Endpoint = "alb"
)
const (
	BillingServiceID Endpoint = "billing"
)
const (
	ContainerRegistryServiceID Endpoint = "container-registry"
)
const (
	DataTransferServiceID Endpoint = "datatransfer"
)
const (
	DatasphereServiceID Endpoint = "datasphere"
)
const InstancegroupServiceID Endpoint = "compute"
const (
	LoadBalancerServiceID Endpoint = "load-balancer"
)

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 IamTokenMiddleware

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

func NewIAMTokenMiddleware

func NewIAMTokenMiddleware(authenticator Authenticator, now func() time.Time) *IamTokenMiddleware

func (*IamTokenMiddleware) GetIAMToken

func (c *IamTokenMiddleware) GetIAMToken(ctx context.Context, originalSubject bool, opts ...grpc.CallOption) (string, error)

func (*IamTokenMiddleware) InterceptStream

func (c *IamTokenMiddleware) InterceptStream(ctx context.Context, desc *grpc.StreamDesc, conn *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

func (*IamTokenMiddleware) InterceptUnary

func (c *IamTokenMiddleware) InterceptUnary(ctx context.Context, method string, req, reply interface{}, conn *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

type IoT

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

func (*IoT) Broker

func (m *IoT) Broker() *broker.Broker

func (*IoT) BrokerData

func (m *IoT) BrokerData() *brokerdata.BrokerData

func (*IoT) Data

func (m *IoT) Data() *data.Data

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) ElasticSearch

func (m *MDB) ElasticSearch() *elasticsearch.ElasticSearch

func (*MDB) Greenplum

func (m *MDB) Greenplum() *greenplum.Greenplum

func (*MDB) Kafka

func (m *MDB) Kafka() *kafka.Kafka

func (*MDB) MongoDB

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

func (*MDB) MySQL

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

func (*MDB) OpenSearch

func (m *MDB) OpenSearch() *opensearch.OpenSearch

func (*MDB) PostgreSQL

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

func (*MDB) Redis

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

func (*MDB) SQLServer

func (m *MDB) SQLServer() *sqlserver.SQLServer

type Marketplace

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

func (*Marketplace) LicenseManager

func (m *Marketplace) LicenseManager() *licensemanager.LicenseManager

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 SAGetter

type SAGetter func(ctx context.Context) (string, 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) ApplicationLoadBalancer

func (sdk *SDK) ApplicationLoadBalancer() *apploadbalancer.LoadBalancer

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

func (*SDK) AuditTrails

func (sdk *SDK) AuditTrails() *audittrails.AuditTrails

AuditTrails returns object for operating with Audit Trails service.

func (*SDK) Backup

func (sdk *SDK) Backup() *backup.Backup

Backup returns backup for operating with Backup service.

func (*SDK) Billing

func (sdk *SDK) Billing() *billing.Billing

Billing returns Billing object that is used to operate on Yandex Billing

func (*SDK) CDN

func (sdk *SDK) CDN() *cdn.CDN

func (*SDK) Certificates

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

func (*SDK) CertificatesData

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

func (*SDK) CheckEndpointConnection

func (sdk *SDK) CheckEndpointConnection(ctx context.Context, endpoint Endpoint) error

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) CreateIAMTokenForServiceAccount

func (sdk *SDK) CreateIAMTokenForServiceAccount(ctx context.Context, serviceAccountID string) (*iampb.CreateIamTokenResponse, error)

func (*SDK) DNS

func (sdk *SDK) DNS() *dns.DNS

DNS returns DNS object that is used to operate on Yandex DNS

func (*SDK) DataTransfer

func (sdk *SDK) DataTransfer() *datatransfer.DataTransfer

DataTransfer returns DataTransfer object that is used to manage Yandex Data Transfer

func (*SDK) Dataproc

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

func (*SDK) Datasphere

func (sdk *SDK) Datasphere() *datasphere.Datasphere

func (*SDK) Endpoint

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

func (*SDK) GroupMappingServiceClient

func (sdk *SDK) GroupMappingServiceClient() *organizationmanager.GroupMappingServiceClient

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) KMSAsymmetricEncryption

func (sdk *SDK) KMSAsymmetricEncryption() *kmsasymmetricencryption.KMSAsymmetricEncryption

func (*SDK) KMSAsymmetricEncryptionCrypto

func (sdk *SDK) KMSAsymmetricEncryptionCrypto() *kmsasymmetricencryptioncrypto.KMSAsymmetricEncryptionCrypto

func (*SDK) KMSAsymmetricSignature

func (sdk *SDK) KMSAsymmetricSignature() *kmsasymmetricsignature.KMSAsymmetricSignature

func (*SDK) KMSAsymmetricSignatureCrypto

func (sdk *SDK) KMSAsymmetricSignatureCrypto() *kmsasymmetricsignaturecrypto.KMSAsymmetricSignatureCrypto

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) Loadtesting

func (sdk *SDK) Loadtesting() *loadtestingapi.Loadtesting

func (*SDK) LoadtestingAgent

func (sdk *SDK) LoadtestingAgent() *loadtestingagent.LoadtestingAgentAPI

func (*SDK) LockboxPayload

func (sdk *SDK) LockboxPayload() *lockboxpayload.LockboxPayload

func (*SDK) LockboxSecret

func (sdk *SDK) LockboxSecret() *lockboxsecret.LockboxSecret

func (*SDK) LogIngestion

func (sdk *SDK) LogIngestion() *ingestion.LogIngestion

func (*SDK) LogReading

func (sdk *SDK) LogReading() *reading.LogReading

func (*SDK) Logging

func (sdk *SDK) Logging() *logging.Logging

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) Monitoring

func (sdk *SDK) Monitoring() *monitoring.Monitoring

Monitoring returns object for operating with Monitoring service.

func (*SDK) OSLoginServiceClient

func (sdk *SDK) OSLoginServiceClient() *organizationmanager.OsLoginServiceClient

func (*SDK) Operation

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

Operation gets OperationService client

func (*SDK) OrganizationManager

func (sdk *SDK) OrganizationManager() *organizationmanager.OrganizationManager

func (*SDK) OrganizationManagerSAML

func (sdk *SDK) OrganizationManagerSAML() *organizationmanagersaml.OrganizationManagerSAML

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) StorageAPI

func (sdk *SDK) StorageAPI() *storage.StorageAPI

StorageAPI returns storage object for operating with Object Storage service.

func (*SDK) UserSSHKeyServiceClient

func (sdk *SDK) UserSSHKeyServiceClient() *organizationmanager.UserSshKeyServiceClient

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

func (*SDK) YDB

func (sdk *SDK) YDB() *ydb.YDB

YDB returns object for Yandex Database operations.

type Serverless

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

func (*Serverless) APIGateway

func (s *Serverless) APIGateway() *apigateway.Apigateway

func (*Serverless) APIGatewayWebsocket

func (s *Serverless) APIGatewayWebsocket() *websocket.Websocket

func (*Serverless) Containers

func (s *Serverless) Containers() *containers.Container

func (*Serverless) Functions

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

func (*Serverless) MDBProxy

func (s *Serverless) MDBProxy() *mdbproxy.Proxy

func (*Serverless) Triggers

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

type ServiceIsNotAvailableError

type ServiceIsNotAvailableError struct {
	ServiceID   Endpoint
	APIEndpoint string
	// contains filtered or unexported fields
}

func (*ServiceIsNotAvailableError) Error

Directories

Path Synopsis
examples
gen
ai/stt
nolint
nolint
ai/translate
nolint
nolint
ai/vision
nolint
nolint
apiendpoint
nolint
nolint
apigateway
nolint
nolint
nolint
nolint
audittrails
nolint
nolint
backup
nolint
nolint
billing
nolint
nolint
cdn
nolint
nolint
nolint
nolint
compute
nolint
nolint
nolint
nolint
containers
nolint
nolint
dataproc
nolint
nolint
datasphere
nolint
nolint
datatransfer
nolint
nolint
dns
nolint
nolint
functions
nolint
nolint
iam
nolint
nolint
nolint
iot/broker
nolint
nolint
nolint
iot/data
nolint
nolint
iot/devices
nolint
nolint
kms
nolint
nolint
nolint
nolint
nolint
nolint
kmscrypto
nolint
nolint
kubernetes
nolint
nolint
loadbalancer
nolint
nolint
loadtesting
nolint
nolint
nolint
nolint
lockboxsecret
nolint
nolint
logging
nolint
nolint
logingestion
nolint
nolint
logreading
nolint
nolint
nolint
nolint
nolint
nolint
mdb/greenplum
nolint
nolint
mdb/kafka
nolint
nolint
mdb/mongodb
nolint
nolint
mdb/mysql
nolint
nolint
nolint
nolint
mdb/redis
nolint
nolint
mdb/sqlserver
nolint
nolint
mdbproxy
nolint
nolint
monitoring
nolint
nolint
operation
nolint
nolint
nolint
nolint
nolint
storage-api
nolint
nolint
triggers
nolint
nolint
vpc
nolint
nolint
ydb
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