Search code examples
phpgoogle-apigoogle-cloud-php-client

PHP and Protobuf FieldMasks for Google API


I found the documentation just fine, but for the life of me I can't figure out how to set up the FieldMasks in PHP to update a CloudSchedulerClient.

The command should be like this: $client->updateJob($job, $updateMask); but no matter what I set the $updateMask variable to, my code keeps saying Expect Google\Protobuf\FieldMask. If for instance I wanted to update the description of a cron job to "test", 'description' => 'test', how should I go about that?


Solution

  • If you share some code, that would be helpful.

    The error suggests that you are not providing the proper type. Your code should look something like this:

    use Google\Protobuf\FieldMask;
    
    $updateMask = new FieldMask([
        'paths' => ['description']
    ]);
    
    $client->updateJob($job, $updateMask);