@@ 1239-1323 (lines=85) @@ | ||
1236 | auto_add_new_families=auto_add_new_families, |
|
1237 | ) |
|
1238 | ||
1239 | def modify_tag( |
|
1240 | self, |
|
1241 | tag_id: str, |
|
1242 | *, |
|
1243 | comment: Optional[str] = None, |
|
1244 | name: Optional[str] = None, |
|
1245 | value=None, |
|
1246 | active=None, |
|
1247 | resource_action: Optional[str] = None, |
|
1248 | resource_type: Optional[EntityType] = None, |
|
1249 | resource_filter: Optional[str] = None, |
|
1250 | resource_ids: Optional[List[str]] = None, |
|
1251 | ) -> Any: |
|
1252 | """Modifies an existing tag. |
|
1253 | ||
1254 | Arguments: |
|
1255 | tag_id: UUID of the tag. |
|
1256 | comment: Comment to add to the tag. |
|
1257 | name: Name of the tag. |
|
1258 | value: Value of the tag. |
|
1259 | active: Whether the tag is active. |
|
1260 | resource_action: Whether to add or remove resources instead of |
|
1261 | overwriting. One of '', 'add', 'set' or 'remove'. |
|
1262 | resource_type: Type of the resources to which to attach the tag. |
|
1263 | Required if resource_filter is set. |
|
1264 | resource_filter: Filter term to select resources the tag is to be |
|
1265 | attached to. |
|
1266 | resource_ids: IDs of the resources to which to attach the tag. |
|
1267 | ||
1268 | Returns: |
|
1269 | The response. See :py:meth:`send_command` for details. |
|
1270 | """ |
|
1271 | if not tag_id: |
|
1272 | raise RequiredArgument( |
|
1273 | function=self.modify_tag.__name__, argument='tag_id' |
|
1274 | ) |
|
1275 | ||
1276 | cmd = XmlCommand("modify_tag") |
|
1277 | cmd.set_attribute("tag_id", str(tag_id)) |
|
1278 | ||
1279 | if comment: |
|
1280 | cmd.add_element("comment", comment) |
|
1281 | ||
1282 | if name: |
|
1283 | cmd.add_element("name", name) |
|
1284 | ||
1285 | if value: |
|
1286 | cmd.add_element("value", value) |
|
1287 | ||
1288 | if active is not None: |
|
1289 | cmd.add_element("active", _to_bool(active)) |
|
1290 | ||
1291 | if resource_action or resource_filter or resource_ids or resource_type: |
|
1292 | if resource_filter and not resource_type: |
|
1293 | raise RequiredArgument( |
|
1294 | function=self.modify_tag.__name__, argument='resource_type' |
|
1295 | ) |
|
1296 | ||
1297 | _xmlresources = cmd.add_element("resources") |
|
1298 | if resource_action is not None: |
|
1299 | _xmlresources.set_attribute("action", resource_action) |
|
1300 | ||
1301 | if resource_filter is not None: |
|
1302 | _xmlresources.set_attribute("filter", resource_filter) |
|
1303 | ||
1304 | for resource_id in resource_ids or []: |
|
1305 | _xmlresources.add_element( |
|
1306 | "resource", attrs={"id": str(resource_id)} |
|
1307 | ) |
|
1308 | ||
1309 | if resource_type is not None: |
|
1310 | if not isinstance(resource_type, self.types.EntityType): |
|
1311 | raise InvalidArgumentType( |
|
1312 | function=self.modify_tag.__name__, |
|
1313 | argument="resource_type", |
|
1314 | arg_type=EntityType.__name__, |
|
1315 | ) |
|
1316 | _actual_resource_type = resource_type |
|
1317 | if resource_type.value == EntityType.AUDIT.value: |
|
1318 | _actual_resource_type = EntityType.TASK |
|
1319 | elif resource_type.value == EntityType.POLICY.value: |
|
1320 | _actual_resource_type = EntityType.SCAN_CONFIG |
|
1321 | _xmlresources.add_element("type", _actual_resource_type.value) |
|
1322 | ||
1323 | return self._send_xml_command(cmd) |
|
1324 | ||
1325 | def modify_tls_certificate( |
|
1326 | self, |
@@ 1360-1444 (lines=85) @@ | ||
1357 | auto_add_new_families=auto_add_new_families, |
|
1358 | ) |
|
1359 | ||
1360 | def modify_tag( |
|
1361 | self, |
|
1362 | tag_id: str, |
|
1363 | *, |
|
1364 | comment: Optional[str] = None, |
|
1365 | name: Optional[str] = None, |
|
1366 | value=None, |
|
1367 | active=None, |
|
1368 | resource_action: Optional[str] = None, |
|
1369 | resource_type: Optional[EntityType] = None, |
|
1370 | resource_filter: Optional[str] = None, |
|
1371 | resource_ids: Optional[List[str]] = None, |
|
1372 | ) -> Any: |
|
1373 | """Modifies an existing tag. |
|
1374 | ||
1375 | Arguments: |
|
1376 | tag_id: UUID of the tag. |
|
1377 | comment: Comment to add to the tag. |
|
1378 | name: Name of the tag. |
|
1379 | value: Value of the tag. |
|
1380 | active: Whether the tag is active. |
|
1381 | resource_action: Whether to add or remove resources instead of |
|
1382 | overwriting. One of '', 'add', 'set' or 'remove'. |
|
1383 | resource_type: Type of the resources to which to attach the tag. |
|
1384 | Required if resource_filter is set. |
|
1385 | resource_filter: Filter term to select resources the tag is to be |
|
1386 | attached to. |
|
1387 | resource_ids: IDs of the resources to which to attach the tag. |
|
1388 | ||
1389 | Returns: |
|
1390 | The response. See :py:meth:`send_command` for details. |
|
1391 | """ |
|
1392 | if not tag_id: |
|
1393 | raise RequiredArgument( |
|
1394 | function=self.modify_tag.__name__, argument='tag_id' |
|
1395 | ) |
|
1396 | ||
1397 | cmd = XmlCommand("modify_tag") |
|
1398 | cmd.set_attribute("tag_id", str(tag_id)) |
|
1399 | ||
1400 | if comment: |
|
1401 | cmd.add_element("comment", comment) |
|
1402 | ||
1403 | if name: |
|
1404 | cmd.add_element("name", name) |
|
1405 | ||
1406 | if value: |
|
1407 | cmd.add_element("value", value) |
|
1408 | ||
1409 | if active is not None: |
|
1410 | cmd.add_element("active", _to_bool(active)) |
|
1411 | ||
1412 | if resource_action or resource_filter or resource_ids or resource_type: |
|
1413 | if resource_filter and not resource_type: |
|
1414 | raise RequiredArgument( |
|
1415 | function=self.modify_tag.__name__, argument='resource_type' |
|
1416 | ) |
|
1417 | ||
1418 | _xmlresources = cmd.add_element("resources") |
|
1419 | if resource_action is not None: |
|
1420 | _xmlresources.set_attribute("action", resource_action) |
|
1421 | ||
1422 | if resource_filter is not None: |
|
1423 | _xmlresources.set_attribute("filter", resource_filter) |
|
1424 | ||
1425 | for resource_id in resource_ids or []: |
|
1426 | _xmlresources.add_element( |
|
1427 | "resource", attrs={"id": str(resource_id)} |
|
1428 | ) |
|
1429 | ||
1430 | if resource_type is not None: |
|
1431 | if not isinstance(resource_type, self.types.EntityType): |
|
1432 | raise InvalidArgumentType( |
|
1433 | function=self.modify_tag.__name__, |
|
1434 | argument="resource_type", |
|
1435 | arg_type=EntityType.__name__, |
|
1436 | ) |
|
1437 | _actual_resource_type = resource_type |
|
1438 | if resource_type.value == EntityType.AUDIT.value: |
|
1439 | _actual_resource_type = EntityType.TASK |
|
1440 | elif resource_type.value == EntityType.POLICY.value: |
|
1441 | _actual_resource_type = EntityType.SCAN_CONFIG |
|
1442 | _xmlresources.add_element("type", _actual_resource_type.value) |
|
1443 | ||
1444 | return self._send_xml_command(cmd) |
|
1445 | ||
1446 | def modify_tls_certificate( |
|
1447 | self, |