export

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBlueprintExclusions added in v0.1.8

func ApplyBlueprintExclusions(all []api.Blueprint, excludeDeep, excludeSchema []string) (iterList, dataList []api.Blueprint)

ApplyBlueprintExclusions returns two filtered slices from all:

  • iterList: used to iterate for fetching entities/scorecards/actions (deep-excluded removed, schema-only kept)
  • dataList: written to data.Blueprints for export output (both deep and schema-only excluded)

func FilterBlueprintsToReferenced added in v0.3.4

func FilterBlueprintsToReferenced(blueprints []api.Blueprint, referenced map[string]bool) []api.Blueprint

FilterBlueprintsToReferenced narrows blueprints to only those whose identifier is present in referenced. Used by AutoScopeBlueprints callers once they've finished gathering every signal of "this blueprint is referenced" (see Data.ReferencedBlueprintIDs).

func FilterByField added in v0.3.1

func FilterByField[T ~map[string]interface{}](items []T, ids []string, field string) []T

FilterByField filters a slice of map-typed resources, keeping only items whose field value appears in the ids set. Returns all items when ids is empty.

func FilterFoldersToAncestors added in v0.3.1

func FilterFoldersToAncestors(folders []api.Folder, pages []api.Page) []api.Folder

FilterFoldersToAncestors returns only the folders that are ancestors of the given pages. It walks up the parent chain from each page's parent folder.

func SelectActionsForResources added in v0.3.7

func SelectActionsForResources(allActions []api.Action, includeActions, includeAutomations bool, actionIDs []string) []api.Action

SelectActionsForResources filters the org-wide /actions response to the resource types requested by the caller. Non-automation actions are treated as actions; trigger.type=automation records are treated as automations.

Types

type ArchiveWriter added in v0.3.2

type ArchiveWriter interface {
	WriteResource(name string, value interface{}) error
	WriteEntities(func(EntitySink) error) error
	Close() error
}

ArchiveWriter writes export resources section by section.

type Collector

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

Collector collects data from Port API concurrently.

func NewCollector

func NewCollector(client *api.Client) *Collector

NewCollector creates a new collector.

func (*Collector) Collect

func (c *Collector) Collect(ctx context.Context, opts Options) (*Data, error)

Collect collects all data from Port API concurrently.

type Data

type Data struct {
	Blueprints []api.Blueprint
	Entities   []api.Entity
	Scorecards []api.Scorecard
	Actions    []api.Action
	// BlueprintPermissions maps blueprint identifier -> permissions object.
	BlueprintPermissions map[string]api.Permissions
	// ActionPermissions maps action identifier -> permissions object.
	ActionPermissions map[string]api.Permissions
	// PagePermissions maps page identifier -> permissions object.
	PagePermissions map[string]api.Permissions
	Teams           []api.Team
	Users           []api.User
	Folders         []api.Folder
	Pages           []api.Page
	Integrations    []api.Integration
	TimeoutErrors   []string // Blueprints that timed out during export
	Warnings        []string // Non-fatal issues encountered during collection
	// ReferencedBlueprintIDs is populated when Options.AutoScopeBlueprints is
	// true: the set of blueprint identifiers that produced at least one
	// matching entity/scorecard/action during Collect. Always non-nil.
	ReferencedBlueprintIDs map[string]bool
}

Data represents collected export data.

func (*Data) WriteJSON added in v0.1.7

func (d *Data) WriteJSON(w io.Writer) error

WriteJSON encodes the Data as indented JSON into w.

type EntitySink added in v0.3.2

type EntitySink interface {
	WriteEntity(api.Entity) error
}

EntitySink accepts entities one at a time while an export archive is being written.

type Module

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

Module handles exporting data from Port.

func NewModule

func NewModule(token *auth.Token, orgConfig *config.OrganizationConfig) *Module

NewModule creates a new export module.

func (*Module) Close

func (m *Module) Close() error

Close closes the API client.

func (*Module) Execute

func (m *Module) Execute(ctx context.Context, opts Options) (*Result, error)

Execute performs the export operation.

type Options

type Options struct {
	OutputPath                    string
	Blueprints                    []string
	Format                        string
	SkipEntities                  bool
	SkipSystemBlueprints          bool // skip _* blueprint schemas and their entities
	SkipSystemBlueprintProperties bool
	IncludeRuleResults            bool // include the _rule_result system blueprint and its entities (excluded by default)
	IncludeResources              []string
	ExcludeBlueprints             []string // deep: exclude blueprint schema + all its resources
	ExcludeBlueprintSchema        []string // shallow: exclude only the blueprint schema, keep resources

	// AutoScopeBlueprints, when true, causes Collect to record which blueprints
	// produced at least one matching entity/scorecard/action into
	// Data.ReferencedBlueprintIDs. It does NOT narrow Data.Blueprints itself —
	// callers that want the narrowed set call FilterBlueprintsToReferenced
	// after combining this signal with any other source of "referenced" (e.g.
	// export.go's separate entity-streaming pass, which never runs inside
	// Collect when SkipEntities is forced true).
	AutoScopeBlueprints bool

	// Per-resource ID filters (client-side, applied after bulk fetch)
	Entities     []string
	Scorecards   []string
	Actions      []string
	Pages        []string
	Integrations []string
	Teams        []string
	Users        []string
}

Options represents export options.

func (*Options) Validate

func (o *Options) Validate() error

Validate validates export options.

type Result

type Result struct {
	Success           bool
	Message           string
	OutputPath        string
	BlueprintsCount   int
	EntitiesCount     int
	ActionsCount      int
	PagesCount        int
	IntegrationsCount int
	UsersCount        int
	TeamsCount        int
	FoldersCount      int
	Format            string
	TimeoutErrors     []string // Blueprints that timed out during export
	Error             error
}

Result represents the result of an export operation.

Jump to

Keyboard shortcuts

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