sync

package
v0.1.42 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEntitlement = errors.New("no entitlement found")
)
View Source
var (
	ErrSyncNotComplete = fmt.Errorf("sync exited without finishing")
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Op                   ActionOp `json:"operation,omitempty"`
	PageToken            string   `json:"page_token,omitempty"`
	ResourceTypeID       string   `json:"resource_type_id,omitempty"`
	ResourceID           string   `json:"resource_id,omitempty"`
	ParentResourceTypeID string   `json:"parent_resource_type_id,omitempty"`
	ParentResourceID     string   `json:"parent_resource_id,omitempty"`
}

Action stores the current operation, page token, and optional fields for which resource is being worked with.

type ActionOp

type ActionOp uint8

ActionOp represents a sync operation.

const (
	UnknownOp ActionOp = iota
	InitOp
	SyncResourceTypesOp
	SyncResourcesOp
	SyncEntitlementsOp
	ListResourcesForEntitlementsOp
	SyncGrantsOp
	SyncAssetsOp
	SyncGrantExpansionOp
)

func (*ActionOp) MarshalJSON

func (s *ActionOp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ActionOp insto a json string.

func (ActionOp) String

func (s ActionOp) String() string

String() returns the string representation for an ActionOp. This is used for marshalling the op.

func (*ActionOp) UnmarshalJSON

func (s *ActionOp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal's the input byte slice and updates this action op.

type EntitlementGraph added in v0.1.6

type EntitlementGraph struct {
	NodeCount int                        `json:"node_count"`
	Nodes     map[int]Node               `json:"nodes"`
	Edges     map[int]map[int]*grantInfo `json:"edges"` // Adjacency list. Source node -> destination node
	Loaded    bool                       `json:"loaded"`
	Depth     int                        `json:"depth"`
	Actions   []EntitlementGraphAction   `json:"actions"`
}

func NewEntitlementGraph added in v0.1.6

func NewEntitlementGraph(ctx context.Context) *EntitlementGraph

func (*EntitlementGraph) AddEdge added in v0.1.6

func (g *EntitlementGraph) AddEdge(ctx context.Context, srcEntitlementID string, dstEntitlementID string, shallow bool, resourceTypeIDs []string) error

func (*EntitlementGraph) AddEntitlement added in v0.1.6

func (g *EntitlementGraph) AddEntitlement(entitlement *v2.Entitlement)

func (*EntitlementGraph) FixCycles added in v0.1.34

func (g *EntitlementGraph) FixCycles() error

func (*EntitlementGraph) GetCycles added in v0.1.6

func (g *EntitlementGraph) GetCycles() ([][]int, bool)

Find the direct ancestors of the given entitlement. The 'all' flag returns all ancestors regardless of 'done' state.

func (*EntitlementGraph) GetDescendantEntitlements added in v0.1.34

func (g *EntitlementGraph) GetDescendantEntitlements(entitlementID string) map[string]*grantInfo

func (*EntitlementGraph) GetEntitlements added in v0.1.34

func (g *EntitlementGraph) GetEntitlements() []string

func (*EntitlementGraph) GetNode added in v0.1.34

func (g *EntitlementGraph) GetNode(entitlementId string) *Node

func (*EntitlementGraph) HasEntitlement added in v0.1.6

func (g *EntitlementGraph) HasEntitlement(entitlementID string) bool

func (*EntitlementGraph) HasUnexpandedAncestors added in v0.1.6

func (g *EntitlementGraph) HasUnexpandedAncestors(entitlementID string) bool

HasUnexpandedAncestors returns true if the given entitlement has ancestors that have not been expanded yet.

func (*EntitlementGraph) IsEntitlementExpanded added in v0.1.6

func (g *EntitlementGraph) IsEntitlementExpanded(entitlementID string) bool

IsEntitlementExpanded returns true if all the outgoing edges for the given entitlement have been expanded.

func (*EntitlementGraph) IsExpanded added in v0.1.6

func (g *EntitlementGraph) IsExpanded() bool

IsExpanded returns true if all entitlements in the graph have been expanded.

func (*EntitlementGraph) MarkEdgeExpanded added in v0.1.6

func (g *EntitlementGraph) MarkEdgeExpanded(sourceEntitlementID string, descendantEntitlementID string)

func (*EntitlementGraph) Str added in v0.1.34

func (g *EntitlementGraph) Str() string

func (*EntitlementGraph) Validate added in v0.1.34

func (g *EntitlementGraph) Validate() error

type EntitlementGraphAction added in v0.1.6

type EntitlementGraphAction struct {
	SourceEntitlementID     string   `json:"source_entitlement_id"`
	DescendantEntitlementID string   `json:"descendant_entitlement_id"`
	Shallow                 bool     `json:"shallow"`
	ResourceTypeIDs         []string `json:"resource_types_ids"`
	PageToken               string   `json:"page_token"`
}

type Node added in v0.1.34

type Node struct {
	Id             int      `json:"id"`
	EntitlementIDs []string `json:"entitlementIds"` // List of entitlements.
}

type Progress added in v0.0.25

type Progress struct {
	Action               string
	ResourceTypeID       string
	ResourceID           string
	ParentResourceTypeID string
	ParentResourceID     string
	Count                uint32
}

func NewProgress added in v0.0.25

func NewProgress(a *Action, c uint32) *Progress

type State

type State interface {
	PushAction(ctx context.Context, action Action)
	FinishAction(ctx context.Context)
	NextPage(ctx context.Context, pageToken string) error
	ResourceTypeID(ctx context.Context) string
	ResourceID(ctx context.Context) string
	EntitlementGraph(ctx context.Context) *EntitlementGraph
	ParentResourceID(ctx context.Context) string
	ParentResourceTypeID(ctx context.Context) string
	PageToken(ctx context.Context) string
	Current() *Action
	Marshal() (string, error)
	Unmarshal(input string) error
	NeedsExpansion() bool
	SetNeedsExpansion()
}

type SyncOpt

type SyncOpt func(s *syncer)

func WithC1ZPath added in v0.1.0

func WithC1ZPath(path string) SyncOpt

func WithConnectorStore added in v0.1.0

func WithConnectorStore(store connectorstore.Writer) SyncOpt

func WithProgressHandler added in v0.0.25

func WithProgressHandler(f func(s *Progress)) SyncOpt

WithProgress sets a `progressHandler` for `NewSyncer` Options.

func WithRunDuration

func WithRunDuration(d time.Duration) SyncOpt

WithRunDuration sets a `time.Duration` for `NewSyncer` Options. `d` represents a duration. The elapsed time between two instants as an int64 nanosecond count.

func WithTmpDir added in v0.1.8

func WithTmpDir(path string) SyncOpt

func WithTransitionHandler

func WithTransitionHandler(f func(s Action)) SyncOpt

WithTransitionHandler sets a `transitionHandler` for `NewSyncer` Options.

type Syncer

type Syncer interface {
	Sync(ctx context.Context) error
	Close(ctx context.Context) error
}

func NewSyncer

func NewSyncer(ctx context.Context, c types.ConnectorClient, opts ...SyncOpt) (Syncer, error)

NewSyncer returns a new syncer object.

Jump to

Keyboard shortcuts

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