@@ 500-606 (lines=107) @@ | ||
497 | cmd.set_attribute("include_certificate_data", "1") |
|
498 | return self._send_xml_command(cmd) |
|
499 | ||
500 | def modify_alert( |
|
501 | self, |
|
502 | alert_id: str, |
|
503 | *, |
|
504 | name: Optional[str] = None, |
|
505 | comment: Optional[str] = None, |
|
506 | filter_id: Optional[str] = None, |
|
507 | event: Optional[AlertEvent] = None, |
|
508 | event_data: Optional[dict] = None, |
|
509 | condition: Optional[AlertCondition] = None, |
|
510 | condition_data: Optional[dict] = None, |
|
511 | method: Optional[AlertMethod] = None, |
|
512 | method_data: Optional[dict] = None |
|
513 | ) -> Any: |
|
514 | """Modifies an existing alert. |
|
515 | ||
516 | Arguments: |
|
517 | alert_id: UUID of the alert to be modified. |
|
518 | name: Name of the Alert. |
|
519 | condition: The condition that must be satisfied for the alert to |
|
520 | occur. If the event is either 'Updated SecInfo |
|
521 | arrived' or 'New SecInfo arrived', condition must be 'Always'. |
|
522 | Otherwise, condition can also be on of 'Severity at least', |
|
523 | 'Filter count changed' or 'Filter count at least'. |
|
524 | condition_data: Data that defines the condition |
|
525 | event: The event that must happen for the alert to occur, one of |
|
526 | 'Task run status changed', 'Updated SecInfo arrived' or |
|
527 | 'New SecInfo arrived' |
|
528 | event_data: Data that defines the event |
|
529 | method: The method by which the user is alerted, one of 'SCP', |
|
530 | 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; |
|
531 | if the event is neither 'Updated SecInfo arrived' nor |
|
532 | 'New SecInfo arrived', method can also be one of 'Start Task', |
|
533 | 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. |
|
534 | method_data: Data that defines the method |
|
535 | filter_id: Filter to apply when executing alert |
|
536 | comment: Comment for the alert |
|
537 | ||
538 | Returns: |
|
539 | The response. See :py:meth:`send_command` for details. |
|
540 | """ |
|
541 | ||
542 | if not alert_id: |
|
543 | raise RequiredArgument( |
|
544 | function=self.modify_alert.__name__, argument='alert_id' |
|
545 | ) |
|
546 | ||
547 | cmd = XmlCommand("modify_alert") |
|
548 | cmd.set_attribute("alert_id", str(alert_id)) |
|
549 | ||
550 | if name: |
|
551 | cmd.add_element("name", name) |
|
552 | ||
553 | if comment: |
|
554 | cmd.add_element("comment", comment) |
|
555 | ||
556 | if filter_id: |
|
557 | cmd.add_element("filter", attrs={"id": filter_id}) |
|
558 | ||
559 | if condition: |
|
560 | if not isinstance(condition, AlertCondition): |
|
561 | raise InvalidArgumentType( |
|
562 | function=self.modify_alert.__name__, |
|
563 | argument='condition', |
|
564 | arg_type=AlertCondition.__name__, |
|
565 | ) |
|
566 | ||
567 | conditions = cmd.add_element("condition", condition.value) |
|
568 | ||
569 | if condition_data is not None: |
|
570 | for key, value in condition_data.items(): |
|
571 | _data = conditions.add_element("data", value) |
|
572 | _data.add_element("name", key) |
|
573 | ||
574 | if method: |
|
575 | if not isinstance(method, AlertMethod): |
|
576 | raise InvalidArgumentType( |
|
577 | function=self.modify_alert.__name__, |
|
578 | argument='method', |
|
579 | arg_type=AlertMethod.__name__, |
|
580 | ) |
|
581 | ||
582 | methods = cmd.add_element("method", method.value) |
|
583 | ||
584 | if method_data is not None: |
|
585 | for key, value in method_data.items(): |
|
586 | _data = methods.add_element("data", value) |
|
587 | _data.add_element("name", key) |
|
588 | ||
589 | if event: |
|
590 | if not isinstance(event, AlertEvent): |
|
591 | raise InvalidArgumentType( |
|
592 | function=self.modify_alert.__name__, |
|
593 | argument='event', |
|
594 | arg_type=AlertEvent.__name__, |
|
595 | ) |
|
596 | ||
597 | _check_event(event, condition, method) |
|
598 | ||
599 | events = cmd.add_element("event", event.value) |
|
600 | ||
601 | if event_data is not None: |
|
602 | for key, value in event_data.items(): |
|
603 | _data = events.add_element("data", value) |
|
604 | _data.add_element("name", key) |
|
605 | ||
606 | return self._send_xml_command(cmd) |
|
607 | ||
608 | def modify_tls_certificate( |
|
609 | self, |
@@ 4349-4455 (lines=107) @@ | ||
4346 | ||
4347 | return self._send_xml_command(cmd) |
|
4348 | ||
4349 | def modify_alert( |
|
4350 | self, |
|
4351 | alert_id: str, |
|
4352 | *, |
|
4353 | name: Optional[str] = None, |
|
4354 | comment: Optional[str] = None, |
|
4355 | filter_id: Optional[str] = None, |
|
4356 | event: Optional[AlertEvent] = None, |
|
4357 | event_data: Optional[dict] = None, |
|
4358 | condition: Optional[AlertCondition] = None, |
|
4359 | condition_data: Optional[dict] = None, |
|
4360 | method: Optional[AlertMethod] = None, |
|
4361 | method_data: Optional[dict] = None |
|
4362 | ) -> Any: |
|
4363 | """Modifies an existing alert. |
|
4364 | ||
4365 | Arguments: |
|
4366 | alert_id: UUID of the alert to be modified. |
|
4367 | name: Name of the Alert. |
|
4368 | condition: The condition that must be satisfied for the alert to |
|
4369 | occur. If the event is either 'Updated SecInfo |
|
4370 | arrived' or 'New SecInfo arrived', condition must be 'Always'. |
|
4371 | Otherwise, condition can also be on of 'Severity at least', |
|
4372 | 'Filter count changed' or 'Filter count at least'. |
|
4373 | condition_data: Data that defines the condition |
|
4374 | event: The event that must happen for the alert to occur, one of |
|
4375 | 'Task run status changed', 'Updated SecInfo arrived' or |
|
4376 | 'New SecInfo arrived' |
|
4377 | event_data: Data that defines the event |
|
4378 | method: The method by which the user is alerted, one of 'SCP', |
|
4379 | 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; |
|
4380 | if the event is neither 'Updated SecInfo arrived' nor |
|
4381 | 'New SecInfo arrived', method can also be one of 'Start Task', |
|
4382 | 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. |
|
4383 | method_data: Data that defines the method |
|
4384 | filter_id: Filter to apply when executing alert |
|
4385 | comment: Comment for the alert |
|
4386 | ||
4387 | Returns: |
|
4388 | The response. See :py:meth:`send_command` for details. |
|
4389 | """ |
|
4390 | ||
4391 | if not alert_id: |
|
4392 | raise RequiredArgument( |
|
4393 | function=self.modify_alert.__name__, argument='alert_id' |
|
4394 | ) |
|
4395 | ||
4396 | cmd = XmlCommand("modify_alert") |
|
4397 | cmd.set_attribute("alert_id", str(alert_id)) |
|
4398 | ||
4399 | if name: |
|
4400 | cmd.add_element("name", name) |
|
4401 | ||
4402 | if comment: |
|
4403 | cmd.add_element("comment", comment) |
|
4404 | ||
4405 | if filter_id: |
|
4406 | cmd.add_element("filter", attrs={"id": filter_id}) |
|
4407 | ||
4408 | if condition: |
|
4409 | if not isinstance(condition, AlertCondition): |
|
4410 | raise InvalidArgumentType( |
|
4411 | function=self.modify_alert.__name__, |
|
4412 | argument='condition', |
|
4413 | arg_type=AlertCondition.__name__, |
|
4414 | ) |
|
4415 | ||
4416 | conditions = cmd.add_element("condition", condition.value) |
|
4417 | ||
4418 | if condition_data is not None: |
|
4419 | for key, value in condition_data.items(): |
|
4420 | _data = conditions.add_element("data", value) |
|
4421 | _data.add_element("name", key) |
|
4422 | ||
4423 | if method: |
|
4424 | if not isinstance(method, AlertMethod): |
|
4425 | raise InvalidArgumentType( |
|
4426 | function=self.modify_alert.__name__, |
|
4427 | argument='method', |
|
4428 | arg_type=AlertMethod.__name__, |
|
4429 | ) |
|
4430 | ||
4431 | methods = cmd.add_element("method", method.value) |
|
4432 | ||
4433 | if method_data is not None: |
|
4434 | for key, value in method_data.items(): |
|
4435 | _data = methods.add_element("data", value) |
|
4436 | _data.add_element("name", key) |
|
4437 | ||
4438 | if event: |
|
4439 | if not isinstance(event, AlertEvent): |
|
4440 | raise InvalidArgumentType( |
|
4441 | function=self.modify_alert.__name__, |
|
4442 | argument='event', |
|
4443 | arg_type=AlertEvent.__name__, |
|
4444 | ) |
|
4445 | ||
4446 | _check_event(event, condition, method) |
|
4447 | ||
4448 | events = cmd.add_element("event", event.value) |
|
4449 | ||
4450 | if event_data is not None: |
|
4451 | for key, value in event_data.items(): |
|
4452 | _data = events.add_element("data", value) |
|
4453 | _data.add_element("name", key) |
|
4454 | ||
4455 | return self._send_xml_command(cmd) |
|
4456 | ||
4457 | def modify_asset(self, asset_id: str, comment: Optional[str] = "") -> Any: |
|
4458 | """Modifies an existing asset. |