@@ 5331-5524 (lines=194) @@ | ||
5328 | ||
5329 | return self._send_xml_command(cmd) |
|
5330 | ||
5331 | def modify_schedule( |
|
5332 | self, |
|
5333 | schedule_id: str, |
|
5334 | *, |
|
5335 | comment: Optional[str] = None, |
|
5336 | name: Optional[str] = None, |
|
5337 | first_time_minute: Optional[int] = None, |
|
5338 | first_time_hour: Optional[int] = None, |
|
5339 | first_time_day_of_month: Optional[int] = None, |
|
5340 | first_time_month: Optional[int] = None, |
|
5341 | first_time_year: Optional[int] = None, |
|
5342 | duration: Optional[int] = None, |
|
5343 | duration_unit: Optional[TimeUnit] = None, |
|
5344 | period: Optional[int] = None, |
|
5345 | period_unit: Optional[TimeUnit] = None, |
|
5346 | timezone: Optional[str] = None |
|
5347 | ) -> Any: |
|
5348 | """Modifies an existing schedule. |
|
5349 | ||
5350 | Arguments: |
|
5351 | schedule_id: UUID of schedule to modify. |
|
5352 | name: Name of the schedule |
|
5353 | comment: Comment for the schedule |
|
5354 | first_time_minute: First time minute the schedule will run. Must be |
|
5355 | an integer >= 0. |
|
5356 | first_time_hour: First time hour the schedule will run. Must be an |
|
5357 | integer >= 0. |
|
5358 | first_time_day_of_month: First time day of month the schedule will |
|
5359 | run. Must be an integer > 0 <= 31. |
|
5360 | first_time_month: First time month the schedule will run. Must be an |
|
5361 | integer >= 1 <= 12. |
|
5362 | first_time_year: First time year the schedule will run |
|
5363 | duration: How long the Manager will run the scheduled task for until |
|
5364 | it gets paused if not finished yet. |
|
5365 | duration_unit: Unit of the duration. One of second, minute, hour, |
|
5366 | day, week, month, year, decade. Required if duration is set. |
|
5367 | period: How often the Manager will repeat the scheduled task. Must |
|
5368 | be an integer > 0. |
|
5369 | period_unit: Unit of the period. One of second, minute, hour, day, |
|
5370 | week, month, year, decade. Required if period is set. |
|
5371 | timezone: The timezone the schedule will follow |
|
5372 | ||
5373 | Returns: |
|
5374 | The response. See :py:meth:`send_command` for details. |
|
5375 | """ |
|
5376 | if not schedule_id: |
|
5377 | raise RequiredArgument( |
|
5378 | function=self.modify_schedule.__name__, argument='schedule_id' |
|
5379 | ) |
|
5380 | ||
5381 | cmd = XmlCommand("modify_schedule") |
|
5382 | cmd.set_attribute("schedule_id", schedule_id) |
|
5383 | ||
5384 | if comment: |
|
5385 | cmd.add_element("comment", comment) |
|
5386 | ||
5387 | if name: |
|
5388 | cmd.add_element("name", name) |
|
5389 | ||
5390 | if ( |
|
5391 | first_time_minute is not None |
|
5392 | or first_time_hour is not None |
|
5393 | or first_time_day_of_month is not None |
|
5394 | or first_time_month is not None |
|
5395 | or first_time_year is not None |
|
5396 | ): |
|
5397 | ||
5398 | if first_time_minute is None: |
|
5399 | raise RequiredArgument( |
|
5400 | function=self.modify_schedule.__name__, |
|
5401 | argument='first_time_minute', |
|
5402 | ) |
|
5403 | elif ( |
|
5404 | not isinstance(first_time_minute, numbers.Integral) |
|
5405 | or first_time_minute < 0 |
|
5406 | ): |
|
5407 | raise InvalidArgument( |
|
5408 | "first_time_minute argument of modify_schedule needs to be " |
|
5409 | "an integer greater or equal 0" |
|
5410 | ) |
|
5411 | ||
5412 | if first_time_hour is None: |
|
5413 | raise RequiredArgument( |
|
5414 | function=self.modify_schedule.__name__, |
|
5415 | argument='first_time_hour', |
|
5416 | ) |
|
5417 | elif ( |
|
5418 | not isinstance(first_time_hour, numbers.Integral) |
|
5419 | or first_time_hour < 0 |
|
5420 | ): |
|
5421 | raise InvalidArgument( |
|
5422 | "first_time_hour argument of modify_schedule needs to be " |
|
5423 | "an integer greater or equal 0" |
|
5424 | ) |
|
5425 | ||
5426 | if first_time_day_of_month is None: |
|
5427 | raise RequiredArgument( |
|
5428 | function=self.modify_schedule.__name__, |
|
5429 | argument='first_time_day_of_month', |
|
5430 | ) |
|
5431 | elif ( |
|
5432 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
5433 | or first_time_day_of_month < 1 |
|
5434 | or first_time_day_of_month > 31 |
|
5435 | ): |
|
5436 | raise InvalidArgument( |
|
5437 | "first_time_day_of_month argument of modify_schedule needs " |
|
5438 | "to be an integer between 1 and 31" |
|
5439 | ) |
|
5440 | ||
5441 | if first_time_month is None: |
|
5442 | raise RequiredArgument( |
|
5443 | function=self.modify_schedule.__name__, |
|
5444 | argument='first_time_month', |
|
5445 | ) |
|
5446 | elif ( |
|
5447 | not isinstance(first_time_month, numbers.Integral) |
|
5448 | or first_time_month < 1 |
|
5449 | or first_time_month > 12 |
|
5450 | ): |
|
5451 | raise InvalidArgument( |
|
5452 | "first_time_month argument of modify_schedule needs " |
|
5453 | "to be an integer between 1 and 12" |
|
5454 | ) |
|
5455 | ||
5456 | if first_time_year is None: |
|
5457 | raise RequiredArgument( |
|
5458 | function=self.modify_schedule.__name__, |
|
5459 | argument='first_time_year', |
|
5460 | ) |
|
5461 | elif ( |
|
5462 | not isinstance(first_time_year, numbers.Integral) |
|
5463 | or first_time_year < 1970 |
|
5464 | ): |
|
5465 | raise InvalidArgument( |
|
5466 | "first_time_year argument of create_schedule needs " |
|
5467 | "to be an integer greater or equal 1970" |
|
5468 | ) |
|
5469 | ||
5470 | _xmlftime = cmd.add_element("first_time") |
|
5471 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
5472 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
5473 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
5474 | _xmlftime.add_element("month", str(first_time_month)) |
|
5475 | _xmlftime.add_element("year", str(first_time_year)) |
|
5476 | ||
5477 | if duration is not None: |
|
5478 | if not duration_unit: |
|
5479 | raise RequiredArgument( |
|
5480 | function=self.modify_schedule.__name__, |
|
5481 | argument='duration_unit', |
|
5482 | ) |
|
5483 | ||
5484 | if not isinstance(duration_unit, TimeUnit): |
|
5485 | raise InvalidArgumentType( |
|
5486 | function=self.modify_schedule.__name__, |
|
5487 | argument='duration_unit', |
|
5488 | arg_type=TimeUnit.__name__, |
|
5489 | ) |
|
5490 | ||
5491 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
5492 | raise InvalidArgument( |
|
5493 | "duration argument must be an integer greater than 0" |
|
5494 | ) |
|
5495 | ||
5496 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
5497 | _xmlduration.add_element("unit", duration_unit.value) |
|
5498 | ||
5499 | if period is not None: |
|
5500 | if not period_unit: |
|
5501 | raise RequiredArgument( |
|
5502 | function=self.modify_schedule.__name__, |
|
5503 | argument='period_unit', |
|
5504 | ) |
|
5505 | ||
5506 | if not isinstance(period_unit, TimeUnit): |
|
5507 | raise InvalidArgumentType( |
|
5508 | function=self.modify_schedule.__name__, |
|
5509 | argument='period_unit', |
|
5510 | arg_type=TimeUnit.__name__, |
|
5511 | ) |
|
5512 | ||
5513 | if not isinstance(period, numbers.Integral) or period < 1: |
|
5514 | raise InvalidArgument( |
|
5515 | "period argument must be an integer greater than 0" |
|
5516 | ) |
|
5517 | ||
5518 | _xmlperiod = cmd.add_element("period", str(period)) |
|
5519 | _xmlperiod.add_element("unit", period_unit.value) |
|
5520 | ||
5521 | if timezone: |
|
5522 | cmd.add_element("timezone", timezone) |
|
5523 | ||
5524 | return self._send_xml_command(cmd) |
|
5525 | ||
5526 | def modify_setting( |
|
5527 | self, |
|
@@ 1487-1678 (lines=192) @@ | ||
1484 | cmd.add_element("copy", scanner_id) |
|
1485 | return self._send_xml_command(cmd) |
|
1486 | ||
1487 | def create_schedule( |
|
1488 | self, |
|
1489 | name: str, |
|
1490 | *, |
|
1491 | comment: Optional[str] = None, |
|
1492 | first_time_minute: Optional[int] = None, |
|
1493 | first_time_hour: Optional[int] = None, |
|
1494 | first_time_day_of_month: Optional[int] = None, |
|
1495 | first_time_month: Optional[int] = None, |
|
1496 | first_time_year: Optional[int] = None, |
|
1497 | duration: Optional[int] = None, |
|
1498 | duration_unit: Optional[TimeUnit] = None, |
|
1499 | period: Optional[int] = None, |
|
1500 | period_unit: Optional[TimeUnit] = None, |
|
1501 | timezone: Optional[str] = None |
|
1502 | ) -> Any: |
|
1503 | """Create a new schedule |
|
1504 | ||
1505 | Arguments: |
|
1506 | name: Name of the schedule |
|
1507 | comment: Comment for the schedule |
|
1508 | first_time_minute: First time minute the schedule will run. Must be |
|
1509 | an integer >= 0. |
|
1510 | first_time_hour: First time hour the schedule will run. Must be an |
|
1511 | integer >= 0. |
|
1512 | first_time_day_of_month: First time day of month the schedule will |
|
1513 | run. Must be an integer > 0 <= 31. |
|
1514 | first_time_month: First time month the schedule will run. Must be an |
|
1515 | integer >= 1 <= 12. |
|
1516 | first_time_year: First time year the schedule will run. Must be an |
|
1517 | integer >= 1970. |
|
1518 | duration: How long the Manager will run the scheduled task for until |
|
1519 | it gets paused if not finished yet. Must be an integer > 0. |
|
1520 | duration_unit: Unit of the duration. One of second, |
|
1521 | minute, hour, day, week, month, year, decade. Required if |
|
1522 | duration is set. |
|
1523 | period: How often the Manager will repeat the |
|
1524 | scheduled task. Must be an integer > 0. |
|
1525 | period_unit: Unit of the period. One of second, |
|
1526 | minute, hour, day, week, month, year, decade. Required if |
|
1527 | period is set. |
|
1528 | timezone: The timezone the schedule will follow |
|
1529 | ||
1530 | Returns: |
|
1531 | The response. See :py:meth:`send_command` for details. |
|
1532 | """ |
|
1533 | if not name: |
|
1534 | raise RequiredArgument( |
|
1535 | function=self.create_schedule.__name__, argument='name' |
|
1536 | ) |
|
1537 | ||
1538 | cmd = XmlCommand("create_schedule") |
|
1539 | cmd.add_element("name", name) |
|
1540 | ||
1541 | if comment: |
|
1542 | cmd.add_element("comment", comment) |
|
1543 | ||
1544 | if ( |
|
1545 | first_time_minute is not None |
|
1546 | or first_time_hour is not None |
|
1547 | or first_time_day_of_month is not None |
|
1548 | or first_time_month is not None |
|
1549 | or first_time_year is not None |
|
1550 | ): |
|
1551 | ||
1552 | if first_time_minute is None: |
|
1553 | raise RequiredArgument( |
|
1554 | function=self.create_schedule.__name__, |
|
1555 | argument='first_time_minute', |
|
1556 | ) |
|
1557 | elif ( |
|
1558 | not isinstance(first_time_minute, numbers.Integral) |
|
1559 | or first_time_minute < 0 |
|
1560 | ): |
|
1561 | raise InvalidArgument( |
|
1562 | "first_time_minute argument of create_schedule needs to be " |
|
1563 | "an integer greater or equal 0" |
|
1564 | ) |
|
1565 | ||
1566 | if first_time_hour is None: |
|
1567 | raise RequiredArgument( |
|
1568 | function=self.create_schedule.__name__, |
|
1569 | argument='first_time_hour', |
|
1570 | ) |
|
1571 | elif ( |
|
1572 | not isinstance(first_time_hour, numbers.Integral) |
|
1573 | or first_time_hour < 0 |
|
1574 | ): |
|
1575 | raise InvalidArgument( |
|
1576 | "first_time_hour argument of create_schedule needs to be " |
|
1577 | "an integer greater or equal 0" |
|
1578 | ) |
|
1579 | ||
1580 | if first_time_day_of_month is None: |
|
1581 | raise RequiredArgument( |
|
1582 | function=self.create_schedule.__name__, |
|
1583 | argument='first_time_day_of_month', |
|
1584 | ) |
|
1585 | elif ( |
|
1586 | not isinstance(first_time_day_of_month, numbers.Integral) |
|
1587 | or first_time_day_of_month < 1 |
|
1588 | or first_time_day_of_month > 31 |
|
1589 | ): |
|
1590 | raise InvalidArgument( |
|
1591 | "first_time_day_of_month argument of create_schedule needs " |
|
1592 | "to be an integer between 1 and 31" |
|
1593 | ) |
|
1594 | ||
1595 | if first_time_month is None: |
|
1596 | raise RequiredArgument( |
|
1597 | function=self.create_schedule.__name__, |
|
1598 | argument='first_time_month', |
|
1599 | ) |
|
1600 | elif ( |
|
1601 | not isinstance(first_time_month, numbers.Integral) |
|
1602 | or first_time_month < 1 |
|
1603 | or first_time_month > 12 |
|
1604 | ): |
|
1605 | raise InvalidArgument( |
|
1606 | "first_time_month argument of create_schedule needs " |
|
1607 | "to be an integer between 1 and 12" |
|
1608 | ) |
|
1609 | ||
1610 | if first_time_year is None: |
|
1611 | raise RequiredArgument( |
|
1612 | function=self.create_schedule.__name__, |
|
1613 | argument='first_time_year', |
|
1614 | ) |
|
1615 | elif ( |
|
1616 | not isinstance(first_time_year, numbers.Integral) |
|
1617 | or first_time_year < 1970 |
|
1618 | ): |
|
1619 | raise InvalidArgument( |
|
1620 | "first_time_year argument of create_schedule needs " |
|
1621 | "to be an integer greater or equal 1970" |
|
1622 | ) |
|
1623 | ||
1624 | _xmlftime = cmd.add_element("first_time") |
|
1625 | _xmlftime.add_element("minute", str(first_time_minute)) |
|
1626 | _xmlftime.add_element("hour", str(first_time_hour)) |
|
1627 | _xmlftime.add_element("day_of_month", str(first_time_day_of_month)) |
|
1628 | _xmlftime.add_element("month", str(first_time_month)) |
|
1629 | _xmlftime.add_element("year", str(first_time_year)) |
|
1630 | ||
1631 | if duration is not None: |
|
1632 | if not duration_unit: |
|
1633 | raise RequiredArgument( |
|
1634 | function=self.create_schedule.__name__, |
|
1635 | argument='duration_unit', |
|
1636 | ) |
|
1637 | ||
1638 | if not isinstance(duration_unit, TimeUnit): |
|
1639 | raise InvalidArgumentType( |
|
1640 | function=self.create_schedule.__name__, |
|
1641 | argument='duration_unit', |
|
1642 | arg_type=TimeUnit.__name__, |
|
1643 | ) |
|
1644 | ||
1645 | if not isinstance(duration, numbers.Integral) or duration < 1: |
|
1646 | raise InvalidArgument( |
|
1647 | "duration argument must be an integer greater than 0" |
|
1648 | ) |
|
1649 | ||
1650 | _xmlduration = cmd.add_element("duration", str(duration)) |
|
1651 | _xmlduration.add_element("unit", duration_unit.value) |
|
1652 | ||
1653 | if period is not None: |
|
1654 | if not period_unit: |
|
1655 | raise RequiredArgument( |
|
1656 | function=self.create_schedule.__name__, |
|
1657 | argument='period_unit', |
|
1658 | ) |
|
1659 | ||
1660 | if not isinstance(period_unit, TimeUnit): |
|
1661 | raise InvalidArgumentType( |
|
1662 | function=self.create_schedule.__name__, |
|
1663 | argument='period_unit', |
|
1664 | arg_type=TimeUnit.__name__, |
|
1665 | ) |
|
1666 | ||
1667 | if not isinstance(period, numbers.Integral) or period < 0: |
|
1668 | raise InvalidArgument( |
|
1669 | "period argument must be a positive integer" |
|
1670 | ) |
|
1671 | ||
1672 | _xmlperiod = cmd.add_element("period", str(period)) |
|
1673 | _xmlperiod.add_element("unit", period_unit.value) |
|
1674 | ||
1675 | if timezone: |
|
1676 | cmd.add_element("timezone", timezone) |
|
1677 | ||
1678 | return self._send_xml_command(cmd) |
|
1679 | ||
1680 | def clone_schedule(self, schedule_id: str) -> Any: |
|
1681 | """Clone an existing schedule |