Nuxeo Python Client¶
-
class
nuxeo.client.
Nuxeo
(auth=None, host='http://localhost:8080/nuxeo/', app_name='Python client', client=<class 'nuxeo.client.NuxeoClient'>, **kwargs)¶ Instantiate the client and all the API Endpoints.
Parameters: - auth – the authenticator
- host – the host URL
- app_name – the name of the application using the client
- client – the client class
- kwargs – any other argument to forward to every requests calls
-
class
nuxeo.client.
NuxeoClient
(auth=None, host='http://localhost:8080/nuxeo/', api_path='api/v1', app_name='Python client', chunk_size=8192, **kwargs)¶ The HTTP client used by Nuxeo.
Parameters: - auth – An authentication object passed to Requests
- host – The url of the Nuxeo Platform
- api_path – The API path appended to the host url
- app_name – The name of the application using the client
- chunk_size – The size of the chunks for blob download
- kwargs – kwargs passed to
NuxeoClient.request()
-
is_reachable
()¶ Check if the Nuxeo Platform is reachable.
-
request
(method, path, headers=None, data=None, raw=False, **kwargs)¶ Send a request to the Nuxeo server.
Parameters: - method – the HTTP method
- path – the path to append to the host host
- headers – the headers for the HTTP request
- data – data to put in the body
- raw – if True, don’t parse the data to JSON
- kwargs – other parameters accepted by
requests.request()
Returns: the HTTP response
-
request_auth_token
(device_id, permission, app_name='Python client', device=None, revoke=False)¶ Request a token for the user.
Parameters: - device_id – device identifier
- permission – read/write permissions
- app_name – application name
- device – optional device description
- revoke – revoke the token
-
set
(repository=None, schemas=None)¶ Set the repository and/or the schemas for the requests.
Returns: The client instance after adding the settings
Models¶
-
class
nuxeo.models.
Batch
(**kwargs)¶ Upload batch.
-
cancel
()¶ Cancel an upload batch.
-
delete
(file_idx)¶ Delete a blob from the batch.
-
get
(file_idx)¶ Get the blob info.
Parameters: file_idx – the index of the blob in the batch Returns: the corresponding blob
-
upload
(blob, **kwargs)¶ Upload a blob.
Parameters: - blob – the blob to upload
- kwargs – the upload settings
Returns: the blob info
-
-
class
nuxeo.models.
Blob
(**kwargs)¶ Blob superclass used for metadata.
-
classmethod
parse
(json, service=None)¶ Parse a JSON object into a blob instance.
-
to_json
()¶ Return a JSON object used during the upload.
-
classmethod
-
class
nuxeo.models.
BufferBlob
(data, **kwargs)¶ InMemory content to upload to Nuxeo.
Acts as a context manager so its data can be read with the with statement.
-
data
¶ Request data.
-
-
class
nuxeo.models.
Directory
(**kwargs)¶ Directory.
-
create
(entry)¶ Create an entry in the directory.
-
delete
(entry=None)¶ Delete the directory or one of its entries.
Parameters: entry – if specified, the entry to delete
-
exists
(entry)¶ Check if an entry is in the directory.
Parameters: entry – the entry name Returns: True if it exists, else False
-
get
(entry)¶ Get an entry of the directory.
Parameters: entry – the name of the entry Returns: the corresponding directory entry
-
save
(entry)¶ Save a modified entry of the directory.
-
-
class
nuxeo.models.
DirectoryEntry
(**kwargs)¶ Directory entry.
-
delete
()¶ Delete the entry.
-
save
()¶ Save the entry.
-
-
class
nuxeo.models.
Document
(**kwargs)¶ Document.
-
add_permission
(params)¶ Add a permission to a document.
Parameters: params – permission to add
-
convert
(params)¶ Convert the document to another format.
Parameters: params – Converter permission Returns: the converter result
-
delete
()¶ Delete the document.
-
fetch_acls
()¶ Fetch document ACLs.
-
fetch_audit
()¶ Fetch audit for current document.
-
fetch_blob
(xpath='blobholder:0')¶ Retrieve one of the blobs attached to the document.
Parameters: xpath – the xpath to the blob Returns: the blob
-
fetch_lock_status
()¶ Get lock informations.
-
fetch_rendition
(name)¶ Parameters: name – Rendition name to use Returns: The rendition content
-
fetch_renditions
()¶ Returns: Available renditions for this document
-
follow_transition
(name)¶ Follow a lifecycle transition on this document.
Parameters: name – transition name
-
get
(prop)¶ Get a property of the document by its name.
-
has_permission
(permission)¶ Verify if a document has the permission.
-
is_locked
()¶ Get the lock status.
-
lock
()¶ Lock the document.
-
move
(dst, name=None)¶ Move a document into another parent.
Parameters: - dst – The new parent path
- name – Rename the document if specified
-
remove_permission
(params)¶ Remove a permission to a document.
-
set
(properties)¶ Add/update the properties of the document.
-
unlock
()¶ Unlock the document.
-
workflows
¶ Return the workflows associated with the document.
-
-
class
nuxeo.models.
FileBlob
(path, **kwargs)¶ File to upload to Nuxeo.
Acts as a context manager so its data can be read with the with statement.
-
data
¶ Request data.
The caller has to close the file descriptor himself if he doesn’t open it with the context manager.
-
-
class
nuxeo.models.
Model
(service=None, **kwargs)¶ Base class for all entities.
-
as_dict
()¶ Returns a dict representation of the resource.
-
classmethod
parse
(json, service=None)¶ Parse a JSON object into a model instance.
-
save
()¶ Save the resource.
-
-
class
nuxeo.models.
Operation
(**kwargs)¶ Automation operation.
-
execute
(**kwargs)¶ Execute the operation.
-
-
class
nuxeo.models.
Task
(**kwargs)¶ Workflow task.
-
complete
(action, variables=None, comment=None)¶ Complete the action of a task.
-
delegate
(actors, comment=None)¶ Delegate the task to someone else.
-
reassign
(actors, comment=None)¶ Reassign the task to someone else.
-
API Endpoints¶
-
class
nuxeo.endpoint.
APIEndpoint
(client, endpoint=None, headers=None, cls=None)¶ Represents an API endpoint for Nuxeo, containing common patterns for CRUD operations.
-
delete
(resource_id)¶ Deletes an existing resource.
Parameters: resource_id – the resource ID to be deleted
-
exists
(path)¶ Checks if a resource exists.
Parameters: path – the endpoint (URL path) for the request Returns: True if it exists, else False
-
get
(path=None, cls=None, raw=False, single=False, **kwargs)¶ Gets the details for one or more resources.
Parameters: - path – the endpoint (URL path) for the request
- cls – a class to use for parsing, if different than the base resource
- raw – if True, directly return the content of the response
- single – if True, do not parse as list
Returns: one or more instances of cls parsed from the returned JSON
-
post
(resource=None, path=None, raw=False, **kwargs)¶ Creates a new instance of the resource.
Parameters: - resource – the data to post
- path – the endpoint (URL path) for the request
- raw – if False, parse the outgoing data to JSON
Returns: the created resource
-
put
(resource=None, path=None, **kwargs)¶ Edits an existing resource.
Parameters: - resource – the resource instance
- path – the endpoint (URL path) for the request
Returns: the modified resource
-
-
class
nuxeo.directories.
API
(client, endpoint='directory', headers=None)¶ Endpoint for directories.
-
create
(resource=None, dir_name=None, **kwargs)¶ Create a directory or an entry.
Parameters: - resource – the directory/entry to create
- dir_name – the name of the directory
Returns: the created directory/entry
-
delete
(dir_name, dir_entry=None)¶ Delete a directory or an entry.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of the entry
-
exists
(dir_name, dir_entry=None)¶ Check if a directory or an entry exists.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of the entry
Returns: True if it exists, else False
-
get
(dir_name, dir_entry=None)¶ Get the entries of a directory.
If dir_entry is not None, return the corresponding entry.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of an entry
Returns: the directory entries
-
post
(resource=None, dir_name=None, **kwargs)¶ Create a directory or an entry.
Parameters: - resource – the directory/entry to create
- dir_name – the name of the directory
Returns: the created directory/entry
-
put
(resource, dir_name)¶ Update an entry.
Parameters: - resource – the entry to update
- dir_name – the name of the directory
Returns: the updated entry
-
-
class
nuxeo.documents.
API
(client, operations, workflows, endpoint=None, headers=None)¶ Endpoint for documents.
-
add_permission
(uid, params)¶ Add a permission to a document.
Parameters: - uid – the uid of the document
- params – the permissions to add
-
convert
(uid, options)¶ Convert a blob into another format.
Parameters: - uid – the uid of the blob to be converted
- options – the target type, target format, or converter for the blob
Returns: the response from the server
-
create
(document, parent_id=None, parent_path=None)¶ Create a document.
Parameters: - document – the document to create
- parent_id – the id of the parent document
- parent_path – the path of the parent document
Returns: the created document
-
delete
(document_id)¶ Delete a document.
Parameters: document_id – the id of the document to delete
-
exists
(uid=None, path=None)¶ Check if a document exists.
Parameters: - uid – the id of the document to check
- path – the path of the document to check
Returns: True if it exists, else False
-
fetch_acls
(uid)¶ Fetch the ACLs of a document.
Parameters: uid – the uid of the document Returns: the ACLs
-
fetch_audit
(uid)¶ Fetch the audit of a document.
Parameters: uid – the uid of the document Returns: the audit
-
fetch_blob
(uid=None, path=None, xpath='blobholder:0')¶ Get the blob of a document.
Parameters: - uid – the uid of the document
- path – the path of the document
- xpath – the xpath of the blob
Returns: the blob
-
fetch_lock_status
(uid)¶ Fetch the lock status of a document.
Parameters: uid – the uid of the document Returns: the lock status
-
fetch_rendition
(uid, name)¶ Fetch a rendition of a document.
Parameters: - uid – the uid of the document
- name – the name of the rendition
Returns: the corresponding rendition
-
fetch_renditions
(uid)¶ Fetch all renditions of a document.
Parameters: uid – the uid of a document Returns: the renditions
-
follow_transition
(uid, name)¶ Follow a lifecycle transition.
Parameters: - uid – the uid of the target document
- name – the name of the transition
-
get
(uid=None, path=None)¶ Get the detail of a document.
Parameters: - uid – the uid of the document
- path – the path of the document
Returns: the document
-
get_children
(uid=None, path=None)¶ Get the children of a document.
Parameters: - uid – the uid of the document
- path – the path of the document
Returns: the document children
-
has_permission
(uid, permission)¶ Check if a document has a permission.
Parameters: - uid – the uid of the document
- permission – the permission to check
Returns: True if the document has it, False otherwise
-
lock
(uid)¶ Lock a document.
-
move
(uid, dst, name=None)¶ Move a document and eventually rename it.
Parameters: - uid – the uid of the target document
- dst – the destination
- name – the new name
-
post
(document, parent_id=None, parent_path=None)¶ Create a document.
Parameters: - document – the document to create
- parent_id – the id of the parent document
- parent_path – the path of the parent document
Returns: the created document
-
put
(document)¶ Update a document.
Parameters: document – the document to update Returns: the updated document
-
query
(opts=None)¶ Run a query on the documents.
Parameters: opts – a query or a pageProvider Returns: the corresponding documents
-
remove_permission
(uid, params)¶ Remove a permission on a document.
Parameters: - uid – the uid of the document
- params – the permission to remove
-
unlock
(uid)¶ Unlock a document.
-
workflows
(document)¶ Get the workflows of a document.
-
-
class
nuxeo.directories.
API
(client, endpoint='directory', headers=None) Endpoint for directories.
-
create
(resource=None, dir_name=None, **kwargs) Create a directory or an entry.
Parameters: - resource – the directory/entry to create
- dir_name – the name of the directory
Returns: the created directory/entry
-
delete
(dir_name, dir_entry=None) Delete a directory or an entry.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of the entry
-
exists
(dir_name, dir_entry=None) Check if a directory or an entry exists.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of the entry
Returns: True if it exists, else False
-
get
(dir_name, dir_entry=None) Get the entries of a directory.
If dir_entry is not None, return the corresponding entry.
Parameters: - dir_name – the name of the directory
- dir_entry – the name of an entry
Returns: the directory entries
-
post
(resource=None, dir_name=None, **kwargs) Create a directory or an entry.
Parameters: - resource – the directory/entry to create
- dir_name – the name of the directory
Returns: the created directory/entry
-
put
(resource, dir_name) Update an entry.
Parameters: - resource – the entry to update
- dir_name – the name of the directory
Returns: the updated entry
-
-
class
nuxeo.groups.
API
(client, endpoint='group', headers=None)¶ Endpoint for groups.
-
create
(group)¶ Create a group.
Parameters: group – the group to create Returns: the created group
-
delete
(group_id)¶ Delete a group.
Parameters: group_id – the id of the group to delete
-
get
(group_id=None)¶ Get the detail of a group.
Parameters: group_id – the id of the group Returns: the group
-
post
(group)¶ Create a group.
Parameters: group – the group to create Returns: the created group
-
put
(group)¶ Update a group.
Parameters: group – the group to update Returns: the updated group
-
-
class
nuxeo.operations.
API
(client, endpoint='site/automation', headers=None)¶ Endpoint for operations.
-
check_params
(command, params)¶ Check given parameters of the command operation. It will also check for types whenever possible.
Raises: - ValueError – When the command is not valid.
- ValueError – On unexpected parameter.
- ValueError – On missing required parameter.
- TypeError – When a parameter has not the required type.
-
execute
(operation=None, void_op=False, headers=None, file_out=None, **kwargs)¶ Execute an operation.
If there is no operation parameter, the command, the input object, and the parameters of the operation will be taken from the kwargs.
Parameters: - operation – the operation
- void_op – if True, the body of the response from the server will be empty
- headers – extra HTTP headers
- file_out – if not None, path of the file where the response will be saved
- kwargs – any other parameter
Returns: the result of the execution
-
get
(**kwargs)¶ Get the list of available operations from the server.
-
get_attributes
(operation, **kwargs)¶ Get the operation attributes.
-
new
(command, **kwargs)¶ Make a new Operation object.
-
operations
¶ Get a dict of available operations.
Returns: the available operations
-
save_to_file
(operation, resp, path, **kwargs)¶ Save the result of an operation to a file.
If there is a digest of the file to check against the server, it can be passed in the kwargs.
Parameters: - operation – the operation
- resp – the response from the Platform
- path – the path to save the file to
- kwargs – additional parameters
Returns: the path of the output file
-
-
class
nuxeo.tasks.
API
(client, endpoint='task', headers=None)¶ Endpoint for tasks.
-
complete
(task, action, variables=None, comment=None)¶ Complete the task.
Parameters: - task – the task
- action – to take
- variables – to add to the Task
- comment – for the action
Returns: Updated task
-
get
(options=None)¶ Get tasks by id or by options.
Parameters: options – the id of the task or the constraints Returns: the task(s)
-
put
(task)¶ Update a task.
Parameters: task – the task to update Returns: the updated task
-
transfer
(task, transfer, actors, comment=None)¶ - Delegate or reassign the Task to someone else.
Parameters: - task – the task to modify
- transfer – ‘delegate’ or ‘reassign’
- actors – the actors involved
- comment – a comment
Returns:
-
-
class
nuxeo.uploads.
API
(client, endpoint='upload', headers=None)¶ Endpoint for uploads.
-
batch
()¶ Create a batch.
Returns: the created batch
-
delete
(batch_id, file_idx=None)¶ Delete a batch or a blob.
If the file_idx is None, deletes the batch, otherwise deletes the corresponding blob.
Parameters: - batch_id – the id of the batch
- file_idx – the index of the blob
-
get
(batch_id, file_idx=None)¶ Get the detail of a batch.
If file_idx is None, returns the details of all its blobs, otherwise returns the details of the corresponding blob.
Parameters: - batch_id – the id of the batch
- file_idx – the index of the blob
Returns: the batch details
-
post
()¶ Create a batch.
Returns: the created batch
-
send_data
(name, data, path, chunked, index, headers)¶ Send data/chunks to the server.
Parameters: - name – name of the file being uploaded
- data – data being sent
- path – url for the upload
- chunked – True if the upload is in chunks
- index – which chunk is being sent (0 if not chunked)
- headers – HTTP request headers
Returns: the blob info
-
state
(path, blob)¶ Get the state of a blob.
If the blob upload has not begun yet, the server will return a 404 error, so we initialize the different values. If the blob upload is incomplete, we return the values the server sent us. If the blob upload is complete, we return None for these values.
Parameters: - path – path for the request
- blob – the target blob
Returns: the chunk size, chunk count, the index of the next blob to upload, and the response from the server
-
upload
(batch, blob, chunked=False, limit=10485760)¶ Upload a blob.
Can be used to upload a new blob or resume the upload of a chunked blob.
Parameters: - batch – batch of the upload
- blob – blob to upload
- chunked – if True, send in chunks
- limit – if blob is bigger, send in chunks
Returns: uploaded blob details
-
-
class
nuxeo.users.
API
(client, endpoint='user', headers=None)¶ Endpoint for users.
-
create
(user)¶ Create a user.
Parameters: user – the user to create Returns: the created user
-
delete
(user_id)¶ Delete a user.
Parameters: user_id – the id of the user to delete
-
get
(user_id=None)¶ Get the detail of a user.
Parameters: user_id – the id of the user Returns: the user
-
post
(user)¶ Create a user.
Parameters: user – the user to create Returns: the created user
-
put
(user)¶ Update a user.
Parameters: user – the user to update Returns: the updated user
-
-
class
nuxeo.workflows.
API
(client, tasks, endpoint='workflow', headers=None)¶ Endpoint for workflows.
-
delete
(workflow_id)¶ Delete a workflow.
Parameters: workflow_id – the id of the workflow to delete
-
get
(workflow_id=None)¶ Get the detail of a workflow.
Parameters: workflow_id – the id of the workflow Returns: the workflow
-
graph
(workflow)¶ Get the graph of the workflow in JSON format.
Parameters: workflow – the worklow to get the graph from Returns: the graph
-
post
(model, document=None, options=None)¶ Start a workflow.
Parameters: - model – the workflow to start
- document – the document to start the workflow on
- options – options for the workflow
Returns: the created workflow
-
start
(model, document=None, options=None)¶ Start a workflow.
Parameters: - model – the workflow to start
- document – the document to start the workflow on
- options – options for the workflow
Returns: the created workflow
-
started
(model)¶ Get started workflows having the specified model.
Parameters: model – the workflow model Returns: the started workflows
-
tasks
(workflow)¶ Get the tasks of a workflow.
-