Skip to content

Commit

Permalink
added function for checking the integration
Browse files Browse the repository at this point in the history
  • Loading branch information
karinafishman committed Jul 9, 2024
1 parent f09ac0a commit 25e7030
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions Packs/CommonDashboards/Scripts/AdoptionMetrics/AdoptionMetrics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401

md_content = """
### Please enable the \"Core REST API\" integration to present Adoption Metrics.
"""


def check_phishing_incidents() -> bool | DemistoException:
"""
Expand Down Expand Up @@ -96,24 +100,37 @@ def get_use_cases() -> Dict[str, Any]:
}


def check_core_api_installed() -> bool | DemistoException:
try:
res = demisto.executeCommand('IsIntegrationAvailable', {'brandname': 'Core REST API'})[0]['Contents']['Offset']
if res == 2: # '1' - enabled / '2' - disabled
return False
return True
except DemistoException as e:
return DemistoException(str(e))


def main():
use_cases_data = get_use_cases()

headers = ['Use Case Adoption & Coverage', 'Status']
t = []
for use_case in use_cases_data['use_cases_in_production']:
t.append({'Use Case Adoption & Coverage': use_case, 'Status': '✅'})
if (check_core_api_installed()):
use_cases_data = get_use_cases()
headers = ['Use Case Adoption & Coverage', 'Status']
t = []
for use_case in use_cases_data['use_cases_in_production']:
t.append({'Use Case Adoption & Coverage': use_case, 'Status': '✅'})

for use_case, _ in use_cases_data['at_risk'].items():
t.append({'Use Case Adoption & Coverage': use_case, 'Status': '❌'})
table = tableToMarkdown(name='Use Case Coverage', t=t, headers=headers)
for use_case, _ in use_cases_data['at_risk'].items():
t.append({'Use Case Adoption & Coverage': use_case, 'Status': '❌'})
table = tableToMarkdown(name='Use Case Coverage', t=t, headers=headers)

return_results(table)
return table
return_results(table)
return table
else:
return_results(md_content)
return None


''' ENTRY POINT '''


if __name__ in ('__main__', '__builtin__', 'builtins'):
main()

0 comments on commit 25e7030

Please sign in to comment.