Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text=auto
*.py eol=lf
*.sh eol=lf
*.bat eol=crlf
*.ps1 eol=crlf
*.md eol=lf
47 changes: 47 additions & 0 deletions examples/demoAdmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import litegraph

sdk = litegraph.configure(
endpoint="http://YOUR_SERVER_URL_HERE:PORT",
access_key="litegraphadmin",
tenant_guid="00000000-0000-0000-0000-000000000000",
)


def create_backup():
backup = litegraph.Admin.create_backup(filename="test.backup")
print(backup)


# create_backup()


def check_backup_exists():
backup = litegraph.Admin.exists(filename="test.backup")
print(backup)


# check_backup_exists()


def retrieve_backup():
backup = litegraph.Admin.retrieve(filename="test.backup")
print(backup)


# retrieve_backup()


def delete_backup():
backup = litegraph.Admin.delete(filename="test.backup")
print(backup)


# delete_backup()


def flush_db_to_disk():
backup = litegraph.Admin.flush_db_to_disk()
print(backup)


# flush_db_to_disk()
39 changes: 39 additions & 0 deletions examples/demoAuthentication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import litegraph

sdk = litegraph.configure(
endpoint="http://YOUR_SERVER_URL_HERE:PORT",
tenant_guid="00000000-0000-0000-0000-000000000000",
access_key="litegraphadmin",
)


def retrieve_tenants_for_email():
tenants = litegraph.Authentication.retrieve_tenants_for_email(
email="default@user.com"
)
print(tenants)


retrieve_tenants_for_email()


def generate_authentication_token():
token = litegraph.Authentication.generate_authentication_token(
email="default@user.com",
password="password",
tenant_guid="00000000-0000-0000-0000-000000000000",
)
print(token)


generate_authentication_token()


def retrieve_token_details():
token_details = litegraph.Authentication.retrieve_token_details(
token="mXCNtMWDsW0/pr+IwRFUjZYDoWLdu5ikKlbZr907gYrfE1YYCDFfFTleuYAW0mY1rkrhpPOgDf3Fbtk0iiy8JBF2WlWMw0MttbH0mDgNf1ZSJHGR5nQDG9oRHFe0q9SaIMCVyRGIdsgewLr7YPM46nsrHcLTA7RPKKOPA/mYZG6/kOGQV3FnT7F3u293+NBgWMXRYzNhmTwqEA021/gc9r1rVXjZcWXgv1apW/xyqCkF4aOriuyThcV55zibCugyDuj7MTSjke7Wp8LyJiBFUxz+745NyEbLACSkJ1wp8nxuRUDD+YhlfgavUHEzFot0mWYuJDU3JeyyDNSHS3VvKOih+51K0H0ucEKhbKUA+zo="
)
print(token_details)


retrieve_token_details()
28 changes: 28 additions & 0 deletions examples/demoBatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import litegraph

sdk = litegraph.configure(
endpoint="http://YOUR_SERVER_URL_HERE:PORT",
tenant_guid="00000000-0000-0000-0000-000000000000",
graph_guid="33773395-d573-4ea1-af25-a7d19bb37b1a",
access_key="litegraphadmin",
)


def batch_existence():
batch_existence = litegraph.Graph.batch_existence(
graph_guid="33773395-d573-4ea1-af25-a7d19bb37b1a",
request=litegraph.ExistenceRequestModel(
nodes=["33773395-d573-4ea1-af25-a7d19bb37b1a"],
edges=["33773395-d573-4ea1-af25-a7d19bb37b1a"],
edges_between=[
litegraph.EdgeBetweenModel(
from_node_guid="33773395-d573-4ea1-af25-a7d19bb37b1a",
to_node_guid="33773395-d573-4ea1-af25-a7d19bb37b1a",
)
],
),
)
print(batch_existence)


batch_existence()
101 changes: 101 additions & 0 deletions examples/demoCredential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import litegraph

sdk = litegraph.configure(
endpoint="http://YOUR_SERVER_URL_HERE:PORT",
tenant_guid="00000000-0000-0000-0000-000000000000",
access_key="litegraphadmin",
)


def create_credential():
credential = litegraph.Credential.create(
user_guid="00000000-0000-0000-0000-000000000000",
name="Test Credential",
bearer_token="test",
)
print(credential)


# create_credential()


def retrieve_all_credential():
credentials = litegraph.Credential.retrieve_all()
print(credentials)


# retrieve_all_credential()


def retrieve_credential():
credential = litegraph.Credential.retrieve(
guid="00000000-0000-0000-0000-000000000000"
)
print(credential)


# retrieve_credential()


def enumerate_credential():
credentials = litegraph.Credential.enumerate()
print(credentials)


# enumerate_credential()


def enumerate_with_query_credential():
credentials = litegraph.Credential.enumerate_with_query(
ordering="CreatedDescending",
MaxResults=10,
Skip=0,
IncludeData=True,
IncludeSubordinates=True,
Expr=litegraph.ExprModel(Left="Name", Operator="Equals", Right="Test"),
)
print(credentials)


# enumerate_with_query_credential()


def retrieve_multiple_credential():
credentials = litegraph.Credential.retrieve_many(
guids=[
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000",
]
)
print(credentials)


# retrieve_multiple_credential()


def update_credential():
credential = litegraph.Credential.update(
guid="00000000-0000-0000-0000-000000000000",
user_guid="00000000-0000-0000-0000-000000000000",
name="Updated Credential",
)
print(credential)


# update_credential()


def delete_credential():
litegraph.Credential.delete(guid="00000000-0000-0000-0000-000000000000")
print("Credential deleted")


# delete_credential()


def exists_credential():
exists = litegraph.Credential.exists(guid="00000000-0000-0000-0000-000000000000")
print(exists)


exists_credential()
149 changes: 149 additions & 0 deletions examples/demoEdge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import litegraph

sdk = litegraph.configure(
endpoint="http://YOUR_SERVER_URL_HERE:PORT",
tenant_guid="00000000-0000-0000-0000-000000000000",
graph_guid="c940d490-6693-4237-bb08-635890c03bcb",
access_key="litegraphadmin",
)


def retrieve_all_edge():
edges = litegraph.Edge.retrieve_all()
print(edges)


# retrieve_all_edge()


def retrieve_edge():
edge = litegraph.Edge.retrieve(guid="1cbb2bc5-a990-49a8-9975-e0b1c34d1011")
print(edge)


# retrieve_edge()


def retrieve_many_edge():
edges = litegraph.Edge.retrieve_many(
graph_guid="1cbb2bc5-a990-49a8-9975-e0b1c34d1011",
guids=[
"e73bbd3f-2637-4ae3-86a0-7d09f4d76028",
"e9e90c37-74cd-4a77-9c1f-96167e2bb3f9",
],
)
print(edges)


# retrieve_many_edge()


def enumerate_edge():
edges = litegraph.Edge.enumerate()
print(edges)


# enumerate_edge()


def enumerate_with_query_edge():
edges = litegraph.Edge.enumerate_with_query(
expr=litegraph.ExprModel(Left="Name", Operator="Equals", Right="Test")
)
print(edges)


enumerate_with_query_edge()


def exists_edge():
exists = litegraph.Edge.exists(guid="e73bbd3f-2637-4ae3-86a0-7d09f4d76028")
print(exists)


# exists_edge()


def create_edge():
edge = litegraph.Edge.create(
from_guid="00000000-0000-0000-0000-000000000000",
to_guid="00000000-0000-0000-0000-000000000001",
name="Test Edge",
cost=1,
)
print(edge)


# create_edge()


def create_multiple_edge():
edges = litegraph.Edge.create_multiple(
[
{
"from_guid": "00000000-0000-0000-0000-000000000000",
"to_guid": "00000000-0000-0000-0000-000000000001",
"name": "Test Edge",
"cost": 1,
},
{
"from_guid": "00000000-0000-0000-0000-000000000001",
"to_guid": "00000000-0000-0000-0000-000000000002",
"name": "Test Edge",
"cost": 1,
},
]
)
print(edges)


# create_multiple_edge()


def update_edge():
edge = litegraph.Edge.update(
guid="e73bbd3f-2637-4ae3-86a0-7d09f4d76028", name="Test Edge Updated", cost=2
)
print(edge)


# update_edge()


def delete_edge():
litegraph.Edge.delete(guid="f040fccb-8337-4666-8175-5cfcfb131189")
print("Edge deleted")


# delete_edge()


def delete_multiple_edge():
litegraph.Edge.delete_multiple(
guid=[
"c818e91d-b414-4bb6-b666-03d37790b45f",
"d3aa9a3f-81d7-4efc-a3bb-a806e722c3b8",
]
)
print("Edges deleted")


# delete_multiple_edge()


def delete_all_edge():
litegraph.Edge.delete_all()
print("Edges deleted")


# delete_all_edge()


def retrieve_first_edge():
graph = litegraph.Edge.retrieve_first(
ordering="CreatedDescending", graph_guid="c940d490-6693-4237-bb08-635890c03bcb"
)
print(graph)


retrieve_first_edge()
Loading
Loading