Skip to content

Update playground.py having inconsistant formatting and quotes #54

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
60 changes: 30 additions & 30 deletions playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

# Helper method to print green colored output.
def p(info):
print("\033[32;1m"+str(info)+"\033[0m")
print(f"\033[32;1m{info}\033[0m")

# Read the docs at https://appwrite.io/docs to get more information
# about API keys and Project IDs
client = Client()
client.set_endpoint('http://YOUR_HOST/v1')
client.set_project('YOUR_PROJECT_ID')
client.set_key('YOU_API_KEY')
client.set_endpoint("http://YOUR_HOST/v1")
client.set_project("YOUR_PROJECT_ID")
client.set_key("YOU_API_KEY")
client.set_self_signed()
# client.set_jwt('JWT') # Use this to authenticate with JWT instead of API_KEY
# client.set_jwt("JWT") # Use this to authenticate with JWT instead of API_KEY

databases = Databases(client)
storage = Storage(client)
Expand All @@ -45,9 +45,9 @@ def create_database():
p("Running Create Database API")
response = databases.create(
database_id=ID.unique(),
name='Movies',
name="Movies",
)
database_id = response['$id']
database_id = response["$id"]
print(response)

def create_collection():
Expand All @@ -57,7 +57,7 @@ def create_collection():
response = databases.create_collection(
database_id,
collection_id=ID.unique(),
name='Movies',
name="Movies",
document_security=True,
permissions=[
Permission.read(Role.any()),
Expand All @@ -67,13 +67,13 @@ def create_collection():
]
)

collection_id = response['$id']
collection_id = response["$id"]
print(response)

response = databases.create_string_attribute(
database_id,
collection_id,
key='name',
key="name",
size=255,
required=True,
)
Expand All @@ -82,7 +82,7 @@ def create_collection():
response = databases.create_integer_attribute(
database_id,
collection_id,
key='release_year',
key="release_year",
required=True,
min=0,
max=9999
Expand All @@ -92,7 +92,7 @@ def create_collection():
response = databases.create_float_attribute(
database_id,
collection_id,
key='rating',
key="rating",
required=True,
min=0.0,
max=99.99
Expand All @@ -102,15 +102,15 @@ def create_collection():
response = databases.create_boolean_attribute(
database_id,
collection_id,
key='kids',
key="kids",
required=True
)
print(response)

response = databases.create_email_attribute(
database_id,
collection_id,
key='email',
key="email",
required=False,
default=""
)
Expand All @@ -122,9 +122,9 @@ def create_collection():
response = databases.create_index(
database_id,
collection_id,
key='name_email_idx',
key="name_email_idx",
type="fulltext",
attributes=['name', 'email']
attributes=["name", "email"]
)
print(response)

Expand All @@ -149,18 +149,18 @@ def add_doc():
collection_id,
document_id=ID.unique(),
data={
'name': "Spider Man",
'release_year': 1920,
'rating': 98.5,
'kids': False
"name": "Spider Man",
"release_year": 1920,
"rating": 98.5,
"kids": False
},
permissions=[
Permission.read(Role.users()),
Permission.update(Role.users()),
Permission.delete(Role.users()),
]
)
document_id = response['$id']
document_id = response["$id"]
print(response)

def list_doc():
Expand Down Expand Up @@ -199,7 +199,7 @@ def create_bucket():
p("Running Create Bucket API")
response = storage.create_bucket(
bucket_id=ID.unique(),
name='awesome bucket',
name="awesome bucket",
file_security=True,
permissions=[
Permission.read(Role.any()),
Expand All @@ -208,7 +208,7 @@ def create_bucket():
Permission.delete(Role.users()),
]
)
bucket_id = response['$id']
bucket_id = response["$id"]
print(response)

def list_buckets():
Expand All @@ -225,7 +225,7 @@ def upload_file():
file_id=ID.unique(),
file=InputFile.from_path("./resources/nature.jpg"),
)
file_id = response['$id']
file_id = response["$id"]
print(response)

def list_files():
Expand All @@ -250,11 +250,11 @@ def create_user():
p("Running Create User API")
response = users.create(
user_id=ID.unique(),
email=f'{name}@test.com',
password=f'{name}@123',
email=f"{name}@test.com",
password=f"{name}@123",
name=name
)
user_id = response['$id']
user_id = response["$id"]
print(response)

def list_user():
Expand All @@ -273,11 +273,11 @@ def create_function():
p("Running Create Function API")
response = functions.create(
function_id=ID.unique(),
name='Test Function',
name="Test Function",
execute=[Role.any()],
runtime='python-3.9',
runtime="python-3.9",
)
function_id = response['$id']
function_id = response["$id"]
print(response)

def list_function():
Expand Down