|
@@ 1441-1491 (lines=51) @@
|
| 1438 |
|
cmd.add_element('copy', schedule_id) |
| 1439 |
|
return self._send_xml_command(cmd) |
| 1440 |
|
|
| 1441 |
|
def create_tag(self, name, resource_id, resource_type, *, value=None, |
| 1442 |
|
comment=None, active=None): |
| 1443 |
|
"""Create a new tag |
| 1444 |
|
|
| 1445 |
|
Arguments: |
| 1446 |
|
name (str): Name of the tag. A full tag name consisting of namespace |
| 1447 |
|
and predicate e.g. `foo:bar`. |
| 1448 |
|
resource_id (str): ID of the resource the tag is to be attached to. |
| 1449 |
|
resource_type (str): Entity type the tag is to be attached to |
| 1450 |
|
value (str, optional): Value associated with the tag |
| 1451 |
|
comment (str, optional): Comment for the tag |
| 1452 |
|
active (boolean, optional): Whether the tag should be active |
| 1453 |
|
|
| 1454 |
|
Returns: |
| 1455 |
|
The response. See :py:meth:`send_command` for details. |
| 1456 |
|
""" |
| 1457 |
|
if not name: |
| 1458 |
|
raise RequiredArgument( |
| 1459 |
|
'create_tag requires name argument' |
| 1460 |
|
) |
| 1461 |
|
|
| 1462 |
|
if not resource_id: |
| 1463 |
|
raise RequiredArgument( |
| 1464 |
|
'create_tag requires resource_id argument' |
| 1465 |
|
) |
| 1466 |
|
|
| 1467 |
|
if not resource_type: |
| 1468 |
|
raise RequiredArgument( |
| 1469 |
|
'create_tag requires resource_type argument' |
| 1470 |
|
) |
| 1471 |
|
|
| 1472 |
|
|
| 1473 |
|
cmd = XmlCommand('create_tag') |
| 1474 |
|
cmd.add_element('name', name) |
| 1475 |
|
_xmlresource = cmd.add_element('resource', |
| 1476 |
|
attrs={'id': str(resource_id)}) |
| 1477 |
|
_xmlresource.add_element('type', resource_type) |
| 1478 |
|
|
| 1479 |
|
if comment: |
| 1480 |
|
cmd.add_element('comment', comment) |
| 1481 |
|
|
| 1482 |
|
if value: |
| 1483 |
|
cmd.add_element('value', value) |
| 1484 |
|
|
| 1485 |
|
if not active is None: |
| 1486 |
|
if active: |
| 1487 |
|
cmd.add_element('active', '1') |
| 1488 |
|
else: |
| 1489 |
|
cmd.add_element('active', '0') |
| 1490 |
|
|
| 1491 |
|
return self._send_xml_command(cmd) |
| 1492 |
|
|
| 1493 |
|
def clone_tag(self, tag_id): |
| 1494 |
|
"""Clone an existing tag |
|
@@ 4441-4485 (lines=45) @@
|
| 4438 |
|
|
| 4439 |
|
return self._send_xml_command(cmd) |
| 4440 |
|
|
| 4441 |
|
def modify_tag(self, tag_id, *, comment=None, name=None, value=None, |
| 4442 |
|
active=None, resource_id=None, resource_type=None): |
| 4443 |
|
"""Modifies an existing tag. |
| 4444 |
|
|
| 4445 |
|
Arguments: |
| 4446 |
|
tag_id (str): UUID of the tag. |
| 4447 |
|
comment (str, optional): Comment to add to the tag. |
| 4448 |
|
name (str, optional): Name of the tag. |
| 4449 |
|
value (str, optional): Value of the tag. |
| 4450 |
|
active (boolean, optional): Whether the tag is active. |
| 4451 |
|
resource_id (str, optional): IDs of the resource to which to |
| 4452 |
|
attach the tag. |
| 4453 |
|
resource_type (str, optional): Type of the resource to which to |
| 4454 |
|
attach the tag. |
| 4455 |
|
|
| 4456 |
|
Returns: |
| 4457 |
|
The response. See :py:meth:`send_command` for details. |
| 4458 |
|
""" |
| 4459 |
|
if not tag_id: |
| 4460 |
|
raise RequiredArgument('modify_tag requires a tag_id element') |
| 4461 |
|
|
| 4462 |
|
cmd = XmlCommand('modify_tag') |
| 4463 |
|
cmd.set_attribute('tag_id', str(tag_id)) |
| 4464 |
|
|
| 4465 |
|
if comment: |
| 4466 |
|
cmd.add_element('comment', comment) |
| 4467 |
|
|
| 4468 |
|
if name: |
| 4469 |
|
cmd.add_element('name', name) |
| 4470 |
|
|
| 4471 |
|
if value: |
| 4472 |
|
cmd.add_element('value', value) |
| 4473 |
|
|
| 4474 |
|
if not active is None: |
| 4475 |
|
if active: |
| 4476 |
|
cmd.add_element('active', '1') |
| 4477 |
|
else: |
| 4478 |
|
cmd.add_element('active', '0') |
| 4479 |
|
|
| 4480 |
|
if resource_id and resource_type: |
| 4481 |
|
_xmlresource = cmd.add_element('resource', |
| 4482 |
|
attrs={'resource_id': resource_id}) |
| 4483 |
|
_xmlresource.add_element('type', resource_type) |
| 4484 |
|
|
| 4485 |
|
return self._send_xml_command(cmd) |
| 4486 |
|
|
| 4487 |
|
def modify_target(self, target_id, *, name=None, comment=None, |
| 4488 |
|
hosts=None, hosts_ordering=None, |