diff --git a/.codegen.json b/.codegen.json index da71885..a8d7e4f 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.4.1" } +{ "engineHash": "66f851a", "specHash": "6ca858e", "version": "1.4.1" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a499691..92e59e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,8 @@ jobs: ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }} BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }} BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }} + APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }} + APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }} WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }} run: | tox @@ -73,3 +75,5 @@ jobs: BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }} BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }} WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }} + APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }} + APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }} diff --git a/README.md b/README.md index 99ca2b4..fc23a04 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Now select `Authorization` and submit application to be reviewed by account admi 3. Set environment variable: `JWT_CONFIG_BASE_64` with base64 encoded jwt configuration file 4. Set environment variable: `BOX_FILE_REQUEST_ID` with ID of file request already created in the user account, `BOX_EXTERNAL_USER_EMAIL` with email of free external user which not belongs to any enterprise. 5. Set environment variable: `WORKFLOW_FOLDER_ID` with the ID of the Relay workflow that deletes the file that triggered the workflow. The workflow should have a manual start to be able to start it from the API. +6. Set environment variable: `APP_ITEM_ASSOCIATION_FILE_ID` to the ID of the file with associated app item and `APP_ITEM_ASSOCIATION_FOLDER_ID` to the ID of the folder with associated app item. ### Running tests diff --git a/docs/app_item_associations.md b/docs/app_item_associations.md index 11e5f8f..0426b89 100644 --- a/docs/app_item_associations.md +++ b/docs/app_item_associations.md @@ -16,7 +16,11 @@ This operation is performed by calling function `get_file_app_item_associations` See the endpoint docs at [API Reference](https://developer.box.com/reference/get-files-id-app-item-associations/). -_Currently we don't have an example for calling `get_file_app_item_associations` in integration tests_ + + +```python +client.app_item_associations.get_file_app_item_associations(file_id) +``` ### Arguments @@ -52,7 +56,11 @@ This operation is performed by calling function `get_folder_app_item_association See the endpoint docs at [API Reference](https://developer.box.com/reference/get-folders-id-app-item-associations/). -_Currently we don't have an example for calling `get_folder_app_item_associations` in integration tests_ + + +```python +client.app_item_associations.get_folder_app_item_associations(folder_id) +``` ### Arguments diff --git a/docs/files.md b/docs/files.md index 7c67ab6..0ac0c5a 100644 --- a/docs/files.md +++ b/docs/files.md @@ -18,7 +18,7 @@ See the endpoint docs at ```python -client.files.get_file_by_id(file.id) +client.files.get_file_by_id(file_id, fields=["is_associated_with_app_item"]) ``` ### Arguments diff --git a/docs/folders.md b/docs/folders.md index 885618f..7762890 100644 --- a/docs/folders.md +++ b/docs/folders.md @@ -28,7 +28,7 @@ See the endpoint docs at ```python -client.folders.get_folder_by_id(new_folder.id) +client.folders.get_folder_by_id(folder_id, fields=["is_associated_with_app_item"]) ``` ### Arguments diff --git a/test/app_item_associations.py b/test/app_item_associations.py new file mode 100644 index 0000000..e4a8b70 --- /dev/null +++ b/test/app_item_associations.py @@ -0,0 +1,55 @@ +from box_sdk_gen.internal.utils import to_string + +from box_sdk_gen.client import BoxClient + +from box_sdk_gen.schemas.app_item_associations import AppItemAssociations + +from box_sdk_gen.schemas.app_item_association import AppItemAssociation + +from box_sdk_gen.schemas.file_full import FileFull + +from box_sdk_gen.schemas.folder_full import FolderFull + +from box_sdk_gen.internal.utils import get_uuid + +from box_sdk_gen.internal.utils import get_env_var + +from test.commons import get_default_client_with_user_subject + + +def testListFileAppItemAssocations(): + client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID')) + file_id: str = get_env_var('APP_ITEM_ASSOCIATION_FILE_ID') + file_app_item_associations: AppItemAssociations = ( + client.app_item_associations.get_file_app_item_associations(file_id) + ) + assert len(file_app_item_associations.entries) == 1 + association: AppItemAssociation = file_app_item_associations.entries[0] + assert not association.id == '' + assert to_string(association.app_item.application_type) == 'hubs' + assert to_string(association.app_item.type) == 'app_item' + assert to_string(association.item.type) == 'file' + assert association.item.id == file_id + file: FileFull = client.files.get_file_by_id( + file_id, fields=['is_associated_with_app_item'] + ) + assert file.is_associated_with_app_item == True + + +def testListFolderAppItemAssocations(): + client: BoxClient = get_default_client_with_user_subject(get_env_var('USER_ID')) + folder_id: str = get_env_var('APP_ITEM_ASSOCIATION_FOLDER_ID') + folder_app_item_associations: AppItemAssociations = ( + client.app_item_associations.get_folder_app_item_associations(folder_id) + ) + assert len(folder_app_item_associations.entries) == 1 + association: AppItemAssociation = folder_app_item_associations.entries[0] + assert not association.id == '' + assert to_string(association.app_item.application_type) == 'hubs' + assert to_string(association.app_item.type) == 'app_item' + assert to_string(association.item.type) == 'folder' + assert association.item.id == folder_id + folder: FolderFull = client.folders.get_folder_by_id( + folder_id, fields=['is_associated_with_app_item'] + ) + assert folder.is_associated_with_app_item == True diff --git a/tox.ini b/tox.ini index 155d04e..a9ad267 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ commands = pytest {posargs} --disable-pytest-warnings deps = -rrequirements-test.txt allowlist_externals = pytest -passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID +passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID [testenv:pycodestyle] commands = @@ -45,7 +45,7 @@ commands = deps = coverage -rrequirements-test.txt -passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID +passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID [testenv:py310-build] description = Build the source and binary wheel packages for distribution.