@@ 724-772 (lines=49) @@ | ||
721 | cmd.add_element("copy", credential_id) |
|
722 | return self._send_xml_command(cmd) |
|
723 | ||
724 | def create_filter( |
|
725 | self, |
|
726 | name: str, |
|
727 | *, |
|
728 | make_unique: Optional[bool] = None, |
|
729 | filter_type: Optional[FilterType] = None, |
|
730 | comment: Optional[str] = None, |
|
731 | term: Optional[str] = None |
|
732 | ) -> Any: |
|
733 | """Create a new filter |
|
734 | ||
735 | Arguments: |
|
736 | name: Name of the new filter |
|
737 | make_unique: |
|
738 | filter_type: Filter for entity type |
|
739 | comment: Comment for the filter |
|
740 | term: Filter term e.g. 'name=foo' |
|
741 | ||
742 | Returns: |
|
743 | The response. See :py:meth:`send_command` for details. |
|
744 | """ |
|
745 | if not name: |
|
746 | raise RequiredArgument( |
|
747 | function=self.create_filter.__name__, argument="name" |
|
748 | ) |
|
749 | ||
750 | cmd = XmlCommand("create_filter") |
|
751 | _xmlname = cmd.add_element("name", name) |
|
752 | ||
753 | if comment: |
|
754 | cmd.add_element("comment", comment) |
|
755 | ||
756 | if term: |
|
757 | cmd.add_element("term", term) |
|
758 | ||
759 | if make_unique is not None: |
|
760 | cmd.add_element("make_unique", _to_bool(make_unique)) |
|
761 | ||
762 | if filter_type: |
|
763 | if not isinstance(filter_type, self.types.FilterType): |
|
764 | raise InvalidArgumentType( |
|
765 | function=self.create_filter.__name__, |
|
766 | argument="filter_type", |
|
767 | arg_type=self.types.FilterType.__name__, |
|
768 | ) |
|
769 | ||
770 | cmd.add_element("type", filter_type.value) |
|
771 | ||
772 | return self._send_xml_command(cmd) |
|
773 | ||
774 | def clone_filter(self, filter_id: str) -> Any: |
|
775 | """Clone an existing filter |
|
@@ 4806-4853 (lines=48) @@ | ||
4803 | ||
4804 | return self._send_xml_command(cmd) |
|
4805 | ||
4806 | def modify_filter( |
|
4807 | self, |
|
4808 | filter_id: str, |
|
4809 | *, |
|
4810 | comment: Optional[str] = None, |
|
4811 | name: Optional[str] = None, |
|
4812 | term: Optional[str] = None, |
|
4813 | filter_type: Optional[FilterType] = None |
|
4814 | ) -> Any: |
|
4815 | """Modifies an existing filter. |
|
4816 | ||
4817 | Arguments: |
|
4818 | filter_id: UUID of the filter to be modified |
|
4819 | comment: Comment on filter. |
|
4820 | name: Name of filter. |
|
4821 | term: Filter term. |
|
4822 | filter_type: Filter type the filter applies to. |
|
4823 | ||
4824 | Returns: |
|
4825 | The response. See :py:meth:`send_command` for details. |
|
4826 | """ |
|
4827 | if not filter_id: |
|
4828 | raise RequiredArgument( |
|
4829 | function=self.modify_filter.__name__, argument='filter_id' |
|
4830 | ) |
|
4831 | ||
4832 | cmd = XmlCommand("modify_filter") |
|
4833 | cmd.set_attribute("filter_id", filter_id) |
|
4834 | ||
4835 | if comment: |
|
4836 | cmd.add_element("comment", comment) |
|
4837 | ||
4838 | if name: |
|
4839 | cmd.add_element("name", name) |
|
4840 | ||
4841 | if term: |
|
4842 | cmd.add_element("term", term) |
|
4843 | ||
4844 | if filter_type: |
|
4845 | if not isinstance(filter_type, self.types.FilterType): |
|
4846 | raise InvalidArgumentType( |
|
4847 | function=self.modify_filter.__name__, |
|
4848 | argument='filter_type', |
|
4849 | arg_type=self.types.FilterType.__name__, |
|
4850 | ) |
|
4851 | cmd.add_element("type", filter_type.value) |
|
4852 | ||
4853 | return self._send_xml_command(cmd) |
|
4854 | ||
4855 | def modify_group( |
|
4856 | self, |
@@ 902-949 (lines=48) @@ | ||
899 | name, filter_type=filter_type, comment=comment, term=term |
|
900 | ) |
|
901 | ||
902 | def modify_filter( |
|
903 | self, |
|
904 | filter_id: str, |
|
905 | *, |
|
906 | comment: Optional[str] = None, |
|
907 | name: Optional[str] = None, |
|
908 | term: Optional[str] = None, |
|
909 | filter_type: Optional[FilterType] = None |
|
910 | ) -> Any: |
|
911 | """Modifies an existing filter. |
|
912 | ||
913 | Arguments: |
|
914 | filter_id: UUID of the filter to be modified |
|
915 | comment: Comment on filter. |
|
916 | name: Name of filter. |
|
917 | term: Filter term. |
|
918 | filter_type: Resource type filter applies to. |
|
919 | ||
920 | Returns: |
|
921 | The response. See :py:meth:`send_command` for details. |
|
922 | """ |
|
923 | if not filter_id: |
|
924 | raise RequiredArgument( |
|
925 | function=self.modify_filter.__name__, argument='filter_id' |
|
926 | ) |
|
927 | ||
928 | cmd = XmlCommand("modify_filter") |
|
929 | cmd.set_attribute("filter_id", filter_id) |
|
930 | ||
931 | if comment: |
|
932 | cmd.add_element("comment", comment) |
|
933 | ||
934 | if name: |
|
935 | cmd.add_element("name", name) |
|
936 | ||
937 | if term: |
|
938 | cmd.add_element("term", term) |
|
939 | ||
940 | if filter_type: |
|
941 | if not isinstance(filter_type, FilterType): |
|
942 | raise InvalidArgumentType( |
|
943 | function=self.modify_filter.__name__, |
|
944 | argument='filter_type', |
|
945 | arg_type=FilterType.__name__, |
|
946 | ) |
|
947 | cmd.add_element("type", filter_type.value) |
|
948 | ||
949 | return self._send_xml_command(cmd) |
|
950 | ||
951 | def create_schedule( |
|
952 | self, |