@@ -22,17 +22,25 @@ async def example():
2222 print (status.running) # True | False
2323 print (status.storage) # '0MB'
2424
25- # managing
26- start = await app.start() # Response(success)
27- stop = await app.stop() # Response(success)
28- restart = await app.restart() # Response(success)
25+ # managing application
26+ start = await app.start()
27+ print (start) # Response(success)
28+
29+ stop = await app.stop()
30+ print (stop) # Response(success)
31+
32+ restart = await app.restart()
33+ print (restart) # Response(success)
34+
35+ app_data = await app.data()
36+ print (app_data) # AppData(...)
2937
3038 backup = await app.backup() # BackupData(downloadURL='https://squarecloud.app/dashboard/backup/123.zip')
31- print (
32- backup.downloadURL) # 'https://squarecloud.app/dashboard/backup/123.zip'
39+ print (backup.downloadURL) # 'https://squarecloud.app/dashboard/backup/123.zip'
3340
3441 # [WARNING] this will delete your app, remember to have some backup saved
35- delete = await app.delete() # Response(success)
42+ delete = await app.delete()
43+ print (delete) # Response(success)
3644
3745 apps_list = await client.all_apps()
3846 for app in apps_list:
@@ -41,6 +49,79 @@ async def example():
4149
4250___
4351
52+ ## Files managing
53+
54+ you can manage your application files easily, let's see some examples
55+
56+ ### Obtaining file list:
57+
58+ ``` python
59+ import squarecloud as square
60+
61+ client = square.Client(api_key = ' API KEY' )
62+
63+
64+ async def example ():
65+ app = await client.app(' application_id' )
66+ files_list = await app.files_list(
67+ path = ' /' ) # [FileInfo(...), FileInfo(...), FileInfo(...)]
68+
69+ first_file = files_list[0 ]
70+ print (first_file.name) # 'main.py'
71+ print (first_file.type) # 'directory' or 'file'
72+ print (first_file.size) # 2140
73+ print (first_file.lastModified) # 1677112835000
74+ ```
75+
76+ ### Reading a file:
77+
78+ ` await app.read_file(path) ` returns the bytes of your file
79+
80+ ``` python
81+ import squarecloud as square
82+
83+ client = square.Client(api_key = ' API KEY' )
84+
85+
86+ async def example ():
87+ app = await client.app(' application_id' )
88+ file_bytes = await app.read_file(path = ' main.py' )
89+ print (file_bytes) # b'01101111 01101001'
90+ ```
91+
92+ ### Creating a file:
93+
94+ ` await app.create_file() ` creates a file in the specified directory
95+
96+ ``` python
97+ import squarecloud as square
98+
99+ client = square.Client(api_key = ' API KEY' )
100+
101+
102+ async def example ():
103+ app = await client.app(' application_id' )
104+ await app.create_file(
105+ path = ' /file.txt' ,
106+ file = square.File(' file.txt' )
107+ )
108+ ```
109+
110+ ### Deleting a file:
111+
112+ ``` python
113+ import squarecloud as square
114+
115+ client = square.Client(api_key = ' API KEY' )
116+
117+
118+ async def example ():
119+ app = await client.app(' application_id' )
120+ await app.delete_file(path = ' /file.txt' )
121+ ```
122+
123+ ---
124+
44125## Caching
45126
46127When a request is made it returns information from the application and caches
@@ -62,19 +143,16 @@ async def example():
62143 # See that since no request was made, the cache is empty
63144 print (app.cache.status) # None
64145 print (app.cache.logs) # None
65- print (app.cache.full_logs) # None
66146 print (app.cache.backup) # None
67147
68148 # Now, lets make some requests
69149 await app.status()
70150 await app.logs()
71- await app.full_logs()
72151 await app.backup()
73152
74153 # Now the cache is updated
75154 print (app.cache.status) # StatusData(...)
76155 print (app.cache.logs) # LogsData(...)
77- print (app.cache.full_logs) # FullLogsData(...)
78156 print (app.cache.backup) # BackupData(...)
79157```
80158
@@ -95,20 +173,18 @@ async def example():
95173 # thus remaining with the old cache
96174 await app.status(update_cache = False )
97175 await app.logs(update_cache = False )
98- await app.full_logs(update_cache = False )
99176 await app.backup(update_cache = False )
100177
101178 print (app.cache.status) # None
102179 print (app.cache.logs) # None
103- print (app.cache.full_logs) # None
104180 print (app.cache.backup) # None
105181```
106182
107183you can also clear and update the cache manually using ` cache.clear() ` and `
108184cache.update()`
109185
110186if the arguments you pass to ` cache.update() ` are not an instance
111- of ` StatusData ` , ` LogsData ` , ` FullLogsData ` or ` BackupData ` a SquareException
187+ of ` StatusData ` , ` LogsData ` , or ` BackupData ` a SquareException
112188error will be raised
113189
114190``` python
@@ -122,25 +198,21 @@ async def example():
122198
123199 status = await app.status()
124200 logs = await app.logs()
125- full_logs = await app.full_logs()
126201 backup = await app.backup()
127202
128203 print (app.cache.status) # StatusData(...)
129204 print (app.cache.logs) # LogsData(...)
130- print (app.cache.full_logs) # FullLogsData(...)
131205 print (app.cache.backup) # BackupData(...)
132206
133207 app.cache.clear() # Clear cache
134208
135209 print (app.cache.status) # None
136210 print (app.cache.logs) # None
137- print (app.cache.full_logs) # None
138211 print (app.cache.backup) # None
139212
140- app.cache.update(status, logs, full_logs, backup) # Update cache
213+ app.cache.update(status, logs, backup) # Update cache
141214
142215 print (app.cache.status) # StatusData(...)
143216 print (app.cache.logs) # LogsData(...)
144- print (app.cache.full_logs) # FullLogsData(...)
145217 print (app.cache.backup) # BackupData(...)
146218```
0 commit comments