|
14 | 14 | from squarecloud.data import ( |
15 | 15 | AppData, |
16 | 16 | BackupData, |
| 17 | + DeployData, |
| 18 | + DomainAnalytics, |
17 | 19 | LogsData, |
18 | 20 | StatusData, |
19 | 21 | UploadData, |
@@ -88,7 +90,7 @@ async def get_app_status(ctx: Context): |
88 | 90 |
|
89 | 91 | table = Table(title='Status', header_style='purple') |
90 | 92 |
|
91 | | - status_list = status.__slots__ |
| 93 | + status_list = status.to_dict() |
92 | 94 | for s in status_list: |
93 | 95 | table.add_column(s.capitalize(), justify='center') |
94 | 96 | table.add_row( |
@@ -158,7 +160,7 @@ async def app_data(ctx: Context): |
158 | 160 | data: AppData = await client.app_data(app_id) |
159 | 161 | table = Table(title='Status', header_style='purple') |
160 | 162 |
|
161 | | - status_list = data.__slots__ |
| 163 | + status_list = data.to_dict() |
162 | 164 | for s in status_list: |
163 | 165 | table.add_column(s.capitalize(), justify='center') |
164 | 166 | table.add_row( |
@@ -329,3 +331,98 @@ async def commit(ctx: Context, file: BufferedReader): |
329 | 331 | style='green', |
330 | 332 | ) |
331 | 333 | ) |
| 334 | + |
| 335 | + |
| 336 | +@app_group.command(name='last-deploys') |
| 337 | +@click.pass_context |
| 338 | +@run_async |
| 339 | +async def last_deploys(ctx: Context): |
| 340 | + with Console().status('loading'): |
| 341 | + client: Client = ctx.obj['client'] |
| 342 | + app_id = ctx.obj['app_id'] |
| 343 | + deploys: list[list[DeployData]] = await client.last_deploys(app_id) |
| 344 | + if not deploys: |
| 345 | + print( |
| 346 | + Panel( |
| 347 | + 'You do not have any recent deploys for this application', |
| 348 | + title='No deploys', |
| 349 | + title_align='left', |
| 350 | + style='red', |
| 351 | + ), |
| 352 | + ) |
| 353 | + return |
| 354 | + for deploy in deploys: |
| 355 | + table = Table(header_style='purple') |
| 356 | + |
| 357 | + attr_list = deploy[0].__dict__ |
| 358 | + for s in attr_list: |
| 359 | + table.add_column(s.capitalize(), justify='center') |
| 360 | + |
| 361 | + for d in deploy: |
| 362 | + table.add_row( |
| 363 | + *[str(getattr(d, attr)) for attr in attr_list], |
| 364 | + style='green', |
| 365 | + ) |
| 366 | + |
| 367 | + print(table) |
| 368 | + |
| 369 | + |
| 370 | +@app_group.command(name='github-integration') |
| 371 | +@click.argument('access_token', type=click.STRING) |
| 372 | +@click.pass_context |
| 373 | +@run_async |
| 374 | +async def github_integration(ctx: Context, access_token: str): |
| 375 | + with Console().status('loading'): |
| 376 | + client: Client = ctx.obj['client'] |
| 377 | + app_id = ctx.obj['app_id'] |
| 378 | + webhook_url: str = await client.github_integration( |
| 379 | + app_id, access_token |
| 380 | + ) |
| 381 | + print( |
| 382 | + Panel( |
| 383 | + webhook_url, |
| 384 | + title='Webhook url', |
| 385 | + border_style='purple', |
| 386 | + style='green', |
| 387 | + ) |
| 388 | + ) |
| 389 | + |
| 390 | + |
| 391 | +@app_group.command(name='custom-domain') |
| 392 | +@click.argument('domain', type=click.STRING) |
| 393 | +@click.pass_context |
| 394 | +@run_async |
| 395 | +async def custom_domain(ctx: Context, domain: str): |
| 396 | + with Console().status('loading'): |
| 397 | + client: Client = ctx.obj['client'] |
| 398 | + app_id = ctx.obj['app_id'] |
| 399 | + await client.set_custom_domain(app_id, domain) |
| 400 | + print( |
| 401 | + Panel( |
| 402 | + f'Domain defined to "{domain}"', |
| 403 | + title='Success', |
| 404 | + border_style='purple', |
| 405 | + style='green', |
| 406 | + ) |
| 407 | + ) |
| 408 | + |
| 409 | + |
| 410 | +@app_group.command(name='domain-analytics') |
| 411 | +@click.pass_context |
| 412 | +@run_async |
| 413 | +async def domain_analytics(ctx: Context): |
| 414 | + with Console().status('loading'): |
| 415 | + client: Client = ctx.obj['client'] |
| 416 | + app_id = ctx.obj['app_id'] |
| 417 | + analytics: DomainAnalytics = await client.domain_analytics(app_id) |
| 418 | + table = Table(title='Status', header_style='purple') |
| 419 | + |
| 420 | + attr_list = analytics.to_dict() |
| 421 | + for s in attr_list: |
| 422 | + table.add_column(s.capitalize(), justify='center') |
| 423 | + table.add_row( |
| 424 | + *[str(getattr(analytics, attr)) for attr in attr_list], |
| 425 | + style='green', |
| 426 | + ) |
| 427 | + |
| 428 | + print(table) |
0 commit comments