Documentation ¶
Index ¶
- Constants
- Variables
- func CloudMultiplex(meta schema.ClientMeta) []schema.ClientMeta
- func FolderMultiplex(meta schema.ClientMeta) []schema.ClientMeta
- func OrganizationMultiplex(meta schema.ClientMeta) []schema.ClientMeta
- func PrependEmptyMultiplex(multiplexer schema.Multiplexer) schema.Multiplexer
- func ResolveCloud(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, ...) error
- func ResolveFolder(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, ...) error
- func ResolveOrganization(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, ...) error
- func ResolveProtoEnum(path string) schema.ColumnResolver
- func ResolveProtoTimestamp(path string) schema.ColumnResolver
- func SharedTransformers() []transformers.StructTransformerOption
- func TransformWithStruct(t any, opts ...transformers.StructTransformerOption) schema.Transform
- type Client
- type ResourceHierarchy
- func (h *ResourceHierarchy) All() []ResourceHierarchyItem
- func (h *ResourceHierarchy) CloudRows() []ResourceHierarchyItem
- func (h *ResourceHierarchy) Clouds() []string
- func (h *ResourceHierarchy) FolderRows() []ResourceHierarchyItem
- func (h *ResourceHierarchy) Folders() []string
- func (h *ResourceHierarchy) OrganizationRows() []ResourceHierarchyItem
- func (h *ResourceHierarchy) Organizations() []string
- type ResourceHierarchyItem
- type Spec
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) client.Logger.Debug().Str("MultiplexedResourceId", client.MultiplexedResourceId) return resource.Set(c.Name, client.MultiplexedResourceId) }, }
View Source
var ParentIdColumn schema.Column = schema.Column{ Name: "id", Type: arrow.BinaryTypes.String, Resolver: schema.ParentColumnResolver("id"), PrimaryKey: true, }
View Source
var PrimaryKeyIdTransformer transformers.StructTransformerOption = transformers.WithPrimaryKeys(("Id"))
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 ResolveFolder ¶
func ResolveOrganization ¶
func ResolveProtoEnum ¶
func ResolveProtoEnum(path string) schema.ColumnResolver
func ResolveProtoTimestamp ¶
func ResolveProtoTimestamp(path string) schema.ColumnResolver
func SharedTransformers ¶
func SharedTransformers() []transformers.StructTransformerOption
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 (*Client) WithFolder ¶
func (*Client) WithMultiplexedResourceId ¶
func (*Client) WithOrganization ¶
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:
- Recursively discover resources using Breadth-first search on resources returned by calling `List` method on Organizations, Clouds, Folders
- Recursively discover resources using Breadth-first search on resources provided in arguments (`organizations`, `clouds`, `folders`)
- Merge and deduplicate results from (1) and (2)
- 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 (h *ResourceHierarchy) All() []ResourceHierarchyItem
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 ¶
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
Click to show internal directories.
Click to hide internal directories.