Skip to content

Commit 6829509

Browse files
author
Patrick Glinsman
committed
Addressed remaining comments
1 parent ea3c47d commit 6829509

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

.kokoro/secrets-example.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export REDIS_PORT=
100100
export GOOGLE_PUBSUB_SUBSCRIPTION=php-example-subscription
101101
export GOOGLE_PUBSUB_TOPIC=php-example-topic
102102

103+
# Security Center
104+
export GOOGLE_ORGANIZATION_ID=
105+
export GOOGLE_PUBSUB_TOPIC=php-example-topic
106+
103107
# Spanner
104108
export GOOGLE_SPANNER_INSTANCE_ID=
105109
export GOOGLE_SPANNER_DATABASE_ID=test-database

securitycenter/src/create_notification.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// [START scc_create_notification_config]
2626
use Google\Cloud\SecurityCenter\V1\SecurityCenterClient;
2727
use Google\Cloud\SecurityCenter\V1\NotificationConfig;
28+
use Google\Cloud\SecurityCenter\V1\NotificationConfig\StreamingConfig;
2829

2930
/** Uncomment and populate these variables in your code */
3031
// $organizationId = "{your-org-id}";
@@ -36,12 +37,12 @@
3637
$organizationName = $securityCenterClient::organizationName($organizationId);
3738
$pubsubTopic = $securityCenterClient::topicName($projectId, $topicName);
3839

39-
$streamingConfig = new NotificationConfig\StreamingConfig();
40+
$streamingConfig = new StreamingConfig();
4041
$streamingConfig->setFilter("state = \"ACTIVE\"");
41-
$notificationConfig = new NotificationConfig();
42-
$notificationConfig->setDescription('A sample notification config');
43-
$notificationConfig->setPubsubTopic($pubsubTopic);
44-
$notificationConfig->setStreamingConfig($streamingConfig);
42+
$notificationConfig = (new NotificationConfig())
43+
->setDescription('A sample notification config')
44+
->setPubsubTopic($pubsubTopic)
45+
->setStreamingConfig($streamingConfig);
4546

4647
$response = $securityCenterClient->createNotificationConfig(
4748
$organizationName,
@@ -50,5 +51,4 @@
5051
);
5152
printf('Notification config was created: %s', $response->getName());
5253

53-
$securityCenterClient->close();
54-
// [END scc_create_notification_config]
54+
// [END scc_create_notification_config]

securitycenter/src/delete_notification.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@
3838
$response = $securityCenterClient->deleteNotificationConfig($notificationConfigName);
3939
print('Notification config was deleted');
4040

41-
$securityCenterClient->close();
42-
// [END scc_delete_notification_config]
41+
// [END scc_delete_notification_config]

securitycenter/src/get_notification.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@
3838
$response = $securityCenterClient->getNotificationConfig($notificationConfigName);
3939
printf('Notification config was retrieved: %s', $response->getName());
4040

41-
$securityCenterClient->close();
42-
// [END scc_get_notification_config]
41+
// [END scc_get_notification_config]

securitycenter/src/list_notification.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
$securityCenterClient = new SecurityCenterClient();
3232
$organizationName = $securityCenterClient::organizationName($organizationId);
3333

34-
$pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName);
35-
foreach ($pagedResponse->iterateAllElements() as $element) {
36-
printf('Found notification config %s', $element->getName());
34+
foreach ($securityCenterClient->listNotificationConfigs($organizationName) as $element) {
35+
printf('Found notification config %s' . PHP_EOL, $element->getName());
3736
}
3837

3938
print('Notification configs were listed');
40-
$securityCenterClient->close();
41-
// [END scc_list_notification_configs]
39+
40+
// [END scc_list_notification_configs]

securitycenter/src/receive_notification.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@
3939
// Acknowledge the Pub/Sub message has been received, so it will not be pulled multiple times.
4040
$subscription->acknowledge($message);
4141
}
42-
// [END scc_receive_notifications]
42+
43+
// [END scc_receive_notifications]

securitycenter/src/update_notification.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,12 @@
4545
$streamingConfig->setFilter("state = \"ACTIVE\"");
4646
$fieldMask = new FieldMask();
4747
$fieldMask->setPaths(['description', 'pubsub_topic']);
48-
$notificationConfig = new NotificationConfig();
49-
$notificationConfig
48+
$notificationConfig = (new NotificationConfig())
5049
->setName($notificationConfigName)
5150
->setDescription('Updated description.')
5251
->setPubsubTopic($pubsubTopic);
5352

5453
$response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]);
5554
printf('Notification config was updated: %s', $response->getName());
5655

57-
$securityCenterClient->close();
58-
// [END scc_update_notification_config]
56+
// [END scc_update_notification_config]

securitycenter/test/securitycenterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static function getOrganizationId()
117117

118118
private static function getTopicName()
119119
{
120-
return self::requireEnv('GOOGLE_TOPIC_ID');
120+
return self::requireEnv('GOOGLE_PUBSUB_TOPIC');
121121
}
122122

123123
private static function randomNotificationId()

0 commit comments

Comments
 (0)