ycconn

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 11 Imported by: 0

README

yc-conn

Go Reference

Yandex.Cloud Go SDK wrapper for getting GRPC client connection with original SDK auth to use with any YC API (even if it's not listed in endpoints)

Why?

Some Yandex.Cloud APIs are not listed in endpoints for some reason. That's why we can't just patch yc-go-sdk to add new services support

Installation

go get -u github.com/afansv/yc-conn

Usage

package main

import (
	"context"
	"fmt"
	"io"
	"os"
	"time"

	ycconn "github.com/afansv/yc-conn"
	"github.com/yandex-cloud/go-genproto/yandex/cloud/speechsense/v1"
	ycsdk "github.com/yandex-cloud/go-sdk"
)

const token = "<YOUR_OAUTH_TOKEN>"

const talkAnalyticsAPIAddr = "api.talk-analytics.yandexcloud.net:443"

func main() {
	ctx := context.Background()

	conn, err := ycconn.GetConnection(ctx, ycconn.ConnectionConfig{
		SDKConfig: ycsdk.Config{
			Credentials: ycsdk.OAuthToken(token),
		},
		APIAddress: talkAnalyticsAPIAddr,
	})
	if err != nil {
		panic(err)
	}

	ss := speechsense.NewTalkServiceClient(conn)

	// Now you can use service client from yandex-cloud/go-genproto
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnection

func GetConnection(ctx context.Context, conf ConnectionConfig, customOpts ...grpc.DialOption) (*grpc.ClientConn, error)

Types

type ConnectionConfig

type ConnectionConfig struct {
	SDKConfig ycsdk.Config

	// API address of any YC service
	APIAddress string
}

Jump to

Keyboard shortcuts

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