Skip to content

Commit

Permalink
docs: Update notification samples to v1 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdh911 authored Mar 12, 2020
1 parent e19f62b commit 7f7b47d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
def create_notification_config(organization_id, notification_config_id, pubsub_topic):

# [START scc_create_notification_config]
from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud.securitycenter_v1p1beta1.proto.notification_config_pb2 import (
NotificationConfig,
)
from google.cloud import securitycenter as securitycenter

client = securitycenter.SecurityCenterClient()

Expand All @@ -39,7 +36,6 @@ def create_notification_config(organization_id, notification_config_id, pubsub_t
{
"description": "Notification for active findings",
"pubsub_topic": pubsub_topic,
"event_type": NotificationConfig.FINDING,
"streaming_config": {"filter": 'state = "ACTIVE"',},
},
)
Expand All @@ -52,7 +48,7 @@ def create_notification_config(organization_id, notification_config_id, pubsub_t
def delete_notification_config(organization_id, notification_config_id):

# [START scc_delete_notification_config]
from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud import securitycenter as securitycenter

client = securitycenter.SecurityCenterClient()

Expand All @@ -72,7 +68,7 @@ def delete_notification_config(organization_id, notification_config_id):
def get_notification_config(organization_id, notification_config_id):

# [START scc_get_notification_config]
from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud import securitycenter as securitycenter

client = securitycenter.SecurityCenterClient()

Expand All @@ -92,7 +88,7 @@ def get_notification_config(organization_id, notification_config_id):
def list_notification_configs(organization_id):

# [START scc_list_notification_configs]
from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud import securitycenter as securitycenter

client = securitycenter.SecurityCenterClient()

Expand All @@ -108,7 +104,7 @@ def list_notification_configs(organization_id):

def update_notification_config(organization_id, notification_config_id, pubsub_topic):
# [START scc_update_notification_config]
from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud import securitycenter as securitycenter
from google.protobuf import field_mask_pb2

client = securitycenter.SecurityCenterClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def receive_notifications(project_id, subscription_name):
# [START scc_receive_notifications]
# Requires https://cloud.google.com/pubsub/docs/quickstart-client-libraries#pubsub-client-libraries-python
from google.cloud import pubsub_v1
from google.cloud.securitycenter_v1p1beta1.proto.notification_message_pb2 import (
from google.cloud.securitycenter_v1.proto.notification_message_pb2 import (
NotificationMessage,
)
from google.protobuf import json_format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import os
import uuid

from google.cloud import securitycenter_v1p1beta1 as securitycenter
from google.cloud.securitycenter_v1p1beta1.proto.notification_config_pb2 import (
NotificationConfig,
)
from google.cloud import securitycenter as securitycenter
import pytest

import snippets_notification_configs
Expand Down Expand Up @@ -59,7 +56,6 @@ def new_notification_config_for_update():
{
"description": "Notification for active findings",
"pubsub_topic": PUBSUB_TOPIC,
"event_type": NotificationConfig.FINDING,
"streaming_config": {"filter": "",},
},
)
Expand All @@ -79,7 +75,6 @@ def new_notification_config_for_get():
{
"description": "Notification for active findings",
"pubsub_topic": PUBSUB_TOPIC,
"event_type": NotificationConfig.FINDING,
"streaming_config": {"filter": "",},
},
)
Expand All @@ -99,7 +94,6 @@ def deleted_notification_config():
{
"description": "Notification for active findings",
"pubsub_topic": PUBSUB_TOPIC,
"event_type": NotificationConfig.FINDING,
"streaming_config": {"filter": "",},
},
)
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-securitycenter/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def snippets(session):
os.path.join('docs', 'snippets_orgs.py'),
os.path.join('docs', 'snippets_findings.py'),
os.path.join('docs', 'snippets_security_marks.py'),
os.path.join('docs', 'v1p1beta1', 'snippets_test.py'),
os.path.join('docs', 'snippets_notification_test.py'),


*session.posargs
Expand Down

0 comments on commit 7f7b47d

Please sign in to comment.