|
@@ 1481-1531 (lines=51) @@
|
| 1478 |
|
cmd.add_element('copy', schedule_id) |
| 1479 |
|
return self._send_xml_command(cmd) |
| 1480 |
|
|
| 1481 |
|
def create_tag(self, name, resource_id, resource_type, *, value=None, |
| 1482 |
|
comment=None, active=None): |
| 1483 |
|
"""Create a new tag |
| 1484 |
|
|
| 1485 |
|
Arguments: |
| 1486 |
|
name (str): Name of the tag. A full tag name consisting of namespace |
| 1487 |
|
and predicate e.g. `foo:bar`. |
| 1488 |
|
resource_id (str): ID of the resource the tag is to be attached to. |
| 1489 |
|
resource_type (str): Entity type the tag is to be attached to |
| 1490 |
|
value (str, optional): Value associated with the tag |
| 1491 |
|
comment (str, optional): Comment for the tag |
| 1492 |
|
active (boolean, optional): Whether the tag should be active |
| 1493 |
|
|
| 1494 |
|
Returns: |
| 1495 |
|
The response. See :py:meth:`send_command` for details. |
| 1496 |
|
""" |
| 1497 |
|
if not name: |
| 1498 |
|
raise RequiredArgument( |
| 1499 |
|
'create_tag requires name argument' |
| 1500 |
|
) |
| 1501 |
|
|
| 1502 |
|
if not resource_id: |
| 1503 |
|
raise RequiredArgument( |
| 1504 |
|
'create_tag requires resource_id argument' |
| 1505 |
|
) |
| 1506 |
|
|
| 1507 |
|
if not resource_type: |
| 1508 |
|
raise RequiredArgument( |
| 1509 |
|
'create_tag requires resource_type argument' |
| 1510 |
|
) |
| 1511 |
|
|
| 1512 |
|
|
| 1513 |
|
cmd = XmlCommand('create_tag') |
| 1514 |
|
cmd.add_element('name', name) |
| 1515 |
|
_xmlresource = cmd.add_element('resource', |
| 1516 |
|
attrs={'id': str(resource_id)}) |
| 1517 |
|
_xmlresource.add_element('type', resource_type) |
| 1518 |
|
|
| 1519 |
|
if comment: |
| 1520 |
|
cmd.add_element('comment', comment) |
| 1521 |
|
|
| 1522 |
|
if value: |
| 1523 |
|
cmd.add_element('value', value) |
| 1524 |
|
|
| 1525 |
|
if not active is None: |
| 1526 |
|
if active: |
| 1527 |
|
cmd.add_element('active', '1') |
| 1528 |
|
else: |
| 1529 |
|
cmd.add_element('active', '0') |
| 1530 |
|
|
| 1531 |
|
return self._send_xml_command(cmd) |
| 1532 |
|
|
| 1533 |
|
def clone_tag(self, tag_id): |
| 1534 |
|
"""Clone an existing tag |
|
@@ 4706-4750 (lines=45) @@
|
| 4703 |
|
|
| 4704 |
|
return self._send_xml_command(cmd) |
| 4705 |
|
|
| 4706 |
|
def modify_tag(self, tag_id, *, comment=None, name=None, value=None, |
| 4707 |
|
active=None, resource_id=None, resource_type=None): |
| 4708 |
|
"""Modifies an existing tag. |
| 4709 |
|
|
| 4710 |
|
Arguments: |
| 4711 |
|
tag_id (str): UUID of the tag. |
| 4712 |
|
comment (str, optional): Comment to add to the tag. |
| 4713 |
|
name (str, optional): Name of the tag. |
| 4714 |
|
value (str, optional): Value of the tag. |
| 4715 |
|
active (boolean, optional): Whether the tag is active. |
| 4716 |
|
resource_id (str, optional): IDs of the resource to which to |
| 4717 |
|
attach the tag. |
| 4718 |
|
resource_type (str, optional): Type of the resource to which to |
| 4719 |
|
attach the tag. |
| 4720 |
|
|
| 4721 |
|
Returns: |
| 4722 |
|
The response. See :py:meth:`send_command` for details. |
| 4723 |
|
""" |
| 4724 |
|
if not tag_id: |
| 4725 |
|
raise RequiredArgument('modify_tag requires a tag_id element') |
| 4726 |
|
|
| 4727 |
|
cmd = XmlCommand('modify_tag') |
| 4728 |
|
cmd.set_attribute('tag_id', str(tag_id)) |
| 4729 |
|
|
| 4730 |
|
if comment: |
| 4731 |
|
cmd.add_element('comment', comment) |
| 4732 |
|
|
| 4733 |
|
if name: |
| 4734 |
|
cmd.add_element('name', name) |
| 4735 |
|
|
| 4736 |
|
if value: |
| 4737 |
|
cmd.add_element('value', value) |
| 4738 |
|
|
| 4739 |
|
if not active is None: |
| 4740 |
|
if active: |
| 4741 |
|
cmd.add_element('active', '1') |
| 4742 |
|
else: |
| 4743 |
|
cmd.add_element('active', '0') |
| 4744 |
|
|
| 4745 |
|
if resource_id and resource_type: |
| 4746 |
|
_xmlresource = cmd.add_element('resource', |
| 4747 |
|
attrs={'resource_id': resource_id}) |
| 4748 |
|
_xmlresource.add_element('type', resource_type) |
| 4749 |
|
|
| 4750 |
|
return self._send_xml_command(cmd) |
| 4751 |
|
|
| 4752 |
|
def modify_target(self, target_id, *, name=None, comment=None, |
| 4753 |
|
hosts=None, hosts_ordering=None, |