StatusModel.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from modules.Mailcow import Mailcow
  2. from models.BaseModel import BaseModel
  3. class StatusModel(BaseModel):
  4. parser_command = "status"
  5. required_args = {
  6. "version": [[]],
  7. "vmail": [[]],
  8. "containers": [[]]
  9. }
  10. def __init__(
  11. self,
  12. **kwargs
  13. ):
  14. self.mailcow = Mailcow()
  15. def version(self):
  16. """
  17. Get the version of the mailcow instance.
  18. :return: Response from the mailcow API.
  19. """
  20. return self.mailcow.getStatusVersion()
  21. def vmail(self):
  22. """
  23. Get the vmail details from the mailcow API.
  24. :return: Response from the mailcow API.
  25. """
  26. return self.mailcow.getStatusVmail()
  27. def containers(self):
  28. """
  29. Get the status of containers in the mailcow instance.
  30. :return: Response from the mailcow API.
  31. """
  32. return self.mailcow.getStatusContainers()
  33. @classmethod
  34. def add_parser(cls, subparsers):
  35. parser = subparsers.add_parser(
  36. cls.parser_command,
  37. help="Get information about mailcow (version, vmail, containers)"
  38. )
  39. parser.add_argument("object", choices=list(cls.required_args.keys()), help="Action to perform: version, vmail, containers")