Ejemplo n.º 1
0
    def update_zone(self, zone, **kwargs):
        """
        Update a zone.

        :param zone: the zone to be created
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones/{0}'.format(zone.id))
        response, data = self.__make_request(url, u'PUT', self.headers, to_json_string(zone), **kwargs)
        return ZoneChange.from_dict(data)
Ejemplo n.º 2
0
    def connect_zone(self, zone, **kwargs):
        """
        Create a new zone with the given name and email.

        :param zone: the zone to be created
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones')
        response, data = self.__make_request(url, u'POST', self.headers, to_json_string(zone), **kwargs)
        return ZoneChange.from_dict(data)
Ejemplo n.º 3
0
    def abandon_zone(self, zone_id, **kwargs):
        """
        Delete the zone for the given id.

        :param zone_id: the id of the zone to be deleted
        :return: nothing, will fail if the status code was not expected
        """
        url = urljoin(self.index_url, u'/zones/{0}'.format(zone_id))
        response, data = self.__make_request(url, u'DELETE', self.headers, **kwargs)

        return ZoneChange.from_dict(data)
Ejemplo n.º 4
0
    def sync_zone(self, zone_id, **kwargs):
        """
        Sync a zone.

        :param zone: the zone to be updated
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones/{0}/sync'.format(zone_id))
        response, data = self.__make_request(url, u'POST', self.headers, **kwargs)

        return ZoneChange.from_dict(data)
Ejemplo n.º 5
0
    def delete_zone_acl_rule(self, zone_id, acl_rule, **kwargs):
        """
        Delete an acl rule from the zone.

        :param zone_id: The id of the zone to remove the acl from
        :param acl_rule: The acl rule to remove
        :return: the content of the response
        """
        url = urljoin(self.index_url, '/zones/{0}/acl/rules'.format(zone_id))
        response, data = self.__make_request(url, 'DELETE', self.headers,
                                             to_json_string(acl_rule), **kwargs)

        return ZoneChange.from_dict(data)
Ejemplo n.º 6
0
    def add_zone_acl_rule(self, zone_id, acl_rule, **kwargs):
        """
        Put an acl rule on the zone.

        :param zone_id: The id of the zone to attach the acl rule to
        :param acl_rule: The acl rule contents
        :return: the content of the response
        """
        url = urljoin(self.index_url, '/zones/{0}/acl/rules'.format(zone_id))
        response, data = self.__make_request(url, 'PUT', self.headers,
                                             to_json_string(acl_rule), **kwargs)

        return ZoneChange.from_dict(data)