public function upsert(array $arr_entities)
{
$obj_request = $this->setupCommit();
$obj_mutation = $obj_request->mutableDeprecatedMutation();
$arr_auto_id_required = [];
foreach ($arr_entities as $obj_gds_entity) {
if (null === $obj_gds_entity->getKeyId() && null === $obj_gds_entity->getKeyName()) {
$obj_entity = $obj_mutation->addInsertAutoId();
$arr_auto_id_required[] = $obj_gds_entity;
// maintain reference to the array of requested auto-ids
} else {
$obj_entity = $obj_mutation->addUpsert();
}
$this->applyNamespace($obj_entity->mutableKey());
$this->determineMapper($obj_gds_entity)->mapToGoogle($obj_gds_entity, $obj_entity);
}
$this->execute('Commit', $obj_request, new CommitResponse());
return $arr_auto_id_required;
}