| @@ 4551-4599 (lines=49) @@ | ||
| 4548 | ||
| 4549 | return self._send_xml_command(cmd) |
|
| 4550 | ||
| 4551 | def modify_filter( |
|
| 4552 | self, |
|
| 4553 | filter_id: str, |
|
| 4554 | *, |
|
| 4555 | comment: Optional[str] = None, |
|
| 4556 | name: Optional[str] = None, |
|
| 4557 | term: Optional[str] = None, |
|
| 4558 | filter_type: Optional[FilterType] = None |
|
| 4559 | ) -> Any: |
|
| 4560 | """Modifies an existing filter. |
|
| 4561 | ||
| 4562 | Arguments: |
|
| 4563 | filter_id: UUID of the filter to be modified |
|
| 4564 | comment: Comment on filter. |
|
| 4565 | name: Name of filter. |
|
| 4566 | term: Filter term. |
|
| 4567 | filter_type: Filter type the filter applies to. |
|
| 4568 | ||
| 4569 | Returns: |
|
| 4570 | The response. See :py:meth:`send_command` for details. |
|
| 4571 | """ |
|
| 4572 | if not filter_id: |
|
| 4573 | raise RequiredArgument( |
|
| 4574 | "modify_filter requires a filter_id " "attribute" |
|
| 4575 | ) |
|
| 4576 | ||
| 4577 | cmd = XmlCommand("modify_filter") |
|
| 4578 | cmd.set_attribute("filter_id", filter_id) |
|
| 4579 | ||
| 4580 | if comment: |
|
| 4581 | cmd.add_element("comment", comment) |
|
| 4582 | ||
| 4583 | if name: |
|
| 4584 | cmd.add_element("name", name) |
|
| 4585 | ||
| 4586 | if term: |
|
| 4587 | cmd.add_element("term", term) |
|
| 4588 | ||
| 4589 | if filter_type: |
|
| 4590 | if not isinstance(filter_type, self.types.FilterType): |
|
| 4591 | raise InvalidArgument( |
|
| 4592 | "modify_filter requires filter_type to be a FilterType " |
|
| 4593 | "instance. was {}".format(filter_type), |
|
| 4594 | function="modify_filter", |
|
| 4595 | argument="filter_type", |
|
| 4596 | ) |
|
| 4597 | cmd.add_element("type", filter_type.value) |
|
| 4598 | ||
| 4599 | return self._send_xml_command(cmd) |
|
| 4600 | ||
| 4601 | def modify_group( |
|
| 4602 | self, |
|
| @@ 689-736 (lines=48) @@ | ||
| 686 | cmd.add_element("copy", credential_id) |
|
| 687 | return self._send_xml_command(cmd) |
|
| 688 | ||
| 689 | def create_filter( |
|
| 690 | self, |
|
| 691 | name: str, |
|
| 692 | *, |
|
| 693 | make_unique: Optional[bool] = None, |
|
| 694 | filter_type: Optional[FilterType] = None, |
|
| 695 | comment: Optional[str] = None, |
|
| 696 | term: Optional[str] = None |
|
| 697 | ) -> Any: |
|
| 698 | """Create a new filter |
|
| 699 | ||
| 700 | Arguments: |
|
| 701 | name: Name of the new filter |
|
| 702 | make_unique: |
|
| 703 | filter_type: Filter for entity type |
|
| 704 | comment: Comment for the filter |
|
| 705 | term: Filter term e.g. 'name=foo' |
|
| 706 | ||
| 707 | Returns: |
|
| 708 | The response. See :py:meth:`send_command` for details. |
|
| 709 | """ |
|
| 710 | if not name: |
|
| 711 | raise RequiredArgument(function="create_filter", argument="name") |
|
| 712 | ||
| 713 | cmd = XmlCommand("create_filter") |
|
| 714 | _xmlname = cmd.add_element("name", name) |
|
| 715 | ||
| 716 | if comment: |
|
| 717 | cmd.add_element("comment", comment) |
|
| 718 | ||
| 719 | if term: |
|
| 720 | cmd.add_element("term", term) |
|
| 721 | ||
| 722 | if make_unique is not None: |
|
| 723 | cmd.add_element("make_unique", _to_bool(make_unique)) |
|
| 724 | ||
| 725 | if filter_type: |
|
| 726 | if not isinstance(filter_type, self.types.FilterType): |
|
| 727 | raise InvalidArgument( |
|
| 728 | "create_filter requires filter_type to be a FilterType " |
|
| 729 | "instance. was {}".format(filter_type), |
|
| 730 | function="create_filter", |
|
| 731 | argument="filter_type", |
|
| 732 | ) |
|
| 733 | ||
| 734 | cmd.add_element("type", filter_type.value) |
|
| 735 | ||
| 736 | return self._send_xml_command(cmd) |
|
| 737 | ||
| 738 | def clone_filter(self, filter_id: str) -> Any: |
|
| 739 | """Clone an existing filter |
|
| @@ 910-958 (lines=49) @@ | ||
| 907 | name, filter_type=filter_type, comment=comment, term=term |
|
| 908 | ) |
|
| 909 | ||
| 910 | def modify_filter( |
|
| 911 | self, |
|
| 912 | filter_id: str, |
|
| 913 | *, |
|
| 914 | comment: Optional[str] = None, |
|
| 915 | name: Optional[str] = None, |
|
| 916 | term: Optional[str] = None, |
|
| 917 | filter_type: Optional[FilterType] = None |
|
| 918 | ) -> Any: |
|
| 919 | """Modifies an existing filter. |
|
| 920 | ||
| 921 | Arguments: |
|
| 922 | filter_id: UUID of the filter to be modified |
|
| 923 | comment: Comment on filter. |
|
| 924 | name: Name of filter. |
|
| 925 | term: Filter term. |
|
| 926 | filter_type: Resource type filter applies to. |
|
| 927 | ||
| 928 | Returns: |
|
| 929 | The response. See :py:meth:`send_command` for details. |
|
| 930 | """ |
|
| 931 | if not filter_id: |
|
| 932 | raise RequiredArgument( |
|
| 933 | function="modify_filter", argument="filter_id" |
|
| 934 | ) |
|
| 935 | ||
| 936 | cmd = XmlCommand("modify_filter") |
|
| 937 | cmd.set_attribute("filter_id", filter_id) |
|
| 938 | ||
| 939 | if comment: |
|
| 940 | cmd.add_element("comment", comment) |
|
| 941 | ||
| 942 | if name: |
|
| 943 | cmd.add_element("name", name) |
|
| 944 | ||
| 945 | if term: |
|
| 946 | cmd.add_element("term", term) |
|
| 947 | ||
| 948 | if filter_type: |
|
| 949 | if not isinstance(filter_type, FilterType): |
|
| 950 | raise InvalidArgument( |
|
| 951 | "modify_filter requires type to be a FilterType instance. " |
|
| 952 | "was {}".format(filter_type), |
|
| 953 | function="modify_filter", |
|
| 954 | argument="filter_type", |
|
| 955 | ) |
|
| 956 | cmd.add_element("type", filter_type.value) |
|
| 957 | ||
| 958 | return self._send_xml_command(cmd) |
|
| 959 | ||
| 960 | def create_schedule( |
|
| 961 | self, |
|