Skip to content

Commit

Permalink
Deprecate demisto-api-* commands (demisto#31388)
Browse files Browse the repository at this point in the history
* deprecate all the demisto-api-* commands.
Replace their usage in OOB scripts and playbooks.

* pre-commit

* update rn

* demisto-sdk format

* demisto-sdk format + update rn

* format

* fixed Mypy and Pylint errors

* Bump pack from version CommonScripts to 1.12.57.

* updated dockers

* validation fixes

* validation fixes

* updated rn dockers

* updated rn 1_3_41.md

* updated rn+integration name

* updated rn+bc

* fixed

* fixed

* Bump pack from version CommonScripts to 1.12.58.

* fixed

* fixed

* fixed

* Bump pack from version CommonScripts to 1.13.1.

* cr updates

* cr updates

* fixed

* Bump pack from version DeveloperTools to 1.3.7.

* Bump pack from version CommonScripts to 1.13.2.

* Bump pack from version CommonScripts to 1.13.6.

* Bump pack from version CommonScripts to 1.13.7.

* Bump pack from version CommonPlaybooks to 2.4.42.

* fixed

* fixed

* changed to test_data

* fixed

* Bump pack from version CommonScripts to 1.13.9.

* Bump pack from version CommonPlaybooks to 2.4.43.

* Bump pack from version DeveloperTools to 1.3.8.

---------

Co-authored-by: Content Bot <[email protected]>
  • Loading branch information
michal-dagan and Content Bot authored Dec 20, 2023
1 parent 21ccb7a commit a1337a0
Show file tree
Hide file tree
Showing 247 changed files with 1,444 additions and 821 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ tasks:
task:
id: 04d3848d-57da-47ab-827d-8950c9063c32
version: -1
name: Is Demisto REST API enabled?
description: Checks whether the Demisto REST API integration is enabled.
name: Is Core REST API enabled?
description: Checks whether the Core REST API integration is enabled.
type: condition
iscommand: false
brand: ""
Expand All @@ -564,7 +564,7 @@ tasks:
iscontext: true
right:
value:
simple: Demisto REST API
simple: Core REST API
- - operator: isEqualString
left:
value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ tasks:
task:
id: 04d3848d-57da-47ab-827d-8950c9063c32
version: -1
name: Is Demisto REST API enabled?
description: Checks whether the Demisto REST API integration is enabled.
name: Is Core REST API enabled?
description: Checks whether the Core REST API integration is enabled.
type: condition
iscommand: false
brand: ""
Expand All @@ -522,7 +522,7 @@ tasks:
iscontext: true
right:
value:
simple: Demisto REST API
simple: Core REST API
- - operator: isEqualString
left:
value:
Expand Down
4 changes: 4 additions & 0 deletions Packs/CommonPlaybooks/ReleaseNotes/2_4_43.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"breakingChanges": true,
"breakingChangesNotes": "The Demisto REST API integration has been deprecated. Use the Core REST API integration in its place. The functionalities are the same."
}
9 changes: 9 additions & 0 deletions Packs/CommonPlaybooks/ReleaseNotes/2_4_43.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#### Playbooks

##### Dedup - Generic v2

Replaced the usage of the deprecated **Demisto REST API** integration with the **Core REST API** integration.
##### Dedup - Generic v3

Replaced the usage of the deprecated **Demisto REST API** integration with the **Core REST API** integration.
2 changes: 1 addition & 1 deletion Packs/CommonPlaybooks/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Common Playbooks",
"description": "Frequently used playbooks pack.",
"support": "xsoar",
"currentVersion": "2.4.42",
"currentVersion": "2.4.43",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
4 changes: 4 additions & 0 deletions Packs/CommonScripts/ReleaseNotes/1_13_9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"breakingChanges": true,
"breakingChangesNotes": "The Demisto REST API integration has been deprecated. Use the Core REST API integration in its place. The functionalities are the same."
}
33 changes: 33 additions & 0 deletions Packs/CommonScripts/ReleaseNotes/1_13_9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#### Scripts

##### IncidentFields

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### ExportIndicatorsToCSV

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### ExportIncidentsToCSV

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### GetFieldsByIncidentType

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### EditServerConfig

- Updated the Docker image to: *demisto/python3:3.10.13.83255*.
- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### GenerateAsBuilt

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### ExportAuditLogsToFile

- Updated the Docker image to: *demisto/python3:3.10.13.83255*.
- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### ContentPackInstaller

- Updated the Docker image to: *demisto/xsoar-tools:1.0.0.83431*.
- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
##### ProvidesCommand

- Deprecated the ***demisto-api-**** commands and replaced with the ***core-api-**** commands. (Commands are identical, no effect is expected.)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import demistomock as demisto
from CommonServerPython import *

from packaging.version import parse, Version, LegacyVersion
from packaging.version import parse, Version

SCRIPT_NAME = 'ContentPackInstaller'

Expand All @@ -12,12 +12,12 @@ class ContentPackInstaller:
PACK_ID_VERSION_FORMAT = '{}::{}'

def __init__(self, instance_name: str = None):
self.installed_packs: Dict[str, Union[Version, LegacyVersion]] = dict()
self.newly_installed_packs: Dict[str, Version] = dict()
self.already_on_machine_packs: Dict[str, Union[Version, LegacyVersion]] = dict()
self.packs_data: Dict[str, Dict[str, str]] = dict()
self.packs_dependencies: Dict[str, Dict[str, Dict[str, str]]] = dict()
self.packs_failed: Dict[str, str] = dict()
self.installed_packs: Dict[str, Version] = {}
self.newly_installed_packs: Dict[str, Version] = {}
self.already_on_machine_packs: Dict[str, Version] = {}
self.packs_data: Dict[str, Dict[str, str]] = {}
self.packs_dependencies: Dict[str, Dict[str, Dict[str, str]]] = {}
self.packs_failed: Dict[str, str] = {}
self.instance_name: Optional[str] = instance_name

self.get_installed_packs()
Expand All @@ -33,7 +33,7 @@ def get_installed_packs(self) -> None:
args['using'] = self.instance_name

status, res = execute_command(
'demisto-api-get',
'core-api-get',
args,
fail_on_error=False,
)
Expand Down Expand Up @@ -73,7 +73,7 @@ def get_pack_data_from_marketplace(self, pack_id: str) -> Dict[str, str]:
args['using'] = self.instance_name

status, res = execute_command(
'demisto-api-get',
'core-api-get',
args,
fail_on_error=False,
)
Expand Down Expand Up @@ -111,7 +111,7 @@ def get_pack_dependencies_from_marketplace(self, pack_data: Dict[str, str]) -> D
args['using'] = self.instance_name

status, res = execute_command(
'demisto-api-post',
'core-api-post',
args,
fail_on_error=False,
)
Expand Down Expand Up @@ -186,7 +186,7 @@ def install_packs(self, packs_to_install: List[Dict[str, str]]) -> None:
args['using'] = self.instance_name

status, res = execute_command(
'demisto-api-install-packs',
'core-api-install-packs',
args,
fail_on_error=False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tags:
- Content Management
timeout: 600ns
type: python
dockerimage: demisto/xsoar-tools:1.0.0.46482
dockerimage: demisto/xsoar-tools:1.0.0.83431
tests:
- ContentPackInstaller_Test
fromversion: 6.0.0
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from CommonServerPython import *

from typing import Dict, Any
from typing import Any
import traceback

SERVER_SYSTEM_CONFIG_PATH = '/system/config'
''' STANDALONE FUNCTION '''


def get_current_server_config() -> dict:
res = execute_command("demisto-api-get", {"uri": SERVER_SYSTEM_CONFIG_PATH})
res = execute_command("core-api-get", {"uri": SERVER_SYSTEM_CONFIG_PATH})
config_json = res['response']
return config_json.get('sysConf', {})


def set_system_config(server_config: dict):
execute_command(
"demisto-api-post",
"core-api-post",
{
"uri": SERVER_SYSTEM_CONFIG_PATH,
"body": {"data": server_config,
Expand All @@ -37,7 +37,7 @@ def update_server_config(key: str, value: str, server_config: dict):
set_system_config(server_config)


def edit_server_config(args: Dict[str, Any]) -> CommandResults:
def edit_server_config(args: dict[str, Any]) -> CommandResults:
action = args.get('action', "")
key = args.get('key', "")
value = args.get('value', "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ script: '-'
timeout: '0'
type: python
subtype: python3
dockerimage: demisto/python3:3.10.12.63474
dockerimage: demisto/python3:3.10.13.83255
fromversion: 6.0.0
tests:
- TestEditServerConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def main(): # pragma: no cover
}

args = {"uri": uri, "body": body}
res = demisto.executeCommand("demisto-api-post", args)
demisto.debug(f'demisto-api-post with {args} returned {res}')
res = demisto.executeCommand("core-api-post", args)
demisto.debug(f'core-api-post with {args} returned {res}')
if is_error(res):
raise DemistoException(f'error occurred when trying to retrieve the audit logs using {args=}, error: {res}')

Expand All @@ -87,8 +87,8 @@ def main(): # pragma: no cover
else: # pagination for xsoar-8
body["request_data"]["search_from"] = page_num # type: ignore[index]
args = {"uri": uri, "body": body}
res = demisto.executeCommand("demisto-api-post", args)
demisto.debug(f'demisto-api-post with {args} returned {res}')
res = demisto.executeCommand("core-api-post", args)
demisto.debug(f'core-api-post with {args} returned {res}')
if is_error(res):
raise DemistoException(f'error occurred when trying to retrieve the audit logs using {args=}, error: {res}')
response = res[0]["Contents"]["response"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ args:
predefined:
- csv
- json
comment: Uses the Demisto REST API integration to query the server audit trail logs, and return back a CSV or JSON file.
comment: Uses the Core REST API integration to query the server audit trail logs, and return back a CSV or JSON file.
commonfields:
id: ExportAuditLogsToFile
version: -1
Expand All @@ -24,8 +24,8 @@ contentitemexportablefields:
fromServerVersion: ""
dependson:
must:
- demisto-api-post
dockerimage: demisto/python3:3.10.13.74666
- core-api-post
dockerimage: demisto/python3:3.10.13.83255
enabled: true
name: ExportAuditLogsToFile
runas: DBotWeakRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def execute_command_side_effect(command: str, args: Dict):
if command == "splunk-submit-event-hec":
return [{'Contents': {'response': ["result1"]}}]
if command == "demisto-api-post":
if command == "core-api-post":
if args["uri"] == '/settings/audits':
return [{'Contents': {'response': {'total': 2, "audits": ["audit1", "audit2"]}}, "Type": entryTypes["note"]}]
return [{'Contents': {'response': {'total': 2, "reply": {"data": ["audit1", "audit2"]}}}, "Type": entryTypes["note"]}]
Expand Down
9 changes: 7 additions & 2 deletions Packs/CommonScripts/Scripts/ExportAuditLogsToFile/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Uses the Demisto REST API integration to query the server audit trail logs, and return back a CSV or JSON file.
Uses the Core REST API integration to query the server audit trail logs, and return back a CSV or JSON file.

## Script Data

---

| **Name** | **Description** |
Expand All @@ -9,11 +10,14 @@ Uses the Demisto REST API integration to query the server audit trail logs, and
| Tags | Utility |

## Dependencies

---
This script uses the following commands and scripts.
* demisto-api-post

* core-api-post

## Inputs

---

| **Argument Name** | **Description** |
Expand All @@ -22,5 +26,6 @@ This script uses the following commands and scripts.
| output | Type of File to return, either JSON, or CSV |

## Outputs

---
There are no outputs for this script.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def main():
}

# generate the file
res = demisto.executeCommand("demisto-api-post", {"uri": "/incident/batch/exportToCsv",
"body": incident_body})[0]["Contents"]["response"]
res = demisto.executeCommand("core-api-post", {"uri": "/incident/batch/exportToCsv",
"body": incident_body})[0]["Contents"]["response"]

# download the file and return to the war room
file = demisto.executeCommand("demisto-api-get", {"uri": f"/incident/csv/{res}"})[0]["Contents"]["response"]
file = demisto.executeCommand("core-api-get", {"uri": f"/incident/csv/{res}"})[0]["Contents"]["response"]
demisto.results(fileResult(res, file))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ args:
name: fetchdays
- description: 'Comma separated list of columns (fields) for the CSV. (Default is: id,name,type,severity,status,owner,roles,playbookId,occurred,created,modified,closed).'
name: columns
comment: This automation uses the Demisto REST API Integration to batch export Incidents to CSV and return the resulting CSV file to the war room.
comment: This automation uses the Core REST API Integration to batch export Incidents to CSV and return the resulting CSV file to the war room.
commonfields:
id: ExportIncidentsToCSV
version: -1
Expand All @@ -16,8 +16,8 @@ contentitemexportablefields:
fromServerVersion: ""
dependson:
must:
- demisto-api-post
- demisto-api-get
- core-api-post
- core-api-get
dockerimage: demisto/python3:3.10.13.83255
enabled: true
name: ExportIncidentsToCSV
Expand Down
11 changes: 8 additions & 3 deletions Packs/CommonScripts/Scripts/ExportIncidentsToCSV/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
This automation uses the Demisto REST API Integration to batch export Incidents to CSV and return the resulting CSV file to the war room.
This automation uses the Core REST API Integration to batch export Incidents to CSV and return the resulting CSV file to the war room.

## Script Data

---

| **Name** | **Description** |
Expand All @@ -9,12 +10,15 @@ This automation uses the Demisto REST API Integration to batch export Incidents
| Tags | Utility |

## Dependencies

---
This script uses the following commands and scripts.
* demisto-api-get
* demisto-api-post

* core-api-get
* core-api-post

## Inputs

---

| **Argument Name** | **Description** |
Expand All @@ -24,5 +28,6 @@ This script uses the following commands and scripts.
| columns | Comma separated list of columns \(fields\) for the CSV. \(Default is: id,name,type,severity,status,owner,roles,playbookId,occurred,created,modified,closed\) |

## Outputs

---
There are no outputs for this script.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def main():
}

# generate the file
res = demisto.executeCommand("demisto-api-post", {"uri": "/indicators/batch/exportToCsv",
"body": indicator_body})[0]["Contents"]["response"]
res = demisto.executeCommand("core-api-post", {"uri": "/indicators/batch/exportToCsv",
"body": indicator_body})[0]["Contents"]["response"]

# download the file and return to the war room
file = demisto.executeCommand("demisto-api-get", {"uri": f"/indicators/csv/{res}"})[0]["Contents"]["response"]
file = demisto.executeCommand("core-api-get", {"uri": f"/indicators/csv/{res}"})[0]["Contents"]["response"]
demisto.results(fileResult(res, file))


Expand Down
Loading

0 comments on commit a1337a0

Please sign in to comment.