dbrepo package¶
Subpackages¶
- dbrepo.api package
- Submodules
- dbrepo.api.dto module
AccessType
ApiError
Column
Column.alias
Column.column_type
Column.concept
Column.d
Column.data_length
Column.database_id
Column.description
Column.enums
Column.id
Column.index_length
Column.internal_name
Column.is_null_allowed
Column.is_public
Column.length
Column.max_data_length
Column.mean
Column.median
Column.model_config
Column.name
Column.num_rows
Column.sets
Column.size
Column.std_dev
Column.table_id
Column.unit
Column.val_max
Column.val_min
ColumnBrief
ColumnMinimal
ColumnStatistic
ColumnType
ColumnType.BIGINT
ColumnType.BINARY
ColumnType.BIT
ColumnType.BLOB
ColumnType.BOOL
ColumnType.CHAR
ColumnType.DATE
ColumnType.DATETIME
ColumnType.DECIMAL
ColumnType.DOUBLE
ColumnType.ENUM
ColumnType.FLOAT
ColumnType.INT
ColumnType.LONGBLOB
ColumnType.LONGTEXT
ColumnType.MEDIUMBLOB
ColumnType.MEDIUMINT
ColumnType.MEDIUMTEXT
ColumnType.SERIAL
ColumnType.SET
ColumnType.SMALLINT
ColumnType.TEXT
ColumnType.TIME
ColumnType.TIMESTAMP
ColumnType.TINYBLOB
ColumnType.TINYINT
ColumnType.TINYTEXT
ColumnType.VARBINARY
ColumnType.VARCHAR
ColumnType.YEAR
Concept
Constraints
Container
ContainerBrief
CreateAccess
CreateContainer
CreateData
CreateDatabase
CreateForeignKey
CreateIdentifier
CreateIdentifier.creators
CreateIdentifier.database_id
CreateIdentifier.descriptions
CreateIdentifier.doi
CreateIdentifier.execution
CreateIdentifier.funders
CreateIdentifier.language
CreateIdentifier.licenses
CreateIdentifier.model_config
CreateIdentifier.publication_day
CreateIdentifier.publication_month
CreateIdentifier.publication_year
CreateIdentifier.publisher
CreateIdentifier.query
CreateIdentifier.query_id
CreateIdentifier.query_normalized
CreateIdentifier.related_identifiers
CreateIdentifier.result_hash
CreateIdentifier.result_number
CreateIdentifier.table_id
CreateIdentifier.titles
CreateIdentifier.type
CreateIdentifier.view_id
CreateIdentifierCreator
CreateIdentifierCreator.affiliation
CreateIdentifierCreator.affiliation_identifier
CreateIdentifierCreator.affiliation_identifier_scheme
CreateIdentifierCreator.affiliation_identifier_scheme_uri
CreateIdentifierCreator.creator_name
CreateIdentifierCreator.firstname
CreateIdentifierCreator.lastname
CreateIdentifierCreator.model_config
CreateIdentifierCreator.name_identifier
CreateIdentifierCreator.name_identifier_scheme
CreateIdentifierCreator.name_identifier_scheme_uri
CreateIdentifierCreator.name_type
CreateIdentifierDescription
CreateIdentifierFunder
CreateIdentifierTitle
CreateRelatedIdentifier
CreateTable
CreateTableColumn
CreateTableConstraints
CreateUser
CreateView
DataType
DataType.d_default
DataType.d_max
DataType.d_min
DataType.d_required
DataType.data_hint
DataType.display_name
DataType.documentation
DataType.is_buildable
DataType.is_quoted
DataType.model_config
DataType.size_default
DataType.size_max
DataType.size_min
DataType.size_required
DataType.type_hint
DataType.value
Database
Database.accesses
Database.contact
Database.container
Database.created
Database.creator
Database.description
Database.exchange_name
Database.exchange_type
Database.id
Database.identifiers
Database.image
Database.internal_name
Database.is_public
Database.model_config
Database.name
Database.owner
Database.subsets
Database.tables
Database.views
DatabaseAccess
DatabaseBrief
DatatypeAnalysis
DeleteData
DescriptionType
ExecuteQuery
ForeignKey
ForeignKeyMinimal
ForeignKeyReference
Identifier
Identifier.created
Identifier.creator
Identifier.creators
Identifier.database_id
Identifier.descriptions
Identifier.doi
Identifier.execution
Identifier.funders
Identifier.id
Identifier.language
Identifier.last_modified
Identifier.licenses
Identifier.model_config
Identifier.publication_day
Identifier.publication_month
Identifier.publication_year
Identifier.publisher
Identifier.query
Identifier.query_id
Identifier.query_normalized
Identifier.related_identifiers
Identifier.result_hash
Identifier.result_number
Identifier.status
Identifier.table_id
Identifier.titles
Identifier.type
Identifier.view_id
IdentifierCreator
IdentifierCreator.affiliation
IdentifierCreator.affiliation_identifier
IdentifierCreator.affiliation_identifier_scheme
IdentifierCreator.affiliation_identifier_scheme_uri
IdentifierCreator.creator_name
IdentifierCreator.firstname
IdentifierCreator.id
IdentifierCreator.lastname
IdentifierCreator.model_config
IdentifierCreator.name_identifier
IdentifierCreator.name_identifier_scheme
IdentifierCreator.name_identifier_scheme_uri
IdentifierCreator.name_type
IdentifierDescription
IdentifierFunder
IdentifierStatusType
IdentifierTitle
IdentifierType
Image
ImageBrief
Import
JwtAuth
KeyAnalysis
Language
Language.AA
Language.AB
Language.AE
Language.AF
Language.AK
Language.AM
Language.AN
Language.AR
Language.AS
Language.AV
Language.AY
Language.AZ
Language.BA
Language.BE
Language.BG
Language.BH
Language.BI
Language.BM
Language.BN
Language.BO
Language.BR
Language.BS
Language.CA
Language.CE
Language.CH
Language.CO
Language.CR
Language.CS
Language.CU
Language.CV
Language.CY
Language.DA
Language.DE
Language.DV
Language.DZ
Language.EE
Language.EL
Language.EN
Language.EO
Language.ES
Language.ET
Language.EU
Language.FA
Language.FF
Language.FI
Language.FJ
Language.FO
Language.FR
Language.FY
Language.GA
Language.GD
Language.GL
Language.GN
Language.GU
Language.GV
Language.HA
Language.HE
Language.HI
Language.HO
Language.HR
Language.HT
Language.HU
Language.HY
Language.HZ
Language.IA
Language.ID
Language.IE
Language.IG
Language.II
Language.IK
Language.IO
Language.IS
Language.IT
Language.IU
Language.JA
Language.JV
Language.KA
Language.KG
Language.KI
Language.KJ
Language.KK
Language.KL
Language.KM
Language.KN
Language.KO
Language.KR
Language.KS
Language.KU
Language.KV
Language.KW
Language.KY
Language.LA
Language.LB
Language.LG
Language.LI
Language.LN
Language.LO
Language.LT
Language.LU
Language.LV
Language.MG
Language.MH
Language.MI
Language.MK
Language.ML
Language.MN
Language.MR
Language.MS
Language.MT
Language.MY
Language.NA
Language.NB
Language.ND
Language.NE
Language.NG
Language.NL
Language.NN
Language.NO
Language.NR
Language.NV
Language.NY
Language.OC
Language.OJ
Language.OM
Language.OR
Language.OS
Language.PA
Language.PI
Language.PL
Language.PS
Language.PT
Language.QU
Language.RM
Language.RN
Language.RO
Language.RU
Language.RW
Language.SA
Language.SC
Language.SD
Language.SE
Language.SG
Language.SI
Language.SK
Language.SL
Language.SM
Language.SN
Language.SO
Language.SQ
Language.SR
Language.SS
Language.ST
Language.SU
Language.SV
Language.SW
Language.TA
Language.TE
Language.TG
Language.TH
Language.TI
Language.TK
Language.TL
Language.TN
Language.TO
Language.TR
Language.TS
Language.TT
Language.TW
Language.TY
Language.UG
Language.UK
Language.UR
Language.UZ
Language.VE
Language.VI
Language.VO
Language.WA
Language.WO
Language.XH
Language.YI
Language.YO
Language.ZA
Language.ZH
Language.ZU
License
ModifyOwner
ModifyVisibility
PrimaryKey
Query
QueryType
ReferenceType
RelatedIdentifier
RelatedIdentifierRelation
RelatedIdentifierRelation.CITES
RelatedIdentifierRelation.COMPILES
RelatedIdentifierRelation.CONTINUES
RelatedIdentifierRelation.DESCRIBES
RelatedIdentifierRelation.DOCUMENTS
RelatedIdentifierRelation.HAS_METADATA
RelatedIdentifierRelation.HAS_PART
RelatedIdentifierRelation.HAS_VERSION
RelatedIdentifierRelation.IS_CITED_BY
RelatedIdentifierRelation.IS_COMPILED_BY
RelatedIdentifierRelation.IS_CONTINUED_BY
RelatedIdentifierRelation.IS_DERIVED_FROM
RelatedIdentifierRelation.IS_DESCRIBED_BY
RelatedIdentifierRelation.IS_DOCUMENTED_BY
RelatedIdentifierRelation.IS_IDENTICAL_TO
RelatedIdentifierRelation.IS_METADATA_FOR
RelatedIdentifierRelation.IS_NEW_VERSION_OF
RelatedIdentifierRelation.IS_OBSOLETED_BY
RelatedIdentifierRelation.IS_ORIGINAL_FORM_OF
RelatedIdentifierRelation.IS_PART_OF
RelatedIdentifierRelation.IS_PREVIOUS_VERSION_OF
RelatedIdentifierRelation.IS_PUBLISHED_IN
RelatedIdentifierRelation.IS_REFERENCED_BY
RelatedIdentifierRelation.IS_REQUIRED_BY
RelatedIdentifierRelation.IS_REVIEWED_BY
RelatedIdentifierRelation.IS_SOURCE_OF
RelatedIdentifierRelation.IS_SUPPLEMENTED_BY
RelatedIdentifierRelation.IS_SUPPLEMENT_TO
RelatedIdentifierRelation.IS_VARIANT_FORM_OF
RelatedIdentifierRelation.IS_VERSION_OF
RelatedIdentifierRelation.OBSOLETES
RelatedIdentifierRelation.REFERENCES
RelatedIdentifierRelation.REQUIRES
RelatedIdentifierRelation.REVIEWS
RelatedIdentifierType
RelatedIdentifierType.ARK
RelatedIdentifierType.ARXIV
RelatedIdentifierType.BIBCODE
RelatedIdentifierType.DOI
RelatedIdentifierType.EAN13
RelatedIdentifierType.EISSN
RelatedIdentifierType.HANDLE
RelatedIdentifierType.IGSN
RelatedIdentifierType.ISBN
RelatedIdentifierType.ISTC
RelatedIdentifierType.LISSN
RelatedIdentifierType.LSID
RelatedIdentifierType.PMID
RelatedIdentifierType.PURL
RelatedIdentifierType.UPC
RelatedIdentifierType.URL
RelatedIdentifierType.URN
RelatedIdentifierType.W3ID
Table
Table.avg_row_length
Table.columns
Table.constraints
Table.created
Table.created_by
Table.creator
Table.data_length
Table.database_id
Table.description
Table.id
Table.identifiers
Table.internal_name
Table.is_public
Table.is_versioned
Table.max_data_length
Table.model_config
Table.name
Table.num_rows
Table.owner
Table.queue_name
Table.queue_type
Table.routing_key
TableBrief
TableMinimal
TableStatistics
TitleType
Unique
Unit
UpdateAccess
UpdateColumn
UpdateData
UpdateQuery
UpdateUser
UpdateUserPassword
UpdateUserTheme
User
UserAttributes
UserBrief
View
ViewBrief
ViewColumn
ViewColumn.alias
ViewColumn.column_type
ViewColumn.concept
ViewColumn.d
ViewColumn.database_id
ViewColumn.id
ViewColumn.index_length
ViewColumn.internal_name
ViewColumn.is_null_allowed
ViewColumn.is_public
ViewColumn.length
ViewColumn.mean
ViewColumn.median
ViewColumn.model_config
ViewColumn.name
ViewColumn.size
ViewColumn.unit
- dbrepo.api.exceptions module
- Module contents
Submodules¶
dbrepo.RestClient module¶
- class dbrepo.RestClient.RestClient(endpoint: str = 'http://gateway-service', username: str = None, password: str = None, secure: bool = True)¶
Bases:
object
The RestClient class for communicating with the DBRepo REST API. All parameters can be set also via environment variables, e.g. set endpoint with REST_API_ENDPOINT, username with REST_API_USERNAME, etc. You can override the constructor parameters with the environment variables.
- Parameters:
endpoint – The REST API endpoint. Optional. Default: “http://gateway-service”
username – The REST API username. Optional.
password – The REST API password. Optional.
secure – When set to false, the requests library will not verify the authenticity of your TLS/SSL certificates (i.e. when using self-signed certificates). Default: true.
- analyse_datatypes(file_path: str, separator: str, enum: bool = None, enum_tol: int = None, upload: bool = True) DatatypeAnalysis ¶
Import a csv dataset from a file and analyse it for the possible enums, line encoding and column data types.
- Parameters:
file_path – The path of the file that is imported on the storage service.
separator – The csv column separator.
enum – If set to true, enumerations should be guessed, otherwise no guessing. Optional.
enum_tol – The tolerance for guessing enumerations (ignored if enum=False). Optional.
upload – If set to true, the file from file_path will be uploaded, otherwise no upload will be performed and the file_path will be treated as S3 filename and analysed instead. Optional. Default: true.
- Returns:
The determined data types, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ResponseCodeError – If something went wrong with the analysis.
- analyse_keys(file_path: str, separator: str, upload: bool = True) KeyAnalysis ¶
Import a csv dataset from a file and analyse it for the possible primary key.
- Parameters:
file_path – The path of the file that is imported on the storage service.
separator – The csv column separator.
upload – If set to true, the file from file_path will be uploaded, otherwise no upload will be performed and the file_path will be treated as S3 filename and analysed instead. Optional. Default: true.
- Returns:
The determined ranking of the primary key candidates, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ResponseCodeError – If something went wrong with the analysis.
- analyse_table_statistics(database_id: int, table_id: int) TableStatistics ¶
Analyses the numerical contents of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Returns:
The table statistics, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ServiceConnectionError – If something went wrong with connection to the metadata service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the analysis.
- check_database_access(database_id: int) bool ¶
Checks access of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
- Returns:
The access type, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- create_container(name: str, host: str, image_id: int, sidecar_host: str, sidecar_port: int, privileged_username: str, privileged_password: str, port: int = None, ui_host: str = None, ui_port: int = None) Container ¶
Register a container instance executing a given container image. Note that this does not create a container, but only saves it in the metadata database to be used within DBRepo. The container still needs to be created through e.g. docker run image:tag -d.
- Parameters:
name – The container name.
host – The container hostname.
image_id – The container image id.
sidecar_host – The container sidecar hostname.
sidecar_port – The container sidecar port.
privileged_username – The container privileged user username.
privileged_password – The container privileged user password.
port – The container port bound to the host. Optional.
ui_host – The container hostname displayed in the user interface. Optional. Default: value of host
ui_port – The container port displayed in the user interface. Optional. Default: default_port of image.
- Returns:
The container, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
NameExistsError – If a container with this name already exists.
ResponseCodeError – If something went wrong with the retrieval.
- create_database(name: str, container_id: int, is_public: bool) Database ¶
Create a databases in a container with given container id.
- Parameters:
name – The name of the database.
container_id – The container id.
is_public – The visibility of the database. If set to true everything will be visible, otherwise only the metadata (schema, identifiers) will be visible to the public.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
QueryStoreError – If something went wrong with the query store.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval.
- create_database_access(database_id: int, user_id: str, type: AccessType) AccessType ¶
Create access to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
type – The access type.
- Returns:
The access type, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- create_identifier(database_id: int, type: IdentifierType, titles: List[CreateIdentifierTitle], publisher: str, creators: List[CreateIdentifierCreator], publication_year: int, descriptions: List[CreateIdentifierDescription] = None, funders: List[CreateIdentifierFunder] = None, licenses: List[License] = None, language: Language = None, subset_id: int = None, view_id: int = None, table_id: int = None, publication_day: int = None, publication_month: int = None, related_identifiers: List[CreateRelatedIdentifier] = None) Identifier ¶
Create an identifier draft.
- Parameters:
database_id – The database id of the created identifier.
type – The type of the created identifier.
titles – The titles of the created identifier.
publisher – The publisher of the created identifier.
creators – The creator(s) of the created identifier.
publication_year – The publication year of the created identifier.
descriptions – The description(s) of the created identifier. Optional.
funders – The funders(s) of the created identifier. Optional.
licenses – The license(s) of the created identifier. Optional.
language – The language of the created identifier. Optional.
subset_id – The subset id of the created identifier. Required when type=SUBSET, otherwise invalid. Optional.
view_id – The view id of the created identifier. Required when type=VIEW, otherwise invalid. Optional.
table_id – The table id of the created identifier. Required when type=TABLE, otherwise invalid. Optional.
publication_day – The publication day of the created identifier. Optional.
publication_month – The publication month of the created identifier. Optional.
related_identifiers – The related identifier(s) of the created identifier. Optional.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- create_subset(database_id: int, query: str, page: int = 0, size: int = 10, timestamp: datetime = None) DataFrame ¶
Executes a SQL query in a database where the current user has at least read access with given database id. The result set can be paginated with setting page and size (both). Historic data can be queried by setting timestamp.
- Parameters:
database_id – The database id.
query – The query statement.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
timestamp – The timestamp at which the data validity is set. Optional. Default: <current timestamp>.
- Returns:
The result set, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table or user does not exist.
QueryStoreError – The query store rejected the query.
FormatNotAvailable – The subset query contains non-supported keywords.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- create_table(database_id: int, name: str, columns: List[CreateTableColumn], constraints: CreateTableConstraints, description: str = None) Table ¶
Updates the database owner of a database with given database id.
- Parameters:
database_id – The database id.
name – The name of the created table.
constraints – The constraints of the created table.
columns – The columns of the created table.
description – The description of the created table. Optional.
- Returns:
The table, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
NameExistsError – If a table with this name already exists.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the creation.
- create_table_data(database_id: int, table_id: int, data: dict) None ¶
Insert data into a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
data – The data dictionary to be inserted into the table with the form column=value of the table.
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the insert.
- create_user(username: str, password: str, email: str) UserBrief ¶
Creates a new user.
- Parameters:
username – The username of the new user. Must be unique.
password – The password of the new user.
email – The email of the new user. Must be unique.
- Returns:
The user, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If the internal authentication to the auth service is invalid.
UsernameExistsError – The username exists already.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the created user was not found in the auth service.
EmailExistsError – The email exists already.
ServiceConnectionError – If something went wrong with connection to the auth service.
ServiceError – If something went wrong with obtaining the information in the auth service.
- create_view(database_id: int, name: str, query: str, is_public: bool) View ¶
Create a view in a database with given database id.
- Parameters:
database_id – The database id.
name – The name of the created view.
query – The query of the created view.
is_public – The visibility of the view. If set to true everything will be visible, otherwise only the metadata (schema, identifiers) will be visible to the public.
- Returns:
The created view, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ExternalSystemError – If the mapped view creation query is erroneous.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval.
- delete_container(container_id: int) None ¶
Deletes a container with given id. Note that this does not delete the container, but deletes the entry in the metadata database. The container still needs to be removed, e.g. docker container stop hash and then docker container rm hash.
- Parameters:
container_id – The container id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the deletion.
- delete_database_access(database_id: int, user_id: str) None ¶
Deletes the access for a user to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- delete_table(database_id: int, table_id: int) None ¶
Delete a table with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the deletion.
- delete_table_data(database_id: int, table_id: int, keys: dict) None ¶
Delete data in a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
keys – The key dictionary matching the rows in the form column=value.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the deletion.
- delete_view(database_id: int, view_id: int) None ¶
Deletes a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ExternalSystemError – If the mapped view deletion query is erroneous.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the deletion.
- endpoint: str = None¶
- get_concepts() List[Concept] ¶
Get list of concepts known to the metadata database.
- Returns:
List of concepts, if successful.
- get_container(container_id: int) Container ¶
Get a container with given id.
- Returns:
List of containers, if successful.
- Raises:
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_containers() List[ContainerBrief] ¶
Get all containers.
- Returns:
List of containers, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_database(database_id: int) Database ¶
Get a databases with given id.
- Parameters:
database_id – The database id.
- Returns:
The database, if successful.
- Raises:
NotExistsError – If the container does not exist.
ServiceConnectionError – If something went wrong with connection to the broker service.
ServiceError – If something went wrong with obtaining the information in the broker service.
ResponseCodeError – If something went wrong with the retrieval.
- get_database_access(database_id: int) AccessType ¶
Get access of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
- Returns:
The access type, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_databases() List[DatabaseBrief] ¶
Get all databases.
- Returns:
List of databases, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_databases_count() int ¶
Count all databases.
- Returns:
Count of databases if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_identifiers(database_id: int = None, subset_id: int = None, view_id: int = None, table_id: int = None) List[Identifier] | str ¶
Get list of identifiers, filter by the remaining optional arguments.
- Parameters:
database_id – The database id. Optional.
subset_id – The subset id. Optional. Requires database_id to be set.
view_id – The view id. Optional. Requires database_id to be set.
table_id – The table id. Optional. Requires database_id to be set.
- Returns:
List of identifiers, if successful.
- Raises:
NotExistsError – If the accept header is neither application/json nor application/ld+json.
FormatNotAvailable – If the service could not represent the output.
ResponseCodeError – If something went wrong with the retrieval of the identifiers.
- get_jwt_auth(username: str = None, password: str = None) JwtAuth ¶
Obtains a JWT auth object from the auth service containing e.g. the access token and refresh token.
- Parameters:
username – The username used to authenticate with the auth service. Optional. Default: username from the RestClient constructor.
password – The password used to authenticate with the auth service. Optional. Default: password from the RestClient constructor.
- Returns:
JWT auth object from the auth service, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
AuthenticationError – If something went wrong with the authentication.
ServiceConnectionError – If something went wrong with connection to the auth service.
ServiceError – If something went wrong with obtaining the information in the auth service.
ResponseCodeError – If something went wrong with the authentication.
- get_licenses() List[License] ¶
Get list of licenses allowed.
- Returns:
List of licenses, if successful.
- get_queries(database_id: int) List[Query] ¶
Get queries from a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
List of queries, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset(database_id: int, subset_id: int) Query ¶
Get query from a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
- Returns:
The query, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
FormatNotAvailable – If the service could not represent the output.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset_data(database_id: int, subset_id: int, page: int = 0, size: int = 10) DataFrame ¶
Re-executes a query in a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
size – The result pagination size. Optional. Default: 10.
- Returns:
The subset data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset_data_count(database_id: int, subset_id: int, page: int = 0, size: int = 10) int ¶
Re-executes a query in a database with given database id and query id and only counts the results.
- Parameters:
database_id – The database id.
subset_id – The subset id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
- Returns:
The result set, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table(database_id: int, table_id: int) Table ¶
Get a table with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Returns:
List of tables, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceConnectionError – If something went wrong with connection to the metadata service.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_data(database_id: int, table_id: int, page: int = 0, size: int = 10, timestamp: datetime = None) DataFrame ¶
Get data of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
timestamp – The query execution time. Optional.
- Returns:
The table data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_data_count(database_id: int, table_id: int, page: int = 0, size: int = 10, timestamp: datetime = None) int ¶
Get data count of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
timestamp – The query execution time. Optional.
- Returns:
The result of the view query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_history(database_id: int, table_id: int, size: int = 100) Database ¶
Get the table history of insert/delete operations.
- Parameters:
database_id – The database id.
table_id – The table id.
size – The number of operations. Optional. Default: 100.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_metadata(database_id: int) Database ¶
Generate metadata of all system-versioned tables in a database with given id.
- Parameters:
database_id – The database id.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_tables(database_id: int) List[TableBrief] ¶
Get all tables.
- Parameters:
database_id – The database id.
- Returns:
List of tables, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_units() List[Unit] ¶
Get all units known to the metadata database.
- Returns:
List of units, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_user(user_id: str) User ¶
Get a user with given user id.
- Returns:
The user, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the user does not exist.
- get_users() List[UserBrief] ¶
Get all users.
- Returns:
List of users, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_view(database_id: int, view_id: int) View ¶
Get a view of a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Returns:
The view, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_view_data(database_id: int, view_id: int, page: int = 0, size: int = 10) DataFrame ¶
Get data of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
- Returns:
The view data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the view does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_view_data_count(database_id: int, view_id: int) int ¶
Get data count of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Returns:
The result count of the view query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the view does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_views(database_id: int) List[View] ¶
Gets views of a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
The list of views, if successful.
- Raises:
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_views_metadata(database_id: int) Database ¶
Generate metadata of all views in a database with given id.
- Parameters:
database_id – The database id.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- import_table_data(database_id: int, table_id: int, file_name_or_data_frame: str | DataFrame, separator: str = ',', quote: str = '"', header: bool = False, line_encoding: str = '\n') None ¶
Import a csv dataset from a file into a table in a database with given database id and table id. ATTENTION: the import is column-ordering sensitive! The csv dataset must have the same columns in the same order as the target table.
- Parameters:
database_id – The database id.
table_id – The table id.
file_name_or_data_frame – The path of the file that is imported on the storage service or pandas dataframe.
separator – The csv column separator. Optional.
quote – The column data quotation character. Optional.
header – If True, the first line contains column names, otherwise the first line is data. Optional. Default: False.
line_encoding – The encoding of the line termination. Optional. Default: CR (Windows).
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the insert.
- password: str = None¶
- publish_identifier(identifier_id: int) Identifier ¶
Publish an identifier with given id.
- Parameters:
identifier_id – The identifier id.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- refresh_jwt_auth(refresh_token: str) JwtAuth ¶
Refreshes a JWT auth object from the auth service containing e.g. the access token and refresh token.
- Parameters:
refresh_token – The refresh token.
- Returns:
JWT auth object from the auth service, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
ServiceConnectionError – If something went wrong with the connection to the auth service.
ResponseCodeError – If something went wrong with the authentication.
- save_identifier(identifier_id: int, database_id: int, type: IdentifierType, titles: List[CreateIdentifierTitle], publisher: str, creators: List[CreateIdentifierCreator], publication_year: int, descriptions: List[CreateIdentifierDescription] = None, funders: List[CreateIdentifierFunder] = None, licenses: List[License] = None, language: Language = None, subset_id: int = None, view_id: int = None, table_id: int = None, publication_day: int = None, publication_month: int = None, related_identifiers: List[CreateRelatedIdentifier] = None) Identifier ¶
Save an existing identifier and update the metadata attached to it.
- Parameters:
identifier_id – The identifier id.
database_id – The database id of the created identifier.
type – The type of the created identifier.
titles – The titles of the created identifier.
publisher – The publisher of the created identifier.
creators – The creator(s) of the created identifier.
publication_year – The publication year of the created identifier.
descriptions – The description(s) of the created identifier. Optional.
funders – The funders(s) of the created identifier. Optional.
licenses – The license(s) of the created identifier. Optional.
language – The language of the created identifier. Optional.
subset_id – The subset id of the created identifier. Required when type=SUBSET, otherwise invalid. Optional.
view_id – The view id of the created identifier. Required when type=VIEW, otherwise invalid. Optional.
table_id – The table id of the created identifier. Required when type=TABLE, otherwise invalid. Optional.
publication_day – The publication day of the created identifier. Optional.
publication_month – The publication month of the created identifier. Optional.
related_identifiers – The related identifier(s) of the created identifier. Optional.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- secure: bool = None¶
- update_database_access(database_id: int, user_id: str, type: AccessType) AccessType ¶
Updates the access for a user to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
type – The access type.
- Returns:
The access type, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- update_database_owner(database_id: int, user_id: str) Database ¶
Updates the database owner of a database with given database id.
- Parameters:
database_id – The database id.
user_id – The user id of the new owner.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the update.
- update_database_schema(database_id: int) Database ¶
Updates the database table and view metadata of a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
The updated database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the update.
- update_database_visibility(database_id: int, is_public: bool) Database ¶
Updates the database visibility of a database with given database id.
- Parameters:
database_id – The database id.
is_public – The visibility of the database. If set to true everything will be visible, otherwise only the metadata (schema, identifiers) will be visible to the public.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the update.
- update_subset(database_id: int, subset_id: int, persist: bool) Query ¶
Save query or mark it for deletion (at a later time) in a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
persist – If set to true, the query will be saved and visible in the user interface, otherwise the query is marked for deletion in the future and not visible in the user interface.
- Returns:
The query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
QueryStoreError – The query store rejected the update.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- update_table_column(database_id: int, table_id: int, column_id: int, concept_uri: str = None, unit_uri: str = None) Column ¶
Update semantic information of a table column by given database id and table id and column id.
- Parameters:
database_id – The database id.
table_id – The table id.
column_id – The column id.
concept_uri – The concept URI. Optional.
unit_uri – The unit URI. Optional.
- Returns:
The column, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the accept header is neither application/json nor application/ld+json.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval of the identifiers.
- update_table_data(database_id: int, table_id: int, data: dict, keys: dict) None ¶
Update data in a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
data – The data dictionary to be updated into the table with the form column=value of the table.
keys – The key dictionary matching the rows in the form column=value.
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB data could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the update.
- update_user(user_id: str, theme: str, language: str, firstname: str = None, lastname: str = None, affiliation: str = None, orcid: str = None) User ¶
Updates a user with given user id.
- Parameters:
user_id – The user id of the user that should be updated.
theme – The user theme. One of “light”, “dark”, “light-contrast”, “dark-contrast”.
language – The user language localization. One of “en”, “de”.
firstname – The updated given name. Optional.
lastname – The updated family name. Optional.
affiliation – The updated affiliation identifier. Optional.
orcid – The updated ORCID identifier. Optional.
- Returns:
The user, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the user does not exist.
ResponseCodeError – If something went wrong with the update.
- update_user_password(user_id: str, password: str) User ¶
Updates the password of a user with given user id.
- Parameters:
user_id – The user id of the user that should be updated.
password – The updated user password.
- Returns:
The user, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the user does not exist.
ServiceConnectionError – If something went wrong with connection to the auth service.
ServiceError – If something went wrong with obtaining the information in the auth service.
ResponseCodeError – If something went wrong with the update.
- upload(file_path: str) str ¶
Uploads a file located at file_path to the Upload Service.
- Parameters:
file_path – The location of the file on the local filesystem.
- Returns:
Filename on the S3 backend of the Upload Service, if successful.
- username: str = None¶
- whoami() str | None ¶
Print the username.
- Returns:
The username, if set.