Skip to content

feat: add generate url #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
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
2 changes: 1 addition & 1 deletion videodb/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" About information for videodb sdk"""


__version__ = "0.2.9"
__version__ = "0.2.10"
__title__ = "videodb"
__author__ = "videodb"
__email__ = "[email protected]"
Expand Down
1 change: 1 addition & 0 deletions videodb/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ApiPath:
storage = "storage"
download = "download"
title = "title"
generate_url = "generate_url"


class Status:
Expand Down
7 changes: 7 additions & 0 deletions videodb/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@ def __repr__(self) -> str:
f"length={self.length})"
)

def generate_url(self) -> str:
url_data = self._connection.post(
path=f"{ApiPath.audio}/{self.id}/{ApiPath.generate_url}",
params={"collection_id": self.collection_id},
)
return url_data.get("signed_url", None)

def delete(self) -> None:
self._connection.delete(f"{ApiPath.audio}/{self.id}")
5 changes: 4 additions & 1 deletion videodb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ def get_collections(self) -> List[Collection]:
for collection in collections_data.get("collections")
]

def create_collection(self, name: str, description: str) -> Collection:
def create_collection(
self, name: str, description: str, is_public: bool = False
) -> Collection:
collection_data = self.post(
path=ApiPath.collection,
data={
"name": name,
"description": description,
"is_public": is_public,
},
)
self.collection_id = collection_data.get("id", "default")
Expand Down
7 changes: 7 additions & 0 deletions videodb/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def __repr__(self) -> str:
f"url={self.url})"
)

def generate_url(self) -> str:
url_data = self._connection.post(
path=f"{ApiPath.image}/{self.id}/{ApiPath.generate_url}",
params={"collection_id": self.collection_id},
)
return url_data.get("signed_url", None)

def delete(self) -> None:
self._connection.delete(f"{ApiPath.image}/{self.id}")

Expand Down