def __init__(self): self.client = VinylDNSClient("http://*****:*****@test.com', description='this is a description', members=[User(id='ok'), User(id='support-user-id')], admins=[User(id='ok'), User(id='support-user-id')]) self.group = self.client.create_group(group) zone = Zone(name='vinyldns.', email='*****@*****.**', admin_group_id=self.group.id) zone_change = self.client.connect_zone(zone) self.zone = zone_change.zone reverse_zone = Zone(name='2.0.192.in-addr.arpa.', email='*****@*****.**', admin_group_id=self.group.id) zone_change = self.client.connect_zone(reverse_zone) self.reverse_zone = zone_change.zone wait_until_zone_exists(self.client, self.reverse_zone.id)
def list_all_my_groups(self, group_name_filter=None, **kwargs): """ Retrieve all my groups, paging through the results until exhausted :param group_name_filter: only returns groups whose names contain filter string :return: the content of the response """ groups = [] args = [] if group_name_filter: args.append(u'groupNameFilter={0}'.format(group_name_filter)) url = urljoin(self.index_url, u'/groups') + u'?' + u'&'.join(args) response, data = self.__make_request(url, u'GET', self.headers, **kwargs) groups.extend(data[u'groups']) while u'nextId' in data and data[u'nextId']: next_args = args[:] next_args.append(u'startFrom={0}'.format(data['nextId'])) url = urljoin(self.index_url, u'/groups') + u'?' + u'&'.join(next_args) response, data = self.__make_request(url, u'GET', self.headers, **kwargs) groups.extend(data[u'groups']) g = [Group.from_dict(elem) for elem in groups] return ListGroupsResponse(groups=g, group_name_filter=group_name_filter)
def update_group(self, group, **kwargs): """ Update an existing group, uses the id of the group provided :param group: A group to be updated :return: the content of the response, which should be a group json """ url = urljoin(self.index_url, u'/groups/{0}'.format(group.id)) response, data = self.__make_request(url, u'PUT', self.headers, to_json_string(group), **kwargs) return Group.from_dict(data)
def delete_group(self, group_id, **kwargs): """ Delete a group. :param group_id: Id of the group to delete :return: the group json """ url = urljoin(self.index_url, u'/groups/' + group_id) response, data = self.__make_request(url, u'DELETE', self.headers, **kwargs) return Group.from_dict(data)
def get_group(self, group_id, **kwargs): """ Get a group. :param group_id: Id of the group to get :return: the group json """ url = urljoin(self.index_url, u'/groups/' + group_id) response, data = self.__make_request(url, u'GET', self.headers, **kwargs) return Group.from_dict(data) if data is not None else None
def create_group(self, group, **kwargs): """ Create a new group. :param group: A group dictionary that can be serialized to json :return: the content of the response, which should be a group json """ url = urljoin(self.index_url, u'/groups') response, data = self.__make_request(url, u'POST', self.headers, to_json_string(group), **kwargs) return Group.from_dict(data)
RecordSet(forward_zone.id, 'sshfp-test', RecordType.SSHFP, 200, records=[SSHFPData('algorithm', 'type', 'fingerprint')], owner_group_id='owner-group-id'), } record_set_values = record_sets.values() sample_user = User('id', 'test200', 'Bobby', 'Bonilla', '*****@*****.**', datetime.utcnow()) sample_group = Group('ok', '*****@*****.**', 'description', datetime.utcnow(), members=[sample_user], admins=[sample_user], id='sample-group') sample_group2 = Group('ok2', '*****@*****.**', 'description', datetime.utcnow(), members=[sample_user], admins=[sample_user], id='sample-group2') def gen_rs_change(record_set): return RecordSetChange(zone=forward_zone, record_set=record_set,