async def sample_update_feed(): # Create a client client = asset_v1.AssetServiceAsyncClient() # Initialize request argument(s) feed = asset_v1.Feed() feed.name = "name_value" request = asset_v1.UpdateFeedRequest(feed=feed, ) # Make the request response = await client.update_feed(request=request) # Handle the response print(response)
def sample_create_feed(): # Create a client client = asset_v1.AssetServiceClient() # Initialize request argument(s) feed = asset_v1.Feed() feed.name = "name_value" request = asset_v1.CreateFeedRequest( parent="parent_value", feed_id="feed_id_value", feed=feed, ) # Make the request response = client.create_feed(request=request) # Handle the response print(response)
def update_feed(feed_name, topic): # [START asset_quickstart_update_feed] from google.cloud import asset_v1 from google.protobuf import field_mask_pb2 # TODO feed_name = 'Feed Name you want to update' # TODO topic = "Topic name you want to update with" client = asset_v1.AssetServiceClient() feed = asset_v1.Feed() feed.name = feed_name feed.feed_output_config.pubsub_destination.topic = topic update_mask = field_mask_pb2.FieldMask() # In this example, we update topic of the feed update_mask.paths.append("feed_output_config.pubsub_destination.topic") response = client.update_feed(request={ "feed": feed, "update_mask": update_mask }) print("updated_feed: {}".format(response))
def create_feed(project_id, feed_id, asset_names, topic): # [START asset_quickstart_create_feed] from google.cloud import asset_v1 # TODO project_id = 'Your Google Cloud Project ID' # TODO feed_id = 'Feed ID you want to create' # TODO asset_names = 'List of asset names the feed listen to' # TODO topic = "Topic name of the feed" client = asset_v1.AssetServiceClient() parent = "projects/{}".format(project_id) feed = asset_v1.Feed() feed.asset_names.extend(asset_names) feed.feed_output_config.pubsub_destination.topic = topic response = client.create_feed(request={ "parent": parent, "feed_id": feed_id, "feed": feed }) print("feed: {}".format(response)) # [END asset_quickstart_create_feed] return response