Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added create-alert #12

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Packs/Doppel/Integrations/Doppel/Doppel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def get_alerts(self, params: Dict[str, Any]) -> List[Dict[str, Any]]:
params=filtered_params
)
return response_content

def create_alert(self, entity: str) -> Dict[str, Any]:
api_name = "alert"
api_url = f"{self._base_url}/{api_name}"
response_content = self._http_request(
method="POST",
full_url=api_url,
json_data={"entity": entity}
)
return response_content

''' HELPER FUNCTIONS '''

Expand Down Expand Up @@ -236,6 +246,19 @@ def get_alerts_command(client: Client, args: Dict[str, Any]) -> CommandResults:
readable_output=readable_output
)

def create_alert_command(client: Client, args: Dict[str, Any]) -> CommandResults:
entity = args.get('entity')
if not entity:
raise ValueError("Entity must be specified to create an alert.")

result = client.create_alert(entity=entity)

return CommandResults(
outputs_prefix='Doppel.CreatedAlert',
outputs_key_field='id',
outputs=result,
)


''' MAIN FUNCTION '''

Expand Down Expand Up @@ -268,6 +291,8 @@ def main() -> None:
return_results(update_alert_command(client, demisto.args()))
elif current_command == 'get-alerts':
return_results(get_alerts_command(client, demisto.args()))
elif current_command == 'create-alert':
return_results(create_alert_command(client, demisto.args()))

# Log exceptions and return errors
except Exception as e:
Expand Down
14 changes: 14 additions & 0 deletions Packs/Doppel/Integrations/Doppel/Doppel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ script:
- contextPath: Doppel.GetAlerts


- name: create-alert
arguments:
description: Creates an alert for a specified entity. This command requires the
entity to be provided in the arguments.
- name: entity
required: true
description: The entity for which the alert should be created.
outputs:
- contextPath: Doppel.CreatedAlert
description: The details of the created alert, including its unique ID and other
relevant metadata.
type: string


- name: update-alert
description: Updates a alert in the system with certain parameters.
arguments:
Expand Down
Loading