Skip to content

Commit

Permalink
feat(python-sdk): collection files (#46)
Browse files Browse the repository at this point in the history
Save, load, delete, tag, list and filter files in collections.
  • Loading branch information
artem-chupryna authored Nov 20, 2024
1 parent 8a347e1 commit 3c625d8
Show file tree
Hide file tree
Showing 27 changed files with 2,785 additions and 618 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repos:
entry: "mypy --strict ./python"
pass_filenames: false
additional_dependencies:
- "types-requests"
- "pytest-asyncio"
- "pydantic"
- "marimo"
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies = [
"typing-extensions>=4.12.2",
"ariadne-codegen[subscriptions]>=0.14.0",
"plotly>4",
"requests>=2.32.3",
]

[project.optional-dependencies]
Expand All @@ -20,6 +21,7 @@ dev = [
"pytest-asyncio==0.24.0",
"ruff==0.6.4",
"mypy==1.11.2",
"types-requests>=2.32.0",
"coverage==7.6.1",
"twine==5.1.1",
"marimo==0.8.14",
Expand Down
92 changes: 92 additions & 0 deletions python/queries.gql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ fragment CollectionNotFound on CollectionNotFound {
id
}

fragment CollectionFileReference on CollectionFile {
id
key
downloadURL
uploadURL
tags {
key
value
}
}

fragment CollectionFileNotFound on CollectionFileNotFound {
id
}

mutation CollectionCreate($organizationID: ID!, $key: ID!, $parentID: ID) {
collectionCreate(
organizationID: $organizationID
Expand Down Expand Up @@ -142,3 +157,80 @@ query CollectionDocuments(
}
}
}

mutation CollectionFileCreate($collectionID: ID!, $key: ID!) {
collectionFileCreate(collectionID: $collectionID, key: $key) {
__typename
... on CollectionFile {
...CollectionFileReference
}
}
}

mutation CollectionFileDelete($id: ID!) {
collectionFileDelete(id: $id) {
__typename
... on CollectionFile {
...CollectionFileReference
}
... on CollectionFileNotFound {
...CollectionFileNotFound
}
}
}

query CollectionFiles(
$collectionID: ID!
$tag: TagInput
$after: ID
$first: Int
) {
collection(id: $collectionID) {
__typename
... on Collection {
id
key
files(after: $after, first: $first, tag: $tag) {
edges {
node {
__typename
... on CollectionFile {
...CollectionFileReference
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}

mutation CollectionFileTagAdd($id: ID!, $tag: TagInput!) {
collectionFileTagAdd(id: $id, tag: $tag) {
__typename
... on CollectionFile {
...CollectionFileReference
}
}
}

mutation CollectionFileTagDelete($id: ID!, $tag_key: String!) {
collectionFileTagDelete(id: $id, key: $tag_key) {
__typename
... on CollectionFile {
...CollectionFileReference
}
}
}

query CollectionFile($id: ID!) {
collectionFile(id: $id) {
__typename
... on CollectionFile {
...CollectionFileReference
}
}
}
Loading

0 comments on commit 3c625d8

Please sign in to comment.