Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions intro/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Listed below are all the changes to the SeaTable API. Each date corresponds to a
> **Base Operations**
>
> - [Create Row Comment](/reference/createrowcomment) <span class="APIMethod APIMethod_fixedWidth APIMethod_post">post</span>
>
> **Account Operations - User**
>
> - [Get Base Asset Size](/reference/getbaseassetsize) <span class="APIMethod APIMethod_fixedWidth APIMethod_get">get</span>

> 👍 Other changes
>
Expand Down
19 changes: 19 additions & 0 deletions tests/test_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Tests for the base asset endpoints."""

from conftest import Base, Secret, user_account_operations
from schemathesis import Case


def test_getBaseAssetSize(base: Base, account_token: Secret):
"""A base without attachments reports a size of 0 and can be exported with its assets."""
case: Case = user_account_operations.find_operation_by_id('getBaseAssetSize') \
.Case(path_parameters={'base_uuid': base.uuid})
response = case.call(headers={'Authorization': f'Bearer {account_token.value}'})

assert response.status_code == 200
assert response.json() == {
'asset_size': 0,
'max_size_of_export': 100,
'unit': 'mb',
'can_export_asset': True,
}
44 changes: 44 additions & 0 deletions user_account_operations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4142,6 +4142,50 @@ paths:
type: object
example:
success: true
/api/v2.1/dtable-asset/{base_uuid}/asset-size/:
get:
tags:
- Attachment
summary: Get Base Asset Size
operationId: getBaseAssetSize
description: >-
Get the total size of all assets (attachments, images and files) stored
in a base and check whether the base can be exported together with its
assets.

All sizes are given in megabytes, rounded down. `max_size_of_export` is
the server-wide limit configured by the system administrator (default:
100). If `can_export_asset` is `false`, the assets of this base exceed
that limit and the base can only be exported without its assets.
security:
- AccountTokenAuth: []
parameters:
- $ref: "#/components/parameters/base_uuid"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
asset_size:
type: integer
description: Total size of all assets of the base.
max_size_of_export:
type: integer
description: Maximum asset size that can be included in an export.
unit:
type: string
description: Unit of the returned sizes.
can_export_asset:
type: boolean
description: Whether the assets of this base can be included in an export.
example:
asset_size: 0
max_size_of_export: 100
unit: mb
can_export_asset: true
/api/v2.1/dtable-recent-asset/{base_uuid}/:
get:
tags:
Expand Down