Skip to content

Commit

Permalink
use objects for resource names at places
Browse files Browse the repository at this point in the history
  • Loading branch information
anguillanneuf committed Oct 19, 2020
1 parent 9ca10e5 commit d6fc04a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions samples/snippets/create_lite_subscription_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def create_lite_subscription(
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
topic_path = str(TopicPath(project_number, location, topic_id))
subscription_path = str(SubscriptionPath(project_number, location, subscription_id))
topic_path = TopicPath(project_number, location, topic_id)
subscription_path = SubscriptionPath(project_number, location, subscription_id)

subscription = Subscription(
name=subscription_path,
topic=topic_path,
name=str(subscription_path),
topic=str(topic_path),
delivery_config=Subscription.DeliveryConfig(
# The server does not wait for a published message to be successfully
# written to storage before delivering it to subscribers. As such, a subscriber
Expand Down
4 changes: 2 additions & 2 deletions samples/snippets/create_lite_topic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def create_lite_topic(project_number, cloud_region, zone_id, topic_id, num_parti
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
topic_path = str(TopicPath(project_number, location, topic_id))
topic_path = TopicPath(project_number, location, topic_id)
topic = Topic(
name=topic_path,
name=str(topic_path),
partition_config=Topic.PartitionConfig(
# This must be greater than 1.
count=num_partitions,
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/delete_lite_subscription_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def delete_lite_subscription(project_number, cloud_region, zone_id, subscription
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
subscription_path = str(SubscriptionPath(project_number, location, subscription_id))
subscription_path = SubscriptionPath(project_number, location, subscription_id)

client.delete_subscription(subscription_path)
print(f"{subscription_path} deleted successfully.")
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/delete_lite_topic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def delete_lite_topic(project_number, cloud_region, zone_id, topic_id):
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
topic_path = str(TopicPath(project_number, location, topic_id))
topic_path = TopicPath(project_number, location, topic_id)

client.delete_topic(topic_path)
print(f"{topic_path} deleted successfully.")
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/get_lite_subscription_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_lite_subscription(project_number, cloud_region, zone_id, subscription_id
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
subscription_path = str(SubscriptionPath(project_number, location, subscription_id))
subscription_path = SubscriptionPath(project_number, location, subscription_id)

response = client.get_subscription(subscription_path)
print(f"{response}\nexists.")
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/get_lite_topic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_lite_topic(project_number, cloud_region, zone_id, topic_id):
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
topic_path = str(TopicPath(project_number, location, topic_id))
topic_path = TopicPath(project_number, location, topic_id)

response = client.get_topic(topic_path)
num_partitions = client.get_topic_partition_count(topic_path)
Expand Down
4 changes: 1 addition & 3 deletions samples/snippets/subscriber_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
def receive_messages(project_number, cloud_region, zone_id, subscription_id, timeout=90):
# [START pubsublite_quickstart_subscriber]
from concurrent.futures._base import TimeoutError
from google.cloud.pubsublite.cloudpubsub.flow_control_settings import (
FlowControlSettings,
)
from google.cloud.pubsublite.cloudpubsub.flow_control_settings import FlowControlSettings
from google.cloud.pubsublite.cloudpubsub.make_subscriber import make_subscriber
from google.cloud.pubsublite.location import CloudRegion, CloudZone
from google.cloud.pubsublite.paths import SubscriptionPath
Expand Down
4 changes: 2 additions & 2 deletions samples/snippets/update_lite_subscription_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def update_lite_subscription(project_number, cloud_region, zone_id, subscription
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
subscription_path = str(SubscriptionPath(project_number, location, subscription_id))
subscription_path = SubscriptionPath(project_number, location, subscription_id)
field_mask = FieldMask(paths=["delivery_config.delivery_requirement"])

subscription = Subscription(
name=subscription_path,
name=str(subscription_path),
delivery_config=Subscription.DeliveryConfig(
# DELIVER_AFTER_STORED ensures that the server won't deliver a published message
# to subscribers until the message has been written to storage successfully.
Expand Down
4 changes: 2 additions & 2 deletions samples/snippets/update_lite_topic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def update_lite_topic(project_number, cloud_region, zone_id, topic_id):
client = make_admin_client(cloud_region)

location = CloudZone(CloudRegion(cloud_region), zone_id)
topic_path = str(TopicPath(project_number, location, topic_id))
topic_path = TopicPath(project_number, location, topic_id)

# Defines which topic fields to update.
field_mask = FieldMask(
Expand All @@ -53,7 +53,7 @@ def update_lite_topic(project_number, cloud_region, zone_id, topic_id):

# Defines how to update the topic fields.
topic = Topic(
name=topic_path,
name=str(topic_path),
partition_config=Topic.PartitionConfig(
# Set publishing throughput to 4x standard partition throughput of 4 MiB
# per second. This must in the range [1,4]. A topic with `scale` of 2 and
Expand Down

0 comments on commit d6fc04a

Please sign in to comment.