def all(self): try: return getattr(get_mailman_client(), self.resource_name_plural) except AttributeError: raise MailmanApiError except MailmanConnectionError as e: raise MailmanApiError(e)
def all(self, advertised=False): try: method = getattr(get_mailman_client(), 'get_' + self.resource_name_plural) return method(advertised=advertised) except AttributeError: raise MailmanApiError except MailmanConnectionError as e: raise MailmanApiError(e)
def _get_context_obj(self): if self.context == 'list': obj = List.objects.get_or_404(fqdn_listname=self.identifier) elif self.context == 'domain': obj = Domain.objects.get_or_404(mail_host=self.identifier) elif self.context == 'site': obj = get_mailman_client() else: obj = None return obj
def get(self, *args, **kwargs): try: method = getattr(get_mailman_client(), 'get_' + self.resource_name) return method(*args, **kwargs) except AttributeError as e: raise MailmanApiError(e) except HTTPError as e: if e.code == 404: raise Mailman404Error('Mailman resource could not be found.') else: raise except MailmanConnectionError as e: raise MailmanApiError(e)
def create(self, *args, **kwargs): try: method = getattr(get_mailman_client(), 'create_' + self.resource_name) return method(*args, **kwargs) except AttributeError as e: raise MailmanApiError(e) except HTTPError as e: if e.code == 409: raise MailmanApiError else: raise except MailmanConnectionError: raise MailmanApiError