diff --git a/.kokoro/secrets.sh.enc b/.kokoro/secrets.sh.enc index eaf26147ae..8bb4b60e69 100644 Binary files a/.kokoro/secrets.sh.enc and b/.kokoro/secrets.sh.enc differ diff --git a/pubsub/api/composer.json b/pubsub/api/composer.json index ce2adc9866..9d6333f87b 100644 --- a/pubsub/api/composer.json +++ b/pubsub/api/composer.json @@ -1,6 +1,6 @@ { "require": { - "google/cloud-pubsub": "^1.39", + "google/cloud-pubsub": "^1.46", "rg/avro-php": "^2.0.1||^3.0.0" } } diff --git a/pubsub/api/src/create_cloud_storage_subscription.php b/pubsub/api/src/create_cloud_storage_subscription.php new file mode 100644 index 0000000000..d64d174f63 --- /dev/null +++ b/pubsub/api/src/create_cloud_storage_subscription.php @@ -0,0 +1,53 @@ + $projectId, + ]); + $topic = $pubsub->topic($topicName); + $subscription = $topic->subscription($subscriptionName); + $config = ['bucket' => $bucket]; + $subscription->create([ + 'cloudStorageConfig' => $config + ]); + + printf('Subscription created: %s' . PHP_EOL, $subscription->name()); +} +# [END pubsub_create_cloud_storage_subscription] +require_once __DIR__ . '/../../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/pubsub/api/test/pubsubTest.php b/pubsub/api/test/pubsubTest.php index 4143db5c64..f908da0d70 100644 --- a/pubsub/api/test/pubsubTest.php +++ b/pubsub/api/test/pubsubTest.php @@ -309,6 +309,31 @@ public function testCreateAndDeleteBigQuerySubscription() $this->assertMatchesRegularExpression(sprintf('/%s/', $subscription), $output); } + public function testCreateAndDeleteStorageSubscription() + { + $topic = $this->requireEnv('GOOGLE_PUBSUB_TOPIC'); + $subscription = 'test-subscription-' . rand(); + $bucket = $this->requireEnv('GOOGLE_PUBSUB_STORAGE_BUCKET'); + + $output = $this->runFunctionSnippet('create_cloud_storage_subscription', [ + self::$projectId, + $topic, + $subscription, + $bucket, + ]); + + $this->assertMatchesRegularExpression('/Subscription created:/', $output); + $this->assertMatchesRegularExpression(sprintf('/%s/', $subscription), $output); + + $output = $this->runFunctionSnippet('delete_subscription', [ + self::$projectId, + $subscription, + ]); + + $this->assertMatchesRegularExpression('/Subscription deleted:/', $output); + $this->assertMatchesRegularExpression(sprintf('/%s/', $subscription), $output); + } + public function testCreateAndDetachSubscription() { $topic = $this->requireEnv('GOOGLE_PUBSUB_TOPIC');