client
GraphDB client module.
Classes:
-
AccessControlListManagement–Manage fine-grained access control lists for GraphDB repositories.
-
ClusterGroupManagement–Manage and monitor GraphDB cluster configurations.
-
GraphDBClient–GraphDB Client
-
MonitoringManagement–Monitor different GraphDB processes.
-
RecoveryManagement–GraphDB Recovery Management client.
-
Repository–GraphDB Repository client.
-
RepositoryManagement–GraphDB Repository Management client.
-
RepositoryManager–GraphDB Repository Manager.
-
SecurityManagement–GraphDB Security Management client.
-
UserManagement–GraphDB User Management client.
Attributes:
-
FileContent– -
FilesType–
FileContent
module-attribute
FileContent = Union[bytes, str, IO[bytes], Tuple[Optional[str], Union[bytes, str, IO[bytes]]], Tuple[Optional[str], Union[bytes, str, IO[bytes]], Optional[str]]]
FilesType
module-attribute
FilesType = Union[Mapping[str, FileContent], Iterable[Tuple[str, FileContent]]]
AccessControlListManagement
Manage fine-grained access control lists for GraphDB repositories.
Methods:
-
add–Add ACL rules to the repository.
-
delete–Delete ACL rules from the repository.
-
list–List ACL rules for the repository.
-
set–Set ACL rules for the repository.
Attributes:
-
http_client– -
identifier–Repository identifier.
Source code in rdflib/contrib/graphdb/client.py
add
add(acl_rules: Sequence[AccessControlEntry], position: int | None = None)
Add ACL rules to the repository.
You can also provide an optional URL request parameter position that specifies the position of the rules to be added. The position is zero-based (0 is the first position). If the position parameter is not provided, the rules are added at the end of the list.
Parameters:
-
(acl_rulesSequence[AccessControlEntry]) –The list of ACL rules to add.
-
(positionint | None, default:None) –The zero-based position to add the rules at.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ValueError–If the position is not an integer or is a negative integer.
-
ValueError–If the ACL rules are not provided as a sequence or are not AccessControlEntry instances.
Source code in rdflib/contrib/graphdb/client.py
delete
delete(acl_rules: Sequence[AccessControlEntry])
Delete ACL rules from the repository.
The provided FGAC rules are removed from the list regardless of their position.
Parameters:
-
(acl_rulesSequence[AccessControlEntry]) –The list of ACL rules to delete.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ValueError–If the ACL rules are not provided as a sequence or are not AccessControlEntry instances.
Source code in rdflib/contrib/graphdb/client.py
list
list(scope: Literal['statement', 'clear_graph', 'plugin', 'system'] | None = None, operation: Literal['read', 'write', '*'] | None = None, subject: str | URIRef | None = None, predicate: str | URIRef | None = None, obj: str | URIRef | Literal | None = None, graph: Literal['*', 'named', 'default'] | URIRef | Graph | None = None, plugin: str | None = None, role: str | None = None, policy: Literal['allow', 'deny', 'abstain'] | None = None) -> List[SystemAccessControlEntry | StatementAccessControlEntry | PluginAccessControlEntry | ClearGraphAccessControlEntry]
List ACL rules for the repository.
Parameters:
-
(scopeLiteral['statement', 'clear_graph', 'plugin', 'system'] | None, default:None) –The scope of the FGAC rule (
statement,clear_graph,plugin,system). -
(operationLiteral['read', 'write', '*'] | None, default:None) –The operation of the FGAC rule (
read,write,*). -
(subjectstr | URIRef | None, default:None) –The subject of the FGAC rule in Turtle format (for example,
<http://example.com/Mary>). -
(predicatestr | URIRef | None, default:None) –The predicate of the FGAC rule in Turtle format (for example,
<http://www.w3.org/2000/01/rdf-schema#label>). -
(objstr | URIRef | Literal | None, default:None) –The object of the FGAC rule in Turtle format (for example,
"Mary"@en). -
(graphLiteral['*', 'named', 'default'] | URIRef | Graph | None, default:None) –The graph of the FGAC rule in Turtle format (for example,
<http://example.org/graphs/graph1>). -
(pluginstr | None, default:None) –The plugin name for the FGAC rule with plugin scope (for example,
elasticsearch-connector). -
(rolestr | None, default:None) –The role associated with the FGAC rule.
-
(policyLiteral['allow', 'deny', 'abstain'] | None, default:None) –The policy for the FGAC rule (
allow,deny,abstain).
Returns:
-
List[SystemAccessControlEntry | StatementAccessControlEntry | PluginAccessControlEntry | ClearGraphAccessControlEntry]–A list of FGAC rules.
Raises:
-
ValueError–If the parameters are invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ResponseFormatError–If the response cannot be parsed.
Source code in rdflib/contrib/graphdb/client.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
set
set(acl_rules: Sequence[AccessControlEntry])
Set ACL rules for the repository.
Note
This method overwrites existing ACL rules in the repository.
If you want to add new rules without overwriting existing ones,
use the add method.
Parameters:
-
(acl_rulesSequence[AccessControlEntry]) –The list of ACL rules to set.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ValueError–If the ACL rules are not provided as a sequence or are not AccessControlEntry instances.
Source code in rdflib/contrib/graphdb/client.py
ClusterGroupManagement
Manage and monitor GraphDB cluster configurations.
Methods:
-
add_nodes–Add nodes to the GraphDB cluster.
-
add_tag–Add primary cluster tag.
-
create_config–Create a GraphDB cluster.
-
delete_config–Delete the GraphDB cluster.
-
delete_tag–Remove primary cluster tag.
-
disable_secondary_mode–Disable cluster secondary mode.
-
enable_secondary_mode–Enable cluster secondary mode.
-
get_config–Get the GraphDB cluster configuration.
-
group_status–Get the status of the GraphDB cluster.
-
node_status–Get the status of this GraphDB cluster node.
-
remove_nodes–Remove nodes from the GraphDB cluster.
-
replace_nodes–Replace nodes in the GraphDB cluster.
-
truncate_log–Truncate the GraphDB cluster log.
-
update_config–Update the GraphDB cluster configuration.
Attributes:
Source code in rdflib/contrib/graphdb/client.py
add_nodes
add_nodes(nodes: list[str]) -> None
Add nodes to the GraphDB cluster.
Parameters:
-
(nodeslist[str]) –List of node addresses to add to the cluster.
Raises:
-
TypeError–If nodes is not a list of strings.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If one or more nodes in the group are not reachable.
Source code in rdflib/contrib/graphdb/client.py
add_tag
add_tag(tag: str) -> None
Add primary cluster tag.
Parameters:
-
(tagstr) –The identifier tag to add to the primary cluster.
Raises:
-
TypeError–If tag is not a string.
-
ValueError–If tag is an empty string.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the cluster is not in a state to add a tag.
Source code in rdflib/contrib/graphdb/client.py
create_config
create_config(nodes: list[str], election_min_timeout: int | None = None, election_range_timeout: int | None = None, heartbeat_interval: int | None = None, message_size_kb: int | None = None, verification_timeout: int | None = None, transaction_log_maximum_size_gb: int | None = None, batch_update_interval: int | None = None) -> None
Create a GraphDB cluster.
Parameters:
-
(nodeslist[str]) –List of node addresses.
-
(election_min_timeoutint | None, default:None) –The minimum wait time in milliseconds for a heartbeat from a leader.
-
(election_range_timeoutint | None, default:None) –The variable portion of each waiting period in milliseconds for a heartbeat.
-
(heartbeat_intervalint | None, default:None) –The interval in milliseconds between each heartbeat that is sent to follower nodes by the leader.
-
(message_size_kbint | None, default:None) –The size of the data blocks, in kilobytes, transferred during data replication streaming through the RPC protocol.
-
(verification_timeoutint | None, default:None) –The amount of time in milliseconds that a follower node would wait before attempting to verify the last committed entry when the first verification is unsuccessful.
-
(transaction_log_maximum_size_gbint | None, default:None) –Maximum size of the transaction log in GBs. The transaction log will be automatically truncated if it becomes bigger than this value. The minimum transaction log size is 1 GB. Setting it to a negative value will disable automatic transaction log truncation.
-
(batch_update_intervalint | None, default:None) –The interval in milliseconds between requesting updates from the primary cluster. Used only when the cluster is in secondary mode.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
ConflictError–If the cluster configuration already exists.
-
PreconditionFailedError–If the cluster is not in a state to create a configuration.
Source code in rdflib/contrib/graphdb/client.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
delete_config
Delete the GraphDB cluster.
By default, the cluster group cannot be deleted if one or more nodes are unreachable.
Reachable here means that the nodes are not in status NO_CONNECTION, therefore there is an
RPC connection to them.
Parameter
force: When set to True, the cluster configuration will be deleted only on the reachable nodes and
the response will always succeed.
Returns:
-
dict[str, str]–A dictionary where the node address is the key and the deletion status message is the value.
Raises:
-
ResponseFormatError–If the response is not in the expected format.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If one or more nodes in the group are not reachable and force is not set to
True.
Source code in rdflib/contrib/graphdb/client.py
delete_tag
delete_tag(tag: str) -> None
Remove primary cluster tag.
Parameters:
-
(tagstr) –The identifier tag to remove from the primary cluster.
Raises:
-
TypeError–If tag is not a string.
-
ValueError–If tag is an empty string.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the cluster is not in a state to delete a tag.
Source code in rdflib/contrib/graphdb/client.py
disable_secondary_mode
Disable cluster secondary mode.
Once in secondary mode, you can disable secondary mode and then you will no longer be in that mode. Doing this will stop the pulling of updates from the primary cluster.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the cluster is not in a state to disable secondary mode.
Source code in rdflib/contrib/graphdb/client.py
enable_secondary_mode
enable_secondary_mode(primary_node: str, tag: str) -> None
Enable cluster secondary mode.
You can switch any healthy primary cluster to secondary mode by providing the RPC address of the primary cluster node that it will replicate and then declaring the tag used to identify it. Once you have switched a cluster to secondary mode, all of its current repositories and data will be removed and replaced with the data and state of the primary cluster.
Note
You can enable the secondary cluster mode from any of the nodes of a cluster, not just the leader node. You can also use any of the healthy nodes of the primary cluster to connect to that cluster.
Warning
Enabling the secondary mode will delete all data on the secondary cluster and replicate the state of the primary cluster.
Parameters:
-
(primary_nodestr) –The RPC address of one of the healthy nodes of the primary cluster.
-
(tagstr) –The identifier tag of the primary cluster.
Raises:
-
TypeError–If primary_node or tag is not a string.
-
ValueError–If primary_node or tag is an empty string.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the cluster is not in a state to enable secondary mode.
Source code in rdflib/contrib/graphdb/client.py
get_config
get_config() -> ClusterRequest
Get the GraphDB cluster configuration.
Returns:
-
ClusterRequest–Cluster configuration.
Raises:
-
ResponseFormatError–If the response is not in the expected format.
-
UnauthorisedError–If the request is unauthorised.
-
NotFoundError–If the cluster configuration is not found.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
group_status
group_status() -> list[NodeStatus]
Get the status of the GraphDB cluster.
Returns:
-
list[NodeStatus]–A list of node statuses for the cluster group.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
BadRequestError–If the request is invalid.
-
NotFoundError–If the group status is not found.
-
InternalServerError–If the internal server error.
Source code in rdflib/contrib/graphdb/client.py
node_status
node_status() -> NodeStatus
Get the status of this GraphDB cluster node.
Returns:
-
NodeStatus(NodeStatus) –The status of this GraphDB cluster node.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
BadRequestError–If the request is invalid.
-
NotFoundError–If the node status is not found.
-
InternalServerError–If the internal server error.
Source code in rdflib/contrib/graphdb/client.py
remove_nodes
remove_nodes(nodes: list[str]) -> None
Remove nodes from the GraphDB cluster.
Parameters:
-
(nodeslist[str]) –List of node addresses to remove from the cluster.
Raises:
-
TypeError–If nodes is not a list of strings.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If one or more nodes in the group are not reachable.
Source code in rdflib/contrib/graphdb/client.py
replace_nodes
replace_nodes(add_nodes: list[str], remove_nodes: list[str]) -> None
Replace nodes in the GraphDB cluster.
Parameters:
-
(add_nodeslist[str]) –List of node addresses to add to the cluster.
-
(remove_nodeslist[str]) –List of node addresses to remove from the cluster.
Raises:
-
TypeError–If add_nodes or remove_nodes is not a list of strings.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If one or more nodes in the group are not reachable.
Source code in rdflib/contrib/graphdb/client.py
truncate_log
Truncate the GraphDB cluster log.
The truncate log operation is used to free up storage space on all cluster nodes by clearing the current transaction log and removing cached recovery snapshots.
Raises:
-
ResponseFormatError–If the response is not in the expected format.
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
update_config
update_config(election_min_timeout: int | None = None, election_range_timeout: int | None = None, heartbeat_interval: int | None = None, message_size_kb: int | None = None, verification_timeout: int | None = None, transaction_log_maximum_size_gb: int | None = None, batch_update_interval: int | None = None) -> ClusterRequest
Update the GraphDB cluster configuration.
If one of the cluster nodes is down or was not able to accept the new configuration, the operation will not be successful. A total consensus between the nodes is required. In case one or more of them cannot append the new configuration, it will be rejected by all of the nodes.
Parameters:
-
(election_min_timeoutint | None, default:None) –The minimum wait time in milliseconds for a heartbeat from a leader.
-
(election_range_timeoutint | None, default:None) –The variable portion of each waiting period in milliseconds for a heartbeat.
-
(heartbeat_intervalint | None, default:None) –The interval in milliseconds between each heartbeat that is sent to follower nodes by the leader.
-
(message_size_kbint | None, default:None) –The size of the data blocks, in kilobytes, transferred during data replication streaming through the RPC protocol.
-
(verification_timeoutint | None, default:None) –The amount of time in milliseconds that a follower node would wait before attempting to verify the last committed entry when the first verification is unsuccessful.
-
(transaction_log_maximum_size_gbint | None, default:None) –Maximum size of the transaction log in GBs. The transaction log will be automatically truncated if it becomes bigger than this value. The minimum transaction log size is 1 GB. Setting it to a negative value will disable automatic transaction log truncation.
-
(batch_update_intervalint | None, default:None) –The interval in milliseconds between requesting updates from the primary cluster. Used only when the cluster is in secondary mode.
Returns:
-
ClusterRequest–The updated cluster configuration.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If one or more nodes in the group are not reachable.
Source code in rdflib/contrib/graphdb/client.py
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
GraphDBClient
GraphDBClient(base_url: str, auth: tuple[str, str] | str | None = None, timeout: float | Timeout = 30.0, **kwargs: Any)
Bases: RDF4JClient
GraphDB Client
This client and its inner management objects perform HTTP requests via httpx and may raise httpx-specific exceptions. Errors documented by GraphDB in its OpenAPI specification are mapped to specific exceptions in this library where applicable. Error mappings are documented on each management method. The underlying httpx client is reused across requests, and connection pooling is handled automatically by httpx.
Parameters:
-
(base_urlstr) –The base URL of the GraphDB server.
-
(authtuple[str, str] | str | None, default:None) –Authentication credentials. Can be a tuple (username, password) for basic auth, or a string for token-based auth (e.g., “GDB
“) which is added as the Authorization header. -
(timeoutfloat | Timeout, default:30.0) –Request timeout in seconds or an httpx.Timeout for fine-grained control (default: 30.0).
-
(kwargsAny, default:{}) –Additional keyword arguments to pass to the httpx.Client.
Methods:
-
login–Authenticate with GraphDB and obtain a GDB token.
Attributes:
-
cluster(ClusterGroupManagement) – -
graphdb_repositories(RepositoryManagement) – -
monitoring(MonitoringManagement) – -
recovery(RecoveryManagement) – -
repositories(RepositoryManager) –Server-level repository management operations (GraphDB-specific).
-
security(SecurityManagement) – -
users(UserManagement) –
Source code in rdflib/contrib/graphdb/client.py
repositories
property
repositories: RepositoryManager
Server-level repository management operations (GraphDB-specific).
login
login(username: str, password: str) -> AuthenticatedUser
Authenticate with GraphDB and obtain a GDB token.
Parameters:
-
(usernamestr) –The username to authenticate with.
-
(passwordstr) –The password to authenticate with.
Returns:
-
AuthenticatedUser–An AuthenticatedUser instance containing user details and the GDB token.
Raises:
-
UnauthorisedError–If the credentials are invalid.
-
BadRequestError–If the request body is invalid.
-
ResponseFormatError–If the response cannot be parsed.
Source code in rdflib/contrib/graphdb/client.py
MonitoringManagement
Monitor different GraphDB processes.
Methods:
-
backup–Track backup operations.
-
cluster–Get cluster statistics.
-
get_repo_stats–Get repository statistics.
Attributes:
-
http_client– -
infrastructure(InfrastructureStatistics) –Get all infrastructure statistics.
-
structures(StructuresStatistics) –Get structures statistics.
Source code in rdflib/contrib/graphdb/client.py
infrastructure
property
infrastructure: InfrastructureStatistics
Get all infrastructure statistics.
Returns:
-
InfrastructureStatistics(InfrastructureStatistics) –The infrastructure statistics.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
structures
property
structures: StructuresStatistics
Get structures statistics.
Returns:
-
StructuresStatistics–The structures statistics.
Raises:
-
ResponseFormatError–If the response format is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ServiceUnavailableError–If the server is unavailable.
backup
backup() -> BackupOperationBean | None
Track backup operations.
Returns:
-
BackupOperationBean | None–On-going backup operations or
Noneif no backup is in progress.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ServiceUnavailableError–If the server is unavailable.
Source code in rdflib/contrib/graphdb/client.py
cluster
Get cluster statistics.
Note
This endpoint is only available in GraphDB EE.
Returns:
-
str–Prometheus-style metrics.
Raises:
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
-
ServiceUnavailableError–If the server is unavailable.
Source code in rdflib/contrib/graphdb/client.py
get_repo_stats
get_repo_stats(repository_id: str)
Get repository statistics.
Parameters:
-
(repository_idstr) –The identifier of the repository.
Returns:
-
RepositoryStatistics–The repository statistics.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
RecoveryManagement
GraphDB Recovery Management client.
Methods:
-
backup–Create a new backup of GraphDB instance.
-
cloud_backup–Create a new backup of GraphDB instance uploaded to a cloud bucket.
-
cloud_restore–Restore GraphDB instance from a cloud backup archive.
-
restore–Restore GraphDB instance from a backup archive.
Attributes:
Source code in rdflib/contrib/graphdb/client.py
backup
backup(repositories: list[str] | None = None, backup_system_data: bool | None = None, *, dest: None = None) -> bytes
backup(repositories: list[str] | None = None, backup_system_data: bool | None = None, *, dest: str | PathLike[str]) -> Path
backup(repositories: list[str] | None = None, backup_system_data: bool | None = None, *, dest: str | PathLike[str] | None = None) -> bytes | Path
Create a new backup of GraphDB instance.
The backup is returned as a tar archive containing repository data and optionally system data (user accounts, saved queries, visual graphs, etc.).
Parameters:
-
(repositorieslist[str] | None, default:None) –List of repositories to be backed up, specified by their repository identifiers. If
None, all repositories will be included in the backup. -
(backup_system_databool | None, default:None) –Determines whether user account data such as user accounts, saved queries, or visual graphs, among others, should be included in the backup.
-
(deststr | PathLike[str] | None, default:None) –Destination path to save the backup archive. If
None, the backup content is returned as bytes (suitable for small backups). If a directory path is provided, the filename from the response Content-Disposition header is used (e.g., backup-2026-01-16-10-30-00.tar). If a file path is provided, that exact path is used. The response is streamed directly to disk (recommended for large backups).
Returns:
-
bytes(bytes | Path) –If
destisNone, returns the backup archive as bytes. -
Path(bytes | Path) –If
destis provided, returns the resolvedpathlib.Pathwhere the backup was saved.
Raises:
-
ValueError–If repositories is not a list or None, or if backup_system_data is not a bool or None.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
OSError–If the destination path cannot be written to.
Source code in rdflib/contrib/graphdb/client.py
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 | |
cloud_backup
cloud_backup(bucket_uri: str, repositories: list[str] | None = None, backup_system_data: bool | None = None, authentication_file: bytes | bytearray | memoryview | IO[bytes] | str | PathLike[str] | None = None) -> None
Create a new backup of GraphDB instance uploaded to a cloud bucket.
GraphDB uploads the resulting .tar archive directly to the configured
cloud bucket. This uses the GraphDB endpoint /rest/recovery/cloud-backup.
Parameters:
-
(bucket_uristr) –Cloud bucket URI including provider-specific parameters (required).
-
(repositorieslist[str] | None, default:None) –Optional list of repositories to be backed up.
-
(backup_system_databool | None, default:None) –Optional flag to include system data (users, saved queries, etc.).
-
(authentication_filebytes | bytearray | memoryview | IO[bytes] | str | PathLike[str] | None, default:None) –Optional credential file content as bytes/bytes-like, a binary file-like object, or a filesystem path.
Raises:
-
ValueError–If parameters are invalid, or authentication_file is not a supported type.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 | |
cloud_restore
cloud_restore(bucket_uri: str, repositories: list[str] | None = None, restore_system_data: bool | None = None, remove_stale_repositories: bool | None = None, authentication_file: bytes | bytearray | memoryview | IO[bytes] | str | PathLike[str] | None = None) -> None
Restore GraphDB instance from a cloud backup archive.
Parameters:
-
(bucket_uristr) –Cloud bucket URI including provider-specific parameters (required).
-
(repositorieslist[str] | None, default:None) –List of repositories to restore. If
None(default), the parameter is omitted and all repositories found in the backup are restored. If an empty list ([]) is provided, no repositories from the backup are restored. -
(restore_system_databool | None, default:None) –Whether to restore system data (users, saved queries, visual graphs, etc.). If omitted, GraphDB defaults to
false. Iftrueand no system data exists in the backup, GraphDB returns an error. -
(remove_stale_repositoriesbool | None, default:None) –Whether to remove repositories on the target instance that are not restored from the backup. If omitted, GraphDB defaults to
false. -
(authentication_filebytes | bytearray | memoryview | IO[bytes] | str | PathLike[str] | None, default:None) –Optional credential file content as bytes/bytes-like, a binary file-like object, or a filesystem path.
Raises:
-
ValueError–If parameters are invalid, or authentication_file is not a supported type.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | |
restore
restore(backup: bytes | bytearray | memoryview | IO[bytes] | str | PathLike[str], repositories: list[str] | None = None, restore_system_data: bool | None = None, remove_stale_repositories: bool | None = None) -> None
Restore GraphDB instance from a backup archive.
Parameters:
-
(backupbytes | bytearray | memoryview | IO[bytes] | str | PathLike[str]) –Backup archive content as bytes/bytes-like, a binary file-like object, or a filesystem path to a
.tarproduced bybackup. -
(repositorieslist[str] | None, default:None) –List of repositories to restore. If
None(default), the parameter is omitted and all repositories found in the backup are restored. If an empty list ([]) is provided, no repositories from the backup are restored. -
(restore_system_databool | None, default:None) –Whether to restore system data (users, saved queries, visual graphs, etc.). If omitted, GraphDB defaults to
false. Iftrueand no system data exists in the backup, GraphDB returns an error. -
(remove_stale_repositoriesbool | None, default:None) –Whether to remove repositories on the target instance that are not restored from the backup. If omitted, GraphDB defaults to
false.
Raises:
-
ValueError–If parameters are invalid, or if backup is not a supported type.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 | |
Repository
Repository(identifier: str, http_client: Client)
Bases: Repository
GraphDB Repository client.
Overrides specific methods of the RDF4J Repository class and also provides GraphDB-only functionality (such as FGAC ACL management) made available through the GraphDB REST API.
Parameters:
-
(identifierstr) –The identifier of the repository.
-
(http_clientClient) –The httpx.Client instance.
Methods:
-
cancel_server_import_file–Cancel server file import operation.
-
get_server_import_files–Get server files available for import.
-
health–Repository health check.
-
import_server_import_file–Import a server file into the repository.
Attributes:
Source code in rdflib/contrib/graphdb/client.py
cancel_server_import_file
cancel_server_import_file(name: str) -> None
Cancel server file import operation.
Parameters:
-
(namestr) –The name of the file import to interrupt.
Raises:
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
get_server_import_files
get_server_import_files() -> list[ImportSettings]
Get server files available for import.
Returns:
-
list[ImportSettings]–A list of files available for import.
Raises:
-
ResponseFormatError–If the response format is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
health
health(timeout: int = 5) -> bool
Repository health check.
Parameters:
-
(timeoutint, default:5) –A timeout parameter in seconds. If provided, the endpoint attempts to retrieve the repository within this timeout. If not, the passive check is performed.
Returns:
-
bool(bool) –True if the repository is healthy, otherwise an error is raised.
Raises:
-
RepositoryNotFoundError–If the repository is not found.
-
RepositoryNotHealthyError–If the repository is not healthy.
Source code in rdflib/contrib/graphdb/client.py
import_server_import_file
import_server_import_file(server_import_body: ServerImportBody) -> None
Import a server file into the repository.
Parameters:
-
(server_import_bodyServerImportBody) –The server import body.
Raises:
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
NotFoundError–If the request is not found.
Source code in rdflib/contrib/graphdb/client.py
RepositoryManagement
GraphDB Repository Management client.
The functionality provided by this management client accepts an optional location parameter to operate on external GraphDB locations.
Methods:
-
create–Create a new repository.
-
delete–Delete a repository.
-
edit–Edit a repository’s configuration.
-
get–Get a repository’s configuration.
-
list–List all repositories.
-
restart–Restart a repository.
-
size–Get repository size.
-
validate–Validate repository data using SHACL shapes.
Attributes:
Source code in rdflib/contrib/graphdb/client.py
create
create(config: RepositoryConfigBeanCreate | str, location: str | None = None, files: FilesType | None = None)
Create a new repository.
Parameters:
-
(configRepositoryConfigBeanCreate | str) –Repository configuration. When a
RepositoryConfigBeanCreateis provided, the request is sent as JSON. When a string is provided, it is treated as Turtle content and sent as multipart/form-data partconfig(required by GraphDB) with the content typetext/turtle. -
(locationstr | None, default:None) –Optional repository location (query param
location). -
(filesFilesType | None, default:None) –Optional extra multipart parts for GraphDB-specific files (e.g.
obdaFile,owlFile,propertiesFile,constraintFile,dbMetadataFile,lensesFile). Keys must be the form part names; values may be file content or httpx-style file tuples. Ignored whenconfigis a dataclass (JSON payload).
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 | |
delete
delete(repository_id: str, location: str | None = None) -> None
Delete a repository.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(locationstr | None, default:None) –The location of the repository.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
edit
edit(repository_id: str, config: RepositoryConfigBeanCreate) -> None
Edit a repository’s configuration.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(configRepositoryConfigBeanCreate) –The repository configuration.
Raises:
-
BadRequestError–If the request is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
get
get(repository_id: str, content_type: Literal['application/json'], location: str | None = None) -> RepositoryConfigBean
get(repository_id: str, content_type: None = None, location: str | None = None) -> RepositoryConfigBean
get(repository_id: str, content_type: Literal['text/turtle'], location: str | None = None) -> Graph
get(repository_id: str, content_type: str, location: str | None = None) -> RepositoryConfigBean | Graph
get(repository_id: str, content_type: str | None = None, location: str | None = None) -> RepositoryConfigBean | Graph
Get a repository’s configuration.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(content_typestr | None, default:None) –The content type of the response. Can be
application/jsonortext/turtle. Defaults toapplication/json. -
(locationstr | None, default:None) –The location of the repository.
Returns:
-
RepositoryConfigBean(RepositoryConfigBean | Graph) –The repository configuration.
-
Graph(RepositoryConfigBean | Graph) –The repository configuration in RDF.
Raises:
-
BadRequestError–If the content type is not supported.
-
ResponseFormatError–If the response cannot be parsed.
-
RepositoryNotFoundError–If the repository is not found.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
list
list(location: str | None = None) -> list[GraphDBRepository]
List all repositories.
Parameters:
-
(locationstr | None, default:None) –The location of the repositories.
Returns:
-
list[GraphDBRepository]–list[GraphDBRepository]: List of GraphDB repositories.
Raises:
-
InternalServerError–If the server returns an internal error.
-
ResponseFormatError–If the response cannot be parsed.
Source code in rdflib/contrib/graphdb/client.py
restart
restart(repository_id: str, sync: bool | None = None, location: str | None = None) -> str
Restart a repository.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(syncbool | None, default:None) –Whether to sync the repository.
-
(locationstr | None, default:None) –The location of the repository.
Returns:
-
str(str) –The response text.
Raises:
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
RepositoryNotFoundError–If the repository is not found.
Source code in rdflib/contrib/graphdb/client.py
size
size(repository_id: str, location: str | None = None) -> RepositorySizeInfo
Get repository size.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(locationstr | None, default:None) –The location of the repository.
Raises:
-
ResponseFormatError–If the response cannot be parsed.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
validate
validate(repository_id: str, *, content_type: str, content: str, location: str | None = None, shapes_repository_id: None = None) -> str
validate(repository_id: str, *, content: IO[bytes], content_type: str | None = None, location: str | None = None, shapes_repository_id: None = None) -> str
validate(repository_id: str, *, shapes_repository_id: str, location: str | None = None) -> str
validate(repository_id: str, *, content_type: str | None = None, content: str | IO[bytes] | None = None, location: str | None = None, shapes_repository_id: str | None = None) -> str
Validate repository data using SHACL shapes.
Parameters:
-
(repository_idstr) –The identifier of the repository.
-
(content_typestr | None, default:None) –Content type of the request body (required for text payloads).
-
(contentstr | IO[bytes] | None, default:None) –SHACL shapes payload; string for text-based validation or file-like (binary) object for multipart validation.
-
(locationstr | None, default:None) –Optional repository location.
-
(shapes_repository_idstr | None, default:None) –ID of repository containing SHACL shapes; when provided, no content is sent and shapes are fetched from that repository.
Returns:
-
str(str) –Validation report as RDF Turtle.
Raises:
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 | |
RepositoryManager
Bases: RepositoryManager
GraphDB Repository Manager.
This manager client overrides specific RDF4J RepositoryManager class methods to provide GraphDB-specific implementations.
Methods:
-
get–Get a repository by ID.
Source code in rdflib/contrib/rdf4j/client.py
get
get(repository_id: str) -> Repository
Get a repository by ID.
Note
This performs a health check before returning the repository object.
Parameters:
-
(repository_idstr) –The identifier of the repository.
Returns:
-
Repository(Repository) –The repository instance.
Raises:
-
RepositoryNotFoundError–If the repository is not found.
-
RepositoryNotHealthyError–If the repository is not healthy.
Source code in rdflib/contrib/graphdb/client.py
SecurityManagement
GraphDB Security Management client.
Methods:
-
get_free_access_details–Check if free access is enabled.
-
set_free_access_details–Enable or disable free access.
Attributes:
-
enabled(bool) –Check if security is enabled.
-
http_client–
Source code in rdflib/contrib/graphdb/client.py
enabled
property
writable
Check if security is enabled.
Returns:
-
bool(bool) –True if security is enabled, False otherwise.
Raises:
-
ResponseFormatError–If the response format is invalid.
-
InternalServerError–If the server returns an internal error.
get_free_access_details
Check if free access is enabled.
Returns:
-
FreeAccessSettings–The free access settings.
Raises:
-
ResponseFormatError–If the response format is invalid.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
set_free_access_details
set_free_access_details(free_access_settings: FreeAccessSettings)
Enable or disable free access.
Parameters:
-
(free_access_settingsFreeAccessSettings) –The free access settings.
Raises:
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the precondition is failed.
Source code in rdflib/contrib/graphdb/client.py
UserManagement
GraphDB User Management client.
Methods:
-
create–Create a user.
-
custom_roles–Retrieve custom roles associated with the user.
-
delete–Delete a user.
-
get–Get a user.
-
list–Get all users.
-
overwrite–Overwrite a user.
-
update–Update a user.
Attributes:
Source code in rdflib/contrib/graphdb/client.py
create
create(username: str, user: UserCreate) -> None
Create a user.
Parameters:
-
(usernamestr) –The username of the user.
-
(userUserCreate) –The user to create.
Raises:
-
TypeError–if username is not a string or user is not an instance of UserCreate.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
Source code in rdflib/contrib/graphdb/client.py
custom_roles
custom_roles(username: str) -> List[str]
Retrieve custom roles associated with the user.
Parameters:
-
(usernamestr) –The username of the user.
Returns:
-
List[str]–list[str]: The custom roles for the user.
Raises:
-
TypeError–if username is not a string.
-
ForbiddenError–If the request is forbidden.
-
NotFoundError–If the user is not found.
-
InternalServerError–If the request fails.
Source code in rdflib/contrib/graphdb/client.py
delete
delete(username: str) -> None
Delete a user.
Parameters:
-
(usernamestr) –The username of the user.
Raises:
-
TypeError–if username is not a string.
-
BadRequestError–If the request is bad.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
NotFoundError–If the user is not found.
Source code in rdflib/contrib/graphdb/client.py
get
Get a user.
Parameters:
-
(usernamestr) –The username of the user.
Returns:
-
User(User) –The user.
Raises:
-
ResponseFormatError–If the response format is invalid.
-
ForbiddenError–If the request is forbidden.
-
NotFoundError–If the user is not found.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
list
Get all users.
Returns:
Raises:
-
ResponseFormatError–If the response format is invalid.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the precondition is failed.
-
InternalServerError–If the server returns an internal error.
Source code in rdflib/contrib/graphdb/client.py
overwrite
Overwrite a user.
Parameters:
-
(usernamestr) –The username of the user.
-
(userUser) –The user to overwrite.
Raises:
-
TypeError–if username is not a string or user is not an instance of User.
-
UnauthorisedError–If the request is unauthorised.
-
ForbiddenError–If the request is forbidden.
-
NotFoundError–If the user is not found.
Source code in rdflib/contrib/graphdb/client.py
update
update(username: str, user: UserUpdate | dict[str, Any]) -> None
Update a user.
Note
Certain user fields are not updatable using PATCH. For example, at the
time of writing, grantedAuthorities are not updatable, but appSettings are.
Parameters:
-
(usernamestr) –The username of the user.
-
(userUserUpdate | dict[str, Any]) –The user data to update, either as a UserUpdate instance or a dict.
Raises:
-
TypeError–if username is not a string or user is not an instance of UserUpdate or dict.
-
ForbiddenError–If the request is forbidden.
-
PreconditionFailedError–If the precondition is failed.