问题描述
我需要删除gcp中的dns记录。我得到了要从changes()。list()方法删除的dns记录。根据文档,我已将要删除的记录追加到changes()。deletions,并称为changes()。create()方法。但是我遇到错误'entity.change.deletions [0]'不满足前提条件
mzone = client.managedZones().get(project=project_id,managedZone='abc-pods').execute()
changes = client.changes().list(project=project_id,managedZone='abc-pods').execute()
records_to_delete = []
for change in changes['changes']:
for record in change['additions']:
if dnsname in record['name']:
records_to_delete.append(change)
for record in records_to_delete:
record['deletions'].append(record['additions'][1])
record['additions'].remove(record['additions'][1])
for record in records_to_delete:
r = client.changes().create(project=project_id,managedZone='abd-pods',body=record).execute()
pprint.pprint(r)
我从changes()。list中得到的杰森:
{u'additions': [{u'kind': u'dns#resourceRecordSet',u'name': u'abc.com.',u'rrdatas': [u'ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 2118 21600 3600 259200 300'],u'signatureRrdatas': [],u'ttl': 21600,u'type': u'SOA'},{u'kind': u'dns#resourceRecordSet',u'name': u'xxx.abc.com.',u'rrdatas': [u'34.76.78.35'],u'ttl': 30,u'type': u'A'}],u'deletions': [{u'kind': u'dns#resourceRecordSet',u'rrdatas': [u'ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 2117 21600 3600 259200 300'],u'type': u'SOA'}],u'id': u'2184',u'kind': u'dns#change',u'startTime': u'2020-07-13T18:04:34.896Z',u'status': u'done'}
为change()。create()方法提供的修改后的Json:
{u'additions': [{u'kind': u'dns#resourceRecordSet',u'status': u'done'}
根据文档,create()方法的主体与list()方法的响应相同。但是,我仍然无法删除记录。知道我在这里想念什么吗?
解决方法
- 尝试查看以下我发现与相似问题匹配的文章:
-
确保python代码使用的帐户具有正确的权限
-
查看Cloud DNS文章,并确保遵循正确的语法: