-
Notifications
You must be signed in to change notification settings - Fork 5
/
create_proxy.py
51 lines (41 loc) · 1.35 KB
/
create_proxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding: utf-8
"""
Full example on how to create a live proxy with the Nuxeo Python Client module.
To install it:
pip install nuxeo
"""
from nuxeo.client import Nuxeo
from nuxeo.models import Document
def main():
# Connection
host = "http://localhost:8080/nuxeo/"
auth = ("Administrator", "Administrator")
nuxeo = Nuxeo(host=host, auth=auth)
# Create a workspace
new_ws = Document(name="Tests", type="Workspace", properties={"dc:title": "Tests"})
workspace = nuxeo.documents.create(new_ws, parent_path="/default-domain/workspaces")
print(workspace)
# Create a document
operation = nuxeo.operations.new("Document.Create")
operation.params = {
"type": "File",
"name": "foo.txt",
"properties": {"dc:title": "foo.txt", "dc:description": "bar"},
}
operation.input_obj = "/"
doc = operation.execute()
print(doc)
# Create a proxy live
operation = nuxeo.operations.new("Document.CreateLiveProxy")
operation.params = {
# NOTICE - ATTENTION
# CREATE A WORKSPACE AS default-domain/workspaces/ws
"Destination Path": "/default-domain/workspaces/ws"
}
operation.input_obj = f"/{doc['title']}"
proxy = operation.execute()
print(proxy)
entry = nuxeo.documents.get(uid=proxy["uid"])
print(entry.type)
if __name__ == "__main__":
exit(main())