Google Cloud DNS Services - entity.change parameter is required but missing

左心房为你撑大大i 提交于 2019-12-10 10:34:42

问题


With the following code using Google's PHP API Client I am receiving this response.

Google_Service_Exception with message 'Error calling POST https://www.googleapis.com/dns/v1/projects/PROJECT-NAME/managedZones/DNSZONE/changes: (400) The 'entity.change' parameter is required but was missing.

Where PROJECT-NAME and DNSZONE are my project and zone.

$client_email = MYCLIENT;
$private_key = file_get_contents('config/credentials/KEY.p12');
$scopes = array('https://www.googleapis.com/auth/ndev.clouddns.readwrite');
$project = "PROJECT-NAME";
$managedZone = "DNSZONE";

$creds = new Google_Auth_AssertionCredentials($client_email,$scopes,$private_key);
$client = new Google_Client();
$client->setAssertionCredentials($creds);

$resource = new Google_Service_Dns_ResourceRecordSet();
$resource->kind = "dns#resourceRecordSet";
$resource->name = "testing.DNSZONE.net.";
$resource->rrdatas[] = "testing.otherhost.com.";
$resource->ttl = 800;
$resource->type = "CNAME";

$dns = new Google_Service_Dns($client);
$change = new Google_Service_Dns_Change();
$change->kind = "dns#change";
$change->setAdditions($resource);

$dns->changes->create($project,$managedZone,$change);

I am a bit confused as to how to set this parameter. Or where I am even am to define it.


回答1:


Just for clarify what the answer is, setAdditions expects an array.

$change->setAdditions([ $resource ]);


来源:https://stackoverflow.com/questions/32132373/google-cloud-dns-services-entity-change-parameter-is-required-but-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!