Skip to content

Commit 93bd6cf

Browse files
committed
Use ID helper
1 parent 5ede427 commit 93bd6cf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

playground.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from appwrite.input_file import InputFile
1212
from appwrite.permission import Permission
1313
from appwrite.role import Role
14+
from appwrite.id import ID
1415

1516
# Helper method to print green colored output.
1617
def p(info):
@@ -43,7 +44,7 @@ def create_database():
4344

4445
p("Running Create Database API")
4546
response = databases.create(
46-
database_id='unique()',
47+
database_id=ID.unique(),
4748
name='Movies',
4849
)
4950
database_id = response['$id']
@@ -55,7 +56,7 @@ def create_collection():
5556
p("Running Create Database API")
5657
response = databases.create_collection(
5758
database_id,
58-
collection_id='unique()',
59+
collection_id=ID.unique(),
5960
name='Movies',
6061
document_security=True,
6162
permissions=[
@@ -146,7 +147,7 @@ def add_doc():
146147
response = databases.create_document(
147148
database_id,
148149
collection_id,
149-
document_id='unique()',
150+
document_id=ID.unique(),
150151
data={
151152
'name': "Spider Man",
152153
'release_year': 1920,
@@ -197,7 +198,7 @@ def create_bucket():
197198

198199
p("Running Create Bucket API")
199200
response = storage.create_bucket(
200-
bucket_id='unique()',
201+
bucket_id=ID.unique(),
201202
name='awesome bucket',
202203
file_security=True,
203204
permissions=[
@@ -221,7 +222,7 @@ def upload_file():
221222
p("Running Upload File API")
222223
response = storage.create_file(
223224
bucket_id,
224-
file_id='unique()',
225+
file_id=ID.unique(),
225226
file=InputFile.from_path("./resources/nature.jpg"),
226227
)
227228
file_id = response['$id']
@@ -248,7 +249,7 @@ def create_user():
248249
name = str(randrange(1, maxsize))
249250
p("Running Create User API")
250251
response = users.create(
251-
user_id='unique()',
252+
user_id=ID.unique(),
252253
email=f'{name}@test.com',
253254
password=f'{name}@123',
254255
name=name
@@ -271,7 +272,7 @@ def create_function():
271272

272273
p("Running Create Function API")
273274
response = functions.create(
274-
function_id='unique()',
275+
function_id=ID.unique(),
275276
name='Test Function',
276277
execute=[Role.any()],
277278
runtime='python-3.9',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy