Hello,
For single key/value it is working fine, but when i try to do with multiple metadata key/values it is just taking the single value. Here below is my code.
/// META-DATA
$googleMetadataItemsObj = new Google_Service_Compute_MetadataItems();
$googleMetadataItemsObj->setKey('dirname','gslocation');
$googleMetadataItemsObj->setValue($dirlocation,$zone);
$items_arr = array($googleMetadataItemsObj);
$googleMetadataObj = new Google_Service_Compute_Metadata();
$googleMetadataObj->setKind('compute#metadata');
$googleMetadataObj->setItems($items_arr);
/// META-DATA
$new_instance = new Google_Service_Compute_Instance();
$new_instance->setName($instance_name);
$new_instance->setKind('compute#operation');
$new_instance->setMachineType($machineType);
$new_instance->setDisks(array($googleAttachDiskObj));
$new_instance->setNetworkInterfaces(array($googleNetworkInterfaceObj));
$new_instance->setMetadata($googleMetadataObj);
$new_instance->setServiceAccounts($googleServiceAccountObj);
$insertInstance = $computeService->instances->insert(DEFAULT_PROJECT,$zone, $new_instance);
AND HERE IS THE REST OUTPUT AFTER CREATING INSTANCE
[metadata] => Array
(
[kind] => compute#metadata
[fingerprint] => DMtjUVHiops=
[items] => Array
(
[0] => Array
(
[key] => dirname
[value] => GS://tempfiles
)
)
)
I have created it as array and even then it is just taking single key/value while setting up metadata.