@@ 1502-1693 (lines=192) @@ | ||
1499 | cmd.add_element("copy", scanner_id) |
|
1500 | return self._send_xml_command(cmd) |
|
1501 | ||
1502 | def create_schedule( |
|
1503 | self, |
|
1504 | name: str, |
|
1505 | *, |
|
1506 | comment: Optional[str] = None, |
|
1507 | first_time_minute: Optional[int] = None, |
|
1508 | first_time_hour: Optional[int] = None, |
|
1509 | first_time_day_of_month: Optional[int] = None, |
|
1510 | first_time_month: Optional[int] = None, |
|
1511 | first_time_year: Optional[int] = None, |
|
1512 | duration: Optional[int] = None, |
|
1513 | duration_unit: Optional[TimeUnit] = None, |
|
1514 | period: Optional[int] = None, |
|
1515 | period_unit: Optional[TimeUnit] = None, |
|
1516 | timezone: Optional[str] = None |
|
1517 | ) -> Any: |
|
1518 | """Create a new schedule |
|
1519 | ||
1520 | Arguments: |
|
1521 | name: Name of the schedule |
|
1522 | comment: Comment for the schedule |
|
1523 | first_time_minute: First time minute the schedule will run. Must be |
|
1524 | an integer >= 0. |
|
1525 | first_time_hour: First time hour the schedule will run. Must be an |
|
1526 | integer >= 0. |
|
1527 | first_time_day_of_month: First time day of month the schedule will |
|
1528 | run. Must be an integer > 0 <= 31. |
|
1529 | first_time_month: First time month the schedule will run. Must be an |
|
1530 | integer >= 1 <= 12. |
|
1531 | first_time_year: First time year the schedule will run. Must be an |
|
1532 | integer >= 1970. |
|
1533 | duration: How long the Manager will run the scheduled task for until |
|
1534 | it gets paused if not finished yet. Must be an integer > 0. |
|
1535 | duration_unit: Unit of the duration. One of second, |
|
1536 | minute, hour, day, week, month, year, decade. Required if |
|
1537 | duration is set. |
|
1538 | period: How often the Manager will repeat the |
|
1539 | scheduled task. Must be an integer > 0. |
|
1540 | period_unit: Unit of the period. One of second, |
|
1541 | minute, hour, day, week, month, year, decade. Required if |
|
1542 | period is set. |
|
1543 | timezone: The timezone the schedule will follow |
|
1544 | ||
1545 | Returns: |
|
1546 | The response. See :py:meth:`send_command` for details. |
|
1547 | """ |
|
1548 | if not name: |
|
1549 | raise RequiredArgument( |
|
1550 | function=self.create_schedule.__name__, argument='name' |
|
1551 | ) |
|
1552 | ||
1553 | cmd = XmlCommand("create_schedule") |
|
1554 | cmd.add_element("name", name) |
|
1555 | ||
1556 | if comment: |
|
1557 | cmd.add_element("comment", comment) |
|
1558 | ||
1559 | if ( |
|
1560 | first_time_minute is not None |
|
1561 | or first_time_hour is not None |
|
1562 | or first_time_day_of_month is not None |
|
1563 | or first_time_month is not None |
|
1564 | or first_time_year is not None |
|
1565 | ): |
|
1566 | ||
1567 | if first_time_minute is None: |
|
1568 | raise RequiredArgument( |
|
1569 | function=self.create_schedule.__name__, |
|
1570 | argument='first_time_minute', |
|
1571 | ) |
|
1572 | elif ( |
|
1573 | not isinstance(first_time_minute, numbers.Integral) |
|
1574 | or first_time_minute < 0 |
|
1575 | ): |
|
1576 | raise InvalidArgument( |
|
1577 | "first_time_minute argument of create_schedule needs to be " |
|
1578 | "an integer greater or equal 0" |
|
1579 | ) |
|
1580 | ||
1581 | if first_time_hour is None: |
|
1582 | raise RequiredArgument( |
|
1583 | function=self.create_schedule.__name__, |
|
1584 | argument='first_time_hour', |
|
1585 | ) |
|
1586 | elif ( |
|
1587 | not isinstance(first_time_hour, numbers.Integral) |
|
1588 | or first_time_hour < 0 |
|
1589 | ): |
|
1590 | raise InvalidArgument( |
|
1591 | "first_time_hour argument of create_schedule needs to be " |
|
1592 | "an integer greater or equal 0" |
|
1593 | ) |
|
1594 | ||
1595 | if first_time_day_of_month is None: |
|
1596 | raise RequiredArgument( |
|
1597 | function=self.create_schedule.__name__, |
|
1598 | argument='first_time_day_of_month', |
|
1599 | ) |
|
1600 | elif ( |
|
1601 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
1602 | or first_time_day_of_month < 1 |
|
1603 | or first_time_day_of_month > 31 |
|
1604 | ): |
|
1605 | raise InvalidArgument( |
|
1606 | "first_time_day_of_month argument of create_schedule needs " |
|
1607 | "to be an integer between 1 and 31" |
|
1608 | ) |
|
1609 | ||
1610 | if first_time_month is None: |
|
1611 | raise RequiredArgument( |
|
1612 | function=self.create_schedule.__name__, |
|
1613 | argument='first_time_month', |
|
1614 | ) |
|
1615 | elif ( |
|
1616 | not isinstance(first_time_month, numbers.Integral) |
|
1617 | or first_time_month < 1 |
|
1618 | or first_time_month > 12 |
|
1619 | ): |
|
1620 | raise InvalidArgument( |
|
1621 | "first_time_month argument of create_schedule needs " |
|
1622 | "to be an integer between 1 and 12" |
|
1623 | ) |
|
1624 | ||
1625 | if first_time_year is None: |
|
1626 | raise RequiredArgument( |
|
1627 | function=self.create_schedule.__name__, |
|
1628 | argument='first_time_year', |
|
1629 | ) |
|
1630 | elif ( |
|
1631 | not isinstance(first_time_year, numbers.Integral) |
|
1632 | or first_time_year < 1970 |
|
1633 | ): |
|
1634 | raise InvalidArgument( |
|
1635 | "first_time_year argument of create_schedule needs " |
|
1636 | "to be an integer greater or equal 1970" |
|
1637 | ) |
|
1638 | ||
1639 | _xmlftime = cmd.add_element("first_time") |
|
1640 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
1641 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
1642 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
1643 | _xmlftime.add_element("month", str(first_time_month)) |
|
1644 | _xmlftime.add_element("year", str(first_time_year)) |
|
1645 | ||
1646 | if duration is not None: |
|
1647 | if not duration_unit: |
|
1648 | raise RequiredArgument( |
|
1649 | function=self.create_schedule.__name__, |
|
1650 | argument='duration_unit', |
|
1651 | ) |
|
1652 | ||
1653 | if not isinstance(duration_unit, TimeUnit): |
|
1654 | raise InvalidArgumentType( |
|
1655 | function=self.create_schedule.__name__, |
|
1656 | argument='duration_unit', |
|
1657 | arg_type=TimeUnit.__name__, |
|
1658 | ) |
|
1659 | ||
1660 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
1661 | raise InvalidArgument( |
|
1662 | "duration argument must be an integer greater than 0" |
|
1663 | ) |
|
1664 | ||
1665 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
1666 | _xmlduration.add_element("unit", duration_unit.value) |
|
1667 | ||
1668 | if period is not None: |
|
1669 | if not period_unit: |
|
1670 | raise RequiredArgument( |
|
1671 | function=self.create_schedule.__name__, |
|
1672 | argument='period_unit', |
|
1673 | ) |
|
1674 | ||
1675 | if not isinstance(period_unit, TimeUnit): |
|
1676 | raise InvalidArgumentType( |
|
1677 | function=self.create_schedule.__name__, |
|
1678 | argument='period_unit', |
|
1679 | arg_type=TimeUnit.__name__, |
|
1680 | ) |
|
1681 | ||
1682 | if not isinstance(period, numbers.Integral) or period < 0: |
|
1683 | raise InvalidArgument( |
|
1684 | "period argument must be a positive integer" |
|
1685 | ) |
|
1686 | ||
1687 | _xmlperiod = cmd.add_element("period", str(period)) |
|
1688 | _xmlperiod.add_element("unit", period_unit.value) |
|
1689 | ||
1690 | if timezone: |
|
1691 | cmd.add_element("timezone", timezone) |
|
1692 | ||
1693 | return self._send_xml_command(cmd) |
|
1694 | ||
1695 | def clone_schedule(self, schedule_id: str) -> Any: |
|
1696 | """Clone an existing schedule |
|
@@ 5449-5642 (lines=194) @@ | ||
5446 | ||
5447 | return self._send_xml_command(cmd) |
|
5448 | ||
5449 | def modify_schedule( |
|
5450 | self, |
|
5451 | schedule_id: str, |
|
5452 | *, |
|
5453 | comment: Optional[str] = None, |
|
5454 | name: Optional[str] = None, |
|
5455 | first_time_minute: Optional[int] = None, |
|
5456 | first_time_hour: Optional[int] = None, |
|
5457 | first_time_day_of_month: Optional[int] = None, |
|
5458 | first_time_month: Optional[int] = None, |
|
5459 | first_time_year: Optional[int] = None, |
|
5460 | duration: Optional[int] = None, |
|
5461 | duration_unit: Optional[TimeUnit] = None, |
|
5462 | period: Optional[int] = None, |
|
5463 | period_unit: Optional[TimeUnit] = None, |
|
5464 | timezone: Optional[str] = None |
|
5465 | ) -> Any: |
|
5466 | """Modifies an existing schedule. |
|
5467 | ||
5468 | Arguments: |
|
5469 | schedule_id: UUID of schedule to modify. |
|
5470 | name: Name of the schedule |
|
5471 | comment: Comment for the schedule |
|
5472 | first_time_minute: First time minute the schedule will run. Must be |
|
5473 | an integer >= 0. |
|
5474 | first_time_hour: First time hour the schedule will run. Must be an |
|
5475 | integer >= 0. |
|
5476 | first_time_day_of_month: First time day of month the schedule will |
|
5477 | run. Must be an integer > 0 <= 31. |
|
5478 | first_time_month: First time month the schedule will run. Must be an |
|
5479 | integer >= 1 <= 12. |
|
5480 | first_time_year: First time year the schedule will run |
|
5481 | duration: How long the Manager will run the scheduled task for until |
|
5482 | it gets paused if not finished yet. |
|
5483 | duration_unit: Unit of the duration. One of second, minute, hour, |
|
5484 | day, week, month, year, decade. Required if duration is set. |
|
5485 | period: How often the Manager will repeat the scheduled task. Must |
|
5486 | be an integer > 0. |
|
5487 | period_unit: Unit of the period. One of second, minute, hour, day, |
|
5488 | week, month, year, decade. Required if period is set. |
|
5489 | timezone: The timezone the schedule will follow |
|
5490 | ||
5491 | Returns: |
|
5492 | The response. See :py:meth:`send_command` for details. |
|
5493 | """ |
|
5494 | if not schedule_id: |
|
5495 | raise RequiredArgument( |
|
5496 | function=self.modify_schedule.__name__, argument='schedule_id' |
|
5497 | ) |
|
5498 | ||
5499 | cmd = XmlCommand("modify_schedule") |
|
5500 | cmd.set_attribute("schedule_id", schedule_id) |
|
5501 | ||
5502 | if comment: |
|
5503 | cmd.add_element("comment", comment) |
|
5504 | ||
5505 | if name: |
|
5506 | cmd.add_element("name", name) |
|
5507 | ||
5508 | if ( |
|
5509 | first_time_minute is not None |
|
5510 | or first_time_hour is not None |
|
5511 | or first_time_day_of_month is not None |
|
5512 | or first_time_month is not None |
|
5513 | or first_time_year is not None |
|
5514 | ): |
|
5515 | ||
5516 | if first_time_minute is None: |
|
5517 | raise RequiredArgument( |
|
5518 | function=self.modify_schedule.__name__, |
|
5519 | argument='first_time_minute', |
|
5520 | ) |
|
5521 | elif ( |
|
5522 | not isinstance(first_time_minute, numbers.Integral) |
|
5523 | or first_time_minute < 0 |
|
5524 | ): |
|
5525 | raise InvalidArgument( |
|
5526 | "first_time_minute argument of modify_schedule needs to be " |
|
5527 | "an integer greater or equal 0" |
|
5528 | ) |
|
5529 | ||
5530 | if first_time_hour is None: |
|
5531 | raise RequiredArgument( |
|
5532 | function=self.modify_schedule.__name__, |
|
5533 | argument='first_time_hour', |
|
5534 | ) |
|
5535 | elif ( |
|
5536 | not isinstance(first_time_hour, numbers.Integral) |
|
5537 | or first_time_hour < 0 |
|
5538 | ): |
|
5539 | raise InvalidArgument( |
|
5540 | "first_time_hour argument of modify_schedule needs to be " |
|
5541 | "an integer greater or equal 0" |
|
5542 | ) |
|
5543 | ||
5544 | if first_time_day_of_month is None: |
|
5545 | raise RequiredArgument( |
|
5546 | function=self.modify_schedule.__name__, |
|
5547 | argument='first_time_day_of_month', |
|
5548 | ) |
|
5549 | elif ( |
|
5550 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
5551 | or first_time_day_of_month < 1 |
|
5552 | or first_time_day_of_month > 31 |
|
5553 | ): |
|
5554 | raise InvalidArgument( |
|
5555 | "first_time_day_of_month argument of modify_schedule needs " |
|
5556 | "to be an integer between 1 and 31" |
|
5557 | ) |
|
5558 | ||
5559 | if first_time_month is None: |
|
5560 | raise RequiredArgument( |
|
5561 | function=self.modify_schedule.__name__, |
|
5562 | argument='first_time_month', |
|
5563 | ) |
|
5564 | elif ( |
|
5565 | not isinstance(first_time_month, numbers.Integral) |
|
5566 | or first_time_month < 1 |
|
5567 | or first_time_month > 12 |
|
5568 | ): |
|
5569 | raise InvalidArgument( |
|
5570 | "first_time_month argument of modify_schedule needs " |
|
5571 | "to be an integer between 1 and 12" |
|
5572 | ) |
|
5573 | ||
5574 | if first_time_year is None: |
|
5575 | raise RequiredArgument( |
|
5576 | function=self.modify_schedule.__name__, |
|
5577 | argument='first_time_year', |
|
5578 | ) |
|
5579 | elif ( |
|
5580 | not isinstance(first_time_year, numbers.Integral) |
|
5581 | or first_time_year < 1970 |
|
5582 | ): |
|
5583 | raise InvalidArgument( |
|
5584 | "first_time_year argument of create_schedule needs " |
|
5585 | "to be an integer greater or equal 1970" |
|
5586 | ) |
|
5587 | ||
5588 | _xmlftime = cmd.add_element("first_time") |
|
5589 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
5590 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
5591 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
5592 | _xmlftime.add_element("month", str(first_time_month)) |
|
5593 | _xmlftime.add_element("year", str(first_time_year)) |
|
5594 | ||
5595 | if duration is not None: |
|
5596 | if not duration_unit: |
|
5597 | raise RequiredArgument( |
|
5598 | function=self.modify_schedule.__name__, |
|
5599 | argument='duration_unit', |
|
5600 | ) |
|
5601 | ||
5602 | if not isinstance(duration_unit, TimeUnit): |
|
5603 | raise InvalidArgumentType( |
|
5604 | function=self.modify_schedule.__name__, |
|
5605 | argument='duration_unit', |
|
5606 | arg_type=TimeUnit.__name__, |
|
5607 | ) |
|
5608 | ||
5609 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
5610 | raise InvalidArgument( |
|
5611 | "duration argument must be an integer greater than 0" |
|
5612 | ) |
|
5613 | ||
5614 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
5615 | _xmlduration.add_element("unit", duration_unit.value) |
|
5616 | ||
5617 | if period is not None: |
|
5618 | if not period_unit: |
|
5619 | raise RequiredArgument( |
|
5620 | function=self.modify_schedule.__name__, |
|
5621 | argument='period_unit', |
|
5622 | ) |
|
5623 | ||
5624 | if not isinstance(period_unit, TimeUnit): |
|
5625 | raise InvalidArgumentType( |
|
5626 | function=self.modify_schedule.__name__, |
|
5627 | argument='period_unit', |
|
5628 | arg_type=TimeUnit.__name__, |
|
5629 | ) |
|
5630 | ||
5631 | if not isinstance(period, numbers.Integral) or period < 1: |
|
5632 | raise InvalidArgument( |
|
5633 | "period argument must be an integer greater than 0" |
|
5634 | ) |
|
5635 | ||
5636 | _xmlperiod = cmd.add_element("period", str(period)) |
|
5637 | _xmlperiod.add_element("unit", period_unit.value) |
|
5638 | ||
5639 | if timezone: |
|
5640 | cmd.add_element("timezone", timezone) |
|
5641 | ||
5642 | return self._send_xml_command(cmd) |
|
5643 | ||
5644 | def modify_setting( |
|
5645 | self, |