So, I have a GKE-based function that does processing on an image file. I want this function to be triggered whenever a new file gets dumped into a bucket, using Pub/Sub. I have an external system that pushes the image file into the bucket. I was using object notifications to do this, now I want to use Pub/Sub.
Can I create a notification in GoogleCloudStorage that generates the Pub/Sub notification that my processing function will be pulling? I was looking at the PHP library (https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.162.0/storage/notification) to do this, but the documentation is ridiculously inadequate.
This code creates a notification, but seems strange that I should be supplying a notification ID, and I'm not sure what the payload is going to be...
$client=new StorageClient(['projectId'=><my project>, 'keyFile'=><key file contents>]);
$bucket_name = <my bucket name>;
$notification_id = '2482'; // ?????
$notification_params = [
'eventType' => 'OBJECT_FINALIZE',
'payloadFormat' => 'JSON_API_V1',
'bucketId' => $bucket_name,
];
$bucket = $client->bucket( $bucket_name );
$notification = $bucket->notification( $notification_id );
Is this the correct way to create the notification I want? Do I specify my own id in this way? What happens if there is a collision?
thanks, andy