@@ 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 |
|
@@ 5531-5724 (lines=194) @@ | ||
5528 | ||
5529 | return self._send_xml_command(cmd) |
|
5530 | ||
5531 | def modify_schedule( |
|
5532 | self, |
|
5533 | schedule_id: str, |
|
5534 | *, |
|
5535 | comment: Optional[str] = None, |
|
5536 | name: Optional[str] = None, |
|
5537 | first_time_minute: Optional[int] = None, |
|
5538 | first_time_hour: Optional[int] = None, |
|
5539 | first_time_day_of_month: Optional[int] = None, |
|
5540 | first_time_month: Optional[int] = None, |
|
5541 | first_time_year: Optional[int] = None, |
|
5542 | duration: Optional[int] = None, |
|
5543 | duration_unit: Optional[TimeUnit] = None, |
|
5544 | period: Optional[int] = None, |
|
5545 | period_unit: Optional[TimeUnit] = None, |
|
5546 | timezone: Optional[str] = None |
|
5547 | ) -> Any: |
|
5548 | """Modifies an existing schedule. |
|
5549 | ||
5550 | Arguments: |
|
5551 | schedule_id: UUID of schedule to modify. |
|
5552 | name: Name of the schedule |
|
5553 | comment: Comment for the schedule |
|
5554 | first_time_minute: First time minute the schedule will run. Must be |
|
5555 | an integer >= 0. |
|
5556 | first_time_hour: First time hour the schedule will run. Must be an |
|
5557 | integer >= 0. |
|
5558 | first_time_day_of_month: First time day of month the schedule will |
|
5559 | run. Must be an integer > 0 <= 31. |
|
5560 | first_time_month: First time month the schedule will run. Must be an |
|
5561 | integer >= 1 <= 12. |
|
5562 | first_time_year: First time year the schedule will run |
|
5563 | duration: How long the Manager will run the scheduled task for until |
|
5564 | it gets paused if not finished yet. |
|
5565 | duration_unit: Unit of the duration. One of second, minute, hour, |
|
5566 | day, week, month, year, decade. Required if duration is set. |
|
5567 | period: How often the Manager will repeat the scheduled task. Must |
|
5568 | be an integer > 0. |
|
5569 | period_unit: Unit of the period. One of second, minute, hour, day, |
|
5570 | week, month, year, decade. Required if period is set. |
|
5571 | timezone: The timezone the schedule will follow |
|
5572 | ||
5573 | Returns: |
|
5574 | The response. See :py:meth:`send_command` for details. |
|
5575 | """ |
|
5576 | if not schedule_id: |
|
5577 | raise RequiredArgument( |
|
5578 | function=self.modify_schedule.__name__, argument='schedule_id' |
|
5579 | ) |
|
5580 | ||
5581 | cmd = XmlCommand("modify_schedule") |
|
5582 | cmd.set_attribute("schedule_id", schedule_id) |
|
5583 | ||
5584 | if comment: |
|
5585 | cmd.add_element("comment", comment) |
|
5586 | ||
5587 | if name: |
|
5588 | cmd.add_element("name", name) |
|
5589 | ||
5590 | if ( |
|
5591 | first_time_minute is not None |
|
5592 | or first_time_hour is not None |
|
5593 | or first_time_day_of_month is not None |
|
5594 | or first_time_month is not None |
|
5595 | or first_time_year is not None |
|
5596 | ): |
|
5597 | ||
5598 | if first_time_minute is None: |
|
5599 | raise RequiredArgument( |
|
5600 | function=self.modify_schedule.__name__, |
|
5601 | argument='first_time_minute', |
|
5602 | ) |
|
5603 | elif ( |
|
5604 | not isinstance(first_time_minute, numbers.Integral) |
|
5605 | or first_time_minute < 0 |
|
5606 | ): |
|
5607 | raise InvalidArgument( |
|
5608 | "first_time_minute argument of modify_schedule needs to be " |
|
5609 | "an integer greater or equal 0" |
|
5610 | ) |
|
5611 | ||
5612 | if first_time_hour is None: |
|
5613 | raise RequiredArgument( |
|
5614 | function=self.modify_schedule.__name__, |
|
5615 | argument='first_time_hour', |
|
5616 | ) |
|
5617 | elif ( |
|
5618 | not isinstance(first_time_hour, numbers.Integral) |
|
5619 | or first_time_hour < 0 |
|
5620 | ): |
|
5621 | raise InvalidArgument( |
|
5622 | "first_time_hour argument of modify_schedule needs to be " |
|
5623 | "an integer greater or equal 0" |
|
5624 | ) |
|
5625 | ||
5626 | if first_time_day_of_month is None: |
|
5627 | raise RequiredArgument( |
|
5628 | function=self.modify_schedule.__name__, |
|
5629 | argument='first_time_day_of_month', |
|
5630 | ) |
|
5631 | elif ( |
|
5632 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
5633 | or first_time_day_of_month < 1 |
|
5634 | or first_time_day_of_month > 31 |
|
5635 | ): |
|
5636 | raise InvalidArgument( |
|
5637 | "first_time_day_of_month argument of modify_schedule needs " |
|
5638 | "to be an integer between 1 and 31" |
|
5639 | ) |
|
5640 | ||
5641 | if first_time_month is None: |
|
5642 | raise RequiredArgument( |
|
5643 | function=self.modify_schedule.__name__, |
|
5644 | argument='first_time_month', |
|
5645 | ) |
|
5646 | elif ( |
|
5647 | not isinstance(first_time_month, numbers.Integral) |
|
5648 | or first_time_month < 1 |
|
5649 | or first_time_month > 12 |
|
5650 | ): |
|
5651 | raise InvalidArgument( |
|
5652 | "first_time_month argument of modify_schedule needs " |
|
5653 | "to be an integer between 1 and 12" |
|
5654 | ) |
|
5655 | ||
5656 | if first_time_year is None: |
|
5657 | raise RequiredArgument( |
|
5658 | function=self.modify_schedule.__name__, |
|
5659 | argument='first_time_year', |
|
5660 | ) |
|
5661 | elif ( |
|
5662 | not isinstance(first_time_year, numbers.Integral) |
|
5663 | or first_time_year < 1970 |
|
5664 | ): |
|
5665 | raise InvalidArgument( |
|
5666 | "first_time_year argument of create_schedule needs " |
|
5667 | "to be an integer greater or equal 1970" |
|
5668 | ) |
|
5669 | ||
5670 | _xmlftime = cmd.add_element("first_time") |
|
5671 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
5672 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
5673 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
5674 | _xmlftime.add_element("month", str(first_time_month)) |
|
5675 | _xmlftime.add_element("year", str(first_time_year)) |
|
5676 | ||
5677 | if duration is not None: |
|
5678 | if not duration_unit: |
|
5679 | raise RequiredArgument( |
|
5680 | function=self.modify_schedule.__name__, |
|
5681 | argument='duration_unit', |
|
5682 | ) |
|
5683 | ||
5684 | if not isinstance(duration_unit, TimeUnit): |
|
5685 | raise InvalidArgumentType( |
|
5686 | function=self.modify_schedule.__name__, |
|
5687 | argument='duration_unit', |
|
5688 | arg_type=TimeUnit.__name__, |
|
5689 | ) |
|
5690 | ||
5691 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
5692 | raise InvalidArgument( |
|
5693 | "duration argument must be an integer greater than 0" |
|
5694 | ) |
|
5695 | ||
5696 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
5697 | _xmlduration.add_element("unit", duration_unit.value) |
|
5698 | ||
5699 | if period is not None: |
|
5700 | if not period_unit: |
|
5701 | raise RequiredArgument( |
|
5702 | function=self.modify_schedule.__name__, |
|
5703 | argument='period_unit', |
|
5704 | ) |
|
5705 | ||
5706 | if not isinstance(period_unit, TimeUnit): |
|
5707 | raise InvalidArgumentType( |
|
5708 | function=self.modify_schedule.__name__, |
|
5709 | argument='period_unit', |
|
5710 | arg_type=TimeUnit.__name__, |
|
5711 | ) |
|
5712 | ||
5713 | if not isinstance(period, numbers.Integral) or period < 1: |
|
5714 | raise InvalidArgument( |
|
5715 | "period argument must be an integer greater than 0" |
|
5716 | ) |
|
5717 | ||
5718 | _xmlperiod = cmd.add_element("period", str(period)) |
|
5719 | _xmlperiod.add_element("unit", period_unit.value) |
|
5720 | ||
5721 | if timezone: |
|
5722 | cmd.add_element("timezone", timezone) |
|
5723 | ||
5724 | return self._send_xml_command(cmd) |
|
5725 | ||
5726 | def modify_setting( |
|
5727 | self, |