Administration API¶
-
class
tgdb.admin.
MemoryType
(value)¶ Represents one of the two memory types: process-specific or shared.
-
class
tgdb.admin.
ServerState
(value)¶ Represents the current server’s state.
-
class
tgdb.admin.
TGAdminConnection
¶ This class represents an administrative connection to the graph database server.
Should only be used when modifying metadata or accessing server state information programmatically.
-
abstract
checkpointServer
()¶ Allows the programmatic controller to checkpoint the server.
- Returns
Nothing.
-
abstract
createAttrDesc
(name: str, ad_type: tgdb.model.TGAttributeType, isArray: bool = False, isEncrypted: bool = False, prec: int = None, scale: int = None)¶ Create a new attribute descriptor on the server.
- Parameters
name – Name of the attribute descriptor. Should not conflict with any other attribute descriptor, index, type, or user already in the system.
ad_type – The type of the attribute descriptor.
isArray – Whether the new attribute descriptor is an array (i.e. can allow multiple values on one node or edge of this attribute descriptor)
isEncrypted – Whether the new attribute descriptor should be encrypted.
prec – The precision of the attribute descriptor. Should only be set when the ad_type parameter is set to Number.
scale – The scale of the attribute descriptor. Should only be set when the ad_type parameter is set to Number. Should not be greater than the prec paramter.
- Returns
-
abstract
createEdgetype
(name: str, attrDescs: List[Union[tgdb.model.TGAttributeDescriptor, str]], dirType: Optional[Union[str, tgdb.model.DirectionType]] = None, fromType: Optional[Union[str, tgdb.model.TGNodeType]] = None, toType: Optional[Union[str, tgdb.model.TGNodeType]] = None, pkeys: Optional[List[Union[tgdb.model.TGAttributeDescriptor, str]]] = None)¶ Creates an edgetype on the server.
- Parameters
name – The name of the edgetype. Should not conflict with any other type, attribute descriptor, index, or user already in the system.
attrDescs – The attributes for this edgetype.
dirType – The direction that this edgetype has. If it is a string, will be checked against approved strings before sending to the server. Default is None which implies that directionality is not important, and for the API to pick.
fromType – The nodetype of all nodes that edge comes from. Default implies that the type is not specified.
toType – The nodetype of all nodes that edge comes from. Default implies that the type is not specified.
pkeys – The primary key for this edge, must be a subset of the attrDescs parameter.
- Returns
Nothing. Will raise an error if not successful.
-
abstract
createIndex
(name: str, attrDescs: List[Union[tgdb.model.TGAttributeDescriptor, str]], isUnique: bool = False, types: Optional[List[Union[tgdb.model.TGEntityType, str]]] = None)¶ Creates an index on the server. :param name: Name of the index. Should not conflict with any other index, attribute descriptor, type, or user already in the system. :param attrDescs: The attributes for this edgetype. :param isUnique: Whether every element on the index must be unique. Will prevent additions to the database if those additions would make an index from being unique if the isUnique paramter is True. :param types: The types that this index is on. Default is any combination of the attribute descriptors specified on any type. :return: Nothing. Will raise an error if not successful.
-
abstract
createNodetype
(name: str, attrDescs: List[Union[tgdb.model.TGAttributeDescriptor, str]], pageSize: int = None, pkeys: Optional[List[Union[tgdb.model.TGAttributeDescriptor, str]]] = None)¶ Creates a nodetype on the server.
- Parameters
name – The name of the nodetype. Should not conflict with any other type, attribute descriptor, index, or user already in the system.
attrDescs – The attributes for this nodetype.
pageSize – Optional, the pagesize for this nodes of this type. Might want to make it smaller for higher efficiency or larger for when each nodetype will have many nodes and/or attributes are numerous and/or large. Default: None, which implies using the system default of 512 bytes.
pkeys – Optional, the primary keys of this nodetype. Must be a subset of the attribute descriptors specified by the attrDescs parameter. Default: None, which implies using the system default of the globally unique identifier.
- Returns
Nothing. Will raise an error if not successful.
-
abstract
createRole
(rolename: str, permissions: List[Tuple[Union[str, tgdb.model.TGNodeType, tgdb.model.TGEdgeType, tgdb.model.TGAttributeDescriptor], Union[tgdb.model.TGPermissionType, str]]], privileges: Union[Iterable[tgdb.model.TGPrivilege], tgdb.model.TGPrivilege] = ())¶ Creates a role with the permissions and privileges passed in.
-
abstract
createUser
(name: str, password: str, roles: List[str] = None)¶ Creates a user on the server.
- Parameters
name – The name of the new user. Should not conflict with any other user, attribute descriptor, type, or index already in the system.
password – The new user’s password.
roles – The role(s) of the new user. If no role is specified, user will have whatever the database’s default role when accessing the database. Otherwise, the permissions and privileges of the user are a union of the roles the user has, always including the database’s default role.
- Returns
Nothing. Will raise an error if not successful.
-
abstract
describe
(name: str) → tgdb.admin.TGAdminDescription¶ Gets description information for a particular type, attribute descriptor, or index.
- Returns
The type’s information, as well as any necessary supporting types (like the attribute descriptors that are mentioned in a nodetype’s attribute list).
-
abstract
dumpServerStacktrace
()¶ Programmatically dumps the server’s stacktrace to the server’s console and log files.
Could be useful if one thread on the server is not responding.
- Returns
Nothing.
-
abstract
fullImport
(dir_path: str = 'import') → List[tgdb.admin.TGImportDescriptor]¶ Imports all of the files found in the directory specified to the server.
- Parameters
dir_path – The directory to get all of the files from.
- Returns
A list of import descriptors that describe what the types are and how many were imported.
-
abstract
getAttributeDescriptors
() → List[tgdb.model.TGAttributeDescriptor]¶ Gets the attribute descriptors on this server.
- Returns
The list of attribute descriptors.
-
abstract
getConnections
() → List[tgdb.admin.TGConnectionInfo]¶ Gets all current live connections to the server.
- Returns
List of all connections that are alive between the server and any clients, including this one.
-
abstract
getIndices
() → List[tgdb.model.TGIndex]¶ Gets the list of indices from the server.
- Returns
The list of index information objects.
-
abstract
getInfo
() → tgdb.admin.TGServerInfo¶ Gets the server state information.
-
abstract
getRoles
() → List[tgdb.model.TGRole]¶ Gets all roles that the database server knows about.
- Returns
List of all known roles.
-
abstract
getStoredProcedures
() → List[tgdb.model.TGStoredProcedure]¶ Gets the stored procedures.
-
abstract
getTypes
() → List[tgdb.model.TGEntityType]¶ Gets a list of types from the server. Will only include entity types, but will include the default, built-in types too.
- Returns
The types returned by the server.
-
abstract
getUsers
() → List[tgdb.admin.TGUserInfo]¶ Gets all users that the database server knows about.
- Returns
List of all known users.
-
abstract
grantPermissions
(rolename: str, permissions: List[Tuple[Union[str, tgdb.model.TGNodeType, tgdb.model.TGEdgeType, tgdb.model.TGAttributeDescriptor], Union[tgdb.model.TGPermissionType, str]]])¶ Grants to a role the permissions passed in.
-
abstract
grantPrivileges
(rolename: str, privileges: Union[Iterable[tgdb.model.TGPrivilege], tgdb.model.TGPrivilege] = ())¶ Grants to a role the privileges passed in.
-
abstract
grantUser
(username: str, roles: List[str])¶ Grants to a user the roles specified in the list of roles.
-
abstract
killConnection
(sessionid: Optional[int] = None) → int¶ Kills a particular connection with the sessionid passed in.
- Parameters
sessionid – The connection’s sessionid of which to terminate. Default: None, which kills all connections.
- Returns
The number of connections killed.
-
abstract
refreshStoredProcedures
()¶ Refreshes the server’s stored procedures.
-
abstract
revokePermissions
(rolename: str, permissions: List[Tuple[Union[str, tgdb.model.TGNodeType, tgdb.model.TGEdgeType, tgdb.model.TGAttributeDescriptor], Union[tgdb.model.TGPermissionType, str]]])¶ Revokes from a role the permissions passed in.
-
abstract
revokePrivileges
(rolename: str, privileges: Union[Iterable[tgdb.model.TGPrivilege], tgdb.model.TGPrivilege] = ())¶ Revokes from a role the privileges passed in.
-
abstract
revokeUser
(username: str, roles: List[str])¶ Revokes from a user the roles specified in the list of roles.
-
abstract
setServerLogLevel
(logcomponent: Union[tgdb.log.TGLogComponent, List[tgdb.log.TGLogComponent]], level: tgdb.log.TGLevel)¶ Sets the server’s log level for a particular component.
- Parameters
logcomponent – The log component to set.
level – The logging level at which to set the component.
- Returns
Nothing.
-
abstract
showTypes
() → None¶ Shows a list of types from the server. Will only include entity types, but will include the default, built-in types too.
- Returns
Nothing.
-
abstract
stopServer
()¶ Stops the server now.
-
abstract
-
class
tgdb.admin.
TGAdminDescription
¶ Used for describing a system type, like a user, role, or to get more information about some of the other types.
-
abstract property
attributes
¶ Gets the attributes of the primary object described.
- Returns
The attribute descriptors of the object. None if this object cannot have indices. Empty list if it could, but there are no such indices.
- Return type
typing.Optional[typing.List[tgdb.model.TGAttributeDescriptor]]
-
abstract property
fromType
¶ Gets the from type of the primary object described.
- Returns
The from node’s type, or None if there is no such type.
- Return type
typing.Optional[tgdb.model.TGNodeType]
-
abstract property
indices
¶ Gets the indices of the primary object described.
- Returns
The indices on this type of object. None if this object cannot have indices. Empty list if it could, but there are no such indices.
- Return type
typing.Optional[typing.List[tgdb.model.TGIndex]]
-
abstract property
primary
¶ Gets the primary object described.
- Returns
The primarily-described system object.
- Return type
-
abstract property
roles
¶ Gets the roles associated with the primary object. Should only be set when the primary is a user.
- Returns
The roles for this object.
- Return type
typing.Optional[typing.List[tgdb.model.TGRole]]
-
abstract property
toType
¶ Gets the to type of the primary object described.
- Returns
The to node’s type, or None if there is no such type.
- Return type
typing.Optional[tgdb.model.TGNodeType]
-
abstract property
-
class
tgdb.admin.
TGCacheStat
¶ -
abstract property
cacheHits
¶ Gets the number of hits for this cache.
-
abstract property
cacheMaxEntries
¶ Gets the maximum number of entries for this cache.
-
abstract property
cacheMaxMemory
¶ Gets the maximum memory that this cache can use.
-
abstract property
cacheMisses
¶ Gets the number of misses for this cache.
-
abstract property
cacheNumEntries
¶ Gets the current number of entries in this cache.
-
abstract property
-
class
tgdb.admin.
TGCacheStatistics
¶ -
abstract property
dataCache
¶ Gets the cache statistics for the data cache.
-
abstract property
entityCache
¶ Gets the cache statistics for the entity cache.
-
abstract property
indexCache
¶ Gets the cache statistics for the index cache.
Gets the cache statistics for the shared cache.
-
abstract property
-
class
tgdb.admin.
TGConnectionInfo
¶ -
abstract property
clientID
¶ Gets the client’s identifier.
-
abstract property
createdTimeInSeconds
¶ Number of seconds that have elapsed since the connection was created.
-
abstract property
listenerName
¶ Gets the name of the listener.
-
abstract property
remoteAddress
¶ Gets the client-side address of the connection.
-
abstract property
sessionID
¶ Gets the session identifier.
-
abstract property
userName
¶ Gets the logged-in user’s name for the connection.
-
abstract property
-
class
tgdb.admin.
TGDatabaseStatistics
¶ -
abstract property
blockSize
¶ Size of index blocks by the database in storage (in bytes)
-
abstract property
dataBlockSize
¶ Size of data blocks by the database in storage (in bytes)
-
abstract property
dataFree
¶ Size of the data free by the database in storage (in bytes)
-
abstract property
dataSize
¶ Total ize of the data chunks of the database when in storage (in bytes)
-
abstract property
dataUsed
¶ Size of the data used by the database in storage (in bytes)
-
abstract property
dbPath
¶ Total size (includes both index and data size) of the database (in bytes)
-
abstract property
dbSize
¶ Total size (includes both index and data size) of the database (in bytes)
-
abstract property
freeIndexSize
¶ Size of the index free by the database in storage (in bytes)
-
abstract property
indexSize
¶ Total size of the index chunks of the database when in storage (in bytes)
-
abstract property
numDataSegments
¶ Total number of data segments
-
abstract property
numIndexSegments
¶ Total number of data segments
-
abstract property
usedIndexSize
¶ Size of the index used by the database in storage (in bytes)
-
abstract property
-
class
tgdb.admin.
TGEntityCache
¶ -
abstract property
averageEntitySize
¶ Gets the average size of the entities currently in the entity cache.
-
abstract property
maxEntitySize
¶ Gets the size of the largest entity possible in the entity cache.
-
abstract property
-
class
tgdb.admin.
TGImportDescriptor
¶ Keeps track of the types that were sent to the server.
-
abstract property
isnode
¶ Whether this type is a node.
-
abstract property
numinstances
¶ The number of instances of this type.
-
abstract property
typename
¶ The name of the type.
-
abstract property
-
class
tgdb.admin.
TGMemoryInfo
¶ -
abstract property
freeMemorySize
¶ Gets the free memory size (in bytes)
-
abstract property
maxMemorySize
¶ Gets the max memory size (in bytes)
Gets location of the shared memory file.
-
abstract property
usedMemorySize
¶ Gets the used memory size (in bytes)
-
abstract property
-
class
tgdb.admin.
TGNetListenerInfo
¶ -
abstract property
currentConnections
¶ Gets the number of currently connected clients.
-
abstract property
listenerName
¶ Gets name of the net listener.
-
abstract property
maxConnections
¶ Gets the maximum allowable number of connections.
-
abstract property
portNumber
¶ Gets the port number on the server side for this net listener
-
abstract property
-
class
tgdb.admin.
TGProcessorSetStatistics
¶ Processing statistics for queries and transactions.
-
abstract property
averageProcessingTime
¶ The average time for processing a transaction (in seconds).
-
abstract property
pendingCount
¶ The number of pending transactions (transactions not yet finalized, successful or not).
-
abstract property
processedCount
¶ The total number of processed transactions.
-
abstract property
processorsCount
¶ The total number of transaction processors (these are each capable of handling a transaction)
-
abstract property
successfulCount
¶ The total number of successfully processed transactions.
-
abstract property
-
class
tgdb.admin.
TGServerInfo
¶ Gets all relevent server information and statistics.
-
abstract property
cacheInfo
¶ Gets the server’s cache information.
-
abstract property
databaseInfo
¶ Gets the server’s database information.
-
abstract
memoryInfo
(type: tgdb.admin.MemoryType) → tgdb.admin.TGMemoryInfo¶ Gets the server’s memory info for the given type.
-
abstract property
netListenersInfo
¶ Gets the information for all of the server’s net listeners.
-
abstract property
queryInfo
¶ Gets the server’s query statistics.
-
abstract property
serverStatus
¶ Gets the server’s status.
-
abstract property
transactionsInfo
¶ Gets the server’s transactional statistics.
-
abstract property
-
class
tgdb.admin.
TGServerMemoryInfo
¶ -
abstract
getMemoryInfo
(type: tgdb.admin.MemoryType) → tgdb.admin.TGMemoryInfo¶ Gets the memory type specified by the type parameter
-
abstract
-
class
tgdb.admin.
TGServerStatus
¶ Information about the server.
-
abstract property
name
¶ The name of the server.
-
abstract property
processID
¶ The process identifier for the server.
-
abstract property
serverPath
¶ The server’s current working directory.
-
abstract property
state
¶ The server’s current state
-
abstract property
uptime
¶ The server’s uptime.
-
abstract property
version
¶ The corresponding version of the server.
-
abstract property
-
class
tgdb.admin.
TGTransactionStatistics
¶ Represents statistics for processing transactions.
-
abstract property
transactionLoggerQueueDepth
¶ The depth of the transaction logger (the number of transactions sent to the database that are not being processed right now.
-
abstract property
-
class
tgdb.admin.
TGUserInfo
¶ The user information.