tm1

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthFunc

type AuthFunc func(req *http.Request) error

AuthFunc adapts a function to the AuthProvider interface.

func (AuthFunc) Apply

func (f AuthFunc) Apply(req *http.Request) error

Apply implements AuthProvider.

type AuthProvider

type AuthProvider interface {
	Apply(req *http.Request) error
}

AuthProvider supplies authentication material for outgoing requests.

type AuthenticationMode

type AuthenticationMode int

AuthenticationMode represents the authentication method being used

const (
	AuthModeBasic            AuthenticationMode = iota + 1
	AuthModeWIA                                 // Windows Integrated Authentication
	AuthModeCAM                                 // CAM authentication
	AuthModeCAMSSO                              // CAM SSO
	AuthModeIBMCloudAPIKey                      // IBM Cloud API Key
	AuthModeServiceToService                    // Service-to-service authentication
	AuthModePAProxy                             // Planning Analytics Proxy
	AuthModeBasicAPIKey                         // Basic API Key
	AuthModeAccessToken                         // Access Token
)

type Axis

type Axis struct {
	Ordinal     int     `json:"Ordinal"`
	Tuples      []Tuple `json:"Tuples,omitempty"`
	Cardinality int     `json:"Cardinality,omitempty"`
}

Axis represents an axis in a cellset

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth provides HTTP Basic authentication.

func (BasicAuth) Apply

func (b BasicAuth) Apply(req *http.Request) error

Apply implements AuthProvider.

type BearerToken

type BearerToken string

BearerToken supplies static bearer token authentication.

func (BearerToken) Apply

func (b BearerToken) Apply(req *http.Request) error

Apply implements AuthProvider.

type Cell

type Cell struct {
	Ordinal        int         `json:"Ordinal"`
	Value          interface{} `json:"Value,omitempty"`
	FormattedValue string      `json:"FormattedValue,omitempty"`
	RuleDerived    bool        `json:"RuleDerived,omitempty"`
	Consolidated   bool        `json:"Consolidated,omitempty"`
	Updateable     bool        `json:"Updateable,omitempty"`
}

Cell represents a single cell in a cellset

type CellService

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

CellService handles read and write operations to TM1 cubes

func NewCellService

func NewCellService(rest *RestService) *CellService

NewCellService creates a new CellService instance

func (*CellService) CreateCellset

func (cs *CellService) CreateCellset(ctx context.Context, mdx string, sandboxName string) (string, error)

CreateCellset creates a cellset from an MDX query

func (*CellService) CreateCellsetFromView

func (cs *CellService) CreateCellsetFromView(ctx context.Context, cubeName, viewName string, private bool, sandboxName string) (string, error)

CreateCellsetFromView creates a cellset from a cube view

func (*CellService) DeleteCellset

func (cs *CellService) DeleteCellset(ctx context.Context, cellsetID string, sandboxName string) error

DeleteCellset deletes a cellset

func (*CellService) ExecuteMDX

func (cs *CellService) ExecuteMDX(ctx context.Context, mdx string, cellProperties []string, sandboxName string) (map[string]map[string]interface{}, error)

ExecuteMDX executes an MDX query and returns cells with their properties Returns a map where keys are coordinate tuples (as strings) and values are cell property maps

func (*CellService) ExecuteView

func (cs *CellService) ExecuteView(ctx context.Context, cubeName, viewName string, private bool, cellProperties []string, sandboxName string) (map[string]map[string]interface{}, error)

ExecuteView executes an existing cube view and returns cells with their properties

func (*CellService) ExtractCellset

func (cs *CellService) ExtractCellset(ctx context.Context, cellsetID string, cellProperties []string, deleteCellset bool, sandboxName string) (map[string]map[string]interface{}, error)

ExtractCellset extracts cell data from a cellset

func (*CellService) GetValue

func (cs *CellService) GetValue(ctx context.Context, cubeName string, elements []string, dimensions []string, sandboxName string) (interface{}, error)

GetValue returns a single cube value from specified coordinates elements can be a slice of element names in the correct dimension order dimensions should contain the dimension names in their natural order

func (*CellService) WriteValue

func (cs *CellService) WriteValue(ctx context.Context, cubeName string, elements []string, dimensions []string, value interface{}, sandboxName string) error

WriteValue writes a single value to a cube at the specified coordinates

func (*CellService) WriteValues

func (cs *CellService) WriteValues(ctx context.Context, cubeName string, cells map[string]interface{}, dimensions []string, sandboxName string) error

WriteValues writes multiple cell values to a cube using comma-separated coordinates. cells is a map where keys are coordinate tuples (comma-separated element names) and values are the cell values. dimensions should contain the dimension names in their natural order.

func (*CellService) WriteValuesByCoords

func (cs *CellService) WriteValuesByCoords(ctx context.Context, cubeName string, coords [][]string, values []interface{}, dimensions []string, sandboxName string) error

WriteValuesByCoords writes multiple cell values to a cube using explicit coordinates. coords is a slice of element tuples (one tuple per cell), and values is the matching list of values. dimensions should contain the dimension names in their natural order.

type CellValue

type CellValue struct {
	Value          interface{}            `json:"Value"`
	Ordinal        int                    `json:"Ordinal,omitempty"`
	RuleDerived    bool                   `json:"RuleDerived,omitempty"`
	Consolidated   bool                   `json:"Consolidated,omitempty"`
	Updateable     bool                   `json:"Updateable,omitempty"`
	FormattedValue string                 `json:"FormattedValue,omitempty"`
	Properties     map[string]interface{} `json:"-"`
}

CellValue represents a single cell value with its properties

type Cellset

type Cellset struct {
	ID      string                            `json:"ID,omitempty"`
	Axes    []Axis                            `json:"Axes,omitempty"`
	Cells   []Cell                            `json:"Cells,omitempty"`
	CellMap map[string]map[string]interface{} `json:"-"` // Coordinate tuple -> cell properties
}

Cellset represents a complete cellset response

type Config

type Config struct {
	// Core connection parameters
	Address  string // Hostname or IP of the TM1 server
	Port     int    // HTTPPortNumber defined in tm1s.cfg
	BaseURL  string // Optional full base URL, e.g. https://localhost:12354/api/v1
	SSL      bool   // Controls http vs https when BaseURL is not provided
	Instance string // Planning Analytics Engine (v12) instance name
	Database string // Planning Analytics Engine (v12) database name

	// Authentication parameters
	User                    string // Username for authentication
	Password                string // Password for authentication
	DecodeBase64            bool   // Whether password argument is base64 encoded
	Namespace               string // Optional namespace for LDAP or CAM authentication
	CAMPassport             string // The CAM passport
	SessionID               string // TM1SessionId for reusing existing session e.g. q7O6e1w49AixeuLVxJ1GZg
	ApplicationClientID     string // Planning Analytics Engine (v12) named application client ID
	ApplicationClientSecret string // Planning Analytics Engine (v12) named application secret
	APIKey                  string // Planning Analytics Engine (v12) API Key from IBM Cloud
	IAMUrl                  string // Planning Analytics Engine (v12) IBM Cloud IAM URL. Default: "https://iam.cloud.ibm.com"
	PAUrl                   string // Planning Analytics Engine (v12) PA URL e.g., "https://us-east-2.aws.planninganalytics.ibm.com"
	CPDUrl                  string // Cloud Pack for Data URL (aka ZEN) e.g., "https://cpd-zen.apps.cp4dpa-test11.cp.fyre.ibm.com"
	Tenant                  string // Planning Analytics Engine (v12) Tenant e.g., YC4B2M1AG2Y6
	Gateway                 string // Optional gateway for CAM authentication
	AuthURL                 string // Auth URL for Planning Analytics Engine (v12)
	AccessToken             string // Access token for token-based authentication

	// Integrated login (Windows authentication) parameters
	IntegratedLogin         bool   // True for IntegratedSecurityMode3
	IntegratedLoginDomain   string // NT Domain name. Default: '.' for local account
	IntegratedLoginService  string // Kerberos Service type for remote Service Principal Name. Default: 'HTTP'
	IntegratedLoginHost     string // Host name for Service Principal Name. Default: Extracted from request URI
	IntegratedLoginDelegate bool   // Indicates that the user's credentials are to be delegated to the server

	// Request behavior parameters
	Timeout             time.Duration // Per-request timeout applied to the HTTP client
	CancelAtTimeout     bool          // Abort operation in TM1 when timeout is reached
	AsyncRequestsMode   bool          // Changes internal REST execution mode to avoid 60s timeout on IBM cloud
	SessionContext      string        // Value for TM1-SessionContext header, surfaced in TM1top/Arc
	Impersonate         string        // Name of user to impersonate
	Verify              interface{}   // Path to .cer file or boolean for SSL verification
	SkipSSLVerification bool          // Allows self-signed certificates during development
	Logging             bool          // Switch on/off verbose http logging

	// Connection pool parameters
	ConnectionPoolSize int // Maximum number of connections to save in the pool (default: 10)
	PoolConnections    int // Number of connection pools to cache (default: 1 for a single TM1 instance)

	// Reconnection behavior
	ReConnectOnSessionTimeout   bool // Attempt to reconnect once if session is timed out (default: true)
	ReConnectOnRemoteDisconnect bool // Attempt to reconnect once if connection is aborted by remote end (default: true)

	// Session management
	KeepAlive bool // If true, Close() will not logout from TM1, keeping the session alive for reuse

	// HTTP client customization
	ProxyURL       string       // Optional HTTP proxy definition
	Proxies        interface{}  // Pass a map or JSON string with proxies e.g. {"http": "http://proxy:8080"}
	HTTPClient     *http.Client // Optional pre-configured HTTP client
	DefaultHeaders http.Header  // Optional additional default headers
	SSLContext     interface{}  // Pass a user defined ssl context
	Cert           interface{}  // If String, path to SSL client cert file (.pem). If Tuple, ('cert', 'key') pair
}

Config captures the connection inputs needed to communicate with a TM1 REST API instance.

func (Config) EffectiveBaseURL

func (c Config) EffectiveBaseURL() (string, error)

EffectiveBaseURL returns the normalized REST root URL.

func (Config) HTTPClientOrDefault

func (c Config) HTTPClientOrDefault() (*http.Client, error)

HTTPClientOrDefault returns the caller-supplied HTTP client or a safe default.

func (Config) HTTPHeaders

func (c Config) HTTPHeaders() http.Header

HTTPHeaders merges default TM1 headers with caller overrides.

func (Config) SessionContextValue

func (c Config) SessionContextValue() string

SessionContextValue resolves the session context header to send with each request.

func (Config) Validate

func (c Config) Validate() error

Validate performs static checks on the configuration.

type DimensionService

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

DimensionService handles operations for TM1 Dimensions

func NewDimensionService

func NewDimensionService(rest *RestService) *DimensionService

NewDimensionService creates a new DimensionService instance

func (*DimensionService) Create

func (ds *DimensionService) Create(ctx context.Context, dimension *models.Dimension) error

Create creates a new dimension in TM1

func (*DimensionService) Delete

func (ds *DimensionService) Delete(ctx context.Context, dimensionName string) error

Delete deletes a dimension

func (*DimensionService) Exists

func (ds *DimensionService) Exists(ctx context.Context, dimensionName string) (bool, error)

Exists checks if a dimension exists

func (*DimensionService) Get

func (ds *DimensionService) Get(ctx context.Context, dimensionName string) (*models.Dimension, error)

Get retrieves a dimension by name

func (*DimensionService) GetAll

func (ds *DimensionService) GetAll(ctx context.Context, skipControlDims bool) ([]*models.Dimension, error)

GetAll retrieves all dimensions

func (*DimensionService) GetAllNames

func (ds *DimensionService) GetAllNames(ctx context.Context, skipControlDims bool) ([]string, error)

GetAllNames retrieves all dimension names

func (*DimensionService) GetNumberOfDimensions

func (ds *DimensionService) GetNumberOfDimensions(ctx context.Context, skipControlDims bool) (int, error)

GetNumberOfDimensions returns the count of dimensions

func (*DimensionService) Update

func (ds *DimensionService) Update(ctx context.Context, dimension *models.Dimension, keepExistingAttributes bool) error

Update updates an existing dimension

func (*DimensionService) UpdateOrCreate

func (ds *DimensionService) UpdateOrCreate(ctx context.Context, dimension *models.Dimension) error

UpdateOrCreate updates a dimension if it exists, otherwise creates it

func (*DimensionService) UsesAlternateHierarchies

func (ds *DimensionService) UsesAlternateHierarchies(ctx context.Context, dimensionName string) (bool, error)

UsesAlternateHierarchies checks if a dimension uses alternate hierarchies

type ElementService

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

ElementService provides methods to interact with TM1 elements

func NewElementService

func NewElementService(rest *RestService) *ElementService

NewElementService creates a new ElementService instance

func (*ElementService) AddEdges

func (es *ElementService) AddEdges(ctx context.Context, dimensionName, hierarchyName string, edges map[[2]string]float64) error

AddEdges adds edges to a hierarchy

func (*ElementService) AddElementAttributes

func (es *ElementService) AddElementAttributes(ctx context.Context, dimensionName, hierarchyName string, attributes []models.ElementAttribute) error

AddElementAttributes adds multiple element attributes to a hierarchy

func (*ElementService) AddElements

func (es *ElementService) AddElements(ctx context.Context, dimensionName, hierarchyName string, elements []models.Element) error

AddElements adds multiple elements to a hierarchy

func (*ElementService) Create

func (es *ElementService) Create(ctx context.Context, dimensionName, hierarchyName string, element models.Element) error

Create creates a new element in a hierarchy

func (*ElementService) CreateElementAttribute

func (es *ElementService) CreateElementAttribute(ctx context.Context, dimensionName, hierarchyName string, attribute models.ElementAttribute) error

CreateElementAttribute creates an element attribute in a hierarchy

func (*ElementService) Delete

func (es *ElementService) Delete(ctx context.Context, dimensionName, hierarchyName, elementName string) error

Delete deletes an element from a hierarchy

func (*ElementService) DeleteElementAttribute

func (es *ElementService) DeleteElementAttribute(ctx context.Context, dimensionName, hierarchyName, attributeName string) error

DeleteElementAttribute deletes an element attribute from a hierarchy

func (*ElementService) ElementIsParent

func (es *ElementService) ElementIsParent(ctx context.Context, dimensionName, hierarchyName, parentName, elementName string) (bool, error)

ElementIsParent checks if an element is a direct parent of another element

func (*ElementService) Exists

func (es *ElementService) Exists(ctx context.Context, dimensionName, hierarchyName, elementName string) (bool, error)

Exists checks if an element exists in a hierarchy

func (*ElementService) Get

func (es *ElementService) Get(ctx context.Context, dimensionName, hierarchyName, elementName string) (*models.Element, error)

Get retrieves an element by name

func (*ElementService) GetConsolidatedElementNames

func (es *ElementService) GetConsolidatedElementNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetConsolidatedElementNames retrieves all consolidated element names

func (*ElementService) GetConsolidatedElements

func (es *ElementService) GetConsolidatedElements(ctx context.Context, dimensionName, hierarchyName string) ([]models.Element, error)

GetConsolidatedElements retrieves all consolidated elements

func (*ElementService) GetEdges

func (es *ElementService) GetEdges(ctx context.Context, dimensionName, hierarchyName string) (map[[2]string]float64, error)

GetEdges retrieves all edges (parent-child relationships) in a hierarchy

func (*ElementService) GetEdgesUnderConsolidation

func (es *ElementService) GetEdgesUnderConsolidation(ctx context.Context, dimensionName, hierarchyName, consolidation string, maxDepth int) (map[[2]string]float64, error)

GetEdgesUnderConsolidation retrieves all edges under a consolidation element

func (*ElementService) GetElementAttributeNames

func (es *ElementService) GetElementAttributeNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetElementAttributeNames retrieves all element attribute names in a hierarchy

func (*ElementService) GetElementAttributes

func (es *ElementService) GetElementAttributes(ctx context.Context, dimensionName, hierarchyName string) ([]models.ElementAttribute, error)

GetElementAttributes retrieves all element attributes in a hierarchy

func (*ElementService) GetElementNames

func (es *ElementService) GetElementNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetElementNames retrieves all element names in a hierarchy

func (*ElementService) GetElementPrincipalName

func (es *ElementService) GetElementPrincipalName(ctx context.Context, dimensionName, hierarchyName, elementName string) (string, error)

GetElementPrincipalName retrieves the principal (server-side) name of an element

func (*ElementService) GetElementTypes

func (es *ElementService) GetElementTypes(ctx context.Context, dimensionName, hierarchyName string, skipConsolidations bool) (map[string]string, error)

GetElementTypes retrieves a map of element names to their types

func (*ElementService) GetElements

func (es *ElementService) GetElements(ctx context.Context, dimensionName, hierarchyName string) ([]models.Element, error)

GetElements retrieves all elements in a hierarchy

func (*ElementService) GetElementsByLevel

func (es *ElementService) GetElementsByLevel(ctx context.Context, dimensionName, hierarchyName string, level int) ([]string, error)

GetElementsByLevel retrieves elements filtered by level

func (*ElementService) GetElementsFilteredByWildcard

func (es *ElementService) GetElementsFilteredByWildcard(ctx context.Context, dimensionName, hierarchyName, wildcard string, level *int) ([]string, error)

GetElementsFilteredByWildcard retrieves elements filtered by wildcard pattern

func (*ElementService) GetLeafElementNames

func (es *ElementService) GetLeafElementNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetLeafElementNames retrieves all leaf element names

func (*ElementService) GetLeafElements

func (es *ElementService) GetLeafElements(ctx context.Context, dimensionName, hierarchyName string) ([]models.Element, error)

GetLeafElements retrieves all leaf (non-consolidated) elements

func (*ElementService) GetLeavesUnderConsolidation

func (es *ElementService) GetLeavesUnderConsolidation(ctx context.Context, dimensionName, hierarchyName, consolidation string) ([]string, error)

GetLeavesUnderConsolidation retrieves all leaf elements under a consolidation

func (*ElementService) GetLevelNames

func (es *ElementService) GetLevelNames(ctx context.Context, dimensionName, hierarchyName string, descending bool) ([]string, error)

GetLevelNames retrieves level names in a hierarchy

func (*ElementService) GetLevelsCount

func (es *ElementService) GetLevelsCount(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetLevelsCount retrieves the count of levels in a hierarchy

func (*ElementService) GetMembersUnderConsolidation

func (es *ElementService) GetMembersUnderConsolidation(ctx context.Context, dimensionName, hierarchyName, consolidation string) ([]string, error)

GetMembersUnderConsolidation retrieves all members under a consolidation element

func (*ElementService) GetNumberOfConsolidatedElements

func (es *ElementService) GetNumberOfConsolidatedElements(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetNumberOfConsolidatedElements retrieves the count of consolidated elements

func (*ElementService) GetNumberOfElements

func (es *ElementService) GetNumberOfElements(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetNumberOfElements retrieves the count of all elements

func (*ElementService) GetNumberOfLeafElements

func (es *ElementService) GetNumberOfLeafElements(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetNumberOfLeafElements retrieves the count of leaf elements

func (*ElementService) GetNumberOfNumericElements

func (es *ElementService) GetNumberOfNumericElements(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetNumberOfNumericElements retrieves the count of numeric elements

func (*ElementService) GetNumberOfStringElements

func (es *ElementService) GetNumberOfStringElements(ctx context.Context, dimensionName, hierarchyName string) (int, error)

GetNumberOfStringElements retrieves the count of string elements

func (*ElementService) GetNumericElementNames

func (es *ElementService) GetNumericElementNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetNumericElementNames retrieves all numeric element names

func (*ElementService) GetNumericElements

func (es *ElementService) GetNumericElements(ctx context.Context, dimensionName, hierarchyName string) ([]models.Element, error)

GetNumericElements retrieves all numeric elements

func (*ElementService) GetParents

func (es *ElementService) GetParents(ctx context.Context, dimensionName, hierarchyName, elementName string) ([]string, error)

GetParents retrieves the parent elements of an element

func (*ElementService) GetParentsOfAllElements

func (es *ElementService) GetParentsOfAllElements(ctx context.Context, dimensionName, hierarchyName string) (map[string][]string, error)

GetParentsOfAllElements retrieves parents for all elements in a hierarchy

func (*ElementService) GetStringElementNames

func (es *ElementService) GetStringElementNames(ctx context.Context, dimensionName, hierarchyName string) ([]string, error)

GetStringElementNames retrieves all string element names

func (*ElementService) GetStringElements

func (es *ElementService) GetStringElements(ctx context.Context, dimensionName, hierarchyName string) ([]models.Element, error)

GetStringElements retrieves all string elements

func (*ElementService) RemoveEdge

func (es *ElementService) RemoveEdge(ctx context.Context, dimensionName, hierarchyName, parent, component string) error

RemoveEdge removes a single edge from a hierarchy

func (*ElementService) Update

func (es *ElementService) Update(ctx context.Context, dimensionName, hierarchyName string, element models.Element) error

Update updates an existing element

func (*ElementService) UpdateOrCreate

func (es *ElementService) UpdateOrCreate(ctx context.Context, dimensionName, hierarchyName string, element models.Element) error

UpdateOrCreate updates an element if it exists, otherwise creates it

type HTTPError

type HTTPError struct {
	Method     string
	URL        string
	StatusCode int
	Body       []byte
}

HTTPError captures non-success responses returned by TM1 REST API.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HeaderAuth

type HeaderAuth map[string]string

HeaderAuth injects arbitrary headers required by upstream gateways.

func (HeaderAuth) Apply

func (h HeaderAuth) Apply(req *http.Request) error

Apply implements AuthProvider.

type HierarchyService

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

HierarchyService provides methods to interact with TM1 hierarchies

func NewHierarchyService

func NewHierarchyService(rest *RestService) *HierarchyService

NewHierarchyService creates a new HierarchyService instance

func (*HierarchyService) AddEdges

func (hs *HierarchyService) AddEdges(ctx context.Context, dimensionName, hierarchyName string, edges map[[2]string]float64) error

AddEdges adds edges to a hierarchy

func (*HierarchyService) AddElementAttributes

func (hs *HierarchyService) AddElementAttributes(ctx context.Context, dimensionName, hierarchyName string, attributes []models.ElementAttribute) error

AddElementAttributes adds element attributes to a hierarchy

func (*HierarchyService) AddElements

func (hs *HierarchyService) AddElements(ctx context.Context, dimensionName, hierarchyName string, elements []models.Element) error

AddElements adds elements to a hierarchy

func (*HierarchyService) Create

func (hs *HierarchyService) Create(ctx context.Context, hierarchy *models.Hierarchy) error

Create creates a new hierarchy in an existing dimension

func (*HierarchyService) CreateElementAttributes

func (hs *HierarchyService) CreateElementAttributes(ctx context.Context, dimensionName, hierarchyName string, attributes []models.ElementAttribute) error

CreateElementAttributes creates element attributes for a hierarchy (alias for AddElementAttributes)

func (*HierarchyService) Delete

func (hs *HierarchyService) Delete(ctx context.Context, dimensionName, hierarchyName string) error

Delete deletes a hierarchy from a dimension

func (*HierarchyService) Elements

func (hs *HierarchyService) Elements() *ElementService

Elements returns the ElementService associated with this HierarchyService

func (*HierarchyService) Exists

func (hs *HierarchyService) Exists(ctx context.Context, dimensionName, hierarchyName string) (bool, error)

Exists checks if a hierarchy exists in a dimension

func (*HierarchyService) Get

func (hs *HierarchyService) Get(ctx context.Context, dimensionName, hierarchyName string) (*models.Hierarchy, error)

Get retrieves a hierarchy by name

func (*HierarchyService) GetAllNames

func (hs *HierarchyService) GetAllNames(ctx context.Context, dimensionName string) ([]string, error)

GetAllNames retrieves all hierarchy names in a dimension

func (*HierarchyService) GetDefaultMember

func (hs *HierarchyService) GetDefaultMember(ctx context.Context, dimensionName, hierarchyName string) (string, error)

GetDefaultMember retrieves the default member of a hierarchy

func (*HierarchyService) GetHierarchySummary

func (hs *HierarchyService) GetHierarchySummary(ctx context.Context, dimensionName, hierarchyName string) (map[string]int, error)

GetHierarchySummary retrieves summary statistics for a hierarchy

func (*HierarchyService) IsBalanced

func (hs *HierarchyService) IsBalanced(ctx context.Context, dimensionName, hierarchyName string) (bool, error)

IsBalanced checks if a hierarchy is balanced

func (*HierarchyService) RemoveAllEdges

func (hs *HierarchyService) RemoveAllEdges(ctx context.Context, dimensionName, hierarchyName string) error

RemoveAllEdges removes all edges from a hierarchy

func (*HierarchyService) RemoveEdgesUnderConsolidation

func (hs *HierarchyService) RemoveEdgesUnderConsolidation(ctx context.Context, dimensionName, hierarchyName, consolidationElement string) error

RemoveEdgesUnderConsolidation removes all edges under a specific consolidation element

func (*HierarchyService) Subsets

func (hs *HierarchyService) Subsets() *SubsetService

Subsets returns the SubsetService associated with this HierarchyService

func (*HierarchyService) Update

func (hs *HierarchyService) Update(ctx context.Context, hierarchy *models.Hierarchy, keepExistingAttributes bool) error

Update updates an existing hierarchy

func (*HierarchyService) UpdateDefaultMember

func (hs *HierarchyService) UpdateDefaultMember(ctx context.Context, dimensionName, hierarchyName, memberName string) error

UpdateDefaultMember updates the default member of a hierarchy

func (*HierarchyService) UpdateElementAttributes

func (hs *HierarchyService) UpdateElementAttributes(ctx context.Context, hierarchy *models.Hierarchy, keepExistingAttributes bool) error

UpdateElementAttributes updates the element attributes of a hierarchy

func (*HierarchyService) UpdateOrCreate

func (hs *HierarchyService) UpdateOrCreate(ctx context.Context, hierarchy *models.Hierarchy) error

UpdateOrCreate updates a hierarchy if it exists, otherwise creates it

type Logger

type Logger interface {
	Printf(format string, args ...any)
}

Logger is the minimal interface required for debug logging inside the clients.

type Member

type Member struct {
	Name          string `json:"Name"`
	UniqueName    string `json:"UniqueName"`
	Type          string `json:"Type,omitempty"`
	Ordinal       int    `json:"Ordinal,omitempty"`
	DimensionName string `json:"DimensionName,omitempty"`
	HierarchyName string `json:"HierarchyName,omitempty"`
}

Member represents a member in a tuple

type ProcessService

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

ProcessService handles operations for TM1 Processes (TurboIntegrator)

func NewProcessService

func NewProcessService(rest *RestService) *ProcessService

NewProcessService creates a new ProcessService instance

func (*ProcessService) Compile

func (ps *ProcessService) Compile(ctx context.Context, processName string) ([]interface{}, error)

Compile compiles a process and returns syntax errors

func (*ProcessService) CompileProcess

func (ps *ProcessService) CompileProcess(ctx context.Context, process *models.Process) ([]interface{}, error)

CompileProcess compiles a process object and returns syntax errors

func (*ProcessService) Create

func (ps *ProcessService) Create(ctx context.Context, process *models.Process) error

Create creates a new process on TM1 Server

func (*ProcessService) DebugAddBreakpoint

func (ps *ProcessService) DebugAddBreakpoint(ctx context.Context, debugID string, breakpoint *models.ProcessDebugBreakpoint) error

DebugAddBreakpoint adds a breakpoint to a debug session

func (*ProcessService) DebugAddBreakpoints

func (ps *ProcessService) DebugAddBreakpoints(ctx context.Context, debugID string, breakpoints []*models.ProcessDebugBreakpoint) error

DebugAddBreakpoints adds multiple breakpoints to a debug session

func (*ProcessService) DebugContinue

func (ps *ProcessService) DebugContinue(ctx context.Context, debugID string) (map[string]interface{}, error)

DebugContinue resumes execution until next breakpoint

func (*ProcessService) DebugGetBreakpoints

func (ps *ProcessService) DebugGetBreakpoints(ctx context.Context, debugID string) ([]*models.ProcessDebugBreakpoint, error)

DebugGetBreakpoints retrieves all breakpoints for a debug session

func (*ProcessService) DebugGetSingleVariableValue

func (ps *ProcessService) DebugGetSingleVariableValue(ctx context.Context, debugID, variableName string) (interface{}, error)

DebugGetSingleVariableValue retrieves a specific variable value in a debug session

func (*ProcessService) DebugGetVariableValues

func (ps *ProcessService) DebugGetVariableValues(ctx context.Context, debugID string) (map[string]interface{}, error)

DebugGetVariableValues retrieves all variable values in a debug session

func (*ProcessService) DebugProcess

func (ps *ProcessService) DebugProcess(ctx context.Context, processName string, parameters map[string]interface{}) (map[string]interface{}, error)

DebugProcess starts a debug session for a process

func (*ProcessService) DebugRemoveBreakpoint

func (ps *ProcessService) DebugRemoveBreakpoint(ctx context.Context, debugID string, breakpointID int) error

DebugRemoveBreakpoint removes a breakpoint from a debug session

func (*ProcessService) DebugStepIn

func (ps *ProcessService) DebugStepIn(ctx context.Context, debugID string) (map[string]interface{}, error)

DebugStepIn runs a single statement and steps into child processes

func (*ProcessService) DebugStepOut

func (ps *ProcessService) DebugStepOut(ctx context.Context, debugID string) (map[string]interface{}, error)

DebugStepOut resumes execution until current process finishes

func (*ProcessService) DebugStepOver

func (ps *ProcessService) DebugStepOver(ctx context.Context, debugID string) (map[string]interface{}, error)

DebugStepOver runs a single statement in the process (does not debug child processes)

func (*ProcessService) DebugUpdateBreakpoint

func (ps *ProcessService) DebugUpdateBreakpoint(ctx context.Context, debugID string, breakpoint *models.ProcessDebugBreakpoint) error

DebugUpdateBreakpoint updates a breakpoint in a debug session

func (*ProcessService) Delete

func (ps *ProcessService) Delete(ctx context.Context, processName string) error

Delete deletes a process from TM1 Server

func (*ProcessService) EvaluateBooleanTIExpression

func (ps *ProcessService) EvaluateBooleanTIExpression(ctx context.Context, formula string) (bool, error)

EvaluateBooleanTIExpression evaluates a boolean TI expression

func (*ProcessService) EvaluateTIExpression

func (ps *ProcessService) EvaluateTIExpression(ctx context.Context, formula string) (string, error)

EvaluateTIExpression evaluates a TI expression and returns the result as a string

func (*ProcessService) Execute

func (ps *ProcessService) Execute(ctx context.Context, processName string, parameters map[string]interface{}, timeout *time.Duration, cancelAtTimeout bool) error

Execute executes a process on TM1 Server

func (*ProcessService) ExecuteProcessWithReturn

func (ps *ProcessService) ExecuteProcessWithReturn(ctx context.Context, process *models.Process, parameters map[string]interface{}) (bool, string, string, error)

ExecuteProcessWithReturn executes an unbound process object and returns execution status

func (*ProcessService) ExecuteWithReturn

func (ps *ProcessService) ExecuteWithReturn(ctx context.Context, processName string, parameters map[string]interface{}, timeout *time.Duration, cancelAtTimeout bool) (bool, string, string, error)

ExecuteWithReturn executes a process and returns execution status

func (*ProcessService) Exists

func (ps *ProcessService) Exists(ctx context.Context, processName string) (bool, error)

Exists checks if a process exists on TM1 Server

func (*ProcessService) Get

func (ps *ProcessService) Get(ctx context.Context, processName string) (*models.Process, error)

Get retrieves a process from TM1 Server

func (*ProcessService) GetAll

func (ps *ProcessService) GetAll(ctx context.Context, skipControlProcesses bool) ([]*models.Process, error)

GetAll retrieves all processes from TM1 Server

func (*ProcessService) GetAllNames

func (ps *ProcessService) GetAllNames(ctx context.Context, skipControlProcesses bool) ([]string, error)

GetAllNames retrieves all process names from TM1 Server

func (*ProcessService) GetErrorLogFileContent

func (ps *ProcessService) GetErrorLogFileContent(ctx context.Context, filename string) (string, error)

GetErrorLogFileContent retrieves the content of an error log file

func (*ProcessService) GetErrorLogFilenames

func (ps *ProcessService) GetErrorLogFilenames(ctx context.Context, processName string, top int, descending bool) ([]string, error)

GetErrorLogFilenames gets error log filenames for a specific process

func (*ProcessService) GetLastMessageFromProcessErrorLog

func (ps *ProcessService) GetLastMessageFromProcessErrorLog(ctx context.Context, processName string) (string, error)

GetLastMessageFromProcessErrorLog gets the latest error log message from a process

func (*ProcessService) GetProcessErrorLogs

func (ps *ProcessService) GetProcessErrorLogs(ctx context.Context, processName string) ([]interface{}, error)

GetProcessErrorLogs gets all ProcessErrorLog entries for a process

func (*ProcessService) SearchErrorLogFilenames

func (ps *ProcessService) SearchErrorLogFilenames(ctx context.Context, searchString string, top int, descending bool) ([]string, error)

SearchErrorLogFilenames searches for error log filenames containing a search string

func (*ProcessService) SearchStringInCode

func (ps *ProcessService) SearchStringInCode(ctx context.Context, searchString string, skipControlProcesses bool) ([]string, error)

SearchStringInCode searches for processes containing a string in their code

func (*ProcessService) SearchStringInName

func (ps *ProcessService) SearchStringInName(ctx context.Context, nameStartsWith string, nameContains []string, nameContainsOperator string, skipControlProcesses bool) ([]string, error)

SearchStringInName searches for processes by name patterns

func (*ProcessService) Update

func (ps *ProcessService) Update(ctx context.Context, process *models.Process) error

Update updates an existing process on TM1 Server

func (*ProcessService) UpdateOrCreate

func (ps *ProcessService) UpdateOrCreate(ctx context.Context, process *models.Process) error

UpdateOrCreate updates or creates a process on TM1 Server

type RequestOption

type RequestOption func(*http.Request)

RequestOption mutates individual HTTP requests before they are sent. Use these for per-request customization (query params, headers, etc).

func WithHeader

func WithHeader(key, value string) RequestOption

WithHeader sets a request-scoped header value.

func WithQueryValue

func WithQueryValue(key, value string) RequestOption

WithQueryValue sets a single query parameter on the request.

func WithQueryValues

func WithQueryValues(values url.Values) RequestOption

WithQueryValues appends the provided query parameters to the request.

type RestOption

type RestOption func(*RestService) error

RestOption configures a RestService instance. These options allow runtime customization beyond what Config provides.

func WithAdditionalHeaders

func WithAdditionalHeaders(headers http.Header) RestOption

WithAdditionalHeaders extends the default headers applied to every request. Use this to add gateway or proxy headers not in Config.

func WithAuthProvider

func WithAuthProvider(provider AuthProvider) RestOption

WithAuthProvider overrides the authentication provider determined from Config. Use this for custom authentication schemes not supported by Config.

func WithLogger

func WithLogger(logger Logger) RestOption

WithLogger sets a custom logger for debugging HTTP requests.

type RestService

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

RestService manages HTTP interactions with the TM1 REST API.

func NewRestService

func NewRestService(cfg Config, opts ...RestOption) (*RestService, error)

NewRestService constructs a RestService using the provided configuration and options.

func (*RestService) AddCompactJSONHeader

func (rs *RestService) AddCompactJSONHeader() string

AddCompactJSONHeader modifies the Accept header to request compact JSON responses. Returns the original Accept header value for restoration if needed.

func (*RestService) AddDefaultHeader

func (rs *RestService) AddDefaultHeader(key, value string)

AddDefaultHeader appends a header that will be sent with every request.

func (*RestService) BaseURL

func (rs *RestService) BaseURL() string

BaseURL returns the effective REST root URL.

func (*RestService) CancelAsyncOperation

func (rs *RestService) CancelAsyncOperation(ctx context.Context, asyncID string) error

CancelAsyncOperation cancels an async operation by its async_id. Returns true if cancellation was successful.

func (*RestService) Close

func (rs *RestService) Close()

Close releases idle connections held by the underlying HTTP client.

func (*RestService) Delete

func (rs *RestService) Delete(ctx context.Context, endpoint string, opts ...RequestOption) (*http.Response, error)

Delete executes an HTTP DELETE.

func (*RestService) Get

func (rs *RestService) Get(ctx context.Context, endpoint string, opts ...RequestOption) (*http.Response, error)

Get executes an HTTP GET.

func (*RestService) IsConnected

func (rs *RestService) IsConnected(ctx context.Context) bool

IsConnected checks if the connection to TM1 server is active.

func (*RestService) JSON

func (rs *RestService) JSON(ctx context.Context, method, endpoint string, payload any, dest any, opts ...RequestOption) error

JSON performs a request where the payload and response are JSON encoded.

func (*RestService) Logout

func (rs *RestService) Logout(ctx context.Context) error

Logout terminates the TM1 session by calling the ActiveSession/tm1.Close endpoint. This properly closes the session on the TM1 server side. Note: This always uses synchronous mode, regardless of asyncRequestsMode setting.

func (*RestService) Patch

func (rs *RestService) Patch(ctx context.Context, endpoint string, body io.Reader, opts ...RequestOption) (*http.Response, error)

Patch executes an HTTP PATCH.

func (*RestService) Ping

func (rs *RestService) Ping(ctx context.Context) error

Ping ensures the TM1 endpoint is reachable by fetching the product version.

func (*RestService) Post

func (rs *RestService) Post(ctx context.Context, endpoint string, body io.Reader, opts ...RequestOption) (*http.Response, error)

Post executes an HTTP POST.

func (*RestService) Put

func (rs *RestService) Put(ctx context.Context, endpoint string, body io.Reader, opts ...RequestOption) (*http.Response, error)

Put executes an HTTP PUT.

func (*RestService) RemoveDefaultHeader

func (rs *RestService) RemoveDefaultHeader(key string)

RemoveDefaultHeader removes a default header.

func (*RestService) Request

func (rs *RestService) Request(ctx context.Context, method, endpoint string, body io.Reader, opts ...RequestOption) (*http.Response, error)

Request executes an HTTP request against the TM1 REST API. The caller is responsible for closing the returned response body. If asyncRequestsMode is enabled, the request will use async mode automatically.

func (*RestService) RequestAsync

func (rs *RestService) RequestAsync(ctx context.Context, method, endpoint string, body io.Reader, returnAsyncID bool, opts ...RequestOption) (*http.Response, string, error)

RequestAsync executes an HTTP request with async mode enabled. It adds the 'Prefer: respond-async' header and handles async response polling. Returns the async_id if returnAsyncID is true, otherwise polls until completion.

func (*RestService) RetrieveAsyncResponse

func (rs *RestService) RetrieveAsyncResponse(ctx context.Context, asyncID string) (*http.Response, error)

RetrieveAsyncResponse retrieves the response from an async operation using the async_id. The async_id is typically returned in the Location header of an async operation.

func (*RestService) SessionID

func (rs *RestService) SessionID() string

SessionID retrieves the current TM1SessionId cookie value. Returns empty string if no session cookie is found.

func (*RestService) SetBaseURL

func (rs *RestService) SetBaseURL(baseURLStr string) error

SetBaseURL sets the base URL for the REST service (used for testing)

type SessionCookieAuth

type SessionCookieAuth struct {
	Name  string
	Value string
}

SessionCookieAuth reuses an existing TM1 session by attaching the TM1SessionId cookie.

func (SessionCookieAuth) Apply

func (s SessionCookieAuth) Apply(req *http.Request) error

Apply implements AuthProvider.

type SubsetService

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

SubsetService handles operations for TM1 Subsets (dynamic and static)

func NewSubsetService

func NewSubsetService(rest *RestService) *SubsetService

NewSubsetService creates a new SubsetService instance

func (*SubsetService) Create

func (ss *SubsetService) Create(ctx context.Context, subset *models.Subset, private bool) error

Create creates a subset on the TM1 Server

func (*SubsetService) Delete

func (ss *SubsetService) Delete(ctx context.Context, subsetName, dimensionName, hierarchyName string, private bool) error

Delete deletes an existing subset on the TM1 Server

func (*SubsetService) DeleteElementsFromStaticSubset

func (ss *SubsetService) DeleteElementsFromStaticSubset(ctx context.Context, dimensionName, hierarchyName, subsetName string, private bool) error

DeleteElementsFromStaticSubset deletes all elements from a static subset

func (*SubsetService) Exists

func (ss *SubsetService) Exists(ctx context.Context, subsetName, dimensionName, hierarchyName string, private bool) (bool, error)

Exists checks if a private or public subset exists

func (*SubsetService) Get

func (ss *SubsetService) Get(ctx context.Context, subsetName, dimensionName, hierarchyName string, private bool) (*models.Subset, error)

Get retrieves a subset from the TM1 Server

func (*SubsetService) GetAllNames

func (ss *SubsetService) GetAllNames(ctx context.Context, dimensionName, hierarchyName string, private bool) ([]string, error)

GetAllNames retrieves names of all private or public subsets in a hierarchy

func (*SubsetService) GetElementNames

func (ss *SubsetService) GetElementNames(ctx context.Context, dimensionName, hierarchyName, subsetName string, private bool) ([]string, error)

GetElementNames gets elements from existing (dynamic or static) subset For static subsets, returns the elements directly For dynamic subsets, returns an error as MDX execution is needed (use ElementService.ExecuteSetMDX)

func (*SubsetService) MakeStatic

func (ss *SubsetService) MakeStatic(ctx context.Context, subsetName, dimensionName, hierarchyName string, private bool) error

MakeStatic converts a dynamic subset into a static subset on the TM1 Server

func (*SubsetService) Update

func (ss *SubsetService) Update(ctx context.Context, subset *models.Subset, private bool) error

Update updates a subset on the TM1 Server

func (*SubsetService) UpdateOrCreate

func (ss *SubsetService) UpdateOrCreate(ctx context.Context, subset *models.Subset, private bool) error

UpdateOrCreate updates if exists, else creates

type TM1Service

type TM1Service struct {
	Dimensions  *DimensionService
	Processes   *ProcessService
	Hierarchies *HierarchyService
	Elements    *ElementService
	Subsets     *SubsetService
	Cells       *CellService
	// contains filtered or unexported fields
}

TM1Service exposes higher level helpers built on top of RestService.

func NewTM1Service

func NewTM1Service(cfg Config, opts ...RestOption) (*TM1Service, error)

NewTM1Service constructs a TM1Service with the supplied configuration.

func (*TM1Service) CancelAsyncOperation

func (s *TM1Service) CancelAsyncOperation(ctx context.Context, asyncID string) error

CancelAsyncOperation cancels an async operation by its async_id.

func (*TM1Service) Close

func (s *TM1Service) Close() error

Close releases resources held by the service and terminates the TM1 session.

func (*TM1Service) IsAdmin

func (s *TM1Service) IsAdmin(ctx context.Context) (bool, error)

IsAdmin checks if the current user has admin privileges.

func (*TM1Service) IsConnected

func (s *TM1Service) IsConnected(ctx context.Context) bool

IsConnected checks if the connection to TM1 server is active.

func (*TM1Service) IsDataAdmin

func (s *TM1Service) IsDataAdmin(ctx context.Context) (bool, error)

IsDataAdmin checks if the current user has data admin privileges.

func (*TM1Service) IsOpsAdmin

func (s *TM1Service) IsOpsAdmin(ctx context.Context) (bool, error)

IsOpsAdmin checks if the current user has operations admin privileges.

func (*TM1Service) IsSecurityAdmin

func (s *TM1Service) IsSecurityAdmin(ctx context.Context) (bool, error)

IsSecurityAdmin checks if the current user has security admin privileges.

func (*TM1Service) Logout

func (s *TM1Service) Logout(ctx context.Context) error

Logout terminates the TM1 session explicitly. This is called automatically by Close(), but can be called separately if needed.

func (*TM1Service) Metadata

func (s *TM1Service) Metadata(ctx context.Context) ([]byte, error)

Metadata retrieves the TM1 REST metadata document.

func (*TM1Service) Ping

func (s *TM1Service) Ping(ctx context.Context) error

Ping verifies that the TM1 instance is reachable.

func (*TM1Service) Reconnect

func (s *TM1Service) Reconnect(cfg Config, opts ...RestOption) error

Reconnect re-establishes the connection to TM1. This can be useful after a session timeout or network interruption.

func (*TM1Service) Rest

func (s *TM1Service) Rest() *RestService

Rest returns the underlying REST client so additional services can be composed.

func (*TM1Service) RetrieveAsyncResponse

func (s *TM1Service) RetrieveAsyncResponse(ctx context.Context, asyncID string) (*http.Response, error)

RetrieveAsyncResponse retrieves the response from an async operation using the async_id.

func (*TM1Service) SandboxingDisabled

func (s *TM1Service) SandboxingDisabled(ctx context.Context) (bool, error)

SandboxingDisabled checks if sandboxing is disabled for the current user.

func (*TM1Service) SessionID

func (s *TM1Service) SessionID() string

SessionID retrieves the current TM1SessionId from the active session. Returns empty string if no session is active or session cookie is not found.

func (*TM1Service) Version

func (s *TM1Service) Version(ctx context.Context) (string, error)

Version returns the TM1 server product version string.

func (*TM1Service) WhoAmI

func (s *TM1Service) WhoAmI(ctx context.Context) (map[string]interface{}, error)

WhoAmI returns the current authenticated user.

type Tuple

type Tuple struct {
	Ordinal int      `json:"Ordinal"`
	Members []Member `json:"Members,omitempty"`
}

Tuple represents a tuple on an axis

Jump to

Keyboard shortcuts

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