From 391e12ebc3fd8d1286ad1a655b67e69aa42e95ea Mon Sep 17 00:00:00 2001 From: JudithB <132264628+jbabazadeh@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:21:02 +0300 Subject: [PATCH] fix gmail-list-labels command XSUP-29195 (#30222) * fix gmail-list-labels command * Update 1_3_14.md --- Packs/Gmail/Integrations/Gmail/Gmail.py | 18 +++--- Packs/Gmail/Integrations/Gmail/Gmail.yml | 70 ++++++++++++------------ Packs/Gmail/ReleaseNotes/1_3_14.md | 7 +++ Packs/Gmail/pack_metadata.json | 2 +- 4 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 Packs/Gmail/ReleaseNotes/1_3_14.md diff --git a/Packs/Gmail/Integrations/Gmail/Gmail.py b/Packs/Gmail/Integrations/Gmail/Gmail.py index 08b450704283..ccdb352cff56 100644 --- a/Packs/Gmail/Integrations/Gmail/Gmail.py +++ b/Packs/Gmail/Integrations/Gmail/Gmail.py @@ -1056,7 +1056,7 @@ def set_autoreply_command(): file_content = '' if response_body_entry_id and not args.get('response-body'): file_entry = demisto.getFilePath(response_body_entry_id) - with open(file_entry['path'], 'r') as f: + with open(file_entry['path']) as f: file_content = str(f.read()) response_body_plain_text = file_content if file_content else args.get('response-body') response_body_type = args.get('response-body-type') @@ -1151,7 +1151,7 @@ def create_user(primary_email, first_name, family_name, password): 'name': { 'givenName': first_name, 'familyName': family_name, - 'fullName': '%s %s' % (first_name, family_name,), + 'fullName': f'{first_name} {family_name}', }, 'password': password } @@ -1190,7 +1190,8 @@ def list_labels(user_key): service = get_service( 'gmail', 'v1', - ['https://www.googleapis.com/auth/gmail.readonly']) + ['https://www.googleapis.com/auth/gmail.readonly'], + delegated_user=user_key) results = service.users().labels().list(userId=user_key).execute() labels = results.get('labels', []) return labels @@ -1205,7 +1206,7 @@ def get_user_role_command(): raise ValueError('Must provide Immutable GoogleApps Id') roles = get_user_role(user_key, GAPPS_ID) - return user_roles_to_entry('User Roles of %s:' % (user_key,), roles) + return user_roles_to_entry(f'User Roles of {user_key}:', roles) def get_user_role(user_key, customer): @@ -1398,7 +1399,7 @@ def search_command(mailbox: str = None, only_return_account_names: bool = False) if max_results > 500: raise ValueError( - 'maxResults must be lower than 500, got %s' % (max_results,)) + f'maxResults must be lower than 500, got {max_results}') try: mails, q = search(user_id, subject, _from, to, before, after, filename, _in, query, @@ -1434,9 +1435,9 @@ def search(user_id, subject='', _from='', to='', before='', after='', filename=' 'in': _in, 'has': 'attachment' if has_attachments else '' } - q = ' '.join('%s:%s ' % (name, value,) + q = ' '.join(f'{name}:{value} ' for name, value in list(query_values.items()) if value != '') - q = ('%s %s' % (q, query,)).strip() + q = (f'{q} {query}').strip() command_args = { 'userId': user_id, @@ -1952,6 +1953,7 @@ def collect_inline_attachments(attach_cids): }) return inline_attachment + return None def collect_manual_attachments(): @@ -2627,7 +2629,7 @@ def fetch_incidents(): demisto.info( f'skipped incident with lower date: {occurred} than fetch: {last_fetch} name: {incident.get("name")}') - demisto.info('extract {} incidents'.format(len(incidents))) + demisto.info(f'extract {len(incidents)} incidents') next_page_token = result.get('nextPageToken', '') if next_page_token: # we still have more results diff --git a/Packs/Gmail/Integrations/Gmail/Gmail.yml b/Packs/Gmail/Integrations/Gmail/Gmail.yml index 05716b1abe17..e78ac8388d3c 100644 --- a/Packs/Gmail/Integrations/Gmail/Gmail.yml +++ b/Packs/Gmail/Integrations/Gmail/Gmail.yml @@ -304,12 +304,12 @@ script: description: The user's email address. The "me" special value can be used to indicate the authenticated user. name: user-id required: true - - description: 'Returns messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". For more syntax information see "https://support.google.com/mail/answer/7190?hl=en"' + - description: 'Returns messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". For more syntax information see "https://support.google.com/mail/answer/7190?hl=en".' name: query - defaultValue: '100' description: The maximum number of results to return. Default is 100. Maximum is 500. Can be 1 to 500, inclusive. name: max-results - - description: 'Enables partial responses to be retrieved, separated by commas. Valid fields are only from the following list: Type, Mailbox, ThreadId, Labels, Headers, Attachments, RawData, Format, Subject, From, To, Body, Cc, Bcc, Date, Html, Attachment Names' + - description: 'Enables partial responses to be retrieved, separated by commas. Valid fields are only from the following list: Type, Mailbox, ThreadId, Labels, Headers, Attachments, RawData, Format, Subject, From, To, Body, Cc, Bcc, Date, Html, Attachment Names.' isArray: true name: fields - description: Returns messages with labels that match all of the specified label IDs in a comma-separated list. @@ -318,24 +318,24 @@ script: name: page-token - auto: PREDEFINED defaultValue: 'False' - description: 'Include messages from SPAM and TRASH in the results. (Default: false)' + description: 'Include messages from SPAM and TRASH in the results. (Default: false).' name: include-spam-trash predefined: - 'False' - 'True' - - description: Specifies the sender. For example, "john" + - description: Specifies the sender. For example, "john". name: from - - description: Specifies the receiver. For example, "john" + - description: Specifies the receiver. For example, "john". name: to - - description: Words in the subject line. For example, "alert" + - description: Words in the subject line. For example, "alert". name: subject - - description: Attachments with a certain name or file type. For example, "pdf" or "report.pdf" + - description: Attachments with a certain name or file type. For example, "pdf" or "report.pdf". name: filename - - description: 'Messages in any folder, including Spam and Trash. For example: shopping' + - description: 'Messages in any folder, including Spam and Trash. For example: shopping.' name: in - - description: 'Search for messages sent after a specific date. For example: 2018/05/06' + - description: 'Search for messages sent after a specific date. For example: 2018/05/06.' name: after - - description: 'Search for messages sent before a specific date. for example: 2018/05/09' + - description: 'Search for messages sent before a specific date. for example: 2018/05/09.' name: before - auto: PREDEFINED description: Whether to search for messages sent with attachments (boolean value). @@ -419,12 +419,12 @@ script: description: The date the email was received. type: String - arguments: - - description: 'Returns messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". For more syntax information,see "https://support.google.com/mail/answer/7190?hl=en"' + - description: 'Returns messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". For more syntax information,see "https://support.google.com/mail/answer/7190?hl=en".' name: query - defaultValue: '100' description: The maximum number of results to return. Default is 100. Maximum is 500. Can be 1 to 500, inclusive. name: max-results - - description: 'Enables partial responses to be retrieved, separated by commas. Valid fields are only from the following list: Type, Mailbox, ThreadId, Labels, Headers, Attachments, RawData, Format, Subject, From, To, Body, Cc, Bcc, Date, Html, Attachment Names' + - description: 'Enables partial responses to be retrieved, separated by commas. Valid fields are only from the following list: Type, Mailbox, ThreadId, Labels, Headers, Attachments, RawData, Format, Subject, From, To, Body, Cc, Bcc, Date, Html, Attachment Names.' isArray: true name: fields - description: Returns messages with labels that match all of the specified label IDs in a comma-separated list. @@ -433,24 +433,24 @@ script: name: page-token - auto: PREDEFINED defaultValue: 'False' - description: 'Includes messages from SPAM and TRASH in the results. (Default: false)' + description: 'Includes messages from SPAM and TRASH in the results. (Default: false).' name: include-spam-trash predefined: - 'False' - 'True' - - description: Specifies the sender. For example, "john" + - description: Specifies the sender. For example, "john". name: from - - description: Specifies the receiver. For example, "john" + - description: Specifies the receiver. For example, "john". name: to - - description: Words in the subject line. For example, "alert" + - description: Words in the subject line. For example, "alert". name: subject - - description: Attachments with a certain name or file type. For example, "pdf" or "report.pdf" + - description: Attachments with a certain name or file type. For example, "pdf" or "report.pdf". name: filename - - description: Messages in any folder, including Spam and Trash. For example, shopping + - description: Messages in any folder, including Spam and Trash. For example, shopping. name: in - - description: Search for messages sent after a specific date. For example, 2018/05/06 + - description: Search for messages sent after a specific date. For example, 2018/05/06. name: after - - description: Search for messages sent before a specific date. For example, 2018/05/09 + - description: Search for messages sent before a specific date. For example, 2018/05/09. name: before - auto: PREDEFINED description: Whether to search for messages sent with attachments. @@ -471,7 +471,7 @@ script: name: search_from - description: Used to track search progress. name: search_to - description: Searches the Gmail records for all Google users. (For more than 2500 accounts, use with the `Search all mailboxes - Gmail with polling` playbook) + description: Searches the Gmail records for all Google users. (For more than 2500 accounts, use with the `Search all mailboxes - Gmail with polling` playbook). polling: true name: gmail-search-all-mailboxes outputs: @@ -585,7 +585,7 @@ script: - 'False' - 'True' - auto: PREDEFINED - description: How to sort the results. Can be ASCENDING/DESCENDING + description: How to sort the results. Can be ASCENDING/DESCENDING. name: sort-order predefined: - ASCENDING @@ -709,7 +709,7 @@ script: required: true - auto: PREDEFINED defaultValue: full - description: 'The format in which to return the message. Can be: "full": Returns the full email message data with body content parsed in the payload field; the raw field is not used. (default) / "metadata": Returns only email message ID, labels, and email headers / "minimal": Returns only email message ID and labels; does not return the email headers, body, or payload / "raw": Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used' + description: 'The format in which to return the message. Can be: "full": Returns the full email message data with body content parsed in the payload field; the raw field is not used. (default) / "metadata": Returns only email message ID, labels, and email headers / "minimal": Returns only email message ID and labels; does not return the email headers, body, or payload / "raw": Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used.' name: format predefined: - full @@ -1047,7 +1047,7 @@ script: - description: The user's email address. The "me" special value can be used to indicate the authenticated user. name: user-id required: true - - description: A comma-separated list of filter IDs (can be retrieve using `gmail-list-filters` command) + - description: A comma-separated list of filter IDs (can be retrieve using `gmail-list-filters` command). isArray: true name: filter_ids required: true @@ -1248,7 +1248,7 @@ script: - description: |- A comma-separated list of new names to rename attachments corresponding to the order that they were attached to the email. Examples - To rename first and third file attachNames=new_fileName1,,new_fileName3 - To rename second and fifth files attachNames=,new_fileName2,,,new_fileName5 + To rename second and fifth files attachNames=,new_fileName2,,,new_fileName5. isArray: true name: attachNames - description: |- @@ -1258,19 +1258,19 @@ script: - description: |- Textual name for an attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test - 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFile - description: |- Content for the attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test - 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFileContent - description: |- CID image for an attached file to include within the email body. Multiple files are supported as a comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" - transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFileCID - description: 'A CSV list of additional headers in the format: headerName=headerValue. For example: "headerName1=headerValue1,headerName2=headerValue2".' @@ -1290,7 +1290,7 @@ script: - 'HTML' - 'Text' defaultValue: Text - - description: Indicates whether to render the email body + - description: Indicates whether to render the email body. name: renderBody auto: PREDEFINED predefined: @@ -1364,22 +1364,22 @@ script: - description: |- A comma-separated list of new names used to rename attachments corresponding to the order in which they were attached to the email. Examples - To rename the first and third file: attachNames=new_fileName1,,new_fileName3 - To rename the second and fifth files: attachNames=,new_fileName2,,,new_fileName5 + To rename the second and fifth files: attachNames=,new_fileName2,,,new_fileName5. isArray: true name: attachNames - description: A comma-separated list of CID images to embed as attachments inside the email. isArray: true name: attachCIDs - description: |- - Textual name for an attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + Textual name for an attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFile - description: |- - Content for the attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + Content for the attached file. Multiple files are supported as a comma-separated list. For example, transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFileContent - description: |- - CID image for an attached file to include within the email body. Multiple files are supported as a comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz") + CID image for an attached file to include within the email body. Multiple files are supported as a comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz"). isArray: true name: transientFileCID - description: 'A comma-separated list of additional headers in the format: headerName=headerValue. For example: "headerName1=headerValue1,headerName2=headerValue2".' @@ -1395,7 +1395,7 @@ script: predefined: - HTML - Text - - description: Indicates whether to render the email body + - description: Indicates whether to render the email body. name: renderBody description: Replies to a mail using Gmail. name: reply-mail @@ -1659,7 +1659,7 @@ script: - contextPath: Gmail.ForwardingAddress.verificationStatus description: Indicates whether this address has been verified and is usable for forwarding. type: String - dockerimage: demisto/google-api-py3:1.0.0.68841 + dockerimage: demisto/google-api-py3:1.0.0.77314 isfetch: true runonce: false script: '-' diff --git a/Packs/Gmail/ReleaseNotes/1_3_14.md b/Packs/Gmail/ReleaseNotes/1_3_14.md new file mode 100644 index 000000000000..942b3c7fa8e5 --- /dev/null +++ b/Packs/Gmail/ReleaseNotes/1_3_14.md @@ -0,0 +1,7 @@ + +#### Integrations + +##### Gmail + +- Fixed an issue where *gmail-list-labels* command was unable to run with delegate user. +- Updated the Docker image to: *demisto/google-api-py3:1.0.0.77314*. diff --git a/Packs/Gmail/pack_metadata.json b/Packs/Gmail/pack_metadata.json index 74e753195a6d..56db3088061b 100644 --- a/Packs/Gmail/pack_metadata.json +++ b/Packs/Gmail/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Gmail", "description": "Gmail API and user management (This integration replaces the Gmail functionality in the GoogleApps API and G Suite integration).", "support": "xsoar", - "currentVersion": "1.3.13", + "currentVersion": "1.3.14", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",