def update_record(self, record, name=None, type=None, data=None, extra=None): """ Update an existing record. API docs: http://www.linode.com/api/dns/domain.resource.update """ params = {'api_action': 'domain.resource.update', 'ResourceID': record.id, 'DomainID': record.zone.id} if name: params['Name'] = name if data: params['Target'] = data if type: params['Type'] = RECORD_TYPE_MAP[type] merged = merge_valid_keys(params=params, valid_keys=VALID_RECORD_EXTRA_PARAMS, extra=extra) result = self.connection.request(API_ROOT, params=params).objects[0] updated_record = get_new_obj(obj=record, klass=Record, attributes={'name': name, 'data': data, 'type': type, 'extra': merged}) return updated_record
def update_record(self, record, name=None, type=None, data=None, extra=None): path = API_ROOT + 'hosts/%s.xml' % (record.id) record_elem = self._to_record_elem(name=name, type=type, data=data, extra=extra) response = self.connection.request(action=path, data=ET.tostring(record_elem), method='PUT') assert response.status == httplib.OK merged = merge_valid_keys(params=copy.deepcopy(record.extra), valid_keys=VALID_RECORD_EXTRA_PARAMS, extra=extra) updated_record = get_new_obj(obj=record, klass=Record, attributes={ 'type': type, 'data': data, 'extra': merged }) return updated_record
def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None): """ Update an existing zone. API docs: http://www.linode.com/api/dns/domain.update """ params = {'api_action': 'domain.update', 'DomainID': zone.id} if type: params['Type'] = type if domain: params['Domain'] = domain if ttl: params['TTL_sec'] = ttl merged = merge_valid_keys(params=params, valid_keys=VALID_ZONE_EXTRA_PARAMS, extra=extra) data = self.connection.request(API_ROOT, params=params).objects[0] updated_zone = get_new_obj(obj=zone, klass=Zone, attributes={'domain': domain, 'type': type, 'ttl': ttl, 'extra': merged}) return updated_zone
def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None): """ Update an existing zone. Provider API docs: https://www.zerigo.com/docs/apis/dns/1.1/zones/update """ if domain: raise LibcloudError('Domain cannot be changed', driver=self) path = API_ROOT + 'zones/%s.xml' % (zone.id) zone_elem = self._to_zone_elem(domain=domain, type=type, ttl=ttl, extra=extra) response = self.connection.request(action=path, data=ET.tostring(zone_elem), method='PUT') assert response.status == httplib.OK merged = merge_valid_keys(params=copy.deepcopy(zone.extra), valid_keys=VALID_ZONE_EXTRA_PARAMS, extra=extra) updated_zone = get_new_obj(obj=zone, klass=Zone, attributes={ 'type': type, 'ttl': ttl, 'extra': merged }) return updated_zone
def update_record(self, record, name=None, type=None, data=None, extra=None): # Only data, ttl, and comment attributes can be modified, but name # attribute must always be present. extra = extra if extra else {} name = self._to_full_record_name(domain=record.zone.domain, name=record.name) payload = {'name': name} if data: payload['data'] = data if 'ttl' in extra: payload['ttl'] = extra['ttl'] if 'comment' in extra: payload['comment'] = extra['comment'] type = type if type else record.type data = data if data else record.data self.connection.set_context({'resource': 'record', 'id': record.id}) self.connection.async_request(action='/domains/%s/records/%s' % (record.zone.id, record.id), method='PUT', data=payload) merged = merge_valid_keys(params=copy.deepcopy(record.extra), valid_keys=VALID_RECORD_EXTRA_PARAMS, extra=extra) updated_record = get_new_obj(obj=record, klass=Record, attributes={'type': type, 'data': data, 'extra': merged}) return updated_record
def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None): # Only ttl, comment and email address can be changed extra = extra if extra else {} if domain: raise LibcloudError('Domain cannot be changed', driver=self) data = {} if ttl: data['ttl'] = int(ttl) if 'email' in extra: data['emailAddress'] = extra['email'] if 'comment' in extra: data['comment'] = extra['comment'] type = type if type else zone.type ttl = ttl if ttl else zone.ttl self.connection.set_context({'resource': 'zone', 'id': zone.id}) self.connection.async_request(action='/domains/%s' % (zone.id), method='PUT', data=data) merged = merge_valid_keys(params=copy.deepcopy(zone.extra), valid_keys=VALID_ZONE_EXTRA_PARAMS, extra=extra) updated_zone = get_new_obj(obj=zone, klass=Zone, attributes={'type': type, 'ttl': ttl, 'extra': merged}) return updated_zone
def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None): """ Update an existing zone. Provider API docs: https://www.zerigo.com/docs/apis/dns/1.1/zones/update """ if domain: raise LibcloudError('Domain cannot be changed', driver=self) path = API_ROOT + 'zones/%s.xml' % (zone.id) zone_elem = self._to_zone_elem(domain=domain, type=type, ttl=ttl, extra=extra) response = self.connection.request(action=path, data=ET.tostring(zone_elem), method='PUT') assert response.status == httplib.OK merged = merge_valid_keys(params=copy.deepcopy(zone.extra), valid_keys=VALID_ZONE_EXTRA_PARAMS, extra=extra) updated_zone = get_new_obj(obj=zone, klass=Zone, attributes={'type': type, 'ttl': ttl, 'extra': merged}) return updated_zone
def update_record(self, record, name=None, type=None, data=None, extra=None): path = API_ROOT + 'hosts/%s.xml' % (record.id) record_elem = self._to_record_elem(name=name, type=type, data=data, extra=extra) response = self.connection.request(action=path, data=ET.tostring(record_elem), method='PUT') assert response.status == httplib.OK merged = merge_valid_keys(params=copy.deepcopy(record.extra), valid_keys=VALID_RECORD_EXTRA_PARAMS, extra=extra) updated_record = get_new_obj(obj=record, klass=Record, attributes={'type': type, 'data': data, 'extra': merged}) return updated_record
def update_record(self, record, name=None, type=None, data=None, extra=None): # Only data, ttl, and comment attributes can be modified, but name # attribute must always be present. extra = extra if extra else {} name = self._to_full_record_name(domain=record.zone.domain, name=record.name) payload = {'name': name} if data: payload['data'] = data if 'ttl' in extra: payload['ttl'] = extra['ttl'] if 'comment' in extra: payload['comment'] = extra['comment'] type = type if type else record.type data = data if data else record.data self.connection.set_context({'resource': 'record', 'id': record.id}) self.connection.async_request(action='/domains/%s/records/%s' % (record.zone.id, record.id), method='PUT', data=payload) merged = merge_valid_keys(params=copy.deepcopy(record.extra), valid_keys=VALID_RECORD_EXTRA_PARAMS, extra=extra) updated_record = get_new_obj(obj=record, klass=Record, attributes={ 'type': type, 'data': data, 'extra': merged }) return updated_record
def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None): # Only ttl, comment and email address can be changed extra = extra if extra else {} if domain: raise LibcloudError('Domain cannot be changed', driver=self) data = {} if ttl: data['ttl'] = int(ttl) if 'email' in extra: data['emailAddress'] = extra['email'] if 'comment' in extra: data['comment'] = extra['comment'] type = type if type else zone.type ttl = ttl if ttl else zone.ttl self.connection.set_context({'resource': 'zone', 'id': zone.id}) self.connection.async_request(action='/domains/%s' % (zone.id), method='PUT', data=data) merged = merge_valid_keys(params=copy.deepcopy(zone.extra), valid_keys=VALID_ZONE_EXTRA_PARAMS, extra=extra) updated_zone = get_new_obj(obj=zone, klass=Zone, attributes={ 'type': type, 'ttl': ttl, 'extra': merged }) return updated_zone