Datastore/src/DatastoreClient.php
public function upsert(EntityInterface $entity, array $options = [])
    {
        $res = $this->upsertBatch([$entity], $options);
        return $this->parseSingleMutationResult($res);
    }
public function upsert(EntityInterface $entity, array $options = [])
    {
        $res = $this->upsertBatch([$entity], $options);
        return $this->parseSingleMutationResult($res);
    }
public function upsert ( EntityInterface $ entity , array $ options = [ ] ) { $ res = $ this -> upsertBatch ( [ $ entity ] , $ options ) ; return $ this -> parseSingleMutationResult ( $ res ) ; }
Upsert an entity

Upsert will create a record if one does not already exist, or overwrite
existing record if one already exists.

Please note that upserting a record in Cloud Datastore will replace the
existing record, if one exists. Adding, editing or removing a single
property is only possible by first retrieving the entire entity in its
existing state.

An entity with incomplete keys will be allocated an ID prior to insertion.

Upsert by this method is non-transactional. If you need transaction
support, use {@see Google\Cloud\Datastore\Transaction::upsert()}.

Example:
```
$key = $datastore->key('Person', 'Bob');
$entity = $datastore->entity($key, ['firstName' => 'Bob']);

$datastore->upsert($entity);
```

@see https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit Commit API documentation

@param EntityInterface $entity The entity to be upserted.
@param array $options [optional] Configuration Options.
@return string The entity version.
@throws DomainException If a conflict occurs, fail.
Upsert an entity