diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py index 0d3f2691e4bd..e54df5f49907 100644 --- a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py @@ -39,6 +39,9 @@ 'EXCEPTION_LIST_GENERIC': 'Exception searching for {}: {}', 'EXCEPTION_GENERIC': 'Exception handling a {} request: {}', + 'MODIFY_LABEL_SUCCESS': 'Modify label successfully assigned to {}.', + 'GET_LABEL_SUCCESS': 'Label successfully retrieved.', + 'GET_LABELS_SUCCESS': 'Labels successfully retrieved.', } SCOPES: dict[str, list[str]] = { @@ -98,12 +101,17 @@ 'FILE_PERMISSIONS_CRUD': [ 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file', - ] + ], + 'MODIFY_LABELS_PERMISSIONS_CRUD': [ + 'https://www.googleapis.com/auth/drive', + 'https://www.googleapis.com/auth/drive.labels', + ] } URLS: dict[str, str] = { - 'DRIVE_ACTIVITY': 'https://driveactivity.googleapis.com/v2/activity:query' + 'DRIVE_ACTIVITY': 'https://driveactivity.googleapis.com/v2/activity:query', + 'DRIVE_LABELS': 'https://drivelabels.googleapis.com/v2/labels' } URL_SUFFIX: dict[str, str] = { 'DRIVE_CHANGES': 'drive/v3/changes', @@ -120,6 +128,8 @@ 'FILE_PERMISSION_CREATE': 'drive/v3/files/{}/permissions', 'FILE_PERMISSION_UPDATE': 'drive/v3/files/{}/permissions/{}', 'FILE_PERMISSION_DELETE': 'drive/v3/files/{}/permissions/{}', + 'FILE_MODIFY_LABEL': 'drive/v3/files/{}/modifyLabels', + 'FILE_GET_LABELS': 'drive/v3/files/{}/listLabels' } OUTPUT_PREFIX: dict[str, str] = { @@ -143,6 +153,8 @@ 'GOOGLE_DRIVE_FILE_PERMISSION_HEADER': 'GoogleDrive.FilePermission', 'FILE_PERMISSION': 'FilePermission', + 'LABELS': 'GoogleDrive.Labels' + } DATE_FORMAT: str = '%Y-%m-%d' # sample - 2020-08-23 @@ -1196,6 +1208,102 @@ def file_replace_existing_command(client: 'GSuiteClient', args: dict[str, str]) return handle_response_file_single(file, args) +@logger +def modify_label_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandResults: + modify_label_request_res = prepare_file_modify_labels_request( + client, args, scopes=COMMAND_SCOPES['MODIFY_LABELS_PERMISSIONS_CRUD']) + http_request_params = modify_label_request_res['http_request_params'] + + url_suffix = URL_SUFFIX['FILE_MODIFY_LABEL'].format(args.get('file_id')) + body_request = { + "kind": "drive#modifyLabelsRequest", + "labelModifications": [ + { + "fieldModifications": [ + { + "kind": "drive#labelFieldModification", + "fieldId": args.get('field_id'), + "setSelectionValues": [ + args.get('selection_label_id') + ] + } + ], + "kind": "drive#labelModification", + "labelId": args.get('label_id'), + "removeLabel": args.get('remove_label', False) + } + ] + } + + response = client.http_request(url_suffix=url_suffix, method='POST', params=http_request_params, body=body_request) + + table_hr_md = tableToMarkdown(HR_MESSAGES['MODIFY_LABEL_SUCCESS'].format(args.get('file_id')), + response, + headerTransform=pascalToSpace, + removeNull=False) + outputs_context = { + OUTPUT_PREFIX['LABELS']: response + } + + return CommandResults( + outputs=outputs_context, + raw_response=response, + readable_output=table_hr_md, + ) + + +def get_file_labels_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandResults: + modify_label_request_res = prepare_file_modify_labels_request( + client, args, scopes=COMMAND_SCOPES['MODIFY_LABELS_PERMISSIONS_CRUD']) + http_request_params = modify_label_request_res['http_request_params'] + + url_suffix = URL_SUFFIX['FILE_GET_LABELS'].format(args.get('file_id')) + + response = client.http_request(url_suffix=url_suffix, method='GET', params=http_request_params) + + outputs_context = { + OUTPUT_PREFIX['LABELS']: response, + OUTPUT_PREFIX['GOOGLE_DRIVE_FILE_HEADER']: { + OUTPUT_PREFIX['FILE']: { + 'id': args.get('file_id'), + }, + } + } + + table_hr_md = tableToMarkdown(HR_MESSAGES['GET_LABEL_SUCCESS'].format(args.get('file_id')), + response['labels'], + headerTransform=pascalToSpace, + removeNull=False) + + return CommandResults( + outputs=outputs_context, + readable_output=table_hr_md, + ) + + +def get_labels_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandResults: + modify_label_request_res = prepare_get_labels_request( + client, args, scopes=COMMAND_SCOPES['MODIFY_LABELS_PERMISSIONS_CRUD']) + http_request_params = modify_label_request_res['http_request_params'] + + full_url = URLS['DRIVE_LABELS'] + '?' + urllib.parse.urlencode(http_request_params) + demisto.info(f'full url for get labels is: {full_url}') + response = client.http_request(full_url=full_url, method='GET') + + outputs_context = { + OUTPUT_PREFIX['LABELS']: response + } + + table_hr_md = tableToMarkdown(HR_MESSAGES['GET_LABELS_SUCCESS'], + response['labels'], + headerTransform=pascalToSpace, + removeNull=False) + return CommandResults( + readable_output=table_hr_md, + outputs=outputs_context + ) + + @logger def file_delete_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandResults: """ @@ -1319,6 +1427,37 @@ def prepare_file_permission_request(client: 'GSuiteClient', args: dict[str, str] } +def prepare_file_modify_labels_request(client: 'GSuiteClient', args: dict[str, str], scopes: list[str]) -> dict[str, Any]: + # user_id can be overridden in the args + user_id = args.get('user_id') or client.user_id + client.set_authorized_http(scopes=scopes, subject=user_id) + # Prepare generic HTTP request params + http_request_params: dict[str, str] = assign_params( + fileId=args.get('file_id') + ) + + return { + 'client': client, + 'http_request_params': http_request_params, + 'user_id': user_id, + } + + +def prepare_get_labels_request(client: 'GSuiteClient', args: dict[str, str], scopes: list[str]) -> dict[str, Any]: + # user_id can be overridden in the args + user_id = args.get('user_id') or client.user_id + client.set_authorized_http(scopes=scopes, subject=user_id) + http_request_params: dict[str, str] = assign_params( + view='LABEL_VIEW_FULL' + ) + + return { + 'client': client, + 'http_request_params': http_request_params, + 'user_id': user_id, + } + + @logger def file_permission_list_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandResults: """ @@ -1675,6 +1814,9 @@ def main() -> None: 'google-drive-file-permission-create': file_permission_create_command, 'google-drive-file-permission-update': file_permission_update_command, 'google-drive-file-permission-delete': file_permission_delete_command, + 'google-drive-file-modify-label': modify_label_command, + 'google-drive-get-labels': get_labels_command, + 'google-drive-get-file-labels': get_file_labels_command, } command = demisto.command() @@ -1709,7 +1851,7 @@ def main() -> None: # This is the call made when pressing the integration Test button. if demisto.command() == 'test-module': result = test_module(gsuite_client, demisto.getLastRun(), params) - demisto.results(result) + return_results(result) elif demisto.command() == 'fetch-incidents': incidents, next_run = fetch_incidents(gsuite_client, diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.yml b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.yml index e4b93cc85b0f..b1b7ef955ac7 100644 --- a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.yml +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.yml @@ -2701,7 +2701,288 @@ script: predefined: - "true" - "false" - dockerimage: demisto/googleapi-python3:1.0.0.68850 + - name: google-drive-file-modify-label + description: Modify labels to file. + arguments: + - name: file_id + description: ID of the requested file. Can be retrieved using the `google-drive-files-list` command. + - name: user_id + description: The user's primary email address + - name: label_id + description: The label id to set for the file + - name: field_id + description: the field id of the label to set + - name: selection_label_id + description: the label id to set for the field + - auto: PREDEFINED + defaultValue: "false" + description: 'Whether the requesting application supports both My Drives and shared drives. Possible values: "true" and "false".' + name: remove_label + predefined: + - "true" + - "false" + outputs: + - contextPath: GoogleDrive.Labels.kind + description: 'The type of resource. This is always drive#modifyLabelsResponse' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.fields.id + description: 'The ID of the label field selected' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.fields.kind + description: 'Kind of resource this is, in this case drive#labelField' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.fields.selection + description: 'Selected label.' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.fields.valueType + description: 'The type of data this label is representing.' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.id + description: 'The label id of the label to set' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.kind + description: 'The type of resource. This is always drive#label' + type: String + - contextPath: GoogleDrive.Labels.modifiedLabels.revisionId + description: '' + type: String + - name: google-drive-get-labels + description: Google Drive get labels. + arguments: + - name: user_id + description: The user's primary email address + outputs: + - contextPath: GoogleDrive.Labels.labels.appliedCapabilities.canApply + description: 'Is able to apply this label to files.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.appliedCapabilities.canRead + description: 'Is able to read this label.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.appliedCapabilities.canRemove + description: 'Is able to remove this label from files.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.appliedLabelPolicy.copyMode + description: 'Copy label to all descendants.' + type: String + - contextPath: GoogleDrive.Labels.labels.createTime + description: 'Time at which this label was created.' + type: Date + - contextPath: GoogleDrive.Labels.labels.creator.person + description: 'The creator of this label.' + type: String + - contextPath: GoogleDrive.Labels.labels.customer + description: 'The customer that owns this label.' + type: String + - contextPath: GoogleDrive.Labels.labels.displayHints.priority + description: 'Priority of the label.' + type: String + - contextPath: GoogleDrive.Labels.labels.displayHints.shownInApply + description: 'Whether this label is shown in the "Apply a label" dropdown.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.appliedCapabilities.canRead + description: 'Is the field readable.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.appliedCapabilities.canSearch + description: 'Is the field searchable.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.appliedCapabilities.canWrite + description: 'Is the field writable.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.creator.person + description: 'The creator of this field.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.displayHints.required + description: 'Is this field required to be set by the user.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.displayHints.shownInApply + description: 'Should this field be shown when editing the label.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.id + description: 'The ID of the field.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.lifecycle.state + description: 'The lifecycle state of this field.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.properties.displayName + description: 'The display name of the property.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.properties.required + description: 'Is this property required to be set by the user.' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.publisher.person + description: 'The user who published this field.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.queryKey + description: 'The query key for this field.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.schemaCapabilities + description: 'Schema capabilities for this field.' + type: Unknown + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canRead + description: '' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canSearch + description: '' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canSelect + description: '' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgePriority + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.shownInApply + description: '' + type: Boolean + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.id + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.lifecycle.state + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.blue + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.green + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.red + description: '' + type: Number + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.displayName + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.selectionOptions.choices.schemaCapabilities + description: '' + type: Unknown + - contextPath: GoogleDrive.Labels.labels.fields.updater.person + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.id + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.labelType + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.lifecycle.state + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.name + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.properties.title + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.publishTime + description: '' + type: Date + - contextPath: GoogleDrive.Labels.labels.publisher.person + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.revisionCreateTime + description: '' + type: Date + - contextPath: GoogleDrive.Labels.labels.revisionCreator.person + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.revisionId + description: '' + type: String + - contextPath: GoogleDrive.Labels.labels.schemaCapabilities + description: '' + type: Unknown + - contextPath: GoogleDrive.Labels.labels.fields.userOptions + description: '' + type: Unknown + - name: google-drive-get-file-labels + description: Modify labels to file. + arguments: + - name: file_id + description: ID of the requested file. Can be retrieved using the `google-drive-files-list` command. + - name: user_id + description: The user's primary email address + outputs: + - contextPath: GoogleDrive.File.File.id + description: 'The ID of the file.' + type: String + - contextPath: GoogleDrive.Labels.kind + description: 'The type of resource. This is always drive#labelList' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.id + description: 'The ID of the label field selected' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.kind + description: 'The kind of this field. This is always drive#labelField' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.selection + description: 'The label field selected.' + type: String + - contextPath: GoogleDrive.Labels.labels.fields.valueType + description: 'The type of data this label is representing.' + type: String + - contextPath: GoogleDrive.Labels.labels.id + description: 'The label id of the label to set' + type: String + - contextPath: GoogleDrive.Labels.labels.kind + description: 'The type of resource. This is always drive#label' + type: String + - contextPath: GoogleDrive.Labels.labels.revisionId + description: 'The revision id of the label' + type: String + dockerimage: demisto/googleapi-python3:1.0.0.71902 isfetch: true runonce: false script: "-" diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive_test.py b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive_test.py index d2c3b24f0dd6..9904607848e8 100644 --- a/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive_test.py +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive_test.py @@ -769,6 +769,67 @@ def test_file_permission_list_command_success(self, mocker_http_request, gsuite_ assert result.readable_output.startswith("### Total") assert HR_MESSAGES['LIST_COMMAND_SUCCESS'].format('Permission(s)', 1) in result.readable_output + @patch(MOCKER_HTTP_METHOD) + def test_list_labels(self, mocker_http_request, gsuite_client): + """ + Scenario: For google-drive-list-labels command successful run. + + Given: + - Command args. + + When: + - Calling google-drive-list-labels command with the parameters provided. + + Then: + - Ensure command's raw_response, outputs should be as expected. + """ + from GoogleDrive import get_labels_command + + with open('test_data/list_labels_response.json', encoding='utf-8') as data: + mock_response = json.load(data) + mocker_http_request.return_value = mock_response + + result = get_labels_command(gsuite_client, {}) + + assert 'GoogleDrive.Labels' in result.outputs + assert len(result.outputs['GoogleDrive.Labels']['labels']) == 2 + + @patch(MOCKER_HTTP_METHOD) + def test_modify_labels_command(self, mocker_http_request, gsuite_client): + """ + Scenario: For google-drive-modify-label command successful run. + + Given: + - Command args. + + When: + - Calling google-drive-modify-label command with the parameters provided. + + Then: + - Ensure command's raw_response, outputs should be as expected. + """ + from GoogleDrive import modify_label_command + + with open('test_data/modify_label_command_response.json', encoding='utf-8') as data: + mock_response = json.load(data) + mocker_http_request.return_value = mock_response + + args = { + 'field_id': 'test', + 'selection_label_id': 'test', + 'label_id': 'test', + 'file_id': 'test' + } + result = modify_label_command(gsuite_client, args) + + assert 'modifiedLabels' in result.outputs.get('GoogleDrive.Labels') + assert result.outputs.get('GoogleDrive.Labels').get('modifiedLabels')[0].get('id') \ + == 'vFmXsMA1fQMz1BdE59YSkisZV4DiKdpxxLQRNNEbbFcb' + + assert result.raw_response == mock_response + + assert HR_MESSAGES['MODIFY_LABEL_SUCCESS'].format(args.get('file_id')) in result.readable_output + @patch(MOCKER_HTTP_METHOD) def test_file_permission_list_command_failure(self, mocker_http_request, gsuite_client): """ @@ -937,8 +998,7 @@ def test_upload_file_with_parent_command_success(self, mocker, gsuite_client): args = { 'parent': 'test_parent', 'entry_id': 'test_entry_id', - 'file_name': 'test_file_name', - 'parent': 'test_parent' + 'file_name': 'test_file_name' } file_upload_command(gsuite_client, args) diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/README.md b/Packs/GoogleDrive/Integrations/GoogleDrive/README.md index 9d32111090cb..be448448a587 100644 --- a/Packs/GoogleDrive/Integrations/GoogleDrive/README.md +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/README.md @@ -9,19 +9,19 @@ This integration was integrated and tested with version 1.31.0 of GoogleDrive | **Parameter** | **Description** | **Required** | | --- | --- | --- | - | User's Service Account JSON | | | - | User ID | The primary email address of the user to fetch the incident\(s\). | | - | User ID | | | - | User's Service Account JSON | | | - | Action Detail Case Include | Action types to include for fetching the incident. | | - | Drive Item Search Field | itemName - Fetch activities for this drive item. The format is "items/ITEM_ID". folderName - Fetch activities for this drive folder and all children and descendants. The format is "items/ITEM_ID". | | - | Drive Item Search Value | itemName or folderName for fetching the incident. | | - | Fetch incidents | | | - | Incident type | | | - | Max Incidents | The maximum number of incidents to fetch each time. | | - | First Fetch Time Interval | The time range to consider for the initial data fetch in the format &lt;number&gt; &lt;unit&gt; e.g., 1 hour, 2 hours, 6 hours, 12 hours, 24 hours, 48 hours. | | - | Trust any certificate (not secure) | | | - | Use system proxy settings | | | + | User's Service Account JSON | | False | + | User ID | The primary email address of the user to fetch the incident\(s\). | False | + | User ID | | False | + | User's Service Account JSON | | False | + | Action Detail Case Include | Action types to include for fetching the incident. | False | + | Drive Item Search Field | itemName - Fetch activities for this drive item. The format is "items/ITEM_ID". folderName - Fetch activities for this drive folder and all children and descendants. The format is "items/ITEM_ID". | False | + | Drive Item Search Value | itemName or folderName for fetching the incident. | False | + | Fetch incidents | | False | + | Incident type | | False | + | Max Incidents | The maximum number of incidents to fetch each time. | False | + | First Fetch Time Interval | The time range to consider for the initial data fetch in the format <number> <unit> e.g., 1 hour, 2 hours, 6 hours, 12 hours, 24 hours, 48 hours. | False | + | Trust any certificate (not secure) | | False | + | Use system proxy settings | | False | 4. Click **Test** to validate the URLs, token, and connection. @@ -568,7 +568,7 @@ Lists the user's shared drives. | page_size | Maximum number of shared drives to return. Acceptable values are 1 to 100, inclusive. Default is 100. | Optional | | page_token | Page token for shared drives. | Optional | | query | Query string for searching shared drives. | Optional | -| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Default is false. | Optional | +| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Possible values are: true, false. Default is false. | Optional | | user_id | The user's primary email address. | Optional | #### Context Output @@ -616,7 +616,7 @@ Gets a user shared drives. | **Argument Name** | **Description** | **Required** | | --- | --- | --- | -| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Default is false. | Optional | +| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Possible values are: true, false. Default is false. | Optional | | user_id | The user's primary email address. | Optional | | drive_id | ID of the shared drive. Can be retrieved using the `google-drive-drives-list` command. | Optional | | fields | The fields you want included in the response. Default is kind, id, name, themeId, capabilities, createdTime, hidden, restrictions. | Optional | @@ -1028,7 +1028,7 @@ Lists a file's or shared drive's permissions. | page_size | Maximum number of shared drives to return. Acceptable values are 1 to 100, inclusive. Default is 100. | Optional | | page_token | Page token for shared drives. | Optional | | supports_all_drives | Whether the requesting application supports both My Drives and shared drives. Possible values: "true" and "false". Possible values are: true, false. Default is false. | Optional | -| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Default is false. | Optional | +| use_domain_admin_access | Issue the request as a domain administrator. If set to true, all shared drives of the domain in which the requester is an administrator are returned. Possible values are: true, false. Default is false. | Optional | #### Context Output @@ -1127,3 +1127,150 @@ Delete a permission. #### Context Output There is no context output for this command. +### google-drive-file-modify-label + +*** +Modify labels to file. + +#### Base Command + +`google-drive-file-modify-label` + +#### Input + +| **Argument Name** | **Description** | **Required** | +| --- | --- | --- | +| file_id | ID of the requested file. Can be retrieved using the `google-drive-files-list` command. | Optional | +| user_id | The user's primary email address. | Optional | +| label_id | The label id to set for the file. | Optional | +| field_id | the field id of the label to set. | Optional | +| selection_label_id | the label id to set for the field. | Optional | +| remove_label | Whether the requesting application supports both My Drives and shared drives. Possible values: "true" and "false". Possible values are: true, false. Default is false. | Optional | + +#### Context Output + +| **Path** | **Type** | **Description** | +| --- | --- | --- | +| GoogleDrive.Labels.kind | String | The type of resource. This is always drive\#modifyLabelsResponse | +| GoogleDrive.Labels.modifiedLabels.fields.id | String | The ID of the label field selected | +| GoogleDrive.Labels.modifiedLabels.fields.kind | String | Kind of resource this is, in this case drive\#labelField | +| GoogleDrive.Labels.modifiedLabels.fields.selection | String | Selected label. | +| GoogleDrive.Labels.modifiedLabels.fields.valueType | String | The type of data this label is representing. | +| GoogleDrive.Labels.modifiedLabels.id | String | The label id of the label to set | +| GoogleDrive.Labels.modifiedLabels.kind | String | The type of resource. This is always drive\#label | +| GoogleDrive.Labels.modifiedLabels.revisionId | String | | + +### google-drive-get-labels + +*** +Google Drive get labels. + +#### Base Command + +`google-drive-get-labels` + +#### Input + +| **Argument Name** | **Description** | **Required** | +| --- | --- | --- | +| user_id | The user's primary email address. | Optional | + +#### Context Output + +| **Path** | **Type** | **Description** | +| --- | --- | --- | +| GoogleDrive.Labels.labels.appliedCapabilities.canApply | Boolean | Is able to apply this label to files. | +| GoogleDrive.Labels.labels.appliedCapabilities.canRead | Boolean | Is able to read this label. | +| GoogleDrive.Labels.labels.appliedCapabilities.canRemove | Boolean | Is able to remove this label from files. | +| GoogleDrive.Labels.labels.appliedLabelPolicy.copyMode | String | Copy label to all descendants. | +| GoogleDrive.Labels.labels.createTime | Date | Time at which this label was created. | +| GoogleDrive.Labels.labels.creator.person | String | The creator of this label. | +| GoogleDrive.Labels.labels.customer | String | The customer that owns this label. | +| GoogleDrive.Labels.labels.displayHints.priority | String | Priority of the label. | +| GoogleDrive.Labels.labels.displayHints.shownInApply | Boolean | Whether this label is shown in the "Apply a label" dropdown. | +| GoogleDrive.Labels.labels.fields.appliedCapabilities.canRead | Boolean | Is the field readable. | +| GoogleDrive.Labels.labels.fields.appliedCapabilities.canSearch | Boolean | Is the field searchable. | +| GoogleDrive.Labels.labels.fields.appliedCapabilities.canWrite | Boolean | Is the field writable. | +| GoogleDrive.Labels.labels.fields.creator.person | String | The creator of this field. | +| GoogleDrive.Labels.labels.fields.displayHints.required | Boolean | Is this field required to be set by the user. | +| GoogleDrive.Labels.labels.fields.displayHints.shownInApply | Boolean | Should this field be shown when editing the label. | +| GoogleDrive.Labels.labels.fields.id | String | The ID of the field. | +| GoogleDrive.Labels.labels.fields.lifecycle.state | String | The lifecycle state of this field. | +| GoogleDrive.Labels.labels.fields.properties.displayName | String | The display name of the property. | +| GoogleDrive.Labels.labels.fields.properties.required | Boolean | Is this property required to be set by the user. | +| GoogleDrive.Labels.labels.fields.publisher.person | String | The user who published this field. | +| GoogleDrive.Labels.labels.fields.queryKey | String | The query key for this field. | +| GoogleDrive.Labels.labels.fields.schemaCapabilities | Unknown | Schema capabilities for this field. | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canRead | Boolean | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canSearch | Boolean | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.appliedCapabilities.canSelect | Boolean | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.backgroundColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.foregroundColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgeColors.soloColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.badgePriority | String | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.backgroundColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.foregroundColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.darkBadgeColors.soloColor.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.displayHints.shownInApply | Boolean | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.id | String | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.lifecycle.state | String | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.blue | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.green | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.badgeConfig.color.red | Number | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.properties.displayName | String | | +| GoogleDrive.Labels.labels.fields.selectionOptions.choices.schemaCapabilities | Unknown | | +| GoogleDrive.Labels.labels.fields.updater.person | String | | +| GoogleDrive.Labels.labels.id | String | | +| GoogleDrive.Labels.labels.labelType | String | | +| GoogleDrive.Labels.labels.lifecycle.state | String | | +| GoogleDrive.Labels.labels.name | String | | +| GoogleDrive.Labels.labels.properties.title | String | | +| GoogleDrive.Labels.labels.publishTime | Date | | +| GoogleDrive.Labels.labels.publisher.person | String | | +| GoogleDrive.Labels.labels.revisionCreateTime | Date | | +| GoogleDrive.Labels.labels.revisionCreator.person | String | | +| GoogleDrive.Labels.labels.revisionId | String | | +| GoogleDrive.Labels.labels.schemaCapabilities | Unknown | | +| GoogleDrive.Labels.labels.fields.userOptions | Unknown | | + +### google-drive-get-file-labels + +*** +Modify labels to file. + +#### Base Command + +`google-drive-get-file-labels` + +#### Input + +| **Argument Name** | **Description** | **Required** | +| --- | --- | --- | +| file_id | ID of the requested file. Can be retrieved using the `google-drive-files-list` command. | Optional | +| user_id | The user's primary email address. | Optional | + +#### Context Output + +| **Path** | **Type** | **Description** | +| --- | --- | --- | +| GoogleDrive.File.File.id | String | The ID of the file. | +| GoogleDrive.Labels.kind | String | The type of resource. This is always drive\#labelList | +| GoogleDrive.Labels.labels.fields.id | String | The ID of the label field selected | +| GoogleDrive.Labels.labels.fields.kind | String | The kind of this field. This is always drive\#labelField | +| GoogleDrive.Labels.labels.fields.selection | String | The label field selected. | +| GoogleDrive.Labels.labels.fields.valueType | String | The type of data this label is representing. | +| GoogleDrive.Labels.labels.id | String | The label id of the label to set | +| GoogleDrive.Labels.labels.kind | String | The type of resource. This is always drive\#label | +| GoogleDrive.Labels.labels.revisionId | String | The revision id of the label | diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/list_labels_response.json b/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/list_labels_response.json new file mode 100644 index 000000000000..97559e692a57 --- /dev/null +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/list_labels_response.json @@ -0,0 +1,345 @@ +{ + "labels": [ + { + "appliedCapabilities": { + "canApply": true, + "canRead": true, + "canRemove": true + }, + "appliedLabelPolicy": { + "copyMode": "COPY_APPLIABLE" + }, + "createTime": "2022-11-17T23:42:19.350072Z", + "creator": { + "person": "people/102317454261294562702" + }, + "customer": "customers/C02mckshm", + "displayHints": { + "priority": "16687285390000", + "shownInApply": true + }, + "fields": [ + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canWrite": true + }, + "creator": { + "person": "people/102317454261294562702" + }, + "displayHints": { + "required": true, + "shownInApply": true + }, + "id": "5B6668EE11", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "displayName": "File sensitivity", + "required": true + }, + "publisher": { + "person": "people/102317454261294562702" + }, + "queryKey": "labels/vFmXsMA1fQMz1BdE59YSkisZV4DiKdpxxLQRNNEbbFcb.5B6668EE11", + "schemaCapabilities": {}, + "selectionOptions": { + "choices": [ + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canSelect": true + }, + "displayHints": { + "badgeColors": { + "backgroundColor": { + "blue": 0.14509805, + "green": 0.1882353, + "red": 0.8509804 + }, + "foregroundColor": { + "blue": 1, + "green": 1, + "red": 1 + }, + "soloColor": { + "blue": 0.07058824, + "green": 0.078431375, + "red": 0.7019608 + } + }, + "badgePriority": "16687285390000", + "darkBadgeColors": { + "backgroundColor": { + "blue": 0.50980395, + "green": 0.54509807, + "red": 0.9490196 + }, + "foregroundColor": { + "blue": 0.14117648, + "green": 0.12941177, + "red": 0.1254902 + }, + "soloColor": { + "blue": 0.8117647, + "green": 0.8235294, + "red": 0.98039216 + } + }, + "shownInApply": true + }, + "id": "17F9F7CA2F", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "badgeConfig": { + "color": { + "blue": 0.14509805, + "green": 0.1882353, + "red": 0.8509804 + } + }, + "displayName": "Restricted" + }, + "schemaCapabilities": {} + }, + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canSelect": true + }, + "displayHints": { + "badgeColors": { + "backgroundColor": { + "blue": 0.015686275, + "green": 0.7372549, + "red": 0.9843137 + }, + "foregroundColor": { + "blue": 0.14117648, + "green": 0.12941177, + "red": 0.1254902 + }, + "soloColor": { + "blue": 0.14117648, + "green": 0.12941177, + "red": 0.1254902 + } + }, + "badgePriority": "16687285390001", + "darkBadgeColors": { + "backgroundColor": { + "blue": 0.3882353, + "green": 0.8392157, + "red": 0.99215686 + }, + "foregroundColor": { + "blue": 0.14117648, + "green": 0.12941177, + "red": 0.1254902 + }, + "soloColor": { + "blue": 0.7647059, + "green": 0.9372549, + "red": 0.99607843 + } + }, + "shownInApply": true + }, + "id": "795CA12FF4", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "badgeConfig": { + "color": { + "blue": 0.015686275, + "green": 0.7372549, + "red": 0.9843137 + } + }, + "displayName": "Confidential" + }, + "schemaCapabilities": {} + }, + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canSelect": true + }, + "displayHints": { + "shownInApply": true + }, + "id": "1442530133", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "displayName": "Internal" + }, + "schemaCapabilities": {} + }, + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canSelect": true + }, + "displayHints": { + "badgeColors": { + "backgroundColor": { + "blue": 0.21960784, + "green": 0.5019608, + "red": 0.09411765 + }, + "foregroundColor": { + "blue": 1, + "green": 1, + "red": 1 + }, + "soloColor": { + "blue": 0.2, + "green": 0.4509804, + "red": 0.07450981 + } + }, + "badgePriority": "16687285390003", + "darkBadgeColors": { + "backgroundColor": { + "blue": 0.58431375, + "green": 0.7882353, + "red": 0.5058824 + }, + "foregroundColor": { + "blue": 0.14117648, + "green": 0.12941177, + "red": 0.1254902 + }, + "soloColor": { + "blue": 0.8392157, + "green": 0.91764706, + "red": 0.80784315 + } + }, + "shownInApply": true + }, + "id": "9451C6F0E3", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "badgeConfig": { + "color": { + "blue": 0.21960784, + "green": 0.5019608, + "red": 0.09411765 + } + }, + "displayName": "Public" + }, + "schemaCapabilities": {} + } + ] + }, + "updater": { + "person": "people/102317454261294562702" + } + } + ], + "id": "vFmXsMA1fQMz1BdE59YSkisZV4DiKdpxxLQRNNEbbFcb", + "labelType": "ADMIN", + "lifecycle": { + "state": "PUBLISHED" + }, + "name": "labels/vFmXsMA1fQMz1BdE59YSkisZV4DiKdpxxLQRNNEbbFcb@5", + "properties": { + "title": "File sensitivity" + }, + "publishTime": "2022-11-17T23:43:29.969288Z", + "publisher": { + "person": "people/102317454261294562702" + }, + "revisionCreateTime": "2022-11-17T23:43:29.969288Z", + "revisionCreator": { + "person": "people/102317454261294562702" + }, + "revisionId": "5", + "schemaCapabilities": {} + }, + { + "appliedCapabilities": { + "canApply": true, + "canRead": true, + "canRemove": true + }, + "appliedLabelPolicy": { + "copyMode": "COPY_APPLIABLE" + }, + "createTime": "2022-11-17T23:47:59.390505Z", + "creator": { + "person": "people/102317454261294562702" + }, + "customer": "customers/C02mckshm", + "displayHints": { + "priority": "16687288790000", + "shownInApply": true + }, + "fields": [ + { + "appliedCapabilities": { + "canRead": true, + "canSearch": true, + "canWrite": true + }, + "creator": { + "person": "people/102317454261294562702" + }, + "displayHints": { + "shownInApply": true + }, + "id": "5AEFADC503", + "lifecycle": { + "state": "PUBLISHED" + }, + "properties": { + "displayName": "New field" + }, + "publisher": { + "person": "people/102317454261294562702" + }, + "queryKey": "labels/xaEgCaYEAuAFTsN7dDiU36zUj8gMMWLPB9XRNNEbbFcb.5AEFADC503", + "schemaCapabilities": {}, + "updater": { + "person": "people/102317454261294562702" + }, + "userOptions": {} + } + ], + "id": "xaEgCaYEAuAFTsN7dDiU36zUj8gMMWLPB9XRNNEbbFcb", + "labelType": "ADMIN", + "lifecycle": { + "state": "PUBLISHED" + }, + "name": "labels/xaEgCaYEAuAFTsN7dDiU36zUj8gMMWLPB9XRNNEbbFcb@4", + "properties": { + "title": "HR" + }, + "publishTime": "2022-11-17T23:49:53.572937Z", + "publisher": { + "person": "people/102317454261294562702" + }, + "revisionCreateTime": "2022-11-17T23:49:53.572937Z", + "revisionCreator": { + "person": "people/102317454261294562702" + }, + "revisionId": "4", + "schemaCapabilities": {} + } + ] +} \ No newline at end of file diff --git a/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/modify_label_command_response.json b/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/modify_label_command_response.json new file mode 100644 index 000000000000..19d2f5b36a6e --- /dev/null +++ b/Packs/GoogleDrive/Integrations/GoogleDrive/test_data/modify_label_command_response.json @@ -0,0 +1,20 @@ +{ + "kind": "drive#modifyLabelsResponse", + "modifiedLabels": [ + { + "fields": { + "5B6668EE11": { + "id": "5B6668EE11", + "kind": "drive#labelField", + "selection": [ + "9451C6F0E3" + ], + "valueType": "selection" + } + }, + "id": "vFmXsMA1fQMz1BdE59YSkisZV4DiKdpxxLQRNNEbbFcb", + "kind": "drive#label", + "revisionId": "5" + } + ] +} \ No newline at end of file diff --git a/Packs/GoogleDrive/ReleaseNotes/1_2_40.md b/Packs/GoogleDrive/ReleaseNotes/1_2_40.md new file mode 100644 index 000000000000..919fa54434d8 --- /dev/null +++ b/Packs/GoogleDrive/ReleaseNotes/1_2_40.md @@ -0,0 +1,4 @@ +#### Integrations +##### Google Drive +- Updated the Docker image to: *demisto/googleapi-python3:1.0.0.71902*. +- Add commands: `google-drive-file-modify-label`, `google-drive-get-labels`, `google-drive-get-file-labels`. diff --git a/Packs/GoogleDrive/pack_metadata.json b/Packs/GoogleDrive/pack_metadata.json index fa16847baef5..115ba90da725 100644 --- a/Packs/GoogleDrive/pack_metadata.json +++ b/Packs/GoogleDrive/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Google Drive", "description": "Google Drive allows users to store files on their servers, synchronize files across devices, and share files. This integration helps you to create a new drive, query past activity and view change logs performed by the users, as well as list drives and files, and manage their permissions.", "support": "xsoar", - "currentVersion": "1.2.39", + "currentVersion": "1.2.40", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",