@@ 6381-6454 (lines=74) @@ | ||
6378 | ||
6379 | return self._send_xml_command(cmd) |
|
6380 | ||
6381 | def modify_note( |
|
6382 | self, |
|
6383 | note_id: str, |
|
6384 | text: str, |
|
6385 | *, |
|
6386 | days_active: Optional[int] = None, |
|
6387 | hosts: Optional[List[str]] = None, |
|
6388 | port: Optional[int] = None, |
|
6389 | result_id: Optional[str] = None, |
|
6390 | severity: Optional[Severity] = None, |
|
6391 | task_id: Optional[str] = None, |
|
6392 | threat: Optional[SeverityLevel] = None, |
|
6393 | ) -> Any: |
|
6394 | """Modifies an existing note. |
|
6395 | ||
6396 | Arguments: |
|
6397 | note_id: UUID of note to modify. |
|
6398 | text: The text of the note. |
|
6399 | days_active: Days note will be active. -1 on always, 0 off. |
|
6400 | hosts: A list of hosts addresses |
|
6401 | port: Port to which note applies. |
|
6402 | result_id: Result to which note applies. |
|
6403 | severity: Severity to which note applies. |
|
6404 | task_id: Task to which note applies. |
|
6405 | threat: Threat level to which note applies. Will be converted to |
|
6406 | severity. |
|
6407 | ||
6408 | Returns: |
|
6409 | The response. See :py:meth:`send_command` for details. |
|
6410 | """ |
|
6411 | if not note_id: |
|
6412 | raise RequiredArgument( |
|
6413 | function=self.modify_note.__name__, argument='note_id' |
|
6414 | ) |
|
6415 | ||
6416 | if not text: |
|
6417 | raise RequiredArgument( |
|
6418 | function=self.modify_note.__name__, argument='text' |
|
6419 | ) |
|
6420 | ||
6421 | cmd = XmlCommand("modify_note") |
|
6422 | cmd.set_attribute("note_id", note_id) |
|
6423 | cmd.add_element("text", text) |
|
6424 | ||
6425 | if days_active is not None: |
|
6426 | cmd.add_element("active", str(days_active)) |
|
6427 | ||
6428 | if hosts: |
|
6429 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
6430 | ||
6431 | if port: |
|
6432 | cmd.add_element("port", str(port)) |
|
6433 | ||
6434 | if result_id: |
|
6435 | cmd.add_element("result", attrs={"id": result_id}) |
|
6436 | ||
6437 | if severity: |
|
6438 | cmd.add_element("severity", str(severity)) |
|
6439 | ||
6440 | if task_id: |
|
6441 | cmd.add_element("task", attrs={"id": task_id}) |
|
6442 | ||
6443 | if threat is not None: |
|
6444 | ||
6445 | if not isinstance(threat, SeverityLevel): |
|
6446 | raise InvalidArgumentType( |
|
6447 | function=self.modify_note.__name__, |
|
6448 | argument='threat', |
|
6449 | arg_type=SeverityLevel.__name__, |
|
6450 | ) |
|
6451 | ||
6452 | cmd.add_element("threat", threat.value) |
|
6453 | ||
6454 | return self._send_xml_command(cmd) |
|
6455 | ||
6456 | def modify_override( |
|
6457 | self, |
|
@@ 3439-3512 (lines=74) @@ | ||
3436 | ||
3437 | return self._send_xml_command(cmd) |
|
3438 | ||
3439 | def create_note( |
|
3440 | self, |
|
3441 | text: str, |
|
3442 | nvt_oid: str, |
|
3443 | *, |
|
3444 | days_active: Optional[int] = None, |
|
3445 | hosts: Optional[List[str]] = None, |
|
3446 | port: Optional[int] = None, |
|
3447 | result_id: Optional[str] = None, |
|
3448 | severity: Optional[Severity] = None, |
|
3449 | task_id: Optional[str] = None, |
|
3450 | threat: Optional[SeverityLevel] = None, |
|
3451 | ) -> Any: |
|
3452 | """Create a new note |
|
3453 | ||
3454 | Arguments: |
|
3455 | text: Text of the new note |
|
3456 | nvt_id: OID of the nvt to which note applies |
|
3457 | days_active: Days note will be active. -1 on |
|
3458 | always, 0 off |
|
3459 | hosts: A list of hosts addresses |
|
3460 | port: Port to which the note applies |
|
3461 | result_id: UUID of a result to which note applies |
|
3462 | severity: Severity to which note applies |
|
3463 | task_id: UUID of task to which note applies |
|
3464 | threat: Severity level to which note applies. Will be converted to |
|
3465 | severity. |
|
3466 | ||
3467 | Returns: |
|
3468 | The response. See :py:meth:`send_command` for details. |
|
3469 | """ |
|
3470 | if not text: |
|
3471 | raise RequiredArgument( |
|
3472 | function=self.create_note.__name__, argument='text' |
|
3473 | ) |
|
3474 | ||
3475 | if not nvt_oid: |
|
3476 | raise RequiredArgument( |
|
3477 | function=self.create_note.__name__, argument='nvt_oid' |
|
3478 | ) |
|
3479 | ||
3480 | cmd = XmlCommand("create_note") |
|
3481 | cmd.add_element("text", text) |
|
3482 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
3483 | ||
3484 | if days_active is not None: |
|
3485 | cmd.add_element("active", str(days_active)) |
|
3486 | ||
3487 | if hosts: |
|
3488 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
3489 | ||
3490 | if port: |
|
3491 | cmd.add_element("port", str(port)) |
|
3492 | ||
3493 | if result_id: |
|
3494 | cmd.add_element("result", attrs={"id": result_id}) |
|
3495 | ||
3496 | if severity: |
|
3497 | cmd.add_element("severity", str(severity)) |
|
3498 | ||
3499 | if task_id: |
|
3500 | cmd.add_element("task", attrs={"id": task_id}) |
|
3501 | ||
3502 | if threat is not None: |
|
3503 | if not isinstance(threat, SeverityLevel): |
|
3504 | raise InvalidArgumentType( |
|
3505 | function="create_note", |
|
3506 | argument="threat", |
|
3507 | arg_type=SeverityLevel.__name__, |
|
3508 | ) |
|
3509 | ||
3510 | cmd.add_element("threat", threat.value) |
|
3511 | ||
3512 | return self._send_xml_command(cmd) |
|
3513 | ||
3514 | def clone_note(self, note_id: str) -> Any: |
|
3515 | """Clone an existing note |
@@ 5100-5173 (lines=74) @@ | ||
5097 | ||
5098 | return self._send_xml_command(cmd) |
|
5099 | ||
5100 | def modify_note( |
|
5101 | self, |
|
5102 | note_id: str, |
|
5103 | text: str, |
|
5104 | *, |
|
5105 | days_active: Optional[int] = None, |
|
5106 | hosts: Optional[List[str]] = None, |
|
5107 | port: Optional[int] = None, |
|
5108 | result_id: Optional[str] = None, |
|
5109 | severity: Optional[Severity] = None, |
|
5110 | task_id: Optional[str] = None, |
|
5111 | threat: Optional[SeverityLevel] = None, |
|
5112 | ) -> Any: |
|
5113 | """Modifies an existing note. |
|
5114 | ||
5115 | Arguments: |
|
5116 | note_id: UUID of note to modify. |
|
5117 | text: The text of the note. |
|
5118 | days_active: Days note will be active. -1 on always, 0 off. |
|
5119 | hosts: A list of hosts addresses |
|
5120 | port: Port to which note applies. |
|
5121 | result_id: Result to which note applies. |
|
5122 | severity: Severity to which note applies. |
|
5123 | task_id: Task to which note applies. |
|
5124 | threat: Threat level to which note applies. Will be converted to |
|
5125 | severity. |
|
5126 | ||
5127 | Returns: |
|
5128 | The response. See :py:meth:`send_command` for details. |
|
5129 | """ |
|
5130 | if not note_id: |
|
5131 | raise RequiredArgument( |
|
5132 | function=self.modify_note.__name__, argument='note_id' |
|
5133 | ) |
|
5134 | ||
5135 | if not text: |
|
5136 | raise RequiredArgument( |
|
5137 | function=self.modify_note.__name__, argument='text' |
|
5138 | ) |
|
5139 | ||
5140 | cmd = XmlCommand("modify_note") |
|
5141 | cmd.set_attribute("note_id", note_id) |
|
5142 | cmd.add_element("text", text) |
|
5143 | ||
5144 | if days_active is not None: |
|
5145 | cmd.add_element("active", str(days_active)) |
|
5146 | ||
5147 | if hosts: |
|
5148 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
5149 | ||
5150 | if port: |
|
5151 | cmd.add_element("port", str(port)) |
|
5152 | ||
5153 | if result_id: |
|
5154 | cmd.add_element("result", attrs={"id": result_id}) |
|
5155 | ||
5156 | if severity: |
|
5157 | cmd.add_element("severity", str(severity)) |
|
5158 | ||
5159 | if task_id: |
|
5160 | cmd.add_element("task", attrs={"id": task_id}) |
|
5161 | ||
5162 | if threat is not None: |
|
5163 | ||
5164 | if not isinstance(threat, SeverityLevel): |
|
5165 | raise InvalidArgumentType( |
|
5166 | function=self.modify_note.__name__, |
|
5167 | argument='threat', |
|
5168 | arg_type=SeverityLevel.__name__, |
|
5169 | ) |
|
5170 | ||
5171 | cmd.add_element("threat", threat.value) |
|
5172 | ||
5173 | return self._send_xml_command(cmd) |
|
5174 | ||
5175 | def modify_override( |
|
5176 | self, |
|
@@ 890-963 (lines=74) @@ | ||
887 | ||
888 | return self._send_xml_command(cmd) |
|
889 | ||
890 | def create_note( |
|
891 | self, |
|
892 | text: str, |
|
893 | nvt_oid: str, |
|
894 | *, |
|
895 | days_active: Optional[int] = None, |
|
896 | hosts: Optional[List[str]] = None, |
|
897 | port: Optional[int] = None, |
|
898 | result_id: Optional[str] = None, |
|
899 | severity: Optional[Severity] = None, |
|
900 | task_id: Optional[str] = None, |
|
901 | threat: Optional[SeverityLevel] = None, |
|
902 | ) -> Any: |
|
903 | """Create a new note |
|
904 | ||
905 | Arguments: |
|
906 | text: Text of the new note |
|
907 | nvt_id: OID of the nvt to which note applies |
|
908 | days_active: Days note will be active. -1 on |
|
909 | always, 0 off |
|
910 | hosts: A list of hosts addresses |
|
911 | port: Port to which the note applies |
|
912 | result_id: UUID of a result to which note applies |
|
913 | severity: Severity to which note applies |
|
914 | task_id: UUID of task to which note applies |
|
915 | threat: Severity level to which note applies. Will be converted to |
|
916 | severity. |
|
917 | ||
918 | Returns: |
|
919 | The response. See :py:meth:`send_command` for details. |
|
920 | """ |
|
921 | if not text: |
|
922 | raise RequiredArgument( |
|
923 | function=self.create_note.__name__, argument='text' |
|
924 | ) |
|
925 | ||
926 | if not nvt_oid: |
|
927 | raise RequiredArgument( |
|
928 | function=self.create_note.__name__, argument='nvt_oid' |
|
929 | ) |
|
930 | ||
931 | cmd = XmlCommand("create_note") |
|
932 | cmd.add_element("text", text) |
|
933 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
934 | ||
935 | if days_active is not None: |
|
936 | cmd.add_element("active", str(days_active)) |
|
937 | ||
938 | if hosts: |
|
939 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
940 | ||
941 | if port: |
|
942 | cmd.add_element("port", str(port)) |
|
943 | ||
944 | if result_id: |
|
945 | cmd.add_element("result", attrs={"id": result_id}) |
|
946 | ||
947 | if severity: |
|
948 | cmd.add_element("severity", str(severity)) |
|
949 | ||
950 | if task_id: |
|
951 | cmd.add_element("task", attrs={"id": task_id}) |
|
952 | ||
953 | if threat is not None: |
|
954 | if not isinstance(threat, SeverityLevel): |
|
955 | raise InvalidArgumentType( |
|
956 | function="create_note", |
|
957 | argument="threat", |
|
958 | arg_type=SeverityLevel.__name__, |
|
959 | ) |
|
960 | ||
961 | cmd.add_element("threat", threat.value) |
|
962 | ||
963 | return self._send_xml_command(cmd) |
|
964 | ||
965 | def clone_note(self, note_id: str) -> Any: |
|
966 | """Clone an existing note |