@@ 1556-1747 (lines=192) @@ | ||
1553 | cmd.add_element("copy", scanner_id) |
|
1554 | return self._send_xml_command(cmd) |
|
1555 | ||
1556 | def create_schedule( |
|
1557 | self, |
|
1558 | name: str, |
|
1559 | *, |
|
1560 | comment: Optional[str] = None, |
|
1561 | first_time_minute: Optional[int] = None, |
|
1562 | first_time_hour: Optional[int] = None, |
|
1563 | first_time_day_of_month: Optional[int] = None, |
|
1564 | first_time_month: Optional[int] = None, |
|
1565 | first_time_year: Optional[int] = None, |
|
1566 | duration: Optional[int] = None, |
|
1567 | duration_unit: Optional[TimeUnit] = None, |
|
1568 | period: Optional[int] = None, |
|
1569 | period_unit: Optional[TimeUnit] = None, |
|
1570 | timezone: Optional[str] = None |
|
1571 | ) -> Any: |
|
1572 | """Create a new schedule |
|
1573 | ||
1574 | Arguments: |
|
1575 | name: Name of the schedule |
|
1576 | comment: Comment for the schedule |
|
1577 | first_time_minute: First time minute the schedule will run. Must be |
|
1578 | an integer >= 0. |
|
1579 | first_time_hour: First time hour the schedule will run. Must be an |
|
1580 | integer >= 0. |
|
1581 | first_time_day_of_month: First time day of month the schedule will |
|
1582 | run. Must be an integer > 0 <= 31. |
|
1583 | first_time_month: First time month the schedule will run. Must be an |
|
1584 | integer >= 1 <= 12. |
|
1585 | first_time_year: First time year the schedule will run. Must be an |
|
1586 | integer >= 1970. |
|
1587 | duration: How long the Manager will run the scheduled task for until |
|
1588 | it gets paused if not finished yet. Must be an integer > 0. |
|
1589 | duration_unit: Unit of the duration. One of second, |
|
1590 | minute, hour, day, week, month, year, decade. Required if |
|
1591 | duration is set. |
|
1592 | period: How often the Manager will repeat the |
|
1593 | scheduled task. Must be an integer > 0. |
|
1594 | period_unit: Unit of the period. One of second, |
|
1595 | minute, hour, day, week, month, year, decade. Required if |
|
1596 | period is set. |
|
1597 | timezone: The timezone the schedule will follow |
|
1598 | ||
1599 | Returns: |
|
1600 | The response. See :py:meth:`send_command` for details. |
|
1601 | """ |
|
1602 | if not name: |
|
1603 | raise RequiredArgument( |
|
1604 | function=self.create_schedule.__name__, argument='name' |
|
1605 | ) |
|
1606 | ||
1607 | cmd = XmlCommand("create_schedule") |
|
1608 | cmd.add_element("name", name) |
|
1609 | ||
1610 | if comment: |
|
1611 | cmd.add_element("comment", comment) |
|
1612 | ||
1613 | if ( |
|
1614 | first_time_minute is not None |
|
1615 | or first_time_hour is not None |
|
1616 | or first_time_day_of_month is not None |
|
1617 | or first_time_month is not None |
|
1618 | or first_time_year is not None |
|
1619 | ): |
|
1620 | ||
1621 | if first_time_minute is None: |
|
1622 | raise RequiredArgument( |
|
1623 | function=self.create_schedule.__name__, |
|
1624 | argument='first_time_minute', |
|
1625 | ) |
|
1626 | elif ( |
|
1627 | not isinstance(first_time_minute, numbers.Integral) |
|
1628 | or first_time_minute < 0 |
|
1629 | ): |
|
1630 | raise InvalidArgument( |
|
1631 | "first_time_minute argument of create_schedule needs to be " |
|
1632 | "an integer greater or equal 0" |
|
1633 | ) |
|
1634 | ||
1635 | if first_time_hour is None: |
|
1636 | raise RequiredArgument( |
|
1637 | function=self.create_schedule.__name__, |
|
1638 | argument='first_time_hour', |
|
1639 | ) |
|
1640 | elif ( |
|
1641 | not isinstance(first_time_hour, numbers.Integral) |
|
1642 | or first_time_hour < 0 |
|
1643 | ): |
|
1644 | raise InvalidArgument( |
|
1645 | "first_time_hour argument of create_schedule needs to be " |
|
1646 | "an integer greater or equal 0" |
|
1647 | ) |
|
1648 | ||
1649 | if first_time_day_of_month is None: |
|
1650 | raise RequiredArgument( |
|
1651 | function=self.create_schedule.__name__, |
|
1652 | argument='first_time_day_of_month', |
|
1653 | ) |
|
1654 | elif ( |
|
1655 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
1656 | or first_time_day_of_month < 1 |
|
1657 | or first_time_day_of_month > 31 |
|
1658 | ): |
|
1659 | raise InvalidArgument( |
|
1660 | "first_time_day_of_month argument of create_schedule needs " |
|
1661 | "to be an integer between 1 and 31" |
|
1662 | ) |
|
1663 | ||
1664 | if first_time_month is None: |
|
1665 | raise RequiredArgument( |
|
1666 | function=self.create_schedule.__name__, |
|
1667 | argument='first_time_month', |
|
1668 | ) |
|
1669 | elif ( |
|
1670 | not isinstance(first_time_month, numbers.Integral) |
|
1671 | or first_time_month < 1 |
|
1672 | or first_time_month > 12 |
|
1673 | ): |
|
1674 | raise InvalidArgument( |
|
1675 | "first_time_month argument of create_schedule needs " |
|
1676 | "to be an integer between 1 and 12" |
|
1677 | ) |
|
1678 | ||
1679 | if first_time_year is None: |
|
1680 | raise RequiredArgument( |
|
1681 | function=self.create_schedule.__name__, |
|
1682 | argument='first_time_year', |
|
1683 | ) |
|
1684 | elif ( |
|
1685 | not isinstance(first_time_year, numbers.Integral) |
|
1686 | or first_time_year < 1970 |
|
1687 | ): |
|
1688 | raise InvalidArgument( |
|
1689 | "first_time_year argument of create_schedule needs " |
|
1690 | "to be an integer greater or equal 1970" |
|
1691 | ) |
|
1692 | ||
1693 | _xmlftime = cmd.add_element("first_time") |
|
1694 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
1695 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
1696 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
1697 | _xmlftime.add_element("month", str(first_time_month)) |
|
1698 | _xmlftime.add_element("year", str(first_time_year)) |
|
1699 | ||
1700 | if duration is not None: |
|
1701 | if not duration_unit: |
|
1702 | raise RequiredArgument( |
|
1703 | function=self.create_schedule.__name__, |
|
1704 | argument='duration_unit', |
|
1705 | ) |
|
1706 | ||
1707 | if not isinstance(duration_unit, TimeUnit): |
|
1708 | raise InvalidArgumentType( |
|
1709 | function=self.create_schedule.__name__, |
|
1710 | argument='duration_unit', |
|
1711 | arg_type=TimeUnit.__name__, |
|
1712 | ) |
|
1713 | ||
1714 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
1715 | raise InvalidArgument( |
|
1716 | "duration argument must be an integer greater than 0" |
|
1717 | ) |
|
1718 | ||
1719 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
1720 | _xmlduration.add_element("unit", duration_unit.value) |
|
1721 | ||
1722 | if period is not None: |
|
1723 | if not period_unit: |
|
1724 | raise RequiredArgument( |
|
1725 | function=self.create_schedule.__name__, |
|
1726 | argument='period_unit', |
|
1727 | ) |
|
1728 | ||
1729 | if not isinstance(period_unit, TimeUnit): |
|
1730 | raise InvalidArgumentType( |
|
1731 | function=self.create_schedule.__name__, |
|
1732 | argument='period_unit', |
|
1733 | arg_type=TimeUnit.__name__, |
|
1734 | ) |
|
1735 | ||
1736 | if not isinstance(period, numbers.Integral) or period < 0: |
|
1737 | raise InvalidArgument( |
|
1738 | "period argument must be a positive integer" |
|
1739 | ) |
|
1740 | ||
1741 | _xmlperiod = cmd.add_element("period", str(period)) |
|
1742 | _xmlperiod.add_element("unit", period_unit.value) |
|
1743 | ||
1744 | if timezone: |
|
1745 | cmd.add_element("timezone", timezone) |
|
1746 | ||
1747 | return self._send_xml_command(cmd) |
|
1748 | ||
1749 | def clone_schedule(self, schedule_id: str) -> Any: |
|
1750 | """Clone an existing schedule |
|
@@ 5543-5736 (lines=194) @@ | ||
5540 | ||
5541 | return self._send_xml_command(cmd) |
|
5542 | ||
5543 | def modify_schedule( |
|
5544 | self, |
|
5545 | schedule_id: str, |
|
5546 | *, |
|
5547 | comment: Optional[str] = None, |
|
5548 | name: Optional[str] = None, |
|
5549 | first_time_minute: Optional[int] = None, |
|
5550 | first_time_hour: Optional[int] = None, |
|
5551 | first_time_day_of_month: Optional[int] = None, |
|
5552 | first_time_month: Optional[int] = None, |
|
5553 | first_time_year: Optional[int] = None, |
|
5554 | duration: Optional[int] = None, |
|
5555 | duration_unit: Optional[TimeUnit] = None, |
|
5556 | period: Optional[int] = None, |
|
5557 | period_unit: Optional[TimeUnit] = None, |
|
5558 | timezone: Optional[str] = None |
|
5559 | ) -> Any: |
|
5560 | """Modifies an existing schedule. |
|
5561 | ||
5562 | Arguments: |
|
5563 | schedule_id: UUID of schedule to modify. |
|
5564 | name: Name of the schedule |
|
5565 | comment: Comment for the schedule |
|
5566 | first_time_minute: First time minute the schedule will run. Must be |
|
5567 | an integer >= 0. |
|
5568 | first_time_hour: First time hour the schedule will run. Must be an |
|
5569 | integer >= 0. |
|
5570 | first_time_day_of_month: First time day of month the schedule will |
|
5571 | run. Must be an integer > 0 <= 31. |
|
5572 | first_time_month: First time month the schedule will run. Must be an |
|
5573 | integer >= 1 <= 12. |
|
5574 | first_time_year: First time year the schedule will run |
|
5575 | duration: How long the Manager will run the scheduled task for until |
|
5576 | it gets paused if not finished yet. |
|
5577 | duration_unit: Unit of the duration. One of second, minute, hour, |
|
5578 | day, week, month, year, decade. Required if duration is set. |
|
5579 | period: How often the Manager will repeat the scheduled task. Must |
|
5580 | be an integer > 0. |
|
5581 | period_unit: Unit of the period. One of second, minute, hour, day, |
|
5582 | week, month, year, decade. Required if period is set. |
|
5583 | timezone: The timezone the schedule will follow |
|
5584 | ||
5585 | Returns: |
|
5586 | The response. See :py:meth:`send_command` for details. |
|
5587 | """ |
|
5588 | if not schedule_id: |
|
5589 | raise RequiredArgument( |
|
5590 | function=self.modify_schedule.__name__, argument='schedule_id' |
|
5591 | ) |
|
5592 | ||
5593 | cmd = XmlCommand("modify_schedule") |
|
5594 | cmd.set_attribute("schedule_id", schedule_id) |
|
5595 | ||
5596 | if comment: |
|
5597 | cmd.add_element("comment", comment) |
|
5598 | ||
5599 | if name: |
|
5600 | cmd.add_element("name", name) |
|
5601 | ||
5602 | if ( |
|
5603 | first_time_minute is not None |
|
5604 | or first_time_hour is not None |
|
5605 | or first_time_day_of_month is not None |
|
5606 | or first_time_month is not None |
|
5607 | or first_time_year is not None |
|
5608 | ): |
|
5609 | ||
5610 | if first_time_minute is None: |
|
5611 | raise RequiredArgument( |
|
5612 | function=self.modify_schedule.__name__, |
|
5613 | argument='first_time_minute', |
|
5614 | ) |
|
5615 | elif ( |
|
5616 | not isinstance(first_time_minute, numbers.Integral) |
|
5617 | or first_time_minute < 0 |
|
5618 | ): |
|
5619 | raise InvalidArgument( |
|
5620 | "first_time_minute argument of modify_schedule needs to be " |
|
5621 | "an integer greater or equal 0" |
|
5622 | ) |
|
5623 | ||
5624 | if first_time_hour is None: |
|
5625 | raise RequiredArgument( |
|
5626 | function=self.modify_schedule.__name__, |
|
5627 | argument='first_time_hour', |
|
5628 | ) |
|
5629 | elif ( |
|
5630 | not isinstance(first_time_hour, numbers.Integral) |
|
5631 | or first_time_hour < 0 |
|
5632 | ): |
|
5633 | raise InvalidArgument( |
|
5634 | "first_time_hour argument of modify_schedule needs to be " |
|
5635 | "an integer greater or equal 0" |
|
5636 | ) |
|
5637 | ||
5638 | if first_time_day_of_month is None: |
|
5639 | raise RequiredArgument( |
|
5640 | function=self.modify_schedule.__name__, |
|
5641 | argument='first_time_day_of_month', |
|
5642 | ) |
|
5643 | elif ( |
|
5644 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
5645 | or first_time_day_of_month < 1 |
|
5646 | or first_time_day_of_month > 31 |
|
5647 | ): |
|
5648 | raise InvalidArgument( |
|
5649 | "first_time_day_of_month argument of modify_schedule needs " |
|
5650 | "to be an integer between 1 and 31" |
|
5651 | ) |
|
5652 | ||
5653 | if first_time_month is None: |
|
5654 | raise RequiredArgument( |
|
5655 | function=self.modify_schedule.__name__, |
|
5656 | argument='first_time_month', |
|
5657 | ) |
|
5658 | elif ( |
|
5659 | not isinstance(first_time_month, numbers.Integral) |
|
5660 | or first_time_month < 1 |
|
5661 | or first_time_month > 12 |
|
5662 | ): |
|
5663 | raise InvalidArgument( |
|
5664 | "first_time_month argument of modify_schedule needs " |
|
5665 | "to be an integer between 1 and 12" |
|
5666 | ) |
|
5667 | ||
5668 | if first_time_year is None: |
|
5669 | raise RequiredArgument( |
|
5670 | function=self.modify_schedule.__name__, |
|
5671 | argument='first_time_year', |
|
5672 | ) |
|
5673 | elif ( |
|
5674 | not isinstance(first_time_year, numbers.Integral) |
|
5675 | or first_time_year < 1970 |
|
5676 | ): |
|
5677 | raise InvalidArgument( |
|
5678 | "first_time_year argument of create_schedule needs " |
|
5679 | "to be an integer greater or equal 1970" |
|
5680 | ) |
|
5681 | ||
5682 | _xmlftime = cmd.add_element("first_time") |
|
5683 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
5684 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
5685 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
5686 | _xmlftime.add_element("month", str(first_time_month)) |
|
5687 | _xmlftime.add_element("year", str(first_time_year)) |
|
5688 | ||
5689 | if duration is not None: |
|
5690 | if not duration_unit: |
|
5691 | raise RequiredArgument( |
|
5692 | function=self.modify_schedule.__name__, |
|
5693 | argument='duration_unit', |
|
5694 | ) |
|
5695 | ||
5696 | if not isinstance(duration_unit, TimeUnit): |
|
5697 | raise InvalidArgumentType( |
|
5698 | function=self.modify_schedule.__name__, |
|
5699 | argument='duration_unit', |
|
5700 | arg_type=TimeUnit.__name__, |
|
5701 | ) |
|
5702 | ||
5703 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
5704 | raise InvalidArgument( |
|
5705 | "duration argument must be an integer greater than 0" |
|
5706 | ) |
|
5707 | ||
5708 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
5709 | _xmlduration.add_element("unit", duration_unit.value) |
|
5710 | ||
5711 | if period is not None: |
|
5712 | if not period_unit: |
|
5713 | raise RequiredArgument( |
|
5714 | function=self.modify_schedule.__name__, |
|
5715 | argument='period_unit', |
|
5716 | ) |
|
5717 | ||
5718 | if not isinstance(period_unit, TimeUnit): |
|
5719 | raise InvalidArgumentType( |
|
5720 | function=self.modify_schedule.__name__, |
|
5721 | argument='period_unit', |
|
5722 | arg_type=TimeUnit.__name__, |
|
5723 | ) |
|
5724 | ||
5725 | if not isinstance(period, numbers.Integral) or period < 1: |
|
5726 | raise InvalidArgument( |
|
5727 | "period argument must be an integer greater than 0" |
|
5728 | ) |
|
5729 | ||
5730 | _xmlperiod = cmd.add_element("period", str(period)) |
|
5731 | _xmlperiod.add_element("unit", period_unit.value) |
|
5732 | ||
5733 | if timezone: |
|
5734 | cmd.add_element("timezone", timezone) |
|
5735 | ||
5736 | return self._send_xml_command(cmd) |
|
5737 | ||
5738 | def modify_setting( |
|
5739 | self, |