client

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 30 Imported by: ? 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

Index

Constants

View Source
const (
	// Exported on purpose to change via `link -X`
	DefaultUserAgent = "cq-source-yc"
)

Variables

View Source
var CloudIdColumn schema.Column = schema.Column{
	Name:     "cloud_id",
	Type:     arrow.BinaryTypes.String,
	Resolver: ResolveCloud,
}
View Source
var FolderIdColumn schema.Column = schema.Column{
	Name:     "folder_id",
	Type:     arrow.BinaryTypes.String,
	Resolver: ResolveFolder,
}
View Source
var MultiplexedResourceIdColumn schema.Column = schema.Column{
	Name: "id",
	Type: arrow.BinaryTypes.String,
	Resolver: func(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
		client := meta.(*Client)
		return resource.Set(c.Name, client.MultiplexedResourceId)
	},
}
View Source
var OrganiztionIdColumn schema.Column = schema.Column{
	Name:     "organization_id",
	Type:     arrow.BinaryTypes.String,
	Resolver: ResolveOrganization,
}
View Source
var ParentIdColumn schema.Column = schema.Column{
	Name:       "id",
	Type:       arrow.BinaryTypes.String,
	Resolver:   schema.ParentColumnResolver("id"),
	PrimaryKey: true,
}

Functions

func CloudMultiplex

func CloudMultiplex(meta schema.ClientMeta) []schema.ClientMeta

func FolderMultiplex

func FolderMultiplex(meta schema.ClientMeta) []schema.ClientMeta

func OrganizationMultiplex

func OrganizationMultiplex(meta schema.ClientMeta) []schema.ClientMeta

func PrependEmptyMultiplex

func PrependEmptyMultiplex(multiplexer schema.Multiplexer) schema.Multiplexer

func ResolveCloud

func ResolveCloud(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error

func ResolveFolder

func ResolveFolder(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error

func ResolveOrganization

func ResolveOrganization(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error

func ResolveProtoEnum

func ResolveProtoEnum(path string) schema.ColumnResolver

func ResolveProtoTimestamp

func ResolveProtoTimestamp(path string) schema.ColumnResolver

func SharedTransformers

func SharedTransformers() []transformers.StructTransformerOption

func TransformColumnPrimaryKey added in v1.4.0

func TransformColumnPrimaryKey(column schema.Column) schema.Column

func TransformWithStruct

func TransformWithStruct(t any, opts ...transformers.StructTransformerOption) schema.Transform

Types

type Client

type Client struct {
	OrganizationId        string
	CloudId               string
	FolderId              string
	MultiplexedResourceId string

	Backend state.Client
	Logger  zerolog.Logger
	SDK     *ycsdk.SDK
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, logger zerolog.Logger, spec *Spec) (*Client, error)

func (*Client) ID

func (c *Client) ID() string

func (*Client) WithBackend

func (c *Client) WithBackend(backend state.Client) *Client

func (*Client) WithCloud

func (c *Client) WithCloud(id string) *Client

func (*Client) WithFolder

func (c *Client) WithFolder(id string) *Client

func (*Client) WithMultiplexedResourceId

func (c *Client) WithMultiplexedResourceId(id string) *Client

func (*Client) WithOrganization

func (c *Client) WithOrganization(id string) *Client

type ResourceHierarchy

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

func NewResourceHierarchy

func NewResourceHierarchy(ctx context.Context, logger zerolog.Logger, sdk *ycsdk.SDK, organizations []string, clouds []string, folders []string, opts ...grpc.CallOption) (*ResourceHierarchy, error)

NewResourceHirarchy fetches all reachable resourse model entities and creates ResourceHirarchy struct while holding the hierarchy (i.e. organization -> cloud -> folder). Some properties of the hierarchy:

  • the hierarchy could be partially incomplete, e.g. nil -> cloud_id1 -> folder_id1.
  • likewise both entries must exist for scoped resolution (e.g. Cloud Access Bindings): cloud_id1 -> nil (resolve tables for Cloud) cloud_id1 -> folder_id1 (resolve tables for Folder)

Discover algorithm is:

  1. Recursively discover resources using Breadth-first search on resources returned by calling `List` method on Organizations, Clouds, Folders
  2. Recursively discover resources using Breadth-first search on resources provided in arguments (`organizations`, `clouds`, `folders`)
  3. Merge and deduplicate results from (1) and (2)
  4. Apply filters from arguments (`organizations`, `clouds`, `folders`)

Step 2 is needed because API does not return all Organizations, which caller account has access to, but only Organization, which caller account belong to

func (*ResourceHierarchy) All

func (*ResourceHierarchy) CloudRows

func (h *ResourceHierarchy) CloudRows() []ResourceHierarchyItem

CloudRows returns all ResourceHierarchyItems with Cloud != ""

func (*ResourceHierarchy) Clouds

func (h *ResourceHierarchy) Clouds() []string

func (*ResourceHierarchy) FolderRows

func (h *ResourceHierarchy) FolderRows() []ResourceHierarchyItem

FolderRows returns all ResourceHierarchyItems with Folder != ""

func (*ResourceHierarchy) Folders

func (h *ResourceHierarchy) Folders() []string

func (*ResourceHierarchy) OrganizationRows

func (h *ResourceHierarchy) OrganizationRows() []ResourceHierarchyItem

OrganizationRows returns all ResourceHierarchyItems with Organization != ""

func (*ResourceHierarchy) Organizations

func (h *ResourceHierarchy) Organizations() []string

type ResourceHierarchyItem

type ResourceHierarchyItem struct {
	Organization string
	Cloud        string
	Folder       string
}

Self-made name for struct holding info about resource model hierarchy. Each field could be nil.

type Spec

type Spec struct {
	// List of all organiztions ids to fetch information from
	OrganizationIDs []string `json:"organization_ids"`

	// List of all clouds ids to fetch information from
	CloudIDs []string `json:"cloud_ids"`

	// List of all folder ids to fetch information from
	FolderIDs []string `json:"folder_ids"`

	// If `true`, will log all GRPC calls (currently YC SDK only)
	DebugGRPC bool `json:"debug_grpc"`

	// Defines the maximum number of times an API request will be retried.
	MaxRetries int `json:"max_retries,omitempty" jsonschema:"default=3"`

	// The base URL endpoint the SDK will use
	Endpoint string `json:"endpoint"`

	// The best effort maximum number of Go routines to use. Lower this number to reduce memory usage.
	Concurrency int `json:"concurrency" jsonschema:"minimum=1,default=50000"`

	// The scheduler to use when determining the priority of resources to sync. By default it is set to `shuffle`.
	//
	// Available options: `dfs`, `round-robin`, `shuffle`
	Scheduler scheduler.Strategy `json:"scheduler,omitempty"`
}

func NewDefaultSpec

func NewDefaultSpec() *Spec

func (*Spec) Validate

func (spec *Spec) Validate() error

Jump to

Keyboard shortcuts

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