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