| @@ 5196-5244 (lines=49) @@ | ||
| 5193 | ||
| 5194 | return self._send_xml_command(cmd) |
|
| 5195 | ||
| 5196 | def modify_filter( |
|
| 5197 | self, |
|
| 5198 | filter_id: str, |
|
| 5199 | *, |
|
| 5200 | comment: Optional[str] = None, |
|
| 5201 | name: Optional[str] = None, |
|
| 5202 | term: Optional[str] = None, |
|
| 5203 | filter_type: Optional[FilterType] = None |
|
| 5204 | ) -> Any: |
|
| 5205 | """Modifies an existing filter. |
|
| 5206 | ||
| 5207 | Arguments: |
|
| 5208 | filter_id: UUID of the filter to be modified |
|
| 5209 | comment: Comment on filter. |
|
| 5210 | name: Name of filter. |
|
| 5211 | term: Filter term. |
|
| 5212 | filter_type: Filter type the filter applies to. |
|
| 5213 | ||
| 5214 | Returns: |
|
| 5215 | The response. See :py:meth:`send_command` for details. |
|
| 5216 | """ |
|
| 5217 | if not filter_id: |
|
| 5218 | raise RequiredArgument( |
|
| 5219 | "modify_filter requires a filter_id " "attribute" |
|
| 5220 | ) |
|
| 5221 | ||
| 5222 | cmd = XmlCommand("modify_filter") |
|
| 5223 | cmd.set_attribute("filter_id", filter_id) |
|
| 5224 | ||
| 5225 | if comment: |
|
| 5226 | cmd.add_element("comment", comment) |
|
| 5227 | ||
| 5228 | if name: |
|
| 5229 | cmd.add_element("name", name) |
|
| 5230 | ||
| 5231 | if term: |
|
| 5232 | cmd.add_element("term", term) |
|
| 5233 | ||
| 5234 | if filter_type: |
|
| 5235 | if not isinstance(filter_type, self._filter_type): |
|
| 5236 | raise InvalidArgument( |
|
| 5237 | "modify_filter requires filter_type to be a FilterType " |
|
| 5238 | "instance. was {}".format(filter_type), |
|
| 5239 | function="modify_filter", |
|
| 5240 | argument="filter_type", |
|
| 5241 | ) |
|
| 5242 | cmd.add_element("type", filter_type.value) |
|
| 5243 | ||
| 5244 | return self._send_xml_command(cmd) |
|
| 5245 | ||
| 5246 | def modify_group( |
|
| 5247 | self, |
|
| @@ 1334-1381 (lines=48) @@ | ||
| 1331 | cmd.add_element("copy", credential_id) |
|
| 1332 | return self._send_xml_command(cmd) |
|
| 1333 | ||
| 1334 | def create_filter( |
|
| 1335 | self, |
|
| 1336 | name: str, |
|
| 1337 | *, |
|
| 1338 | make_unique: Optional[bool] = None, |
|
| 1339 | filter_type: Optional[FilterType] = None, |
|
| 1340 | comment: Optional[str] = None, |
|
| 1341 | term: Optional[str] = None |
|
| 1342 | ) -> Any: |
|
| 1343 | """Create a new filter |
|
| 1344 | ||
| 1345 | Arguments: |
|
| 1346 | name: Name of the new filter |
|
| 1347 | make_unique: |
|
| 1348 | filter_type: Filter for entity type |
|
| 1349 | comment: Comment for the filter |
|
| 1350 | term: Filter term e.g. 'name=foo' |
|
| 1351 | ||
| 1352 | Returns: |
|
| 1353 | The response. See :py:meth:`send_command` for details. |
|
| 1354 | """ |
|
| 1355 | if not name: |
|
| 1356 | raise RequiredArgument(function="create_filter", argument="name") |
|
| 1357 | ||
| 1358 | cmd = XmlCommand("create_filter") |
|
| 1359 | _xmlname = cmd.add_element("name", name) |
|
| 1360 | ||
| 1361 | if comment: |
|
| 1362 | cmd.add_element("comment", comment) |
|
| 1363 | ||
| 1364 | if term: |
|
| 1365 | cmd.add_element("term", term) |
|
| 1366 | ||
| 1367 | if make_unique is not None: |
|
| 1368 | cmd.add_element("make_unique", _to_bool(make_unique)) |
|
| 1369 | ||
| 1370 | if filter_type: |
|
| 1371 | if not isinstance(filter_type, self._filter_type): |
|
| 1372 | raise InvalidArgument( |
|
| 1373 | "create_filter requires filter_type to be a FilterType " |
|
| 1374 | "instance. was {}".format(filter_type), |
|
| 1375 | function="create_filter", |
|
| 1376 | argument="filter_type", |
|
| 1377 | ) |
|
| 1378 | ||
| 1379 | cmd.add_element("type", filter_type.value) |
|
| 1380 | ||
| 1381 | return self._send_xml_command(cmd) |
|
| 1382 | ||
| 1383 | def clone_filter(self, filter_id: str) -> Any: |
|
| 1384 | """Clone an existing filter |
|
| @@ 1071-1119 (lines=49) @@ | ||
| 1068 | name, filter_type=filter_type, comment=comment, term=term |
|
| 1069 | ) |
|
| 1070 | ||
| 1071 | def modify_filter( |
|
| 1072 | self, |
|
| 1073 | filter_id: str, |
|
| 1074 | *, |
|
| 1075 | comment: Optional[str] = None, |
|
| 1076 | name: Optional[str] = None, |
|
| 1077 | term: Optional[str] = None, |
|
| 1078 | filter_type: Optional[FilterType] = None |
|
| 1079 | ) -> Any: |
|
| 1080 | """Modifies an existing filter. |
|
| 1081 | ||
| 1082 | Arguments: |
|
| 1083 | filter_id: UUID of the filter to be modified |
|
| 1084 | comment: Comment on filter. |
|
| 1085 | name: Name of filter. |
|
| 1086 | term: Filter term. |
|
| 1087 | filter_type: Resource type filter applies to. |
|
| 1088 | ||
| 1089 | Returns: |
|
| 1090 | The response. See :py:meth:`send_command` for details. |
|
| 1091 | """ |
|
| 1092 | if not filter_id: |
|
| 1093 | raise RequiredArgument( |
|
| 1094 | function="modify_filter", argument="filter_id" |
|
| 1095 | ) |
|
| 1096 | ||
| 1097 | cmd = XmlCommand("modify_filter") |
|
| 1098 | cmd.set_attribute("filter_id", filter_id) |
|
| 1099 | ||
| 1100 | if comment: |
|
| 1101 | cmd.add_element("comment", comment) |
|
| 1102 | ||
| 1103 | if name: |
|
| 1104 | cmd.add_element("name", name) |
|
| 1105 | ||
| 1106 | if term: |
|
| 1107 | cmd.add_element("term", term) |
|
| 1108 | ||
| 1109 | if filter_type: |
|
| 1110 | if not isinstance(filter_type, FilterType): |
|
| 1111 | raise InvalidArgument( |
|
| 1112 | "modify_filter requires type to be a FilterType instance. " |
|
| 1113 | "was {}".format(filter_type), |
|
| 1114 | function="modify_filter", |
|
| 1115 | argument="filter_type", |
|
| 1116 | ) |
|
| 1117 | cmd.add_element("type", filter_type.value) |
|
| 1118 | ||
| 1119 | return self._send_xml_command(cmd) |
|
| 1120 | ||