Skip to content

Commit bba0bea

Browse files
Update docs/client.md
1 parent 76298a8 commit bba0bea

File tree

1 file changed

+86
-8
lines changed

1 file changed

+86
-8
lines changed

docs/client.md

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ async def example():
1616
print(logs.logs) # 'Hello World'
1717

1818
full_logs = await client.get_logs(app_id)
19-
print(full_logs) # FullLogsData(logs='https://squarecloud.app/dashboard/logs/...')
19+
print(
20+
full_logs) # FullLogsData(logs='https://squarecloud.app/dashboard/logs/...')
2021
print(full_logs.logs) # 'https://squarecloud.app/dashboard/logs/...'
2122

2223
status = await client.app_status(app_id) # StatusData(...)
23-
24+
2425
print(status.ram) # '70MB'
2526
print(status.cpu) # '5%'
2627
print(status.requests) # 0
@@ -29,6 +30,7 @@ async def example():
2930
print(status.storage) # '0MB'
3031

3132
````
33+
3234
## Managing your application
3335

3436
````python
@@ -42,23 +44,99 @@ app_id = 'application id'
4244

4345

4446
async def example():
45-
start = await client.start_app(app_id) # Response(success)
46-
stop = await client.stop_app(app_id) # Response(success)
47-
restart = await client.restart_app(app_id) # Response(success)
47+
start = await client.start_app(app_id)
48+
print(start) # Response(success)
49+
50+
stop = await client.stop_app(app_id)
51+
print(stop) # Response(success)
52+
53+
restart = await client.restart_app(app_id)
54+
print(restart) # Response(success)
55+
4856
commit = await client.commit(app_id, file=square.File('path/to/your/file'))
49-
57+
5058
backup = await client.backup(app_id) # BackupData(downloadURL='https://squarecloud.app/dashboard/backup/123.zip')
5159
print(backup.downloadURL) # 'https://squarecloud.app/dashboard/backup/123.zip'
52-
53-
60+
5461
# [WARNING] this will delete your app, remember to have some backup saved
5562
delete = await client.delete_app(app_id) # Response(success)
5663
````
64+
65+
## Files managing
66+
67+
you can manage your application files easily, let's see some examples
68+
69+
### Obtaining file list:
70+
71+
```python
72+
import squarecloud as square
73+
74+
client = square.Client(api_key='API KEY')
75+
76+
77+
async def example():
78+
files_list = await client.app_files_list(app_id='application_id', path='/') # [FileInfo(...), FileInfo(...), FileInfo(...)]
79+
80+
first_file = files_list[0]
81+
print(first_file.name) # 'main.py'
82+
print(first_file.type) # 'directory' or 'file'
83+
print(first_file.size) # 2140
84+
print(first_file.lastModified) # 1677112835000
85+
```
86+
87+
### Reading a file:
88+
89+
`await app.read_file(path)` returns the bytes of your file
90+
91+
```python
92+
import squarecloud as square
93+
94+
client = square.Client(api_key='API KEY')
95+
96+
97+
async def example():
98+
file_bytes = await client.read_app_file(app_id='application_id', path='main.py')
99+
print(file_bytes) # b'01101111 01101001'
100+
```
101+
102+
### Creating a file:
103+
104+
`await app.create_file()` creates a file in the specified directory
105+
106+
```python
107+
import squarecloud as square
108+
109+
client = square.Client(api_key='API KEY')
110+
111+
112+
async def example():
113+
await client.create_app_file(
114+
app_id='application_id',
115+
path='/file.txt',
116+
file=square.File('file.txt')
117+
)
118+
```
119+
120+
### Deleting a file:
121+
122+
```python
123+
import squarecloud as square
124+
125+
client = square.Client(api_key='API KEY')
126+
127+
128+
async def example():
129+
await client.delete_app_file(app_id='application_id', path='/file.txt')
130+
```
131+
57132
___
133+
58134
### Debug mode
135+
59136
Every time a request is made logs are displayed in the terminal containing
60137
useful information, You can disable this by setting the `debug` parameter to
61138
False for the client, this value by default is True.
139+
62140
````py
63141
import squarecloud as square
64142

0 commit comments

Comments
 (0)