diff --git a/README.md b/README.md index 38d6504..e01520e 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ # MS Graph for SharePoint Publisher: Splunk -Connector Version: 1.3.0 +Connector Version: 1.4.0 Product Vendor: Microsoft Product Name: SharePoint Product Version Supported (regex): ".\*" -Minimum Product Version: 6.1.0 +Minimum Product Version: 6.1.1 This app connects to SharePoint using the MS Graph API to support investigate and generic actions @@ -149,13 +149,16 @@ VARIABLE | REQUIRED | TYPE | DESCRIPTION -------- | -------- | ---- | ----------- **tenant_id** | required | string | Tenant ID **site_id** | optional | string | SharePoint Site ID -**endpoint_test_connectivity** | optional | string | Endpoint for test connectivity +**endpoint_test_connectivity** | optional | string | Endpoint for test connectivity (Valid format: /sites/{hostname}:/{site-server-relative-url}) **admin_consent** | optional | boolean | Admin Consent Already Provided **client_id** | required | string | Client/Application ID **client_secret** | required | password | Client Secret ### Supported Actions [test connectivity](#action-test-connectivity) - Validate the asset configuration for connectivity using supplied configuration +[copy drive item](#action-copy-drive-item) - Using SharePoint Site ID app config value, and given source_drive_id, copy source_item_id into a folder identified with dest values +[create folder](#action-create-folder) - Create new Drive item Folder using SharePoint site in asset config and provided Parent Item ID +[list drive children](#action-list-drive-children) - List the items in a drive folder by drive ID or search for a specific file name if provided [list sites](#action-list-sites) - Fetch the details of the SharePoint sites [list lists](#action-list-lists) - Fetch the available lists under a SharePoint site [get list](#action-get-list) - Retrieves a list from a SharePoint Site @@ -176,6 +179,148 @@ No parameters are required for this action #### Action Output No Output +## action: 'copy drive item' +Using SharePoint Site ID app config value, and given source_drive_id, copy source_item_id into a folder identified with dest values + +Type: **generic** +Read only: **False** + +While copying the file if file_name is provided without file extension, the copied file will not have any extension. + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**source_item_id** | required | ID for drive item that needs to be copied | string | `sharepoint drive item id` +**dest_drive_id** | required | Drive ID that contains target folder to copy item to | string | `sharepoint drive id` +**dest_folder_id** | required | ID of target folder to copy drive item to | string | `sharepoint drive item id` +**file_name** | optional | Optional new folder/file name for the copy. If not provided will use the original name | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.dest_drive_id | string | `sharepoint drive id` | b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi +action_result.parameter.dest_folder_id | string | `sharepoint drive item id` | 01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62 +action_result.parameter.file_name | string | | test_file_name +action_result.parameter.source_item_id | string | `sharepoint drive item id` | 01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62 +action_result.data | string | | +action_result.summary | string | | +action_result.message | string | | Successfully copied an item +summary.total_objects | numeric | | 1 +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'create folder' +Create new Drive item Folder using SharePoint site in asset config and provided Parent Item ID + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**parent_item_id** | required | Parent Drive Item ID | string | `sharepoint drive item id` +**folder_name** | required | Name of newly created folder | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.folder_name | string | | Test_folder +action_result.parameter.parent_item_id | string | `sharepoint drive item id` | 01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62 +action_result.data.\*.@odata.context | string | | https://test.microsoft.com/v1.0/$metadata#sites('test.sharepoint.com%2Cdc6f43e9-54fa-4a39-8783-314e3bbbed41%2Cc42b48c4-59b9-48f1-b96e-e8145b5539fa')/drive/items('01SNFLYIVBMJQZCZK6ZFAZ5PVEXODNRV3N')/children/$entity +action_result.data.\*.@odata.etag | string | | "{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},1" +action_result.data.\*.cTag | string | | "c:{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},0" +action_result.data.\*.commentSettings.commentingDisabled.isDisabled | boolean | | True False +action_result.data.\*.createdBy.application.displayName | string | | sharepoint_test +action_result.data.\*.createdBy.application.id | string | | 71b307af-1dcb-4e39-9640-5129afc83162 +action_result.data.\*.createdBy.user.displayName | string | | SharePoint App +action_result.data.\*.createdDateTime | string | | 2023-10-25T08:55:48Z +action_result.data.\*.eTag | string | | "{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},1" +action_result.data.\*.fileSystemInfo.createdDateTime | string | | 2023-10-25T08:55:48Z +action_result.data.\*.fileSystemInfo.lastModifiedDateTime | string | | 2023-10-25T08:55:48Z +action_result.data.\*.folder.childCount | numeric | | 0 +action_result.data.\*.id | string | `sharepoint drive item id` | +action_result.data.\*.lastModifiedBy.application.displayName | string | | sharepoint_test +action_result.data.\*.lastModifiedBy.application.id | string | | 71b307af-1dcb-4e39-9640-5129afc83162 +action_result.data.\*.lastModifiedBy.user.displayName | string | | SharePoint App +action_result.data.\*.lastModifiedDateTime | string | | 2023-10-25T08:55:48Z +action_result.data.\*.name | string | | test2 +action_result.data.\*.parentReference.driveId | string | `sharepoint drive id` | b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi +action_result.data.\*.parentReference.driveType | string | | documentLibrary +action_result.data.\*.parentReference.id | string | `sharepoint drive item id` | 01SNFLYIVBMJQZCZK6ZFAZ5PVEXODNRV3N +action_result.data.\*.parentReference.path | string | | /drives/b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi/root:/SizeTest-Playbook-Don't Delete +action_result.data.\*.parentReference.sharepointIds.listId | string | | 498fd15d-ef79-4c0b-8ac4-c4ea27ed8be2 +action_result.data.\*.parentReference.sharepointIds.listItemUniqueId | string | | 916162a1-5e65-41c9-9ebe-a4bb86d8d76d +action_result.data.\*.parentReference.sharepointIds.siteId | string | | dc6f43e9-54fa-4a39-8783-314e3bbbed41 +action_result.data.\*.parentReference.sharepointIds.siteUrl | string | `url` | https://test.sharepoint.com/sites/TestSite +action_result.data.\*.parentReference.sharepointIds.tenantId | string | | 140fe46d-819d-4b6d-b7ef-1c0a8270f4f0 +action_result.data.\*.parentReference.sharepointIds.webId | string | | c42b48c4-59b9-48f1-b96e-e8145b5539fa +action_result.data.\*.shared.scope | string | | unknown +action_result.data.\*.size | numeric | | 0 +action_result.data.\*.webUrl | string | `url` | +action_result.summary | string | | +action_result.message | string | | Successfully created a folder +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'list drive children' +List the items in a drive folder by drive ID or search for a specific file name if provided + +Type: **investigate** +Read only: **True** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**drive_id** | required | ID of drive to list | string | `sharepoint drive id` + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.drive_id | string | `sharepoint drive id` | b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi +action_result.data.\*.@microsoft.graph.downloadUrl | string | `url` | https://test.sharepoint.com/sites/Test/_layouts/15/download.aspx?UniqueId=d5bfdd47-e0e8-4a7e-99a3-c96f30191b12&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvcGhhbnRvbWVuZ2luZWVyaW5nMi5zaGFyZXBvaW50LmNvbUAxNDBmZTQ2ZC04MTlkLTRiNmQtYjdlZi0xYzBhODI3MGY0ZjAiLCJpc3MiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAiLCJuYmYiOiIxNjk5MjU1NDY4IiwiZXhwIjoiMTY5OTI1OTA2OCIsImVuZHBvaW50dXJsIjoiM1hObzdUK3U4YnFXUU1DTko0OXdiQXVDZ01ad0FNRDh3ckZvVC9yWkxKbz0iLCJlbmRwb2ludHVybExlbmd0aCI6IjE0OCIsImlzbG9vcGJhY2siOiJUcnVlIiwiY2lkIjoiUS9ZVVdDcFQvMEsrQThFOWtxeEIvQT09IiwidmVyIjoiaGFzaGVkcHJvb2Z0b2tlbiIsInNpdGVpZCI6IlpHTTJaalF6WlRrdE5UUm1ZUzAwWVRNNUxUZzNPRE10TXpFMFpUTmlZbUpsWkRReCIsImFwcF9kaXNwbGF5bmFtZSI6ImlnaGVsYW5pX3NoYXJlcG9pbnRfdGVzdCIsIm5hbWVpZCI6IjcxYjMwN2FmLTFkY2ItNGUzOS05NjQwLTUxMjlhZmM4MzE2MkAxNDBmZTQ2ZC04MTlkLTRiNmQtYjdlZi0xYzBhODI3MGY0ZjAiLCJyb2xlcyI6ImFsbGZpbGVzLndyaXRlIHNlbGVjdGVkc2l0ZXMgZ3JvdXAucmVhZCBhbGxzaXRlcy5yZWFkIGFsbHNpdGVzLndyaXRlIGdyb3VwLndyaXRlIGFsbGZpbGVzLnJlYWQgYWxsc2l0ZXMuZnVsbGNvbnRyb2wgYWxscHJvZmlsZXMucmVhZCIsInR0IjoiMSIsImlwYWRkciI6IjQwLjEyNi40LjQwIn0.y13AkyxdRPgziPhIV8_FFBGjtZGHgNpgkW0GU7MMUfA&ApiVersion=2.0 +action_result.data.\*.image.width | numeric | | 1752 +action_result.data.\*.image.height | numeric | | 1244 +action_result.data.\*.cTag | string | | "c:{E1E93D43-F034-489F-8304-BAF7F064A30D},0" +action_result.data.\*.createdBy.application.displayName | string | | Yammer +action_result.data.\*.createdBy.application.id | string | | 00000005-0000-0ff1-ce00-000000000000 +action_result.data.\*.createdBy.user.displayName | string | | SharePoint App +action_result.data.\*.createdBy.user.email | string | | test@gmail.com +action_result.data.\*.createdBy.user.id | string | | eeb3645f-df19-47a1-8e8c-fcd234cb5f6f +action_result.data.\*.createdDateTime | string | | 2020-07-28T20:15:33Z +action_result.data.\*.decorator.iconColor | string | | darkGreen +action_result.data.\*.eTag | string | | "{E1E93D43-F034-489F-8304-BAF7F064A30D},1" +action_result.data.\*.file.hashes.quickXorHash | string | | 8JpxaQB3wX1/FkQ5Gt3prUbUUFU= +action_result.data.\*.file.mimeType | string | | application/vnd.ms-excel +action_result.data.\*.fileSystemInfo.createdDateTime | string | | 2020-07-28T20:15:33Z +action_result.data.\*.fileSystemInfo.lastModifiedDateTime | string | | 2020-07-28T20:15:33Z +action_result.data.\*.folder.childCount | numeric | | 1 +action_result.data.\*.id | string | `sharepoint drive item id` | +action_result.data.\*.lastModifiedBy.application.displayName | string | | Yammer +action_result.data.\*.lastModifiedBy.application.id | string | | 00000005-0000-0ff1-ce00-000000000000 +action_result.data.\*.lastModifiedBy.user.displayName | string | | SharePoint App +action_result.data.\*.lastModifiedBy.user.email | string | | test@gmail.com +action_result.data.\*.lastModifiedBy.user.id | string | | eeb3645f-df19-47a1-8e8c-fcd234cb5f6f +action_result.data.\*.lastModifiedDateTime | string | | 2020-07-28T20:15:33Z +action_result.data.\*.name | string | | +action_result.data.\*.parentReference.driveId | string | `sharepoint drive id` | b!P_PLxcYmjkiP68Fx-chtHkdhtZd0TeZPokKrsyopCWbKblNpI0pzRa5Mk398L4cc +action_result.data.\*.parentReference.driveType | string | | documentLibrary +action_result.data.\*.parentReference.id | string | `sharepoint drive item id` | 01WJINUWV6Y2GOVW7725BZO354PWSELRRZ +action_result.data.\*.parentReference.name | string | | Shared Documents +action_result.data.\*.parentReference.path | string | | /drives/b!P_PLxcYmjkiP68Fx-chtHkdhtZd0TeZPokKrsyopCWbKblNpI0pzRa5Mk398L4cc/root: +action_result.data.\*.parentReference.siteId | string | | c5cbf33f-26c6-488e-8feb-c171f9c86d1e +action_result.data.\*.shared.scope | string | | users +action_result.data.\*.size | numeric | | 775 +action_result.data.\*.specialFolder.name | string | | apps +action_result.data.\*.webUrl | string | `url` | +action_result.summary.drive_children_count | numeric | | 2 +action_result.message | string | | Drive children count: 2 +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + ## action: 'list sites' Fetch the details of the SharePoint sites @@ -197,6 +342,7 @@ action_result.parameter.limit | numeric | | 500 action_result.data.\*.createdDateTime | string | | 2016-10-31T20:25:06Z action_result.data.\*.displayName | string | | Test Site Name action_result.data.\*.id | string | | tenant-name.sharepoint.com,595384ee-13aa-49d1-814b-00ed3e024cde,70abfe37-8aa1-4168-b83e-41b6e9721509 +action_result.data.\*.isPersonalSite | boolean | | True False action_result.data.\*.lastModifiedDateTime | string | | 2022-02-16T12:12:25.9162131Z action_result.data.\*.name | string | | Test Site Name action_result.data.\*.siteCollection.hostname | string | `host name` | tenant-name.sharepoint.com @@ -413,8 +559,9 @@ action_result.data.\*.eTag | string | | action_result.data.\*.fields.@odata.etag | string | | action_result.data.\*.fields.AppAuthorLookupId | string | | action_result.data.\*.fields.AppEditorLookupId | string | | +action_result.data.\*.fields.Approved | boolean | | True False action_result.data.\*.fields.AssetType | string | | Laptop -action_result.data.\*.fields.Attachments | numeric | | +action_result.data.\*.fields.Attachments | boolean | | True False action_result.data.\*.fields.AuthorLookupId | string | | action_result.data.\*.fields.Color | string | | Color of the Asset action_result.data.\*.fields.Complete | boolean | | False @@ -440,6 +587,7 @@ action_result.data.\*.fields.PurchasePrice | numeric | | 1 action_result.data.\*.fields.SerialNumber | string | | Test-SerialNumber-Asset action_result.data.\*.fields.Status | string | | Status of the Asset action_result.data.\*.fields.Title | string | | Test Title +action_result.data.\*.fields.TravelDuration | string | | 0 action_result.data.\*.fields._ComplianceFlags | string | | action_result.data.\*.fields._ComplianceTag | string | | action_result.data.\*.fields._ComplianceTagUserId | string | | @@ -491,7 +639,7 @@ action_result.data.\*.fields.@odata.etag | string | | action_result.data.\*.fields.AppAuthorLookupId | string | | action_result.data.\*.fields.AppEditorLookupId | string | | action_result.data.\*.fields.AssetType | string | | Mobile -action_result.data.\*.fields.Attachments | numeric | | +action_result.data.\*.fields.Attachments | boolean | | True False action_result.data.\*.fields.AuthorLookupId | string | | action_result.data.\*.fields.Color | string | | Red action_result.data.\*.fields.ConditionNotes | string | | Note for the Updated Asset @@ -557,6 +705,8 @@ action_result.parameter.file_name | string | | test_file_name.txt action_result.parameter.file_path | string | | /test_folder_name/ action_result.data.\*.@microsoft.graph.downloadUrl | string | `url` | https://test-tenant-name.sharepoint.com/sites/TestSiteName/_layouts/15/download.aspx?UniqueId=c743b2e0-36ec-4c8a-9ce0-190c2fd4dd97&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJub0&ApiVersion=2.0 action_result.data.\*.@odata.context | string | `url` | https://graph.test.com/v1.0/$metadata#sites('tenant-name.sharepoint.com%2Cdc6f43e9-54fa-4a39-8783-314e3bbbed41%2Cc42b48c4-59b9-48f1-b96e-e8145b5539fb')/drive/root/$entity +action_result.data.\*.image.width | numeric | | 256 +action_result.data.\*.image.height | numeric | | 266 action_result.data.\*.cTag | string | | "c:{C743B2E0-36EB-4C9A-9CE0-190C2FD4DD97},1" action_result.data.\*.createdBy.user.displayName | string | | Test User action_result.data.\*.createdBy.user.email | string | `email` | test_user@tenant-name.ontest.com @@ -567,16 +717,19 @@ action_result.data.\*.file.hashes.quickXorHash | string | | EIDYEgye8dEx3XhA7 action_result.data.\*.file.mimeType | string | | text/plain action_result.data.\*.fileSystemInfo.createdDateTime | string | | 2022-02-10T15:25:21Z action_result.data.\*.fileSystemInfo.lastModifiedDateTime | string | | 2022-02-10T15:25:21Z -action_result.data.\*.id | string | | 01SNFLYIXAWJB4P2ZWTJGJZYAZBQX5JXMX +action_result.data.\*.id | string | `sharepoint drive item id` | 01SNFLYIXAWJB4P2ZWTJGJZYAZBQX5JXMX action_result.data.\*.lastModifiedBy.user.displayName | string | | Test User action_result.data.\*.lastModifiedBy.user.email | string | `email` | test_user@tenant-name.ontest.com action_result.data.\*.lastModifiedBy.user.id | string | | eeb3645f-df19-47a1-8e8c-fcd234cb5f6f action_result.data.\*.lastModifiedDateTime | string | | 2022-02-10T15:25:21Z action_result.data.\*.name | string | | test_file_name.txt -action_result.data.\*.parentReference.driveId | string | | b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi +action_result.data.\*.parentReference.driveId | string | `sharepoint drive id` | b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi action_result.data.\*.parentReference.driveType | string | | documentLibrary -action_result.data.\*.parentReference.id | string | | 01SNFLYIRDSQLQVWP7EVDKSL3YYUNW6I4G +action_result.data.\*.parentReference.id | string | `sharepoint drive item id` | 01SNFLYIRDSQLQVWP7EVDKSL3YYUNW6I4G +action_result.data.\*.parentReference.name | string | | Playbook-Folder action_result.data.\*.parentReference.path | string | | /drive/root:/test_folder_name +action_result.data.\*.parentReference.siteId | string | | dc6f43e9-54fa-4a39-8783-314e3bbbed41 +action_result.data.\*.shared.scope | string | | users action_result.data.\*.size | numeric | | 1422 action_result.data.\*.webUrl | string | `url` | https://test-tenant-name.sharepoint.com/sites/TestSiteName/Shared%20Documents/test_folder_name/test_file_name.txt action_result.summary.vault_id | string | `sha1` `vault id` | 8b11ac28c0e276a4f9fa8a2fd2a17b499a415786 diff --git a/msgraphforsharepoint.json b/msgraphforsharepoint.json index 84316fd..20d2570 100644 --- a/msgraphforsharepoint.json +++ b/msgraphforsharepoint.json @@ -11,20 +11,23 @@ "product_version_regex": ".*", "publisher": "Splunk", "license": "Copyright (c) 2022-2023 Splunk Inc.", - "app_version": "1.3.0", + "app_version": "1.4.0", "utctime_updated": "2022-02-11T08:37:12.891220Z", "package_name": "phantom_msgraphforsharepoint", "main_module": "msgraphforsharepoint_connector.py", "rest_handler": "msgraphforsharepoint_connector.handle_request", "fips_compliant": true, - "min_phantom_version": "6.1.0", + "min_phantom_version": "6.1.1", "contributors": [ { "name": "import-au" + }, + { + "name": "Chris Hutto" } ], "latest_tested_versions": [ - "SharePoint Cloud: 20 September, 2023" + "SharePoint Cloud: 18 December, 2023" ], "app_wizard_version": "1.0.0", "configuration": { @@ -40,7 +43,7 @@ "order": 1 }, "endpoint_test_connectivity": { - "description": "Endpoint for test connectivity", + "description": "Endpoint for test connectivity (Valid format: /sites/{hostname}:/{site-server-relative-url})", "data_type": "string", "order": 2, "default": "/sites/root" @@ -74,6 +77,793 @@ "read_only": true, "versions": "EQ(*)" }, + { + "action": "copy drive item", + "identifier": "copy_drive_item", + "description": "Using SharePoint Site ID app config value, and given source_drive_id, copy source_item_id into a folder identified with dest values", + "verbose": "While copying the file if file_name is provided without file extension, the copied file will not have any extension.", + "type": "generic", + "read_only": false, + "parameters": { + "source_item_id": { + "description": "ID for drive item that needs to be copied", + "data_type": "string", + "required": true, + "order": 0, + "contains": [ + "sharepoint drive item id" + ], + "primary": true + }, + "dest_drive_id": { + "description": "Drive ID that contains target folder to copy item to", + "data_type": "string", + "required": true, + "order": 1, + "primary": true, + "contains": [ + "sharepoint drive id" + ] + }, + "dest_folder_id": { + "description": "ID of target folder to copy drive item to", + "data_type": "string", + "required": true, + "order": 2, + "contains": [ + "sharepoint drive item id" + ], + "primary": true + }, + "file_name": { + "description": "Optional new folder/file name for the copy. If not provided will use the original name", + "data_type": "string", + "order": 3 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 0, + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.dest_drive_id", + "data_type": "string", + "example_values": [ + "b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi" + ], + "contains": [ + "sharepoint drive id" + ] + }, + { + "data_path": "action_result.parameter.dest_folder_id", + "data_type": "string", + "example_values": [ + "01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.parameter.file_name", + "data_type": "string", + "example_values": [ + "test_file_name" + ] + }, + { + "data_path": "action_result.parameter.source_item_id", + "data_type": "string", + "example_values": [ + "01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data", + "data_type": "string" + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Successfully copied an item" + ] + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "create folder", + "identifier": "create_folder", + "description": "Create new Drive item Folder using SharePoint site in asset config and provided Parent Item ID", + "type": "generic", + "read_only": false, + "parameters": { + "parent_item_id": { + "description": "Parent Drive Item ID", + "data_type": "string", + "required": true, + "order": 0, + "contains": [ + "sharepoint drive item id" + ], + "primary": true + }, + "folder_name": { + "description": "Name of newly created folder", + "data_type": "string", + "required": true, + "order": 1 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.folder_name", + "data_type": "string", + "column_name": "Created Folder Name", + "column_order": 0, + "example_values": [ + "Test_folder" + ] + }, + { + "data_path": "action_result.parameter.parent_item_id", + "data_type": "string", + "example_values": [ + "01WJINUWTOBQ2QUVMHZ5E2XPKITGJIST62" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.@odata.context", + "data_type": "string", + "example_values": [ + "https://test.microsoft.com/v1.0/$metadata#sites('test.sharepoint.com%2Cdc6f43e9-54fa-4a39-8783-314e3bbbed41%2Cc42b48c4-59b9-48f1-b96e-e8145b5539fa')/drive/items('01SNFLYIVBMJQZCZK6ZFAZ5PVEXODNRV3N')/children/$entity" + ] + }, + { + "data_path": "action_result.data.*.@odata.etag", + "data_type": "string", + "example_values": [ + "\"{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},1\"" + ] + }, + { + "data_path": "action_result.data.*.cTag", + "data_type": "string", + "example_values": [ + "\"c:{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},0\"" + ] + }, + { + "data_path": "action_result.data.*.commentSettings.commentingDisabled.isDisabled", + "data_type": "boolean", + "example_values": [ + true, + false + ] + }, + { + "data_path": "action_result.data.*.createdBy.application.displayName", + "data_type": "string", + "example_values": [ + "sharepoint_test" + ] + }, + { + "data_path": "action_result.data.*.createdBy.application.id", + "data_type": "string", + "example_values": [ + "71b307af-1dcb-4e39-9640-5129afc83162" + ] + }, + { + "data_path": "action_result.data.*.createdBy.user.displayName", + "data_type": "string", + "example_values": [ + "SharePoint App" + ] + }, + { + "data_path": "action_result.data.*.createdDateTime", + "data_type": "string", + "example_values": [ + "2023-10-25T08:55:48Z" + ] + }, + { + "data_path": "action_result.data.*.eTag", + "data_type": "string", + "example_values": [ + "\"{24A7DBF0-E193-4E0A-A960-ECF5DB994FFF},1\"" + ] + }, + { + "data_path": "action_result.data.*.fileSystemInfo.createdDateTime", + "data_type": "string", + "example_values": [ + "2023-10-25T08:55:48Z" + ] + }, + { + "data_path": "action_result.data.*.fileSystemInfo.lastModifiedDateTime", + "data_type": "string", + "example_values": [ + "2023-10-25T08:55:48Z" + ] + }, + { + "data_path": "action_result.data.*.folder.childCount", + "data_type": "numeric", + "example_values": [ + 0 + ] + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string", + "column_name": "Created Drive Item ID", + "column_order": 1, + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.application.displayName", + "data_type": "string", + "example_values": [ + "sharepoint_test" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.application.id", + "data_type": "string", + "example_values": [ + "71b307af-1dcb-4e39-9640-5129afc83162" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.user.displayName", + "data_type": "string", + "example_values": [ + "SharePoint App" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedDateTime", + "data_type": "string", + "example_values": [ + "2023-10-25T08:55:48Z" + ] + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string", + "example_values": [ + "test2" + ] + }, + { + "data_path": "action_result.data.*.parentReference.driveId", + "data_type": "string", + "example_values": [ + "b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi" + ], + "contains": [ + "sharepoint drive id" + ], + "column_name": "Drive ID", + "column_order": 3 + }, + { + "data_path": "action_result.data.*.parentReference.driveType", + "data_type": "string", + "example_values": [ + "documentLibrary" + ] + }, + { + "data_path": "action_result.data.*.parentReference.id", + "data_type": "string", + "example_values": [ + "01SNFLYIVBMJQZCZK6ZFAZ5PVEXODNRV3N" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.parentReference.path", + "data_type": "string", + "example_values": [ + "/drives/b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi/root:/SizeTest-Playbook-Don't Delete" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.listId", + "data_type": "string", + "example_values": [ + "498fd15d-ef79-4c0b-8ac4-c4ea27ed8be2" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.listItemUniqueId", + "data_type": "string", + "example_values": [ + "916162a1-5e65-41c9-9ebe-a4bb86d8d76d" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.siteId", + "data_type": "string", + "example_values": [ + "dc6f43e9-54fa-4a39-8783-314e3bbbed41" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.siteUrl", + "data_type": "string", + "example_values": [ + "https://test.sharepoint.com/sites/TestSite" + ], + "contains": [ + "url" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.tenantId", + "data_type": "string", + "example_values": [ + "140fe46d-819d-4b6d-b7ef-1c0a8270f4f0" + ] + }, + { + "data_path": "action_result.data.*.parentReference.sharepointIds.webId", + "data_type": "string", + "example_values": [ + "c42b48c4-59b9-48f1-b96e-e8145b5539fa" + ] + }, + { + "data_path": "action_result.data.*.shared.scope", + "data_type": "string", + "example_values": [ + "unknown" + ] + }, + { + "data_path": "action_result.data.*.size", + "data_type": "numeric", + "example_values": [ + 0 + ] + }, + { + "data_path": "action_result.data.*.webUrl", + "data_type": "string", + "column_name": "Web URL", + "column_order": 2, + "contains": [ + "url" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Successfully created a folder" + ] + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "list drive children", + "identifier": "list_drive_children", + "description": "List the items in a drive folder by drive ID or search for a specific file name if provided", + "type": "investigate", + "read_only": true, + "parameters": { + "drive_id": { + "description": "ID of drive to list", + "data_type": "string", + "required": true, + "order": 0, + "primary": true, + "contains": [ + "sharepoint drive id" + ] + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.drive_id", + "data_type": "string", + "example_values": [ + "b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi" + ], + "contains": [ + "sharepoint drive id" + ] + }, + { + "data_path": "action_result.data.*.@microsoft.graph.downloadUrl", + "data_type": "string", + "example_values": [ + "https://test.sharepoint.com/sites/Test/_layouts/15/download.aspx?UniqueId=d5bfdd47-e0e8-4a7e-99a3-c96f30191b12&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvcGhhbnRvbWVuZ2luZWVyaW5nMi5zaGFyZXBvaW50LmNvbUAxNDBmZTQ2ZC04MTlkLTRiNmQtYjdlZi0xYzBhODI3MGY0ZjAiLCJpc3MiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAiLCJuYmYiOiIxNjk5MjU1NDY4IiwiZXhwIjoiMTY5OTI1OTA2OCIsImVuZHBvaW50dXJsIjoiM1hObzdUK3U4YnFXUU1DTko0OXdiQXVDZ01ad0FNRDh3ckZvVC9yWkxKbz0iLCJlbmRwb2ludHVybExlbmd0aCI6IjE0OCIsImlzbG9vcGJhY2siOiJUcnVlIiwiY2lkIjoiUS9ZVVdDcFQvMEsrQThFOWtxeEIvQT09IiwidmVyIjoiaGFzaGVkcHJvb2Z0b2tlbiIsInNpdGVpZCI6IlpHTTJaalF6WlRrdE5UUm1ZUzAwWVRNNUxUZzNPRE10TXpFMFpUTmlZbUpsWkRReCIsImFwcF9kaXNwbGF5bmFtZSI6ImlnaGVsYW5pX3NoYXJlcG9pbnRfdGVzdCIsIm5hbWVpZCI6IjcxYjMwN2FmLTFkY2ItNGUzOS05NjQwLTUxMjlhZmM4MzE2MkAxNDBmZTQ2ZC04MTlkLTRiNmQtYjdlZi0xYzBhODI3MGY0ZjAiLCJyb2xlcyI6ImFsbGZpbGVzLndyaXRlIHNlbGVjdGVkc2l0ZXMgZ3JvdXAucmVhZCBhbGxzaXRlcy5yZWFkIGFsbHNpdGVzLndyaXRlIGdyb3VwLndyaXRlIGFsbGZpbGVzLnJlYWQgYWxsc2l0ZXMuZnVsbGNvbnRyb2wgYWxscHJvZmlsZXMucmVhZCIsInR0IjoiMSIsImlwYWRkciI6IjQwLjEyNi40LjQwIn0.y13AkyxdRPgziPhIV8_FFBGjtZGHgNpgkW0GU7MMUfA&ApiVersion=2.0" + ], + "contains": [ + "url" + ] + }, + { + "data_path": "action_result.data.*.image.width", + "data_type": "numeric", + "example_values": [ + 1752 + ] + }, + { + "data_path": "action_result.data.*.image.height", + "data_type": "numeric", + "example_values": [ + 1244 + ] + }, + { + "data_path": "action_result.data.*.cTag", + "data_type": "string", + "example_values": [ + "\"c:{E1E93D43-F034-489F-8304-BAF7F064A30D},0\"" + ] + }, + { + "data_path": "action_result.data.*.createdBy.application.displayName", + "data_type": "string", + "example_values": [ + "Yammer" + ] + }, + { + "data_path": "action_result.data.*.createdBy.application.id", + "data_type": "string", + "example_values": [ + "00000005-0000-0ff1-ce00-000000000000" + ] + }, + { + "data_path": "action_result.data.*.createdBy.user.displayName", + "data_type": "string", + "example_values": [ + "SharePoint App" + ] + }, + { + "data_path": "action_result.data.*.createdBy.user.email", + "data_type": "string", + "example_values": [ + "test@gmail.com" + ] + }, + { + "data_path": "action_result.data.*.createdBy.user.id", + "data_type": "string", + "example_values": [ + "eeb3645f-df19-47a1-8e8c-fcd234cb5f6f" + ] + }, + { + "data_path": "action_result.data.*.createdDateTime", + "data_type": "string", + "example_values": [ + "2020-07-28T20:15:33Z" + ] + }, + { + "data_path": "action_result.data.*.decorator.iconColor", + "data_type": "string", + "example_values": [ + "darkGreen" + ] + }, + { + "data_path": "action_result.data.*.eTag", + "data_type": "string", + "example_values": [ + "\"{E1E93D43-F034-489F-8304-BAF7F064A30D},1\"" + ] + }, + { + "data_path": "action_result.data.*.file.hashes.quickXorHash", + "data_type": "string", + "example_values": [ + "8JpxaQB3wX1/FkQ5Gt3prUbUUFU=" + ] + }, + { + "data_path": "action_result.data.*.file.mimeType", + "data_type": "string", + "example_values": [ + "application/vnd.ms-excel" + ] + }, + { + "data_path": "action_result.data.*.fileSystemInfo.createdDateTime", + "data_type": "string", + "example_values": [ + "2020-07-28T20:15:33Z" + ] + }, + { + "data_path": "action_result.data.*.fileSystemInfo.lastModifiedDateTime", + "data_type": "string", + "example_values": [ + "2020-07-28T20:15:33Z" + ] + }, + { + "data_path": "action_result.data.*.folder.childCount", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string", + "column_name": "Drive Item ID", + "column_order": 0, + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.application.displayName", + "data_type": "string", + "example_values": [ + "Yammer" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.application.id", + "data_type": "string", + "example_values": [ + "00000005-0000-0ff1-ce00-000000000000" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.user.displayName", + "data_type": "string", + "example_values": [ + "SharePoint App" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.user.email", + "data_type": "string", + "example_values": [ + "test@gmail.com" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedBy.user.id", + "data_type": "string", + "example_values": [ + "eeb3645f-df19-47a1-8e8c-fcd234cb5f6f" + ] + }, + { + "data_path": "action_result.data.*.lastModifiedDateTime", + "data_type": "string", + "example_values": [ + "2020-07-28T20:15:33Z" + ] + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string", + "column_name": "Item Name", + "column_order": 1 + }, + { + "data_path": "action_result.data.*.parentReference.driveId", + "data_type": "string", + "example_values": [ + "b!P_PLxcYmjkiP68Fx-chtHkdhtZd0TeZPokKrsyopCWbKblNpI0pzRa5Mk398L4cc" + ], + "contains": [ + "sharepoint drive id" + ], + "column_name": "Drive ID", + "column_order": 3 + }, + { + "data_path": "action_result.data.*.parentReference.driveType", + "data_type": "string", + "example_values": [ + "documentLibrary" + ] + }, + { + "data_path": "action_result.data.*.parentReference.id", + "data_type": "string", + "example_values": [ + "01WJINUWV6Y2GOVW7725BZO354PWSELRRZ" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.parentReference.name", + "data_type": "string", + "example_values": [ + "Shared Documents" + ] + }, + { + "data_path": "action_result.data.*.parentReference.path", + "data_type": "string", + "example_values": [ + "/drives/b!P_PLxcYmjkiP68Fx-chtHkdhtZd0TeZPokKrsyopCWbKblNpI0pzRa5Mk398L4cc/root:" + ] + }, + { + "data_path": "action_result.data.*.parentReference.siteId", + "data_type": "string", + "example_values": [ + "c5cbf33f-26c6-488e-8feb-c171f9c86d1e" + ] + }, + { + "data_path": "action_result.data.*.shared.scope", + "data_type": "string", + "example_values": [ + "users" + ] + }, + { + "data_path": "action_result.data.*.size", + "data_type": "numeric", + "example_values": [ + 775 + ] + }, + { + "data_path": "action_result.data.*.specialFolder.name", + "data_type": "string", + "example_values": [ + "apps" + ] + }, + { + "data_path": "action_result.data.*.webUrl", + "data_type": "string", + "column_name": "Web URL", + "column_order": 2, + "contains": [ + "url" + ] + }, + { + "data_path": "action_result.summary.drive_children_count", + "data_type": "numeric", + "example_values": [ + 2 + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Drive children count: 2" + ] + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, { "action": "list sites", "identifier": "list_sites", @@ -129,6 +919,14 @@ "column_name": "Sharepoint Site ID", "column_order": 1 }, + { + "data_path": "action_result.data.*.isPersonalSite", + "data_type": "boolean", + "example_values": [ + true, + false + ] + }, { "data_path": "action_result.data.*.lastModifiedDateTime", "data_type": "string", @@ -1416,6 +2214,14 @@ "data_path": "action_result.data.*.fields.AppEditorLookupId", "data_type": "string" }, + { + "data_path": "action_result.data.*.fields.Approved", + "data_type": "boolean", + "example_values": [ + true, + false + ] + }, { "data_path": "action_result.data.*.fields.AssetType", "data_type": "string", @@ -1425,7 +2231,11 @@ }, { "data_path": "action_result.data.*.fields.Attachments", - "data_type": "numeric" + "data_type": "boolean", + "example_values": [ + true, + false + ] }, { "data_path": "action_result.data.*.fields.AuthorLookupId", @@ -1569,6 +2379,13 @@ "Test Title" ] }, + { + "data_path": "action_result.data.*.fields.TravelDuration", + "data_type": "string", + "example_values": [ + "0" + ] + }, { "data_path": "action_result.data.*.fields._ComplianceFlags", "data_type": "string" @@ -1800,7 +2617,11 @@ }, { "data_path": "action_result.data.*.fields.Attachments", - "data_type": "numeric" + "data_type": "boolean", + "example_values": [ + true, + false + ] }, { "data_path": "action_result.data.*.fields.AuthorLookupId", @@ -2102,6 +2923,20 @@ "url" ] }, + { + "data_path": "action_result.data.*.image.width", + "data_type": "numeric", + "example_values": [ + 256 + ] + }, + { + "data_path": "action_result.data.*.image.height", + "data_type": "numeric", + "example_values": [ + 266 + ] + }, { "data_path": "action_result.data.*.cTag", "data_type": "string", @@ -2183,7 +3018,10 @@ "example_values": [ "01SNFLYIXAWJB4P2ZWTJGJZYAZBQX5JXMX" ], - "column_name": "Item ID", + "contains": [ + "sharepoint drive item id" + ], + "column_name": "Drive Item ID", "column_order": 0 }, { @@ -2231,7 +3069,12 @@ "data_type": "string", "example_values": [ "b!6UNv3PpUOUqHgzFOO7vtQcRIK8S5WfFIuW7oFFtVOfpd0Y9Jee8LTIrExOon7Yvi" - ] + ], + "contains": [ + "sharepoint drive id" + ], + "column_name": "Drive ID", + "column_order": 3 }, { "data_path": "action_result.data.*.parentReference.driveType", @@ -2245,6 +3088,16 @@ "data_type": "string", "example_values": [ "01SNFLYIRDSQLQVWP7EVDKSL3YYUNW6I4G" + ], + "contains": [ + "sharepoint drive item id" + ] + }, + { + "data_path": "action_result.data.*.parentReference.name", + "data_type": "string", + "example_values": [ + "Playbook-Folder" ] }, { @@ -2254,6 +3107,20 @@ "/drive/root:/test_folder_name" ] }, + { + "data_path": "action_result.data.*.parentReference.siteId", + "data_type": "string", + "example_values": [ + "dc6f43e9-54fa-4a39-8783-314e3bbbed41" + ] + }, + { + "data_path": "action_result.data.*.shared.scope", + "data_type": "string", + "example_values": [ + "users" + ] + }, { "data_path": "action_result.data.*.size", "data_type": "numeric", @@ -2413,7 +3280,7 @@ }, { "module": "soupsieve", - "input_file": "wheels/py3/soupsieve-2.4.1-py3-none-any.whl" + "input_file": "wheels/py3/soupsieve-2.5-py3-none-any.whl" } ] } diff --git a/msgraphforsharepoint_connector.py b/msgraphforsharepoint_connector.py index 1477d27..7570ad5 100644 --- a/msgraphforsharepoint_connector.py +++ b/msgraphforsharepoint_connector.py @@ -29,6 +29,7 @@ from phantom.action_result import ActionResult from phantom.base_connector import BaseConnector from phantom.vault import Vault +from phantom_common import paths from msgraphforsharepoint_consts import * @@ -271,7 +272,7 @@ def _validate_integer(self, action_result, parameter, key, allow_zero=True): return phantom.APP_SUCCESS, parameter def _process_empty_response(self, response, action_result): - if response.status_code in [200, 204]: + if response.status_code in [200, 202, 204]: return RetVal(phantom.APP_SUCCESS, {}) return RetVal( @@ -418,7 +419,8 @@ def _make_rest_call( if hasattr(Vault, 'get_vault_tmp_dir'): fd, tmp_file_path = tempfile.mkstemp(dir=Vault.get_vault_tmp_dir()) else: - fd, tmp_file_path = tempfile.mkstemp(dir='/opt/phantom/vault/tmp') + vault_tmp = os.path.join(paths.PHANTOM_VAULT, "tmp") + fd, tmp_file_path = tempfile.mkstemp(dir=vault_tmp) os.close(fd) r = request_func(endpoint, json=json, data=data, headers=headers, params=params, stream=True) @@ -756,15 +758,106 @@ def _handle_update_item(self, param): return action_result.set_status(phantom.APP_SUCCESS) - def _handle_list_sites(self, param): + def _handle_list_drive_children(self, param): + action_result = self.add_action_result(ActionResult(dict(param))) + + endpoint = MS_DRIVES_ROOT_ENDPOINT.format( + self._site_id + ) + "/{0}/items/root/children".format(param["drive_id"]) + + ret_val, children = self._paginator(action_result, endpoint) + + if phantom.is_fail(ret_val): + return action_result.get_status() + + for child in children: + action_result.add_data(child) + + summary = action_result.update_summary({}) + summary[MS_SHAREPOINT_JSON_DRIVE_CHILDREN_COUNT] = action_result.get_data_size() + + return action_result.set_status(phantom.APP_SUCCESS) + def _handle_copy_drive_item(self, param): action_result = self.add_action_result(ActionResult(dict(param))) - ret_val, limit = self._validate_integer(action_result, param.get(MS_SHAREPOINT_JSON_LIMIT), MS_SHAREPOINT_LIMIT_KEY, False) + endpoint = MS_DRIVE_ROOT_ENDPOINT.format( + self._site_id + ) + MS_DRIVE_COPY_ITEM_ENDPOINT.format(param["source_item_id"]) + + dest_drive_id = param.get("dest_drive_id", "") + dest_folder_id = param.get("dest_folder_id", "") + file_name = param.get("file_name", "") + + if file_name: + data = { + "parentReference": {"driveId": dest_drive_id, "id": dest_folder_id}, + "name": file_name, + } + else: + data = { + "parentReference": {"driveId": dest_drive_id, "id": dest_folder_id} + } + + payload = json.dumps(data) + + ret_val, response = self._make_rest_call_helper( + method="post", + endpoint=endpoint, + data=payload, + action_result=action_result, + ) + if phantom.is_fail(ret_val): return action_result.get_status() - ret_val, sites = self._paginator(action_result, MS_LIST_SITES_ENDPOINT, limit=limit) + action_result.add_data(response) + + return action_result.set_status(phantom.APP_SUCCESS, "Successfully copied an item") + + def _handle_create_folder(self, param): + action_result = self.add_action_result(ActionResult(dict(param))) + + endpoint = MS_DRIVE_ROOT_ENDPOINT.format( + self._site_id + ) + MS_DRIVE_CREATE_FOLDER_ENDPOINT.format(param["parent_item_id"]) + + data = { + "name": param["folder_name"], + "folder": {}, + "@microsoft.graph.conflictBehavior": "rename", + } + + payload = json.dumps(data) + + ret_val, response = self._make_rest_call_helper( + method="post", + endpoint=endpoint, + data=payload, + action_result=action_result, + ) + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + + return action_result.set_status(phantom.APP_SUCCESS, "Successfully created a folder") + + def _handle_list_sites(self, param): + action_result = self.add_action_result(ActionResult(dict(param))) + + ret_val, limit = self._validate_integer( + action_result, + param.get(MS_SHAREPOINT_JSON_LIMIT), + MS_SHAREPOINT_LIMIT_KEY, + False, + ) + if phantom.is_fail(ret_val): + return action_result.get_status() + + ret_val, sites = self._paginator( + action_result, MS_LIST_SITES_ENDPOINT, limit=limit + ) if phantom.is_fail(ret_val): return action_result.get_status() @@ -911,6 +1004,12 @@ def handle_action(self, param): ret_val = self._handle_add_item(param) elif action_id == "update_item": ret_val = self._handle_update_item(param) + elif action_id == "list_drive_children": + ret_val = self._handle_list_drive_children(param) + elif action_id == "create_folder": + ret_val = self._handle_create_folder(param) + elif action_id == "copy_drive_item": + ret_val = self._handle_copy_drive_item(param) return ret_val diff --git a/msgraphforsharepoint_consts.py b/msgraphforsharepoint_consts.py index c1e5239..1519ab4 100644 --- a/msgraphforsharepoint_consts.py +++ b/msgraphforsharepoint_consts.py @@ -27,6 +27,7 @@ MS_SHAREPOINT_JSON_SITES_COUNT = 'sites_count' MS_SHAREPOINT_JSON_LISTS_COUNT = 'lists_count' MS_SHAREPOINT_JSON_ITEM_COUNT = 'item_count' +MS_SHAREPOINT_JSON_DRIVE_CHILDREN_COUNT = 'drive_children_count' # URLs and Endpoints MS_GRAPH_BASE_URL = 'https://graph.microsoft.com/v1.0' @@ -37,6 +38,10 @@ MS_GET_LIST_ENDPOINT = '/sites/{0}/lists/{1}' MS_GET_FILE_METADATA_ENDPOINT = '/sites/{0}/drive/root:/{1}/{2}' MS_GET_FILE_CONTENT_ENDPOINT = '{0}:/content' +MS_DRIVE_ROOT_ENDPOINT = "/sites/{0}/drive" +MS_DRIVES_ROOT_ENDPOINT = "/sites/{0}/drives" +MS_DRIVE_CREATE_FOLDER_ENDPOINT = "/items/{0}/children" +MS_DRIVE_COPY_ITEM_ENDPOINT = "/items/{0}/copy" # Splunk SOAR Endpoints SOAR_SYS_INFO_URL = "{url}rest/system_info" diff --git a/release_notes/1.4.0.md b/release_notes/1.4.0.md new file mode 100644 index 0000000..3e53d33 --- /dev/null +++ b/release_notes/1.4.0.md @@ -0,0 +1,4 @@ +* Added support for the below new actions: + * copy item + * create folder + * list drive children \ No newline at end of file diff --git a/wheels/py3/soupsieve-2.4.1-py3-none-any.whl b/wheels/py3/soupsieve-2.4.1-py3-none-any.whl deleted file mode 100644 index 26a486c..0000000 Binary files a/wheels/py3/soupsieve-2.4.1-py3-none-any.whl and /dev/null differ diff --git a/wheels/py3/soupsieve-2.5-py3-none-any.whl b/wheels/py3/soupsieve-2.5-py3-none-any.whl new file mode 100644 index 0000000..e1be128 Binary files /dev/null and b/wheels/py3/soupsieve-2.5-py3-none-any.whl differ