diff --git a/intro/changelog.md b/intro/changelog.md index 6f52a7f..a4a0a63 100644 --- a/intro/changelog.md +++ b/intro/changelog.md @@ -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) post +> +> **Account Operations - User** +> +> - [Get Base Asset Size](/reference/getbaseassetsize) get > 👍 Other changes > diff --git a/tests/test_assets.py b/tests/test_assets.py new file mode 100644 index 0000000..0612ef3 --- /dev/null +++ b/tests/test_assets.py @@ -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, + } diff --git a/user_account_operations.yaml b/user_account_operations.yaml index 0cbce0f..ee4e22f 100644 --- a/user_account_operations.yaml +++ b/user_account_operations.yaml @@ -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: