Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(ctx context.Context, client *goclientnew.ClientWithResponses, ...) ([]ApplyResult, *Inventory, error)
- func BuildWhereFilterFromImportFilters(filters []goclientnew.ImportFilter) (string, error)
- func GetEntityBySlug(ctx context.Context, client *goclientnew.ClientWithResponses, ...) (interface{}, error)
- func GetRevisionByNum(ctx context.Context, client *goclientnew.ClientWithResponses, ...) (*goclientnew.ExtendedRevision, error)
- func GetSpaceDetailURL(serverURL, spaceID string) string
- func GetSpaceListURL(serverURL string) string
- func GetTargetListURL(serverURL string) string
- func GetUnitDetailURL(serverURL, spaceID, unitID string) string
- func GetUnitEditURL(serverURL, spaceID, unitID string) string
- func GetUnitListURL(serverURL string) string
- func GetUnitRevisionsURL(serverURL, spaceID, unitID string) string
- func GetWorkerListURL(serverURL string) string
- func InterpretErrorGeneric(err error, resp interface{}) error
- func IsAPIError(err error, resp APIResponse) bool
- func ListEntitiesForImport(ctx context.Context, client *goclientnew.ClientWithResponses, spaceID string, ...) ([]interface{}, error)
- func MarshalYAMLWithoutReadonlyFields(entityType string, entity interface{}, spaceSlug string) ([]byte, error)
- func ParseBoolOption(options *goclientnew.ImportOptions, key string, defaultValue bool) bool
- func ParseStringOption(options *goclientnew.ImportOptions, key string, defaultValue string) string
- func Refresh(ctx context.Context, client *goclientnew.ClientWithResponses, ...) ([]ApplyResult, *Inventory, []byte, error)
- type APIResponse
- type ApplyResult
- type AuthSession
- type Inventory
- type InventoryResource
- type User
Constants ¶
const ( EntityTypeSpace = "Space" EntityTypeFilter = "Filter" EntityTypeView = "View" EntityTypeInvocation = "Invocation" EntityTypeTrigger = "Trigger" EntityTypeTag = "Tag" EntityTypeChangeSet = "ChangeSet" EntityTypeTarget = "Target" EntityTypeBridgeWorker = "BridgeWorker" EntityTypeUnit = "Unit" EntityTypeLink = "Link" EntityTypeSet = "Set" // Pseudo-EntityType EntityTypeInventory = "Inventory" )
Entity types
const ( AuthTypeBasic = "Basic" AuthTypeJWT = "JWT" )
Variables ¶
var ErrEntityNotFound = errors.New("entity not found")
ErrEntityNotFound is used to mark entities that are not found during refresh
Functions ¶
func Apply ¶
func Apply( ctx context.Context, client *goclientnew.ClientWithResponses, data, lastAppliedData []byte, oldInventory *Inventory, defaultSpaceSlug string, ) ([]ApplyResult, *Inventory, error)
Apply processes the configuration data and returns the results and updated inventory.
func BuildWhereFilterFromImportFilters ¶
func BuildWhereFilterFromImportFilters(filters []goclientnew.ImportFilter) (string, error)
BuildWhereFilterFromImportFilters constructs a where filter string from ImportFilters
func GetEntityBySlug ¶
func GetEntityBySlug(ctx context.Context, client *goclientnew.ClientWithResponses, entityType, slug, spaceID string) (interface{}, error)
GetEntityBySlug fetches an entity by its slug, similar to the old apiGet* functions but using direct client library calls without global variable dependencies
func GetRevisionByNum ¶
func GetRevisionByNum(ctx context.Context, client *goclientnew.ClientWithResponses, spaceID, unitID string, revisionNum int64) (*goclientnew.ExtendedRevision, error)
GetRevisionByNum fetches a revision by its RevisionNum for a specific unit
func GetSpaceDetailURL ¶
GetSpaceDetailURL returns the web UI URL for a specific space detail page
func GetSpaceListURL ¶
GetSpaceListURL returns the web UI URL for the spaces list page
func GetTargetListURL ¶
GetTargetListURL returns the web UI URL for the targets list page
func GetUnitDetailURL ¶
GetUnitDetailURL returns the web UI URL for a specific unit detail page
func GetUnitEditURL ¶
GetUnitEditURL returns the web UI URL for unit edit view Tab 1 is the edit tab in the unit detail page
func GetUnitListURL ¶
GetUnitListURL returns the web UI URL for the units list page Note: Space context is handled by the UI session
func GetUnitRevisionsURL ¶
GetUnitRevisionsURL returns the web UI URL for unit revisions view Tab 2 is the revisions tab in the unit detail page
func GetWorkerListURL ¶
GetWorkerListURL returns the web UI URL for the bridge workers list page
func InterpretErrorGeneric ¶
InterpretErrorGeneric checks the response for any errors and returns an error if found. If we found no non-nil JSON4xx or JSON5xx, presumably it is a 2xx success or client initiated termination.
func IsAPIError ¶
func IsAPIError(err error, resp APIResponse) bool
func ListEntitiesForImport ¶
func ListEntitiesForImport(ctx context.Context, client *goclientnew.ClientWithResponses, spaceID string, entityType string, whereFilter string) ([]interface{}, error)
ListEntitiesForImport fetches entities of a specific type using the provided where filter. It returns the entities as a slice of interfaces that can be processed further.
func MarshalYAMLWithoutReadonlyFields ¶
func MarshalYAMLWithoutReadonlyFields(entityType string, entity interface{}, spaceSlug string) ([]byte, error)
MarshalYAMLWithoutReadonlyFields marshals an entity to YAML while excluding readonly fields. It uses the Patch types which contain only the mutable fields that should be included in LiveState. It also removes null fields, the Version field, and adds SpaceSlug for space-resident entities.
func ParseBoolOption ¶
func ParseBoolOption(options *goclientnew.ImportOptions, key string, defaultValue bool) bool
ParseBoolOption extracts a boolean option from the options map
func ParseStringOption ¶
func ParseStringOption(options *goclientnew.ImportOptions, key string, defaultValue string) string
ParseStringOption extracts a string option from the options map
func Refresh ¶
func Refresh( ctx context.Context, client *goclientnew.ClientWithResponses, currentData []byte, oldInventory *Inventory, defaultSpaceSlug string, liveRevisionNum int64, spaceID, unitID string, ) ([]ApplyResult, *Inventory, []byte, error)
Refresh gets the current state of entities in the inventory and updates the config data, inventory, and live state. It returns the same ApplyResult structure as Apply, along with updated inventory and refreshed config data.
Types ¶
type APIResponse ¶
type APIResponse interface {
StatusCode() int
}
type ApplyResult ¶
type ApplyResult struct {
EntityType string
EntityName string
EntityID string
SpaceSlug string
Action string // "created", "updated", "deleted", "failed"
Error error
Entity interface{} // Store the created/updated entity for display
}
func Destroy ¶
func Destroy(ctx context.Context, client *goclientnew.ClientWithResponses, inventory *Inventory, defaultSpaceSlug string) []ApplyResult
type AuthSession ¶
type AuthSession struct {
User User `json:"user"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
OrganizationID string `json:"organization_id"`
AuthType string `json:"auth_type"`
// Note: This field is not part of the API. We just use it to pass the password to setAuthHeaderToken.
BasicAuthPassword string `json:"basic_auth_password,omitempty"`
}
func PerformWorkerAuth ¶
func PerformWorkerAuth(serverURL, workerID, workerSecret string) (*AuthSession, error)
type Inventory ¶
type Inventory struct {
EntityType string `yaml:"EntityType"`
Resources []InventoryResource `yaml:"Resources"`
}
type InventoryResource ¶
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
ProfilePictureURL string `json:"profile_picture_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ExternalID string `json:"external_id,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}