mlclient.clients package
The ML Clients package.
This package contains Python API to connect with MarkLogic server using various clients. It contains the following modules
- ml_client
The ML Client module.
- documents_client
The ML Documents Client module.
- eval_client
The ML Eval Client module.
- logs_client
The ML Logs Client module.
- This package exports the following classes:
- MLClient
A low-level class used to send simple HTTP requests to a MarkLogic instance.
- MLResourceClient
A MLClient subclass calling ResourceCall implementation classes.
- MLResourcesClient
A MLResourceClient subclass supporting REST Resources of the MarkLogic server.
- EvalClient
An MLResourceClient calling /v1/eval endpoint.
- LogsClient
An MLResourceClient calling /manage/v2/logs endpoint.
- LogType
An enumeration class representing MarkLogic log types.
Examples
>>> from mlclient.clients import MLResourceClient
- class mlclient.clients.DocumentsClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
MLResourceClientAn MLResourceClient calling /v1/documents endpoint.
It is a high-level class performing CRUD operations in a MarkLogic server.
- create(data: Document | Metadata | list[mlclient.structures.documents.Document | mlclient.structures.documents.Metadata], database: str | None = None, temporal_collection: str | None = None) dict[source]
Create or update document(s) content or metadata in a MarkLogic database.
- Parameters:
data (Document | Metadata | list[Document | Metadata]) – One or more document or default metadata.
database (str | None, default None) – Perform this operation on the named content database instead of the default content database associated with the REST API instance.
temporal_collection (str | None, default None) – Specify the name of a temporal collection into which the documents are to be inserted.
- Returns:
An origin response from a MarkLogic server.
- Return type:
dict
- Raises:
MarkLogicError – If MarkLogic returns an error
- delete(uris: str | list[str] | tuple[str] | set[str], category: str | list | None = None, database: str | None = None, temporal_collection: str | None = None, wipe_temporal: bool | None = None)[source]
Delete document(s) content or metadata in a MarkLogic database.
- Parameters:
uris (str | list[str] | tuple[str] | set[str]) – The URI of a document to delete or for which to remove metadata. You can specify multiple documents.
category (str | list | None, default None) – The category of data to remove/reset. Category may be specified multiple times to remove or reset any combination of content and metadata. Valid categories: content (default), metadata, metadata-values, collections, permissions, properties, and quality. Use metadata to reset all metadata.
database (str | None, default None) – Perform this operation on the named content database instead of the default content database associated with the REST API instance.
temporal_collection (str | None, default None) – Specify the name of a temporal collection that contains the document(s) to be deleted. Applies to all documents when deleting more than one.
wipe_temporal (bool | None, default None) – Remove all versions of a temporal document rather than performing a temporal delete. You can only use this parameter when you also specify a temporal-collection parameter.
- Raises:
MarkLogicError – If MarkLogic returns an error
- read(uris: str | list[str] | tuple[str] | set[str], category: str | list | None = None, database: str | None = None, output_type: type | None = None) Document | list[mlclient.structures.documents.Document][source]
Return document(s) content or metadata from a MarkLogic database.
When uris is a string it returns a single Document instance. Otherwise, result is a list.
- Parameters:
uris (str | list[str] | tuple[str] | set[str]) – One or more URIs for documents in the database.
category (str | list | None, default None) – The category of data to fetch about the requested document. Category can be specified multiple times to retrieve any combination of content and metadata. Valid categories: content (default), metadata, metadata-values, collections, permissions, properties, and quality. Use metadata to request all categories except content.
database (str | None, default None) – Perform this operation on the named content database instead of the default content database associated with the REST API instance.
output_type (type | None, default None) – A raw output type (supported: str, bytes)
- Returns:
One or more documents from the database.
- Return type:
Document | list[Document]
- Raises:
MarkLogicError – If MarkLogic returns an error
- class mlclient.clients.EvalClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
MLResourceClientAn MLResourceClient calling /v1/eval endpoint.
It is a high-level class parsing MarkLogic response and extracting values from the server.
- eval(file: str | None = None, xq: str | None = None, js: str | None = None, variables: dict | None = None, database: str | None = None, txid: str | None = None, output_type: type | None = None, **kwargs) bytes | str | int | float | bool | dict | ElementTree | Element | list[source]
Evaluate code in a MarkLogic server and get results.
- Parameters:
file (str | None, default None) – A file path of a code to evaluate
xq (str | None, default None) – A raw XQuery code to evaluate
js (str | None, default None) – A raw JavaScript code to evaluate
variables (dict | None, default None) – External variables to pass to the query during evaluation
database (str | None, default None) – Perform this operation on the named content database instead of the default content database associated with the REST API instance. The database can be identified by name or by database id.
txid (str | None, default None) – The transaction identifier of the multi-statement transaction in which to service this request.
output_type (type | None, default None) – A raw output type (supported: str, bytes)
kwargs (dict) – Key value arguments used as variables
- Returns:
bytes | str | int | float | bool | dict |
ElemTree.ElementTree | ElemTree.Element |
list – A code evaluation result
- Raises:
MarkLogicError – If MarkLogic returns an error
- class mlclient.clients.LogType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumAn enumeration class representing MarkLogic log types.
- ACCESS = 'AccessLog'
- AUDIT = 'AuditLog'
- ERROR = 'ErrorLog'
- REQUEST = 'RequestLog'
- class mlclient.clients.LogsClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
MLResourceClientAn MLResourceClient calling /manage/v2/logs endpoint.
It is a high-level class parsing MarkLogic response and extracting logs from the server.
- get_logs(app_server: int | str | None = None, log_type: LogType = LogType.ERROR, start_time: str | None = None, end_time: str | None = None, regex: str | None = None, host: str | None = None) Iterator[dict][source]
Return logs from a MarkLogic server.
- Parameters:
app_server (int | str | None, default None) – An app server (port) with logs to retrieve
log_type (LogType, default LogType.ERROR) – A log type
start_time (str | None, default None) – A start time to search error logs
end_time (str | None, default None) – An end time to search error logs
regex (str | None, default None) – A regex to search error logs
host (str | None, default None) – A host name with logs to retrieve
- Returns:
A log details generator.
- Return type:
Iterator[dict]
- Raises:
MarkLogicError – If MarkLogic returns an error (most likely XDMP-NOSUCHHOST)
- get_logs_list() dict[source]
Return a logs list from a MarkLogic server.
Result of this method is a parsed dict of log files with 3 keys:
source: points to origin log list items
parsed: points to parsed log list items includes a filename, server, log type and a number of days
grouped: points to a dictionary { <server>: { <log-type>: { <num-of-days>: <file-name> } } }
- Returns:
A parsed list of log files in the MarkLogic server
- Return type:
list
- Raises:
MarkLogicError – If MarkLogic returns an error
- class mlclient.clients.MLClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
objectA low-level class used to send simple HTTP requests to a MarkLogic instance.
Using configuration details provided it allows you to hit MarkLogic’s endpoints. It can connect with the MarkLogic Server as a Context Manager or explicitly by using the connect method.
- protocol
a protocol used for HTTP requests (http / https)
- Type:
str
- host
a host name
- Type:
str
- port
an App Service port
- Type:
int
- auth_method
an authorization method (basic / digest)
- Type:
str
- username
a username
- Type:
str
- password
a password
- Type:
str
- base_url
a base url built based on the protocol, the host name and the port provided
- Type:
str
Examples
>>> from mlclient import MLClient >>> config = { ... "host": "localhost", ... "port": 8002, ... "username": "admin", ... "password": "admin", ... } >>> with MLClient(**config) as client: ... resp = client.post( ... endpoint="/v1/eval", ... body={"xquery": "xdmp:database() => xdmp:database-name()"}) ... print(resp.text) ... --6a5df7d535c71968 Content-Type: text/plain X-Primitive: string App-Services --6a5df7d535c71968--
- delete_(endpoint: str, params: dict | None = None, headers: dict | None = None) Response | None[source]
Send a DELETE request.
- Parameters:
endpoint (str) – A REST endpoint to call
params (dict) – Request parameters
headers (dict) – Request headers
- Returns:
An HTTP response
- Return type:
Response
- get(endpoint: str, params: dict | None = None, headers: dict | None = None) Response | None[source]
Send a GET request.
- Parameters:
endpoint (str) – A REST endpoint to call
params (dict) – Request parameters
headers (dict) – Request headers
- Returns:
An HTTP response
- Return type:
Response
- is_connected() bool[source]
Return a connection status.
- Returns:
True if the client has started a connection; otherwise False
- Return type:
bool
- post(endpoint: str, params: dict | None = None, headers: dict | None = None, body: str | dict | None = None) Response | None[source]
Send a POST request.
- Parameters:
endpoint (str) – A REST endpoint to call
params (dict) – Request parameters
headers (dict) – Request headers
body (str | dict) – A request body
- Returns:
An HTTP response
- Return type:
Response
- put(endpoint: str, params: dict | None = None, headers: dict | None = None, body: str | dict | None = None) Response | None[source]
Send a PUT request.
- Parameters:
endpoint (str) – A REST endpoint to call
params (dict) – Request parameters
headers (dict) – Request headers
body (str | dict) – A request body
- Returns:
An HTTP response
- Return type:
Response
- request(method: str, endpoint: str, params: dict | None = None, headers: dict | None = None, body: str | dict | None = None)[source]
Send an HTTP request.
- Parameters:
method (str) – An HTTP request method
endpoint (str) – A REST endpoint to call
params (dict) – Request parameters
headers (dict) – Request headers
body (str | dict) – A request body
- Returns:
An HTTP response
- Return type:
Response
- class mlclient.clients.MLResourceClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
MLClientAn MLClient subclass calling ResourceCall implementation classes.
It can connect with the MarkLogic Server as a Context Manager or explicitly by using the connect method.
You can call ML REST Resource by using the call() method accepting a ResourceCall implementation classes.
- All attributes are inherited from the MLClient superclass.
Examples
>>> from mlclient import MLResourceClient >>> from mlclient.calls import EvalCall >>> config = { ... "host": "localhost", ... "port": 8002, ... "username": "admin", ... "password": "admin", ... } >>> with MLResourceClient(**config) as client: ... eval_call = EvalCall(xquery="xdmp:database() => xdmp:database-name()") ... resp = client.call(eval_call) ... print(resp.text) ... --6a5df7d535c71968 Content-Type: text/plain X-Primitive: string App-Services --6a5df7d535c71968--
- call(call: ResourceCall) Response[source]
Send a custom request to a MarkLogic endpoint.
- Parameters:
call (ResourceCall) – A specific endpoint call implementation
- Returns:
An HTTP response
- Return type:
Response
- class mlclient.clients.MLResourcesClient(protocol: str = 'http', host: str = 'localhost', port: int = 8002, auth_method: str = 'basic', username: str = 'admin', password: str = 'admin', retry: Retry = Retry(total=10, connect=5, read=None, redirect=None, status=None))[source]
Bases:
MLResourceClientAn MLResourceClient subclass supporting REST Resources of the MarkLogic server.
It can connect with the MarkLogic Server as a Context Manager or explicitly by using the connect method.
There are two ways to call ML REST Resources: - by using defined methods corresponding to a resource (e.g. /v1/eval -> eval()) - by using the call() method accepting a ResourceCall implementation classes.
This class can be treated as an example of MLClient class extension for your own dedicated APIs or as a superclass for your client.
- All attributes are inherited from the MLClient superclass.
Examples
>>> from mlclient import MLResourcesClient >>> config = { ... "host": "localhost", ... "port": 8002, ... "username": "admin", ... "password": "admin", ... } >>> with MLResourcesClient(**config) as client: ... resp = client.eval(xquery="xdmp:database() => xdmp:database-name()") ... print(resp.text) ... --6a5df7d535c71968 Content-Type: text/plain X-Primitive: string App-Services --6a5df7d535c71968--
- delete_database(database: str, forest_delete: str | None = None) Response[source]
Send a DELETE request to the /manage/v2/databases/{id|name} endpoint.
- Parameters:
database (str) – A database identifier. The database can be identified either by ID or name.
forest_delete (str) – Specifies to delete the forests attached to the database. If unspecified, the forests will not be affected. If “configuration” is specified, the forest configuration will be removed but public forest data will remain. If “data” is specified, the forest configuration and data will be removed.
- Returns:
An HTTP response
- Return type:
Response
- delete_documents(uri: str | list, database: str | None = None, category: str | list | None = None, txid: str | None = None, temporal_collection: str | None = None, system_time: str | None = None, wipe_temporal: bool | None = None)[source]
Send a DELETE request to the /v1/documents endpoint.
- Parameters:
uri (str | list) – One or more URIs for documents in the database. If you specify multiple URIs, the Accept header must be multipart/mixed.
database (str) – Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the “eval-in” privilege.
category (str | list) – The category of data to fetch about the requested document. Category can be specified multiple times to retrieve any combination of content and metadata. Valid categories: content (default), metadata, metadata-values, collections, permissions, properties, and quality. Use metadata to request all categories except content.
txid (str) – The transaction identifier of the multi-statement transaction in which to service this request. Use the /transactions service to create and manage multi-statement transactions.
temporal_collection (str) – Specify the name of a temporal collection into which the documents are to be inserted.
system_time (str) – Set the system start time for the insertion or update. This time will override the system time set by MarkLogic. Ignored if temporal-collection is not included in the request.
wipe_temporal (bool) – Remove all versions of a temporal document rather than performing a temporal delete. You can only use this parameter when you also specify a temporal-collection parameter.
- Returns:
An HTTP response
- Return type:
Response
- delete_forest(forest: str, level: str, replicas: str | None = None) Response[source]
Send a DELETE request to the /manage/v2/forests/{id|name} endpoint.
- Parameters:
forest (str) – A forest identifier. The forest can be identified either by ID or name.
level (str) – The type of state change to initiate. Allowed values: full, config-only. A config-only deletion removes only the forest configuration; the data contained in the forest remains on disk. A full deletion removes both the forest configuration and the data.
replicas (str) – Determines how to process the replicas. Allowed values: detach to detach the replica but keep it; delete to detach and delete the replica.
- Returns:
An HTTP response
- Return type:
Response
- delete_role(role: str) Response[source]
Send a DELETE request to the /manage/v2/roles/{id|name} endpoint.
- Parameters:
role (str) – A role identifier. The role can be identified either by ID or name.
- Returns:
An HTTP response
- Return type:
Response
- delete_server(server: str, group_id: str) Response[source]
Send a DELETE request to the /manage/v2/servers/{id|name} endpoint.
- Parameters:
server (str) – A server identifier. The server can be identified either by ID or name.
group_id (str) – The id or name of the group to which the App Server belongs. This parameter is required.
- Returns:
An HTTP response
- Return type:
Response
- delete_user(user: str) Response[source]
Send a DELETE request to the /manage/v2/users/{id|name} endpoint.
- Parameters:
user (str) – A user identifier. The user can be identified either by ID or name.
- Returns:
An HTTP response
- Return type:
Response
- eval(xquery: str | None = None, javascript: str | None = None, variables: dict | None = None, database: str | None = None, txid: str | None = None) Response[source]
Send a POST request to the /v1/eval endpoint.
- Parameters:
xquery (str) – The query to evaluate, expressed using XQuery. You must include either this parameter or the javascript parameter, but not both.
javascript (str) – The query to evaluate, expressed using server-side JavaScript. You must include either this parameter or the xquery parameter, but not both.
variables – External variables to pass to the query during evaluation
database – Perform this operation on the named content database instead of the default content database associated with the REST API instance. The database can be identified by name or by database id.
txid – The transaction identifier of the multi-statement transaction in which to service this request.
- Returns:
An HTTP response
- Return type:
Response
- get_database(database: str, data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/databases/{id|name} endpoint.
- Parameters:
database (str) – A database identifier. The database can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either html, json, or xml (default). This parameter is not meaningful with view=edit.
view (str) – A specific view of the returned data. Can be properties-schema, package, describe, config, counts, edit, status, forest-storage, or default.
- Returns:
An HTTP response
- Return type:
Response
- get_database_properties(database: str, data_format: str | None = None) Response[source]
Send a GET request to the /manage/v2/databases/{id|name}/properties endpoint.
- Parameters:
database (str) – A database identifier. The database can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either json or xml (default). This parameter overrides the Accept header if both are present.
- Returns:
An HTTP response
- Return type:
Response
- get_databases(data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/databases endpoint.
- Parameters:
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be schema, properties-schema, metrics, package, describe, or default.
- Returns:
An HTTP response
- Return type:
Response
- get_documents(uri: str | list, database: str | None = None, category: str | list | None = None, data_format: str | None = None, timestamp: str | None = None, transform: str | None = None, transform_params: dict | None = None, txid: str | None = None)[source]
Send a GET request to the /v1/documents endpoint.
- Parameters:
uri (str | list) – One or more URIs for documents in the database. If you specify multiple URIs, the Accept header must be multipart/mixed.
database (str) – Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the “eval-in” privilege.
category (str) – The category of data to fetch about the requested document. Category can be specified multiple times to retrieve any combination of content and metadata. Valid categories: content (default), metadata, metadata-values, collections, permissions, properties, and quality. Use metadata to request all categories except content.
data_format (str) – The expected format of metadata returned in the response. Accepted values: xml or json. This parameter does not affect document content. For metadata, this parameter overrides the MIME type in the Accept header, except when the Accept header is multipart/mixed.
timestamp (str) – A timestamp returned in the ML-Effective-Timestamp header of a previous request. Use this parameter to fetch documents based on the contents of the database at a fixed point-in-time.
transform (str) – Names a content transformation previously installed via the /config/transforms service. The service applies the transformation to all documents prior to constructing the response.
transform_params (str) – A transform parameter names and values. For example, { “myparam”: 1 }. Transform parameters are passed to the transform named in the transform parameter.
txid (str) – The transaction identifier of the multi-statement transaction in which to service this request. Use the /transactions service to create and manage multi-statement transactions.
- Returns:
An HTTP response
- Return type:
Response
- get_forest(forest: str, data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/forests/{id|name} endpoint.
- Parameters:
forest (str) – A forest identifier. The forest can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be properties-schema, config, edit, package, describe, status, xdmp:server-status or default.
- Returns:
An HTTP response
- Return type:
Response
- get_forest_properties(forest: str, data_format: str | None = None) Response[source]
Send a GET request to the /manage/v2/forests/{id|name}/properties endpoint.
- Parameters:
forest (str) – A forest identifier. The forest can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either json or xml (default). This parameter overrides the Accept header if both are present.
- Returns:
An HTTP response
- Return type:
Response
- get_forests(data_format: str | None = None, view: str | None = None, database: str | None = None, group: str | None = None, host: str | None = None, full_refs: bool | None = None) Response[source]
Send a GET request to the /manage/v2/forests endpoint.
- Parameters:
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be either describe, default, status, metrics, schema, storage, or properties-schema.
database (str) – Returns a summary of the forests for the specified database. The database can be identified either by id or name.
group (str) – Returns a summary of the forests for the specified group. The group can be identified either by id or name.
host (str) – Returns a summary of the forests for the specified host. The host can be identified either by id or name.
full_refs (bool) – If set to true, full detail is returned for all relationship references. A value of false (the default) indicates to return detail only for first references.
- Returns:
An HTTP response
- Return type:
Response
- get_logs(filename: str, data_format: str | None = None, host: str | None = None, start_time: str | None = None, end_time: str | None = None, regex: str | None = None) Response[source]
Send a GET request to the /manage/v2/logs endpoint.
- Parameters:
filename (str) – The log file to be returned.
data_format (str) – The format of the data in the log file. The supported formats are xml, json or html.
host (str) – The host from which to return the log data.
start_time (str) – The start time for the log data.
end_time (str) – The end time for the log data.
regex (str) – Filters the log data, based on a regular expression.
- Returns:
An HTTP response
- Return type:
Response
- get_role(role: str, data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/roles/{id|name} endpoint.
- Parameters:
role (str) – A role identifier. The role can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be: describe, or default.
- Returns:
An HTTP response
- Return type:
Response
- get_role_properties(role: str, data_format: str | None = None) Response[source]
Send a GET request to the /manage/v2/roles/{id|name}/properties endpoint.
- Parameters:
role (str) – A role identifier. The role can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either json or xml (default). This parameter overrides the Accept header if both are present.
- Returns:
An HTTP response
- Return type:
Response
- get_roles(data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/roles endpoint.
- Parameters:
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be: describe, or default.
- Returns:
An HTTP response
- Return type:
Response
- get_server(server: str, group_id: str, data_format: str | None = None, view: str | None = None, host_id: str | None = None, full_refs: bool | None = None, modules: bool | None = None) Response[source]
Send a GET request to the /manage/v2/servers/{id|name} endpoint.
- Parameters:
server (str) – A server identifier. The server can be identified either by ID or name.
group_id (str) – The id or name of the group to which the App Server belongs. This parameter is required.
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be properties-schema, config, edit, package, describe, status, xdmp:server-status or default.
host_id (str) – Meaningful only when view=status. Specifies to return the status for the server in the specified host. The host can be identified either by id or name.
full_refs (bool) – If set to true, full detail is returned for all relationship references. A value of false (the default) indicates to return detail only for first references. This parameter is not meaningful with view=package.
modules (bool) – Meaningful only with view=package. Whether to include a manifest of the modules database for the App Server in the results, if one exists. It is an error to request a modules database manifest for an App Server that uses the filesystem for modules. Default: false.
- Returns:
An HTTP response
- Return type:
Response
- get_server_properties(server: str, group_id: str, data_format: str | None = None) Response[source]
Send a GET request to the /manage/v2/servers/{id|name}/properties endpoint.
- Parameters:
server (str) – A server identifier. The server can be identified either by ID or name.
group_id (str) – The id or name of the group to which the App Server belongs. This parameter is required.
data_format (str) – The format of the returned data. Can be either json or xml (default). This parameter overrides the Accept header if both are present.
- Returns:
An HTTP response
- Return type:
Response
- get_servers(data_format: str | None = None, group_id: str | None = None, view: str | None = None, full_refs: bool | None = None) Response[source]
Send a GET request to the /manage/v2/servers endpoint.
- Parameters:
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
group_id (str) – Specifies to return only the servers in the specified group. The group can be identified either by id or name. If not specified, the response includes information about all App Servers.
view (str) – A specific view of the returned data. Can be schema, properties-schema, metrics, package, describe, or default.
full_refs (bool) – If set to true, full detail is returned for all relationship references. A value of false (the default) indicates to return detail only for first references. This parameter is not meaningful with view=package.
- Returns:
An HTTP response
- Return type:
Response
- get_user(user: str, data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/users/{id|name} endpoint.
- Parameters:
user (str) – A user identifier. The user can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be: describe, or default.
- Returns:
An HTTP response
- Return type:
Response
- get_user_properties(user: str, data_format: str | None = None) Response[source]
Send a GET request to the /manage/v2/users/{id|name}/properties endpoint.
- Parameters:
user (str) – A user identifier. The user can be identified either by ID or name.
data_format (str) – The format of the returned data. Can be either json or xml (default). This parameter overrides the Accept header if both are present.
- Returns:
An HTTP response
- Return type:
Response
- get_users(data_format: str | None = None, view: str | None = None) Response[source]
Send a GET request to the /manage/v2/users endpoint.
- Parameters:
data_format (str) – The format of the returned data. Can be either html, json, or xml (default).
view (str) – A specific view of the returned data. Can be: describe, or default.
- Returns:
An HTTP response
- Return type:
Response
- post_database(database: str, body: str | dict) Response[source]
Send a POST request to the /manage/v2/databases/{id|name} endpoint.
- Parameters:
database (str) – A database identifier. The database can be identified either by ID or name.
body (str | dict) – A database properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- post_databases(body: str | dict) Response[source]
Send a POST request to the /manage/v2/databases endpoint.
- Parameters:
body (str | dict) – A database properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- post_documents(body_parts: list[mlclient.structures.calls.documents.DocumentsBodyPart], database: str | None = None, transform: str | None = None, transform_params: dict | None = None, txid: str | None = None, temporal_collection: str | None = None, system_time: str | None = None)[source]
Send a POST request to the /v1/documents endpoint.
- Parameters:
body_parts (list[DocumentsBodyPart]) – A list of multipart request body parts
database (str) – Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the “eval-in” privilege.
transform (str) – Names a content transformation previously installed via the /config/transforms service. The service applies the transformation to all documents prior to constructing the response.
transform_params (str) – A transform parameter names and values. For example, { “myparam”: 1 }. Transform parameters are passed to the transform named in the transform parameter.
txid (str) – The transaction identifier of the multi-statement transaction in which to service this request. Use the /transactions service to create and manage multi-statement transactions.
temporal_collection (str) – Specify the name of a temporal collection into which the documents are to be inserted.
system_time (str) – Set the system start time for the insertion or update. This time will override the system time set by MarkLogic. Ignored if temporal-collection is not included in the request.
- Returns:
An HTTP response
- Return type:
Response
- post_forest(forest: str, body: str | dict) Response[source]
Send a POST request to the /manage/v2/forests/{id|name} endpoint.
- Parameters:
forest (str) – A forest identifier. The forest can be identified either by ID or name.
body (dict) – A list of properties. Need to include the ‘state’ property (the type of state change to initiate). Allowed values: clear, merge, restart, attach, detach, retire, employ.
- Returns:
An HTTP response
- Return type:
Response
- post_forests(body: str | dict, wait_for_forest_to_mount: bool | None = None) Response[source]
Send a POST request to the /manage/v2/forests endpoint.
- Parameters:
body (str | dict) – A database properties in XML or JSON format.
wait_for_forest_to_mount (bool) – Whether to wait for the new forest to mount before sending a response to this request. Allowed values: true (default) or false.
- Returns:
An HTTP response
- Return type:
Response
- post_roles(body: str | dict) Response[source]
Send a POST request to the /manage/v2/roles endpoint.
- Parameters:
body (str | dict) – A role properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- post_servers(body: str | dict, group_id: str | None = None, server_type: str | None = None) Response[source]
Send a POST request to the /manage/v2/servers endpoint.
- Parameters:
body (str | dict) – A database properties in XML or JSON format.
group_id (str) – The id or name of the group to which the App Server belongs. The group must be specified by this parameter or by the group-name property in the request payload. If it is specified in both places, the values must be the same.
server_type (str) – The type of App Server to create. The App Server type must be specified by this parameter or in the request payload. If it is specified in both places, the values must be the same. The valid types are: http, odbc, xdbc, or webdav.
- Returns:
An HTTP response
- Return type:
Response
- post_users(body: str | dict) Response[source]
Send a POST request to the /manage/v2/users endpoint.
- Parameters:
body (str | dict) – A user properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_database_properties(database: str, body: str | dict) Response[source]
Send a PUT request to the /manage/v2/databases/{id|name}/properties endpoint.
- Parameters:
database (str) – A database identifier. The database can be identified either by ID or name.
body (str | dict) – A database properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_forest_properties(forest: str, body: str | dict) Response[source]
Send a PUT request to the /manage/v2/databases/{id|name}/properties endpoint.
- Parameters:
forest (str) – A forest identifier. The forest can be identified either by ID or name.
body (str | dict) – A forest properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_forests(body: str | dict) Response[source]
Send a PUT request to the /manage/v2/forests endpoint.
- Parameters:
body (str | dict) – A database properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_role_properties(role: str, body: str | dict) Response[source]
Send a PUT request to the /manage/v2/roles/{id|name}/properties endpoint.
- Parameters:
role (str) – A role identifier. The role can be identified either by ID or name.
body (str | dict) – A role properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_server_properties(server: str, group_id: str, body: str | dict) Response[source]
Send a PUT request to the /manage/v2/servers/{id|name}/properties endpoint.
- Parameters:
server (str) – A server identifier. The server can be identified either by ID or name.
group_id (str) – The id or name of the group to which the App Server belongs. This parameter is required.
body (str | dict) – A database properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- put_user_properties(user: str, body: str | dict) Response[source]
Send a PUT request to the /manage/v2/users/{id|name}/properties endpoint.
- Parameters:
user (str) – A user identifier. The user can be identified either by ID or name.
body (str | dict) – A user properties in XML or JSON format.
- Returns:
An HTTP response
- Return type:
Response
- Raises:
NotImplementedError – If the call’s method is not GET, POST, PUT nor DELETE.