# Path: planb/models.py
# class HostGroup(models.Model):
#     name = models.CharField(max_length=63, unique=True)
#     notify_email = MultiEmailField(
#         blank=True, null=True,
#         help_text=_('Use a newline per emailaddress'))
#     last_monthly_report = models.DateTimeField(blank=True, null=True)
#     notes = models.TextField(blank=True, help_text=_(
#         'Description, guidelines and agreements for the hostgroup.'))
# 
#     blacklist_hours = models.CharField(
#         _('Blacklist hours'), max_length=31, blank=True,
#         validators=[validate_blacklist_hours], help_text=_(
#             'Specify hours during which backups are disabled using notation '
#             'h,h-h or none to disable blacklist hours. When left empty the '
#             'system blacklist hours are used.'))
#     retention = models.CharField(
#         max_length=31, blank=True, validators=[validate_retention],
#         help_text=_(
#             'The backup retention period using notation <n><period> separated '
#             'by comma: 1y,6m,3w,15d. When left empty the system retention '
#             'periods are used.'))
# 
#     def get_blacklist_hours(self):
#         if self.blacklist_hours:
#             return self.blacklist_hours
#         return settings.PLANB_BLACKLIST_HOURS
#     get_blacklist_hours.short_description = _('Blacklist hours')
# 
#     def get_retention(self):
#         if self.retention:
#             return self.retention
#         return settings.PLANB_RETENTION
#     get_retention.short_description = _('Retention')
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)


import logging
import requests
from datetime import date
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from planb.models import HostGroup
        elif (('Backup history with this '
               'Name and Date already exists') in response):
            logger.warning(response)
        else:
            logger.error(response)

    def format_data(self, hostgroup, fileset, report_date):
        return {
            'name': '{}-{}'.format(
                hostgroup.name, fileset.friendly_name),
            'date': report_date,
            'size': fileset.total_size_mb << 20  # MiB to B
        }


class BossoRESTPoster(BasePoster):
    UNIQUE_ERROR = [
        'The fields relation_code, item_code, service_code, date must make a '
        'unique set.']

    def __init__(self, url, auth_token, use_batch=True):
        super().__init__(url, use_batch)
        self.auth_token = auth_token
        self.session = requests.Session()
        self.session.headers.update(self.get_headers())

    def get_headers(self):
        return {
            'User-Agent': 'PlanB',
            'Authorization': 'Token {}'.format(self.auth_token),

# Path: planb/models.py
# class HostGroup(models.Model):
#     name = models.CharField(max_length=63, unique=True)
#     notify_email = MultiEmailField(
#         blank=True, null=True,
#         help_text=_('Use a newline per emailaddress'))
#     last_monthly_report = models.DateTimeField(blank=True, null=True)
#     notes = models.TextField(blank=True, help_text=_(
#         'Description, guidelines and agreements for the hostgroup.'))
# 
#     blacklist_hours = models.CharField(
#         _('Blacklist hours'), max_length=31, blank=True,
#         validators=[validate_blacklist_hours], help_text=_(
#             'Specify hours during which backups are disabled using notation '
#             'h,h-h or none to disable blacklist hours. When left empty the '
#             'system blacklist hours are used.'))
#     retention = models.CharField(
#         max_length=31, blank=True, validators=[validate_retention],
#         help_text=_(
#             'The backup retention period using notation <n><period> separated '
#             'by comma: 1y,6m,3w,15d. When left empty the system retention '
#             'periods are used.'))
# 
#     def get_blacklist_hours(self):
#         if self.blacklist_hours:
#             return self.blacklist_hours
#         return settings.PLANB_BLACKLIST_HOURS
#     get_blacklist_hours.short_description = _('Blacklist hours')
# 
#     def get_retention(self):
#         if self.retention:
#             return self.retention
#         return settings.PLANB_RETENTION
#     get_retention.short_description = _('Retention')
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)


# Path: planb/contrib/billing.py
import logging
import requests
from datetime import date
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from planb.models import HostGroup

        elif (('Backup history with this '
               'Name and Date already exists') in response):
            logger.warning(response)
        else:
            logger.error(response)

    def format_data(self, hostgroup, fileset, report_date):
        return {
            'name': '{}-{}'.format(
                hostgroup.name, fileset.friendly_name),
            'date': report_date,
            'size': fileset.total_size_mb << 20  # MiB to B
        }


class BossoRESTPoster(BasePoster):
    UNIQUE_ERROR = [
        'The fields relation_code, item_code, service_code, date must make a '
        'unique set.']

    def __init__(self, url, auth_token, use_batch=True):
        super().__init__(url, use_batch)
        self.auth_token = auth_token
        self.session = requests.Session()
        self.session.headers.update(self.get_headers())

    def get_headers(self):
        return {
            'User-Agent': 'PlanB',
            'Authorization': 'Token {}'.format(self.auth_token),

        }