From 077f0da2e93b5810603a319f89adb6aa806efdca Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Thu, 28 Apr 2022 04:39:05 -0700 Subject: [PATCH 01/55] docs(samples): add code samples (#21) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(samples): add code samples * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix region tags * enforce Python type hints * use build specific projects for samples testing * Remove project number env variable. Remove cloud storage dependency. Clean up resources > 3 hours old (instead of 2 days old). * Remove project number in favor of project ID. Avoid infinite loops in responses to LROs. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Anthonios Partheniou Co-authored-by: Owl Bot --- video/live-stream/README.md | 45 +++++++ video/live-stream/channel_event_test.py | 93 +++++++++++++ video/live-stream/channel_test.py | 132 +++++++++++++++++++ video/live-stream/create_channel.py | 152 ++++++++++++++++++++++ video/live-stream/create_channel_event.py | 92 +++++++++++++ video/live-stream/create_input.py | 74 +++++++++++ video/live-stream/delete_channel.py | 66 ++++++++++ video/live-stream/delete_channel_event.py | 75 +++++++++++ video/live-stream/delete_input.py | 66 ++++++++++ video/live-stream/get_channel.py | 67 ++++++++++ video/live-stream/get_channel_event.py | 77 +++++++++++ video/live-stream/get_input.py | 67 ++++++++++ video/live-stream/input_test.py | 69 ++++++++++ video/live-stream/list_channel_events.py | 72 ++++++++++ video/live-stream/list_channels.py | 65 +++++++++ video/live-stream/list_inputs.py | 65 +++++++++ video/live-stream/noxfile_config.py | 42 ++++++ video/live-stream/requirements-test.txt | 1 + video/live-stream/requirements.txt | 3 + video/live-stream/start_channel.py | 66 ++++++++++ video/live-stream/stop_channel.py | 66 ++++++++++ video/live-stream/update_channel.py | 92 +++++++++++++ video/live-stream/update_input.py | 83 ++++++++++++ video/live-stream/utils.py | 17 +++ 24 files changed, 1647 insertions(+) create mode 100644 video/live-stream/README.md create mode 100644 video/live-stream/channel_event_test.py create mode 100644 video/live-stream/channel_test.py create mode 100644 video/live-stream/create_channel.py create mode 100644 video/live-stream/create_channel_event.py create mode 100644 video/live-stream/create_input.py create mode 100644 video/live-stream/delete_channel.py create mode 100644 video/live-stream/delete_channel_event.py create mode 100644 video/live-stream/delete_input.py create mode 100644 video/live-stream/get_channel.py create mode 100644 video/live-stream/get_channel_event.py create mode 100644 video/live-stream/get_input.py create mode 100644 video/live-stream/input_test.py create mode 100644 video/live-stream/list_channel_events.py create mode 100644 video/live-stream/list_channels.py create mode 100644 video/live-stream/list_inputs.py create mode 100644 video/live-stream/noxfile_config.py create mode 100644 video/live-stream/requirements-test.txt create mode 100644 video/live-stream/requirements.txt create mode 100644 video/live-stream/start_channel.py create mode 100644 video/live-stream/stop_channel.py create mode 100644 video/live-stream/update_channel.py create mode 100644 video/live-stream/update_input.py create mode 100644 video/live-stream/utils.py diff --git a/video/live-stream/README.md b/video/live-stream/README.md new file mode 100644 index 000000000000..fb4f05bff3a8 --- /dev/null +++ b/video/live-stream/README.md @@ -0,0 +1,45 @@ +# Live Stream API Python Samples + +This directory contains samples for the Live Stream API. Use this API to +transcode live, linear video streams into a variety of formats. The Live Stream +API benefits broadcasters, production companies, businesses, and individuals +looking to transform their live video content for use across a variety of user +devices. For more information, see the +[Live Stream API documentation](https://cloud.google.com/livestream/). + +## Setup + +To run the samples, you need to first follow the steps in +[Before you begin](https://cloud.google.com/livestream/docs/how-to/before-you-begin). + +For more information on authentication, refer to the +[Authentication Getting Started Guide](https://cloud.google.com/docs/authentication/getting-started). + +## Install Dependencies + +1. Clone python-video-live-stream and change directories to the sample directory +you want to use. + + $ git clone https://github.com/googleapis/python-video-live-stream.git + +1. Install [pip](https://pip.pypa.io/) and +[virtualenv](https://virtualenv.pypa.io/) if you do not already have them. You +may want to refer to the +[Python Development Environment Setup Guide](https://cloud.google.com/python/setup) +for Google Cloud Platform for instructions. + +1. Create a virtualenv. Samples are compatible with Python 3.6+. + + $ virtualenv env + $ source env/bin/activate + +1. Install the dependencies needed to run the samples. + + $ pip install -r requirements.txt + +## Testing + +Make sure to enable the Live Stream API on the test project. Set the following +environment variable: + +* `GOOGLE_CLOUD_PROJECT` diff --git a/video/live-stream/channel_event_test.py b/video/live-stream/channel_event_test.py new file mode 100644 index 000000000000..c90868a612bc --- /dev/null +++ b/video/live-stream/channel_event_test.py @@ -0,0 +1,93 @@ +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import uuid + +import pytest + +import create_channel +import create_channel_event +import create_input +import delete_channel +import delete_channel_event +import delete_input +import get_channel_event +import list_channel_events +import start_channel +import stop_channel + +project_name = os.environ["GOOGLE_CLOUD_PROJECT"] +location = "us-central1" +input_id = f"python-test-input-{uuid.uuid4()}" +channel_id = f"python-test-channel-{uuid.uuid4()}" +event_id = f"python-test-event-{uuid.uuid4()}" +output_bucket_name = f"python-test-bucket-{uuid.uuid4()}" +output_uri = f"gs://{output_bucket_name}/channel-test/" + + +def test_channel_event_operations(capsys: pytest.fixture) -> None: + + # Set up + + channel_name_project_id = ( + f"projects/{project_name}/locations/{location}/channels/{channel_id}" + ) + event_name_project_id = f"projects/{project_name}/locations/{location}/channels/{channel_id}/events/{event_id}" + + create_input.create_input(project_name, location, input_id) + + create_channel.create_channel( + project_name, location, channel_id, input_id, output_uri + ) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + + start_channel.start_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Started channel" in out + + # Tests + + create_channel_event.create_channel_event( + project_name, location, channel_id, event_id + ) + out, _ = capsys.readouterr() + assert event_name_project_id in out + + get_channel_event.get_channel_event(project_name, location, channel_id, event_id) + out, _ = capsys.readouterr() + assert event_name_project_id in out + + list_channel_events.list_channel_events(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert event_name_project_id in out + + delete_channel_event.delete_channel_event( + project_name, location, channel_id, event_id + ) + out, _ = capsys.readouterr() + assert "Deleted channel event" in out + + # Clean up + + stop_channel.stop_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Stopped channel" in out + + delete_channel.delete_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Deleted channel" in out + + delete_input.delete_input(project_name, location, input_id) diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py new file mode 100644 index 000000000000..a7cfacdbcc37 --- /dev/null +++ b/video/live-stream/channel_test.py @@ -0,0 +1,132 @@ +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import uuid + +from google.api_core.exceptions import FailedPrecondition, NotFound +import pytest + +import create_channel +import create_input +import delete_channel +import delete_channel_event +import delete_input +import get_channel +import list_channel_events +import list_channels +import start_channel +import stop_channel +import update_channel +import utils + +project_name = os.environ["GOOGLE_CLOUD_PROJECT"] +location = "us-central1" +input_id = f"python-test-input-{uuid.uuid4()}" +updated_input_id = f"python-test-up-input-{uuid.uuid4()}" +channel_id = f"python-test-channel-{uuid.uuid4()}" +output_bucket_name = f"python-test-bucket-{uuid.uuid4()}" +output_uri = f"gs://{output_bucket_name}/channel-test/" + + +def test_channel_operations(capsys: pytest.fixture) -> None: + + # Clean up old resources in the test project + channel_responses = list_channels.list_channels(project_name, location) + + for response in channel_responses: + next_channel_id = response.name.rsplit("/", 1)[-1] + input_attachments = response.input_attachments + if utils.is_resource_stale(response.create_time): + try: + event_responses = list_channel_events.list_channel_events( + project_name, location, next_channel_id + ) + for response in event_responses: + next_event_id = response.name.rsplit("/", 1)[-1] + try: + delete_channel_event.delete_channel_event( + project_name, location, next_channel_id, next_event_id + ) + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + try: + stop_channel.stop_channel(project_name, location, next_channel_id) + except FailedPrecondition as e: + print(f"Ignoring FailedPrecondition, details: {e}") + try: + delete_channel.delete_channel( + project_name, location, next_channel_id + ) + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + + for input_attachment in input_attachments: + next_input_id = input_attachment.input.rsplit("/", 1)[-1] + try: + delete_input.delete_input(project_name, location, next_input_id) + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + + # Set up + + channel_name_project_id = ( + f"projects/{project_name}/locations/{location}/channels/{channel_id}" + ) + + create_input.create_input(project_name, location, input_id) + create_input.create_input(project_name, location, updated_input_id) + + # Tests + + create_channel.create_channel( + project_name, location, channel_id, input_id, output_uri + ) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + + list_channels.list_channels(project_name, location) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + + response = update_channel.update_channel( + project_name, location, channel_id, updated_input_id + ) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + for input_attachment in response.input_attachments: + assert "updated-input" in input_attachment.key + + get_channel.get_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + + start_channel.start_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Started channel" in out + + stop_channel.stop_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Stopped channel" in out + + delete_channel.delete_channel(project_name, location, channel_id) + out, _ = capsys.readouterr() + assert "Deleted channel" in out + + # Clean up + + delete_input.delete_input(project_name, location, input_id) + delete_input.delete_input(project_name, location, updated_input_id) diff --git a/video/live-stream/create_channel.py b/video/live-stream/create_channel.py new file mode 100644 index 000000000000..9db514887d35 --- /dev/null +++ b/video/live-stream/create_channel.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for creating a channel. A channel resource + represents the processor that performs a user-defined "streaming" operation. +Example usage: + python create_channel.py --project_id --location \ + --channel_id --input_id --output_uri +""" + +# [START livestream_create_channel] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_channel( + project_id: str, location: str, channel_id: str, input_id: str, output_uri: str +) -> str: + """Creates a channel. + Args: + project_id: The GCP project ID. + location: The location in which to create the channel. + channel_id: The user-defined channel ID. + input_id: The user-defined input ID. + output_uri: Uri of the channel output folder in a Cloud Storage bucket.""" + + client = LivestreamServiceClient() + parent = f"projects/{project_id}/locations/{location}" + input = f"projects/{project_id}/locations/{location}/inputs/{input_id}" + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + + channel = live_stream_v1.types.Channel( + name=name, + input_attachments=[ + live_stream_v1.types.InputAttachment( + key="my-input", + input=input, + ), + ], + output=live_stream_v1.types.Channel.Output( + uri=output_uri, + ), + elementary_streams=[ + live_stream_v1.types.ElementaryStream( + key="es_video", + video_stream=live_stream_v1.types.VideoStream( + h264=live_stream_v1.types.VideoStream.H264CodecSettings( + profile="main", + width_pixels=1280, + height_pixels=720, + bitrate_bps=1000000, + frame_rate=30, + ), + ), + ), + live_stream_v1.types.ElementaryStream( + key="es_audio", + audio_stream=live_stream_v1.types.AudioStream( + codec="aac", channel_count=2, bitrate_bps=160000 + ), + ), + ], + mux_streams=[ + live_stream_v1.types.MuxStream( + key="mux_video", + elementary_streams=["es_video"], + segment_settings=live_stream_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=2, + ), + ), + ), + live_stream_v1.types.MuxStream( + key="mux_audio", + elementary_streams=["es_audio"], + segment_settings=live_stream_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=2, + ), + ), + ), + ], + manifests=[ + live_stream_v1.types.Manifest( + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["mux_video", "mux_audio"], + max_segment_count=5, + ), + ], + ) + operation = client.create_channel( + parent=parent, channel=channel, channel_id=channel_id + ) + response = operation.result(60) + print(f"Channel: {response.name}") + + return response + + +# [END livestream_create_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location in which to create the channel.", + default="us-central1", + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="The Cloud Storage bucket (and optional folder) in which to save the livestream output.", + required=True, + ) + args = parser.parse_args() + create_channel( + args.project_id, + args.location, + args.channel_id, + args.input_id, + args.output_uri, + ) diff --git a/video/live-stream/create_channel_event.py b/video/live-stream/create_channel_event.py new file mode 100644 index 000000000000..1096e1d5bccd --- /dev/null +++ b/video/live-stream/create_channel_event.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for creating a channel event. An event is a + sub-resource of a channel, which can be scheduled by the user to execute + operations on a channel resource without having to stop the channel. +Example usage: + python create_channel_event.py --project_id --location \ + --channel_id --event_id +""" + +# [START livestream_create_channel_event] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_channel_event( + project_id: str, location: str, channel_id: str, event_id: str +) -> str: + """Creates a channel event. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID. + event_id: The user-defined event ID.""" + + client = LivestreamServiceClient() + parent = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}" + + event = live_stream_v1.types.Event( + name=name, + ad_break=live_stream_v1.types.Event.AdBreakTask( + duration=duration.Duration( + seconds=30, + ), + ), + execute_now=True, + ) + + response = client.create_event(parent=parent, event=event, event_id=event_id) + print(f"Channel event: {response.name}") + + return response + + +# [END livestream_create_channel_event] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + default="us-central1", + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--event_id", + help="The user-defined event ID.", + required=True, + ) + args = parser.parse_args() + create_channel_event( + args.project_id, + args.location, + args.channel_id, + args.event_id, + ) diff --git a/video/live-stream/create_input.py b/video/live-stream/create_input.py new file mode 100644 index 000000000000..ca5e3d6e318e --- /dev/null +++ b/video/live-stream/create_input.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for creating an input endpoint. You send an + input video stream to this endpoint. +Example usage: + python create_input.py --project_id --location --input_id +""" + +# [START livestream_create_input] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def create_input(project_id: str, location: str, input_id: str) -> str: + """Creates an input. + Args: + project_id: The GCP project ID. + location: The location in which to create the input. + input_id: The user-defined input ID.""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + + input = live_stream_v1.types.Input( + type_="RTMP_PUSH", + ) + operation = client.create_input(parent=parent, input=input, input_id=input_id) + response = operation.result(60) + print(f"Input: {response.name}") + + return response + + +# [END livestream_create_input] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location in which to create the input.", + default="us-central1", + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + args = parser.parse_args() + create_input( + args.project_id, + args.location, + args.input_id, + ) diff --git a/video/live-stream/delete_channel.py b/video/live-stream/delete_channel.py new file mode 100644 index 000000000000..31dfa978b751 --- /dev/null +++ b/video/live-stream/delete_channel.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for deleting a channel. +Example usage: + python delete_channel.py --project_id --location --channel_id +""" + +# [START livestream_delete_channel] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def delete_channel(project_id: str, location: str, channel_id: str) -> None: + """Deletes a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + operation = client.delete_channel(name=name) + operation.result(60) + print("Deleted channel") + + +# [END livestream_delete_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + args = parser.parse_args() + delete_channel( + args.project_id, + args.location, + args.channel_id, + ) diff --git a/video/live-stream/delete_channel_event.py b/video/live-stream/delete_channel_event.py new file mode 100644 index 000000000000..649f65c031fa --- /dev/null +++ b/video/live-stream/delete_channel_event.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for deleting a channel event. +Example usage: + python delete_channel_event.py --project_id --location \ + --channel_id --event_id +""" + +# [START livestream_delete_channel_event] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def delete_channel_event( + project_id: str, location: str, channel_id: str, event_id: str +) -> None: + """Deletes a channel event. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID. + event_id: The user-defined event ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}" + client.delete_event(name=name) + print("Deleted channel event") + + +# [END livestream_delete_channel_event] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--event_id", + help="The user-defined event ID.", + required=True, + ) + args = parser.parse_args() + delete_channel_event( + args.project_id, + args.location, + args.channel_id, + args.event_id, + ) diff --git a/video/live-stream/delete_input.py b/video/live-stream/delete_input.py new file mode 100644 index 000000000000..55e895b38a32 --- /dev/null +++ b/video/live-stream/delete_input.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for deleting an input. +Example usage: + python delete_input.py --project_id --location --input_id +""" + +# [START livestream_delete_input] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def delete_input(project_id: str, location: str, input_id: str) -> None: + """Deletes an input. + Args: + project_id: The GCP project ID. + location: The location of the input. + input_id: The user-defined input ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/inputs/{input_id}" + operation = client.delete_input(name=name) + operation.result(60) + print("Deleted input") + + +# [END livestream_delete_input] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the input.", + required=True, + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + args = parser.parse_args() + delete_input( + args.project_id, + args.location, + args.input_id, + ) diff --git a/video/live-stream/get_channel.py b/video/live-stream/get_channel.py new file mode 100644 index 000000000000..47df66d10772 --- /dev/null +++ b/video/live-stream/get_channel.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for getting a channel. +Example usage: + python get_channel.py --project_id --location --channel_id +""" + +# [START livestream_get_channel] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def get_channel(project_id: str, location: str, channel_id: str) -> str: + """Gets a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + response = client.get_channel(name=name) + print(f"Channel: {response.name}") + + return response + + +# [END livestream_get_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + args = parser.parse_args() + get_channel( + args.project_id, + args.location, + args.channel_id, + ) diff --git a/video/live-stream/get_channel_event.py b/video/live-stream/get_channel_event.py new file mode 100644 index 000000000000..9a70563e58c4 --- /dev/null +++ b/video/live-stream/get_channel_event.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for getting a channel event. +Example usage: + python get_channel.py --project_id --location \ + --channel_id --event_id +""" + +# [START livestream_get_channel_event] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def get_channel_event( + project_id: str, location: str, channel_id: str, event_id: str +) -> str: + """Gets a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID. + event_id: The user-defined event ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}" + response = client.get_event(name=name) + print(f"Channel event: {response.name}") + + return response + + +# [END livestream_get_channel_event] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--event_id", + help="The user-defined event ID.", + required=True, + ) + args = parser.parse_args() + get_channel_event( + args.project_id, + args.location, + args.channel_id, + args.event_id, + ) diff --git a/video/live-stream/get_input.py b/video/live-stream/get_input.py new file mode 100644 index 000000000000..d840cb4e79be --- /dev/null +++ b/video/live-stream/get_input.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for getting an input. +Example usage: + python get_input.py --project_id --location --input_id +""" + +# [START livestream_get_input] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def get_input(project_id: str, location: str, input_id: str) -> str: + """Gets an input. + Args: + project_id: The GCP project ID. + location: The location of the input. + input_id: The user-defined input ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/inputs/{input_id}" + response = client.get_input(name=name) + print(f"Input: {response.name}") + + return response + + +# [END livestream_get_input] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the input.", + required=True, + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + args = parser.parse_args() + get_input( + args.project_id, + args.location, + args.input_id, + ) diff --git a/video/live-stream/input_test.py b/video/live-stream/input_test.py new file mode 100644 index 000000000000..21ad23f38e16 --- /dev/null +++ b/video/live-stream/input_test.py @@ -0,0 +1,69 @@ +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import uuid + +from google.api_core.exceptions import NotFound +import pytest + +import create_input +import delete_input +import get_input +import list_inputs +import update_input +import utils + +project_name = os.environ["GOOGLE_CLOUD_PROJECT"] +location = "us-central1" +input_id = f"my-python-test-input-{uuid.uuid4()}" + + +def test_input_operations(capsys: pytest.fixture) -> None: + # Clean up old resources in the test project + responses = list_inputs.list_inputs(project_name, location) + for response in responses: + next_input_id = response.name.rsplit("/", 1)[-1] + if utils.is_resource_stale(response.create_time): + try: + delete_input.delete_input(project_name, location, next_input_id) + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + + input_name_project_id = ( + f"projects/{project_name}/locations/{location}/inputs/{input_id}" + ) + + # Tests + + create_input.create_input(project_name, location, input_id) + out, _ = capsys.readouterr() + assert input_name_project_id in out + + list_inputs.list_inputs(project_name, location) + out, _ = capsys.readouterr() + assert input_name_project_id in out + + response = update_input.update_input(project_name, location, input_id) + out, _ = capsys.readouterr() + assert input_name_project_id in out + assert response.preprocessing_config.crop.top_pixels == 5 + + get_input.get_input(project_name, location, input_id) + out, _ = capsys.readouterr() + assert input_name_project_id in out + + delete_input.delete_input(project_name, location, input_id) + out, _ = capsys.readouterr() + assert "Deleted input" in out diff --git a/video/live-stream/list_channel_events.py b/video/live-stream/list_channel_events.py new file mode 100644 index 000000000000..54d60b9dbe5c --- /dev/null +++ b/video/live-stream/list_channel_events.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for listing all events for a channel. +Example usage: + python list_channel_events.py --project_id --location --channel_id +""" + +# [START livestream_list_channel_events] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def list_channel_events(project_id: str, location: str, channel_id: str) -> list: + """Lists all events for a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID.""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + page_result = client.list_events(parent=parent) + print("Events:") + + responses = [] + for response in page_result: + print(response.name) + responses.append(response) + + return responses + + +# [END livestream_list_channel_events] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + args = parser.parse_args() + list_channel_events( + args.project_id, + args.location, + args.channel_id, + ) diff --git a/video/live-stream/list_channels.py b/video/live-stream/list_channels.py new file mode 100644 index 000000000000..009f5676d6c5 --- /dev/null +++ b/video/live-stream/list_channels.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for listing all channels in a location. +Example usage: + python list_channels.py --project_id --location +""" + +# [START livestream_list_channels] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def list_channels(project_id: str, location: str) -> list: + """Lists all channels in a location. + Args: + project_id: The GCP project ID. + location: The location of the channels.""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + page_result = client.list_channels(parent=parent) + print("Channels:") + + responses = [] + for response in page_result: + print(response.name) + responses.append(response) + + return responses + + +# [END livestream_list_channels] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channels.", + required=True, + ) + args = parser.parse_args() + list_channels( + args.project_id, + args.location, + ) diff --git a/video/live-stream/list_inputs.py b/video/live-stream/list_inputs.py new file mode 100644 index 000000000000..d04e3ba21527 --- /dev/null +++ b/video/live-stream/list_inputs.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for listing all inputs in a location. +Example usage: + python list_inputs.py --project_id --location +""" + +# [START livestream_list_inputs] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def list_inputs(project_id: str, location: str) -> list: + """Lists all inputs in a location. + Args: + project_id: The GCP project ID. + location: The location of the inputs.""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + page_result = client.list_inputs(parent=parent) + print("Inputs:") + + responses = [] + for response in page_result: + print(response.name) + responses.append(response) + + return responses + + +# [END livestream_list_inputs] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the inputs.", + required=True, + ) + args = parser.parse_args() + list_inputs( + args.project_id, + args.location, + ) diff --git a/video/live-stream/noxfile_config.py b/video/live-stream/noxfile_config.py new file mode 100644 index 000000000000..947c76615f41 --- /dev/null +++ b/video/live-stream/noxfile_config.py @@ -0,0 +1,42 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": [], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": True, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt new file mode 100644 index 000000000000..76593bb6e893 --- /dev/null +++ b/video/live-stream/requirements-test.txt @@ -0,0 +1 @@ +pytest==7.0.1 \ No newline at end of file diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt new file mode 100644 index 000000000000..a48d607380a6 --- /dev/null +++ b/video/live-stream/requirements.txt @@ -0,0 +1,3 @@ +google-api-python-client==2.34.0 +grpcio==1.44.0 +google-cloud-video-live-stream==0.1.1 \ No newline at end of file diff --git a/video/live-stream/start_channel.py b/video/live-stream/start_channel.py new file mode 100644 index 000000000000..b4f79d102c18 --- /dev/null +++ b/video/live-stream/start_channel.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for starting a channel. +Example usage: + python start_channel.py --project_id --location --channel_id +""" + +# [START livestream_start_channel] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def start_channel(project_id: str, location: str, channel_id: str) -> None: + """Starts a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + operation = client.start_channel(name=name) + operation.result(60) + print("Started channel") + + +# [END livestream_start_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + args = parser.parse_args() + start_channel( + args.project_id, + args.location, + args.channel_id, + ) diff --git a/video/live-stream/stop_channel.py b/video/live-stream/stop_channel.py new file mode 100644 index 000000000000..f580e37093f1 --- /dev/null +++ b/video/live-stream/stop_channel.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for stopping a channel. +Example usage: + python stop_channel.py --project_id --location --channel_id +""" + +# [START livestream_stop_channel] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def stop_channel(project_id: str, location: str, channel_id: str) -> None: + """Stops a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + operation = client.stop_channel(name=name) + operation.result(60) + print("Stopped channel") + + +# [END livestream_stop_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + args = parser.parse_args() + stop_channel( + args.project_id, + args.location, + args.channel_id, + ) diff --git a/video/live-stream/update_channel.py b/video/live-stream/update_channel.py new file mode 100644 index 000000000000..e4533c00425d --- /dev/null +++ b/video/live-stream/update_channel.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for updating a channel with a different input. +Example usage: + python update_channel.py --project_id --location \ + --channel_id --input_id +""" + +# [START livestream_update_channel] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import field_mask_pb2 as field_mask + + +def update_channel( + project_id: str, location: str, channel_id: str, input_id: str +) -> str: + """Updates a channel. + Args: + project_id: The GCP project ID. + location: The location of the channel. + channel_id: The user-defined channel ID. + input_id: The user-defined input ID for the new input.""" + + client = LivestreamServiceClient() + input = f"projects/{project_id}/locations/{location}/inputs/{input_id}" + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + + channel = live_stream_v1.types.Channel( + name=name, + input_attachments=[ + live_stream_v1.types.InputAttachment( + key="updated-input", + input=input, + ), + ], + ) + update_mask = field_mask.FieldMask(paths=["input_attachments"]) + + operation = client.update_channel(channel=channel, update_mask=update_mask) + response = operation.result(60) + print(f"Updated channel: {response.name}") + + return response + + +# [END livestream_update_channel] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location in of the channel.", + required=True, + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + args = parser.parse_args() + update_channel( + args.project_id, + args.location, + args.channel_id, + args.input_id, + ) diff --git a/video/live-stream/update_input.py b/video/live-stream/update_input.py new file mode 100644 index 000000000000..6b45bdea193b --- /dev/null +++ b/video/live-stream/update_input.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for updating an input endpoint. This sample + adds a preprocessing configuration to an existing input. +Example usage: + python update_input.py --project_id --location --input_id +""" + +# [START livestream_update_input] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import field_mask_pb2 as field_mask + + +def update_input(project_id: str, location: str, input_id: str) -> str: + """Updates an input. + Args: + project_id: The GCP project ID. + location: The location of the input. + input_id: The user-defined input ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/inputs/{input_id}" + + input = live_stream_v1.types.Input( + name=name, + preprocessing_config=live_stream_v1.types.PreprocessingConfig( + crop=live_stream_v1.types.PreprocessingConfig.Crop( + top_pixels=5, + bottom_pixels=5, + ) + ), + ) + update_mask = field_mask.FieldMask(paths=["preprocessing_config"]) + + operation = client.update_input(input=input, update_mask=update_mask) + response = operation.result(60) + print(f"Updated input: {response.name}") + + return response + + +# [END livestream_update_input] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the input.", + required=True, + ) + parser.add_argument( + "--input_id", + help="The user-defined input ID.", + required=True, + ) + args = parser.parse_args() + update_input( + args.project_id, + args.location, + args.input_id, + ) diff --git a/video/live-stream/utils.py b/video/live-stream/utils.py new file mode 100644 index 000000000000..e0221d9c6225 --- /dev/null +++ b/video/live-stream/utils.py @@ -0,0 +1,17 @@ +from google.protobuf import timestamp_pb2 + +seconds_per_hour = 3600 + + +def is_resource_stale(create_time: str) -> bool: + """Checks the create timestamp to see if the resource is stale (and should be deleted). + Args: + create_time: Creation time in Timestamp format.""" + timestamp = timestamp_pb2.Timestamp() + timestamp.FromDatetime(create_time) + now = timestamp_pb2.Timestamp() + now.GetCurrentTime() + if (now.seconds - timestamp.seconds) > (3 * seconds_per_hour): + return True + else: + return False From b479bb92e51fc811463b6a5c017eeb8005107647 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 28 Apr 2022 20:33:01 +0200 Subject: [PATCH 02/55] chore(deps): update all dependencies (#33) --- video/live-stream/requirements-test.txt | 2 +- video/live-stream/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index 76593bb6e893..6a3d7bca6791 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.1 \ No newline at end of file +pytest==7.1.2 \ No newline at end of file diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index a48d607380a6..5c12344121cc 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,3 +1,3 @@ -google-api-python-client==2.34.0 +google-api-python-client==2.46.0 grpcio==1.44.0 google-cloud-video-live-stream==0.1.1 \ No newline at end of file From c1acfecaad94e3714366de8e56512272bada8d22 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 29 Apr 2022 00:27:45 +0200 Subject: [PATCH 03/55] chore(deps): update dependency google-cloud-video-live-stream to v0.1.2 (#34) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 5c12344121cc..c7e84aa712c9 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.46.0 grpcio==1.44.0 -google-cloud-video-live-stream==0.1.1 \ No newline at end of file +google-cloud-video-live-stream==0.1.2 \ No newline at end of file From 4b51400bc393bc6a3152b19ab076b05cce0bddd1 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 29 Apr 2022 03:00:02 -0700 Subject: [PATCH 04/55] ci: try to stop channel again before deleting it in the test (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Try to stop channel again before deleting it in the test. * docs(samples): try to stop channel again before deleting it in the test. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- video/live-stream/channel_test.py | 8 ++++++++ video/live-stream/input_test.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py index a7cfacdbcc37..2d9e890c65b9 100644 --- a/video/live-stream/channel_test.py +++ b/video/live-stream/channel_test.py @@ -69,6 +69,14 @@ def test_channel_operations(capsys: pytest.fixture) -> None: delete_channel.delete_channel( project_name, location, next_channel_id ) + except FailedPrecondition as e: + print(f"Ignoring FailedPrecondition, try to stop channel: {e}") + try: + stop_channel.stop_channel( + project_name, location, next_channel_id + ) + except FailedPrecondition as e: + print(f"Ignoring FailedPrecondition, details: {e}") except NotFound as e: print(f"Ignoring NotFound, details: {e}") except NotFound as e: diff --git a/video/live-stream/input_test.py b/video/live-stream/input_test.py index 21ad23f38e16..a0224b4f4d56 100644 --- a/video/live-stream/input_test.py +++ b/video/live-stream/input_test.py @@ -15,7 +15,7 @@ import os import uuid -from google.api_core.exceptions import NotFound +from google.api_core.exceptions import FailedPrecondition, NotFound import pytest import create_input @@ -38,6 +38,8 @@ def test_input_operations(capsys: pytest.fixture) -> None: if utils.is_resource_stale(response.create_time): try: delete_input.delete_input(project_name, location, next_input_id) + except FailedPrecondition as e: + print(f"Ignoring FailedPrecondition, details: {e}") except NotFound as e: print(f"Ignoring NotFound, details: {e}") From 1fda5b31d85b3c8f6038f3128afdacc11af4bcf6 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Mon, 2 May 2022 17:11:32 -0700 Subject: [PATCH 05/55] docs(samples): add sample for creating a channel with a failover backup input (#37) --- video/live-stream/channel_test.py | 8 + .../create_channel_with_backup_input.py | 179 ++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 video/live-stream/create_channel_with_backup_input.py diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py index 2d9e890c65b9..1b4ac7856b7c 100644 --- a/video/live-stream/channel_test.py +++ b/video/live-stream/channel_test.py @@ -19,6 +19,7 @@ import pytest import create_channel +import create_channel_with_backup_input import create_input import delete_channel import delete_channel_event @@ -134,7 +135,14 @@ def test_channel_operations(capsys: pytest.fixture) -> None: out, _ = capsys.readouterr() assert "Deleted channel" in out + create_channel_with_backup_input.create_channel_with_backup_input( + project_name, location, channel_id, input_id, updated_input_id, output_uri + ) + out, _ = capsys.readouterr() + assert channel_name_project_id in out + # Clean up + delete_channel.delete_channel(project_name, location, channel_id) delete_input.delete_input(project_name, location, input_id) delete_input.delete_input(project_name, location, updated_input_id) diff --git a/video/live-stream/create_channel_with_backup_input.py b/video/live-stream/create_channel_with_backup_input.py new file mode 100644 index 000000000000..3bcdc481f677 --- /dev/null +++ b/video/live-stream/create_channel_with_backup_input.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python + +# Copyright 2022 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for creating a channel with a backup input. + A channel resource represents the processor that performs a user-defined + "streaming" operation. +Example usage: + python create_channel_with_backup_input.py --project_id \ + --location --channel_id \ + --primary_input_id \ + --backup_input_id --output_uri +""" + +# [START livestream_create_channel_with_backup_input] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import duration_pb2 as duration + + +def create_channel_with_backup_input( + project_id: str, + location: str, + channel_id: str, + primary_input_id: str, + backup_input_id: str, + output_uri: str, +) -> str: + """Creates a channel. + Args: + project_id: The GCP project ID. + location: The location in which to create the channel. + channel_id: The user-defined channel ID. + primary_input_id: The user-defined primary input ID. + backup_input_id: The user-defined backup input ID. + output_uri: Uri of the channel output folder in a Cloud Storage bucket.""" + + client = LivestreamServiceClient() + parent = f"projects/{project_id}/locations/{location}" + primary_input = ( + f"projects/{project_id}/locations/{location}/inputs/{primary_input_id}" + ) + backup_input = ( + f"projects/{project_id}/locations/{location}/inputs/{backup_input_id}" + ) + name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" + + channel = live_stream_v1.types.Channel( + name=name, + input_attachments=[ + live_stream_v1.types.InputAttachment( + key="my-primary-input", + input=primary_input, + automatic_failover=live_stream_v1.types.InputAttachment.AutomaticFailover( + input_keys=["my-backup-input"], + ), + ), + live_stream_v1.types.InputAttachment( + key="my-backup-input", + input=backup_input, + ), + ], + output=live_stream_v1.types.Channel.Output( + uri=output_uri, + ), + elementary_streams=[ + live_stream_v1.types.ElementaryStream( + key="es_video", + video_stream=live_stream_v1.types.VideoStream( + h264=live_stream_v1.types.VideoStream.H264CodecSettings( + profile="main", + width_pixels=1280, + height_pixels=720, + bitrate_bps=1000000, + frame_rate=30, + ), + ), + ), + live_stream_v1.types.ElementaryStream( + key="es_audio", + audio_stream=live_stream_v1.types.AudioStream( + codec="aac", channel_count=2, bitrate_bps=160000 + ), + ), + ], + mux_streams=[ + live_stream_v1.types.MuxStream( + key="mux_video", + elementary_streams=["es_video"], + segment_settings=live_stream_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=2, + ), + ), + ), + live_stream_v1.types.MuxStream( + key="mux_audio", + elementary_streams=["es_audio"], + segment_settings=live_stream_v1.types.SegmentSettings( + segment_duration=duration.Duration( + seconds=2, + ), + ), + ), + ], + manifests=[ + live_stream_v1.types.Manifest( + file_name="manifest.m3u8", + type_="HLS", + mux_streams=["mux_video", "mux_audio"], + max_segment_count=5, + ), + ], + ) + operation = client.create_channel( + parent=parent, channel=channel, channel_id=channel_id + ) + response = operation.result(60) + print(f"Channel: {response.name}") + + return response + + +# [END livestream_create_channel_with_backup_input] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location in which to create the channel.", + default="us-central1", + ) + parser.add_argument( + "--channel_id", + help="The user-defined channel ID.", + required=True, + ) + parser.add_argument( + "--primary_input_id", + help="The user-defined primary input ID.", + required=True, + ) + parser.add_argument( + "--backup_input_id", + help="The user-defined backup input ID.", + required=True, + ) + parser.add_argument( + "--output_uri", + help="The Cloud Storage bucket (and optional folder) in which to save the livestream output.", + required=True, + ) + args = parser.parse_args() + create_channel_with_backup_input( + args.project_id, + args.location, + args.channel_id, + args.primary_input_id, + args.backup_input_id, + args.output_uri, + ) From 02c8682bd3105d3a6db2648e65630b531129706a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 3 May 2022 16:17:03 +0200 Subject: [PATCH 06/55] chore(deps): update dependency google-cloud-video-live-stream to v0.1.3 (#39) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index c7e84aa712c9..6ebf4899040f 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,3 +1,3 @@ google-api-python-client==2.46.0 grpcio==1.44.0 -google-cloud-video-live-stream==0.1.2 \ No newline at end of file +google-cloud-video-live-stream==0.1.3 \ No newline at end of file From 73f80ceaa68ad199e492ade0da9d035a94e68708 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 3 May 2022 20:21:42 +0200 Subject: [PATCH 07/55] chore: remove dependency google-api-python-client in samples (#40) * chore(deps): update dependency google-api-python-client to v2.47.0 * chore: remove dependency google-api-python-client in samples Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 6ebf4899040f..c80d1ae76c0b 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,3 +1,2 @@ -google-api-python-client==2.46.0 grpcio==1.44.0 -google-cloud-video-live-stream==0.1.3 \ No newline at end of file +google-cloud-video-live-stream==0.1.3 From 0d2b02ce89fc876745d93d1476e7f275e1d1e4d6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 02:44:34 +0200 Subject: [PATCH 08/55] chore(deps): update dependency grpcio to v1.46.0 (#41) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index c80d1ae76c0b..e5d8ae940b4c 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.44.0 +grpcio==1.46.0 google-cloud-video-live-stream==0.1.3 From 5d01257b97b0dc3c1e54c03016ff2ca7c52387e6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 12 May 2022 20:17:34 +0200 Subject: [PATCH 09/55] chore(deps): update dependency grpcio to v1.46.1 (#44) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index e5d8ae940b4c..16f9f0fb22a3 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.46.0 +grpcio==1.46.1 google-cloud-video-live-stream==0.1.3 From 35a6031eefb201b757f4501d04abf39cca600193 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 22 May 2022 20:08:22 +0200 Subject: [PATCH 10/55] chore(deps): update dependency grpcio to v1.46.3 (#47) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 16f9f0fb22a3..55abb7cc2f9c 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.46.1 +grpcio==1.46.3 google-cloud-video-live-stream==0.1.3 From bf58dbd3f84b16d57d65beb8a183b6ce65f58e21 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 25 May 2022 22:35:37 +0200 Subject: [PATCH 11/55] chore(deps): update dependency google-cloud-video-live-stream to v0.1.4 (#48) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 55abb7cc2f9c..cfa54638f6df 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.46.3 -google-cloud-video-live-stream==0.1.3 +google-cloud-video-live-stream==0.1.4 From fc76f67ea887dcb14399321ce56abc3b47c36a27 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Tue, 28 Jun 2022 15:57:30 -0700 Subject: [PATCH 12/55] docs: align channel config with best practices (#71) skipping optional check for kokoro pre-release dependencies. --- video/live-stream/create_channel.py | 4 ++-- video/live-stream/create_channel_with_backup_input.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/video/live-stream/create_channel.py b/video/live-stream/create_channel.py index 9db514887d35..67ed7fce7d41 100644 --- a/video/live-stream/create_channel.py +++ b/video/live-stream/create_channel.py @@ -64,10 +64,10 @@ def create_channel( key="es_video", video_stream=live_stream_v1.types.VideoStream( h264=live_stream_v1.types.VideoStream.H264CodecSettings( - profile="main", + profile="high", width_pixels=1280, height_pixels=720, - bitrate_bps=1000000, + bitrate_bps=3000000, frame_rate=30, ), ), diff --git a/video/live-stream/create_channel_with_backup_input.py b/video/live-stream/create_channel_with_backup_input.py index 3bcdc481f677..0b7284b12fc9 100644 --- a/video/live-stream/create_channel_with_backup_input.py +++ b/video/live-stream/create_channel_with_backup_input.py @@ -85,10 +85,10 @@ def create_channel_with_backup_input( key="es_video", video_stream=live_stream_v1.types.VideoStream( h264=live_stream_v1.types.VideoStream.H264CodecSettings( - profile="main", + profile="high", width_pixels=1280, height_pixels=720, - bitrate_bps=1000000, + bitrate_bps=3000000, frame_rate=30, ), ), From 287fff2186b83e4ba4203dd6057b542d2fcac168 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 16 Jul 2022 17:16:53 +0200 Subject: [PATCH 13/55] chore(deps): update all dependencies (#70) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index cfa54638f6df..041da07357c7 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.46.3 -google-cloud-video-live-stream==0.1.4 +google-cloud-video-live-stream==0.1.5 From c979dc8ce176442b94a58ea108def07aba185743 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Mon, 25 Jul 2022 18:53:49 -0700 Subject: [PATCH 14/55] docs(samples): fix timeout for LROs; first call can take up to 10 minutes (#82) Co-authored-by: Anthonios Partheniou --- video/live-stream/create_channel.py | 2 +- video/live-stream/create_channel_with_backup_input.py | 2 +- video/live-stream/create_input.py | 2 +- video/live-stream/delete_channel.py | 2 +- video/live-stream/delete_input.py | 2 +- video/live-stream/start_channel.py | 2 +- video/live-stream/stop_channel.py | 2 +- video/live-stream/update_channel.py | 2 +- video/live-stream/update_input.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/video/live-stream/create_channel.py b/video/live-stream/create_channel.py index 67ed7fce7d41..5bb2326ebfb9 100644 --- a/video/live-stream/create_channel.py +++ b/video/live-stream/create_channel.py @@ -111,7 +111,7 @@ def create_channel( operation = client.create_channel( parent=parent, channel=channel, channel_id=channel_id ) - response = operation.result(60) + response = operation.result(600) print(f"Channel: {response.name}") return response diff --git a/video/live-stream/create_channel_with_backup_input.py b/video/live-stream/create_channel_with_backup_input.py index 0b7284b12fc9..5e49b7a88843 100644 --- a/video/live-stream/create_channel_with_backup_input.py +++ b/video/live-stream/create_channel_with_backup_input.py @@ -132,7 +132,7 @@ def create_channel_with_backup_input( operation = client.create_channel( parent=parent, channel=channel, channel_id=channel_id ) - response = operation.result(60) + response = operation.result(600) print(f"Channel: {response.name}") return response diff --git a/video/live-stream/create_input.py b/video/live-stream/create_input.py index ca5e3d6e318e..ab80f89e46ba 100644 --- a/video/live-stream/create_input.py +++ b/video/live-stream/create_input.py @@ -45,7 +45,7 @@ def create_input(project_id: str, location: str, input_id: str) -> str: type_="RTMP_PUSH", ) operation = client.create_input(parent=parent, input=input, input_id=input_id) - response = operation.result(60) + response = operation.result(600) print(f"Input: {response.name}") return response diff --git a/video/live-stream/delete_channel.py b/video/live-stream/delete_channel.py index 31dfa978b751..b7bd485358c6 100644 --- a/video/live-stream/delete_channel.py +++ b/video/live-stream/delete_channel.py @@ -39,7 +39,7 @@ def delete_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.delete_channel(name=name) - operation.result(60) + operation.result(600) print("Deleted channel") diff --git a/video/live-stream/delete_input.py b/video/live-stream/delete_input.py index 55e895b38a32..fe74a6438d83 100644 --- a/video/live-stream/delete_input.py +++ b/video/live-stream/delete_input.py @@ -39,7 +39,7 @@ def delete_input(project_id: str, location: str, input_id: str) -> None: name = f"projects/{project_id}/locations/{location}/inputs/{input_id}" operation = client.delete_input(name=name) - operation.result(60) + operation.result(600) print("Deleted input") diff --git a/video/live-stream/start_channel.py b/video/live-stream/start_channel.py index b4f79d102c18..3d77cb5f09ee 100644 --- a/video/live-stream/start_channel.py +++ b/video/live-stream/start_channel.py @@ -39,7 +39,7 @@ def start_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.start_channel(name=name) - operation.result(60) + operation.result(600) print("Started channel") diff --git a/video/live-stream/stop_channel.py b/video/live-stream/stop_channel.py index f580e37093f1..6440a8d7a972 100644 --- a/video/live-stream/stop_channel.py +++ b/video/live-stream/stop_channel.py @@ -39,7 +39,7 @@ def stop_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.stop_channel(name=name) - operation.result(60) + operation.result(600) print("Stopped channel") diff --git a/video/live-stream/update_channel.py b/video/live-stream/update_channel.py index e4533c00425d..9bd25deb0cda 100644 --- a/video/live-stream/update_channel.py +++ b/video/live-stream/update_channel.py @@ -57,7 +57,7 @@ def update_channel( update_mask = field_mask.FieldMask(paths=["input_attachments"]) operation = client.update_channel(channel=channel, update_mask=update_mask) - response = operation.result(60) + response = operation.result(600) print(f"Updated channel: {response.name}") return response diff --git a/video/live-stream/update_input.py b/video/live-stream/update_input.py index 6b45bdea193b..64f2dfb19287 100644 --- a/video/live-stream/update_input.py +++ b/video/live-stream/update_input.py @@ -54,7 +54,7 @@ def update_input(project_id: str, location: str, input_id: str) -> str: update_mask = field_mask.FieldMask(paths=["preprocessing_config"]) operation = client.update_input(input=input, update_mask=update_mask) - response = operation.result(60) + response = operation.result(600) print(f"Updated input: {response.name}") return response From d11988ec1ce5a9b670cd069b37e60a46c3678d2a Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 29 Jul 2022 07:46:35 -0700 Subject: [PATCH 15/55] docs(samples): fix timeout for create input and start channel LROs; first call can take up to 15 minutes (#86) --- video/live-stream/create_input.py | 2 +- video/live-stream/start_channel.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/create_input.py b/video/live-stream/create_input.py index ab80f89e46ba..45f5a508e156 100644 --- a/video/live-stream/create_input.py +++ b/video/live-stream/create_input.py @@ -45,7 +45,7 @@ def create_input(project_id: str, location: str, input_id: str) -> str: type_="RTMP_PUSH", ) operation = client.create_input(parent=parent, input=input, input_id=input_id) - response = operation.result(600) + response = operation.result(900) print(f"Input: {response.name}") return response diff --git a/video/live-stream/start_channel.py b/video/live-stream/start_channel.py index 3d77cb5f09ee..9e05aaa3abba 100644 --- a/video/live-stream/start_channel.py +++ b/video/live-stream/start_channel.py @@ -39,7 +39,7 @@ def start_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.start_channel(name=name) - operation.result(600) + operation.result(900) print("Started channel") From 49d73e72fc424715c106151d799f1fcd96cdd071 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 2 Aug 2022 14:23:36 +0200 Subject: [PATCH 16/55] chore(deps): update all dependencies (#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 041da07357c7..287a6b99a847 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.46.3 -google-cloud-video-live-stream==0.1.5 +grpcio==1.48.0 +google-cloud-video-live-stream==1.0.0 From 2803de6e093fd853cb980f498f5850b5a37aec95 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 10 Aug 2022 18:57:52 +0200 Subject: [PATCH 17/55] chore(deps): update all dependencies to v1.0.1 (#90) * chore(deps): update all dependencies to v1.0.1 * revert Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 287a6b99a847..c4eac7e63d30 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.48.0 -google-cloud-video-live-stream==1.0.0 +google-cloud-video-live-stream==1.0.1 From 835151929ef1979c1dec424a9b3ea934ea2c5eff Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 16 Aug 2022 16:38:46 +0200 Subject: [PATCH 18/55] chore(deps): update dependency google-cloud-video-live-stream to v1.0.2 (#94) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index c4eac7e63d30..6d69ba483029 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.48.0 -google-cloud-video-live-stream==1.0.1 +google-cloud-video-live-stream==1.0.2 From 2767b94edc7a9cf4861a192f94e8290f42bd2b28 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 2 Sep 2022 13:17:36 +0200 Subject: [PATCH 19/55] chore(deps): update dependency grpcio to v1.48.1 (#101) Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 6d69ba483029..af2d3af479c2 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.48.0 +grpcio==1.48.1 google-cloud-video-live-stream==1.0.2 From 009a47adbb8e19c01a54f05209131cf358a21c49 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 6 Sep 2022 17:20:16 +0200 Subject: [PATCH 20/55] chore(deps): update dependency pytest to v7.1.3 (#106) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index 6a3d7bca6791..f97bae64aa54 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.1.2 \ No newline at end of file +pytest==7.1.3 \ No newline at end of file From 4fff6e34af0a21857fa9ff6a8c3d8667d4e6e227 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 16 Sep 2022 17:52:44 +0200 Subject: [PATCH 21/55] chore(deps): update dependency grpcio to v1.49.0 (#111) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index af2d3af479c2..d87fc779624e 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.48.1 +grpcio==1.49.0 google-cloud-video-live-stream==1.0.2 From e653cdd9550b20f3049e3671d841e29d6a0ab036 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 02:58:44 +0200 Subject: [PATCH 22/55] chore(deps): update dependency grpcio to v1.49.1 (#112) Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index d87fc779624e..0da0abe62320 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.49.0 +grpcio==1.49.1 google-cloud-video-live-stream==1.0.2 From 47bb0cc1f42542541eec74667abc1786d1062927 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 03:08:57 +0200 Subject: [PATCH 23/55] chore(deps): update dependency google-cloud-video-live-stream to v1.0.3 (#115) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 0da0abe62320..75b26535ec0b 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.49.1 -google-cloud-video-live-stream==1.0.2 +google-cloud-video-live-stream==1.0.3 From 53e04822d31a27406e8a8088faf89c942ed839cd Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 18 Oct 2022 15:18:08 +0200 Subject: [PATCH 24/55] chore(deps): update dependency google-cloud-video-live-stream to v1.0.4 (#118) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 75b26535ec0b..fa9b173d30be 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.49.1 -google-cloud-video-live-stream==1.0.3 +google-cloud-video-live-stream==1.0.4 From 58578e2242530506bed992151ea16690fad99554 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 19 Oct 2022 16:04:24 +0200 Subject: [PATCH 25/55] chore(deps): update dependency grpcio to v1.50.0 (#119) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index fa9b173d30be..fafdd5137eb1 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.49.1 +grpcio==1.50.0 google-cloud-video-live-stream==1.0.4 From b8fbb3501a982b95f8cdfac85bf5c89545ea0e83 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 26 Oct 2022 13:15:20 +0200 Subject: [PATCH 26/55] chore(deps): update dependency pytest to v7.2.0 (#120) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index f97bae64aa54..89cb815c988e 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.1.3 \ No newline at end of file +pytest==7.2.0 \ No newline at end of file From e9e05248f54d00cf69ab16756c343e7aad41d07c Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 15 Dec 2022 20:11:47 +0100 Subject: [PATCH 27/55] chore(deps): update dependency grpcio to v1.51.1 (#128) Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index fafdd5137eb1..aeac8e4be885 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.50.0 +grpcio==1.51.1 google-cloud-video-live-stream==1.0.4 From 637882b5d6ad0ebddb284157436a11f86721c8e6 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 16 Dec 2022 03:28:54 +0100 Subject: [PATCH 28/55] chore(deps): update dependency google-cloud-video-live-stream to v1.1.0 (#131) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index aeac8e4be885..eb52c9d9a44a 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.51.1 -google-cloud-video-live-stream==1.0.4 +google-cloud-video-live-stream==1.1.0 From e099ce7fd55b08fd98c7b144b453172a7c5b609d Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 10 Jan 2023 18:33:26 +0000 Subject: [PATCH 29/55] chore(deps): update dependency google-cloud-video-live-stream to v1.2.0 (#135) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index eb52c9d9a44a..167ccc2bfdf9 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.51.1 -google-cloud-video-live-stream==1.1.0 +google-cloud-video-live-stream==1.2.0 From f5f1dadb9ace996b38632795a365574cd3c77446 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 14 Jan 2023 18:09:57 +0000 Subject: [PATCH 30/55] chore(deps): update dependency pytest to v7.2.1 (#136) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index 89cb815c988e..dd3c7330bb99 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.2.0 \ No newline at end of file +pytest==7.2.1 \ No newline at end of file From 3199befa18f0c2dfdded955b3e2bc39adc9a553c Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 23 Jan 2023 16:28:58 +0000 Subject: [PATCH 31/55] chore(deps): update dependency google-cloud-video-live-stream to v1.2.1 (#139) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 167ccc2bfdf9..af492486a662 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.51.1 -google-cloud-video-live-stream==1.2.0 +google-cloud-video-live-stream==1.2.1 From 1885872a77075e24692138cf53cac11c4c865133 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 10:10:33 +0000 Subject: [PATCH 32/55] chore(deps): update all dependencies (#146) --- video/live-stream/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index af492486a662..5741a21f29a1 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.51.1 -google-cloud-video-live-stream==1.2.1 +grpcio==1.51.3 +google-cloud-video-live-stream==1.3.0 From 99a26997745d1b82fc5e6bbe13f3daa55bd2114f Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 4 Mar 2023 11:32:10 +0000 Subject: [PATCH 33/55] chore(deps): update dependency pytest to v7.2.2 (#149) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index dd3c7330bb99..b705adb655e6 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.2.1 \ No newline at end of file +pytest==7.2.2 \ No newline at end of file From 384958caac06ab6799b946a9c02796c663c51182 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 6 Apr 2023 17:11:05 +0100 Subject: [PATCH 34/55] chore(deps): update all dependencies (#155) --- video/live-stream/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 5741a21f29a1..f66b06ca7684 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.51.3 -google-cloud-video-live-stream==1.3.0 +grpcio==1.53.0 +google-cloud-video-live-stream==1.4.0 From 2c46002aef6ffdf0e9693ca36cfc74677e9da7b2 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 15 Apr 2023 15:01:03 +0100 Subject: [PATCH 35/55] chore(deps): update dependency pytest to v7.3.0 (#156) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index b705adb655e6..437b2a0342e6 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.2.2 \ No newline at end of file +pytest==7.3.0 \ No newline at end of file From fd8ff02fa5ec8be248440066534fb39c8555efeb Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 17 Apr 2023 22:03:19 +0100 Subject: [PATCH 36/55] chore(deps): update dependency pytest to v7.3.1 (#157) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index 437b2a0342e6..a6510db8d39a 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.3.0 \ No newline at end of file +pytest==7.3.1 \ No newline at end of file From b55bfb5c6f1b96ce51caaea8eba08b18236fe9af Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 18 Apr 2023 17:58:31 +0200 Subject: [PATCH 37/55] chore(deps): update dependency grpcio to v1.54.0 (#158) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index f66b06ca7684..0f6077710f28 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.53.0 +grpcio==1.54.0 google-cloud-video-live-stream==1.4.0 From 534330cbbc7d5e7037eb50538efdc657b31354d1 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 16 May 2023 11:55:57 +0200 Subject: [PATCH 38/55] chore(deps): update dependency grpcio to v1.54.2 (#159) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 0f6077710f28..21202c705a7d 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.54.0 +grpcio==1.54.2 google-cloud-video-live-stream==1.4.0 From 589a8e5ed07224e77562c8160f7df72ebcf96e91 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 12 Jun 2023 23:02:02 +0200 Subject: [PATCH 39/55] chore(deps): update dependency pytest to v7.3.2 (#163) --- video/live-stream/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index a6510db8d39a..28706bebc1f8 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.3.1 \ No newline at end of file +pytest==7.3.2 \ No newline at end of file From c49577c58143f8b91caeae5b4d82fee87a0c674e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 5 Jul 2023 17:23:03 +0200 Subject: [PATCH 40/55] chore(deps): update all dependencies (#164) Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements-test.txt | 2 +- video/live-stream/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/video/live-stream/requirements-test.txt b/video/live-stream/requirements-test.txt index 28706bebc1f8..6950eb5a7b6a 100644 --- a/video/live-stream/requirements-test.txt +++ b/video/live-stream/requirements-test.txt @@ -1 +1 @@ -pytest==7.3.2 \ No newline at end of file +pytest==7.4.0 \ No newline at end of file diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 21202c705a7d..516f95b4b57f 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.54.2 +grpcio==1.56.0 google-cloud-video-live-stream==1.4.0 From 454667d7f51c861215c86e1b17f0b26b0f89421d Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 5 Jul 2023 21:25:21 +0200 Subject: [PATCH 41/55] chore(deps): update dependency google-cloud-video-live-stream to v1.4.1 (#169) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 516f95b4b57f..cfaf3ed5be79 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.56.0 -google-cloud-video-live-stream==1.4.0 +google-cloud-video-live-stream==1.4.1 From 709cae24bd491aa09821435de49173df31ba8289 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 22 Jul 2023 13:13:42 +0200 Subject: [PATCH 42/55] chore(deps): update dependency grpcio to v1.56.2 (#173) Co-authored-by: Anthonios Partheniou --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index cfaf3ed5be79..569c0f17543a 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.56.0 +grpcio==1.56.2 google-cloud-video-live-stream==1.4.1 From 903b4f12645865034b66c433530b6627b5e27eb4 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 9 Aug 2023 18:26:27 +0200 Subject: [PATCH 43/55] chore(deps): update dependency google-cloud-video-live-stream to v1.5.0 (#179) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 569c0f17543a..e58016e8f651 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.56.2 -google-cloud-video-live-stream==1.4.1 +google-cloud-video-live-stream==1.5.0 From 5f2a4b8be3c9d71fc7bbb8659e8da69877086a3b Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 10 Aug 2023 22:19:17 +0200 Subject: [PATCH 44/55] chore(deps): update dependency grpcio to v1.57.0 (#181) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index e58016e8f651..aee9a2b6364d 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ -grpcio==1.56.2 +grpcio==1.57.0 google-cloud-video-live-stream==1.5.0 From 588147fa09b7ad1ffe0e58533f6ba2c03cb66f25 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 11 Aug 2023 13:51:13 -0700 Subject: [PATCH 45/55] docs(samples): add samples and tests for pools and assets (#180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(samples): add samples and tests for pools and assets * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- video/live-stream/asset_test.py | 64 +++++++++++++ video/live-stream/channel_event_test.py | 30 ++----- video/live-stream/channel_test.py | 24 +++-- video/live-stream/create_asset.py | 86 ++++++++++++++++++ video/live-stream/create_channel.py | 2 +- video/live-stream/create_channel_event.py | 2 +- .../create_channel_with_backup_input.py | 2 +- video/live-stream/create_input.py | 4 +- video/live-stream/delete_asset.py | 69 ++++++++++++++ video/live-stream/delete_channel.py | 7 +- video/live-stream/delete_channel_event.py | 4 +- video/live-stream/delete_input.py | 7 +- video/live-stream/get_asset.py | 70 +++++++++++++++ video/live-stream/get_channel.py | 5 +- video/live-stream/get_channel_event.py | 3 +- video/live-stream/get_input.py | 5 +- video/live-stream/get_pool.py | 68 ++++++++++++++ video/live-stream/input_test.py | 19 ++-- video/live-stream/list_assets.py | 66 ++++++++++++++ video/live-stream/list_channel_events.py | 5 +- video/live-stream/list_channels.py | 3 +- video/live-stream/list_inputs.py | 3 +- video/live-stream/pool_test.py | 41 +++++++++ video/live-stream/start_channel.py | 9 +- video/live-stream/stop_channel.py | 9 +- video/live-stream/update_channel.py | 2 +- video/live-stream/update_input.py | 4 +- video/live-stream/update_pool.py | 90 +++++++++++++++++++ 28 files changed, 635 insertions(+), 68 deletions(-) create mode 100644 video/live-stream/asset_test.py create mode 100644 video/live-stream/create_asset.py create mode 100644 video/live-stream/delete_asset.py create mode 100644 video/live-stream/get_asset.py create mode 100644 video/live-stream/get_pool.py create mode 100644 video/live-stream/list_assets.py create mode 100644 video/live-stream/pool_test.py create mode 100644 video/live-stream/update_pool.py diff --git a/video/live-stream/asset_test.py b/video/live-stream/asset_test.py new file mode 100644 index 000000000000..df6d1d4881c3 --- /dev/null +++ b/video/live-stream/asset_test.py @@ -0,0 +1,64 @@ +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import uuid + +from google.api_core.exceptions import FailedPrecondition, NotFound +from google.protobuf import empty_pb2 as empty +import pytest + +import create_asset +import delete_asset +import get_asset +import list_assets +import utils + +project_name = os.environ["GOOGLE_CLOUD_PROJECT"] +location = "us-central1" +asset_id = f"my-python-test-asset-{uuid.uuid4()}" +asset_uri = "gs://cloud-samples-data/media/ForBiggerEscapes.mp4" + + +def test_asset_operations(capsys: pytest.fixture) -> None: + # Clean up old resources in the test project + responses = list_assets.list_assets(project_name, location) + for response in responses: + next_asset_id = response.name.rsplit("/", 1)[-1] + if utils.is_resource_stale(response.create_time): + try: + delete_asset.delete_asset(project_name, location, next_asset_id) + except FailedPrecondition as e: + print(f"Ignoring FailedPrecondition, details: {e}") + except NotFound as e: + print(f"Ignoring NotFound, details: {e}") + + asset_name_project_id = ( + f"projects/{project_name}/locations/{location}/assets/{asset_id}" + ) + + # Tests + + response = create_asset.create_asset(project_name, location, asset_id, asset_uri) + assert asset_name_project_id in response.name + + list_assets.list_assets(project_name, location) + out, _ = capsys.readouterr() + assert asset_name_project_id in out + + response = get_asset.get_asset(project_name, location, asset_id) + assert asset_name_project_id in response.name + + response = delete_asset.delete_asset(project_name, location, asset_id) + assert response == empty.Empty() diff --git a/video/live-stream/channel_event_test.py b/video/live-stream/channel_event_test.py index c90868a612bc..bb44c9e39202 100644 --- a/video/live-stream/channel_event_test.py +++ b/video/live-stream/channel_event_test.py @@ -41,9 +41,6 @@ def test_channel_event_operations(capsys: pytest.fixture) -> None: # Set up - channel_name_project_id = ( - f"projects/{project_name}/locations/{location}/channels/{channel_id}" - ) event_name_project_id = f"projects/{project_name}/locations/{location}/channels/{channel_id}/events/{event_id}" create_input.create_input(project_name, location, input_id) @@ -51,43 +48,32 @@ def test_channel_event_operations(capsys: pytest.fixture) -> None: create_channel.create_channel( project_name, location, channel_id, input_id, output_uri ) - out, _ = capsys.readouterr() - assert channel_name_project_id in out start_channel.start_channel(project_name, location, channel_id) - out, _ = capsys.readouterr() - assert "Started channel" in out # Tests - create_channel_event.create_channel_event( + response = create_channel_event.create_channel_event( project_name, location, channel_id, event_id ) - out, _ = capsys.readouterr() - assert event_name_project_id in out + assert event_name_project_id in response.name - get_channel_event.get_channel_event(project_name, location, channel_id, event_id) - out, _ = capsys.readouterr() - assert event_name_project_id in out + response = get_channel_event.get_channel_event( + project_name, location, channel_id, event_id + ) + assert event_name_project_id in response.name list_channel_events.list_channel_events(project_name, location, channel_id) out, _ = capsys.readouterr() assert event_name_project_id in out - delete_channel_event.delete_channel_event( + response = delete_channel_event.delete_channel_event( project_name, location, channel_id, event_id ) - out, _ = capsys.readouterr() - assert "Deleted channel event" in out + assert response is None # Clean up stop_channel.stop_channel(project_name, location, channel_id) - out, _ = capsys.readouterr() - assert "Stopped channel" in out - delete_channel.delete_channel(project_name, location, channel_id) - out, _ = capsys.readouterr() - assert "Deleted channel" in out - delete_input.delete_input(project_name, location, input_id) diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py index 1b4ac7856b7c..99416ce9cf71 100644 --- a/video/live-stream/channel_test.py +++ b/video/live-stream/channel_test.py @@ -16,6 +16,7 @@ import uuid from google.api_core.exceptions import FailedPrecondition, NotFound +from google.protobuf import empty_pb2 as empty import pytest import create_channel @@ -101,11 +102,10 @@ def test_channel_operations(capsys: pytest.fixture) -> None: # Tests - create_channel.create_channel( + response = create_channel.create_channel( project_name, location, channel_id, input_id, output_uri ) - out, _ = capsys.readouterr() - assert channel_name_project_id in out + assert channel_name_project_id in response.name list_channels.list_channels(project_name, location) out, _ = capsys.readouterr() @@ -114,14 +114,12 @@ def test_channel_operations(capsys: pytest.fixture) -> None: response = update_channel.update_channel( project_name, location, channel_id, updated_input_id ) - out, _ = capsys.readouterr() - assert channel_name_project_id in out + assert channel_name_project_id in response.name for input_attachment in response.input_attachments: assert "updated-input" in input_attachment.key - get_channel.get_channel(project_name, location, channel_id) - out, _ = capsys.readouterr() - assert channel_name_project_id in out + response = get_channel.get_channel(project_name, location, channel_id) + assert channel_name_project_id in response.name start_channel.start_channel(project_name, location, channel_id) out, _ = capsys.readouterr() @@ -131,15 +129,13 @@ def test_channel_operations(capsys: pytest.fixture) -> None: out, _ = capsys.readouterr() assert "Stopped channel" in out - delete_channel.delete_channel(project_name, location, channel_id) - out, _ = capsys.readouterr() - assert "Deleted channel" in out + response = delete_channel.delete_channel(project_name, location, channel_id) + assert response == empty.Empty() - create_channel_with_backup_input.create_channel_with_backup_input( + response = create_channel_with_backup_input.create_channel_with_backup_input( project_name, location, channel_id, input_id, updated_input_id, output_uri ) - out, _ = capsys.readouterr() - assert channel_name_project_id in out + assert channel_name_project_id in response.name # Clean up diff --git a/video/live-stream/create_asset.py b/video/live-stream/create_asset.py new file mode 100644 index 000000000000..b76e1f52c307 --- /dev/null +++ b/video/live-stream/create_asset.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for creating an asset. You use an + asset to create a slate. +Example usage: + python create_asset.py --project_id --location \ + --asset_id --asset_uri +""" + +# [START livestream_create_asset] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def create_asset( + project_id: str, location: str, asset_id: str, asset_uri: str +) -> live_stream_v1.types.Asset: + """Creates an asset. + Args: + project_id: The GCP project ID. + location: The location in which to create the asset. + asset_id: The user-defined asset ID. + asset_uri: The asset URI (e.g., 'gs://my-bucket/my-video.mp4').""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + + asset = live_stream_v1.types.Asset( + video=live_stream_v1.types.Asset.VideoAsset( + uri=asset_uri, + ) + ) + operation = client.create_asset(parent=parent, asset=asset, asset_id=asset_id) + response = operation.result(600) + print(f"Asset: {response.name}") + + return response + + +# [END livestream_create_asset] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location in which to create the asset.", + default="us-central1", + ) + parser.add_argument( + "--asset_id", + help="The user-defined asset ID.", + required=True, + ) + parser.add_argument( + "--asset_uri", + help="The asset URI (e.g., 'gs://my-bucket/my-video.mp4').", + required=True, + ) + args = parser.parse_args() + create_asset( + args.project_id, + args.location, + args.asset_id, + args.asset_uri, + ) diff --git a/video/live-stream/create_channel.py b/video/live-stream/create_channel.py index 5bb2326ebfb9..41ccab51407b 100644 --- a/video/live-stream/create_channel.py +++ b/video/live-stream/create_channel.py @@ -34,7 +34,7 @@ def create_channel( project_id: str, location: str, channel_id: str, input_id: str, output_uri: str -) -> str: +) -> live_stream_v1.types.Channel: """Creates a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/create_channel_event.py b/video/live-stream/create_channel_event.py index 1096e1d5bccd..c4ac5c1a3bd7 100644 --- a/video/live-stream/create_channel_event.py +++ b/video/live-stream/create_channel_event.py @@ -35,7 +35,7 @@ def create_channel_event( project_id: str, location: str, channel_id: str, event_id: str -) -> str: +) -> live_stream_v1.types.Event: """Creates a channel event. Args: project_id: The GCP project ID. diff --git a/video/live-stream/create_channel_with_backup_input.py b/video/live-stream/create_channel_with_backup_input.py index 5e49b7a88843..0fda7a75f12c 100644 --- a/video/live-stream/create_channel_with_backup_input.py +++ b/video/live-stream/create_channel_with_backup_input.py @@ -42,7 +42,7 @@ def create_channel_with_backup_input( primary_input_id: str, backup_input_id: str, output_uri: str, -) -> str: +) -> live_stream_v1.types.Channel: """Creates a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/create_input.py b/video/live-stream/create_input.py index 45f5a508e156..4481ce52c0c6 100644 --- a/video/live-stream/create_input.py +++ b/video/live-stream/create_input.py @@ -30,7 +30,9 @@ ) -def create_input(project_id: str, location: str, input_id: str) -> str: +def create_input( + project_id: str, location: str, input_id: str +) -> live_stream_v1.types.Input: """Creates an input. Args: project_id: The GCP project ID. diff --git a/video/live-stream/delete_asset.py b/video/live-stream/delete_asset.py new file mode 100644 index 000000000000..c5c9c19b5990 --- /dev/null +++ b/video/live-stream/delete_asset.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for deleting an asset. +Example usage: + python delete_asset.py --project_id --location --asset_id +""" + +# [START livestream_delete_asset] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import empty_pb2 as empty + + +def delete_asset(project_id: str, location: str, asset_id: str) -> empty.Empty: + """Deletes an asset. + Args: + project_id: The GCP project ID. + location: The location of the asset. + asset_id: The user-defined asset ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/assets/{asset_id}" + operation = client.delete_asset(name=name) + response = operation.result(600) + print("Deleted asset") + + return response + + +# [END livestream_delete_asset] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the asset.", + required=True, + ) + parser.add_argument( + "--asset_id", + help="The user-defined asset ID.", + required=True, + ) + args = parser.parse_args() + delete_asset( + args.project_id, + args.location, + args.asset_id, + ) diff --git a/video/live-stream/delete_channel.py b/video/live-stream/delete_channel.py index b7bd485358c6..a7ae03f6e509 100644 --- a/video/live-stream/delete_channel.py +++ b/video/live-stream/delete_channel.py @@ -26,9 +26,10 @@ from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) +from google.protobuf import empty_pb2 as empty -def delete_channel(project_id: str, location: str, channel_id: str) -> None: +def delete_channel(project_id: str, location: str, channel_id: str) -> empty.Empty: """Deletes a channel. Args: project_id: The GCP project ID. @@ -39,9 +40,11 @@ def delete_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.delete_channel(name=name) - operation.result(600) + response = operation.result(600) print("Deleted channel") + return response + # [END livestream_delete_channel] diff --git a/video/live-stream/delete_channel_event.py b/video/live-stream/delete_channel_event.py index 649f65c031fa..040f712b7d7f 100644 --- a/video/live-stream/delete_channel_event.py +++ b/video/live-stream/delete_channel_event.py @@ -42,9 +42,11 @@ def delete_channel_event( client = LivestreamServiceClient() name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}" - client.delete_event(name=name) + response = client.delete_event(name=name) print("Deleted channel event") + return response + # [END livestream_delete_channel_event] diff --git a/video/live-stream/delete_input.py b/video/live-stream/delete_input.py index fe74a6438d83..0278082afe4d 100644 --- a/video/live-stream/delete_input.py +++ b/video/live-stream/delete_input.py @@ -26,9 +26,10 @@ from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) +from google.protobuf import empty_pb2 as empty -def delete_input(project_id: str, location: str, input_id: str) -> None: +def delete_input(project_id: str, location: str, input_id: str) -> empty.Empty: """Deletes an input. Args: project_id: The GCP project ID. @@ -39,9 +40,11 @@ def delete_input(project_id: str, location: str, input_id: str) -> None: name = f"projects/{project_id}/locations/{location}/inputs/{input_id}" operation = client.delete_input(name=name) - operation.result(600) + response = operation.result(600) print("Deleted input") + return response + # [END livestream_delete_input] diff --git a/video/live-stream/get_asset.py b/video/live-stream/get_asset.py new file mode 100644 index 000000000000..66d9b25d367b --- /dev/null +++ b/video/live-stream/get_asset.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for getting an asset. +Example usage: + python get_asset.py --project_id --location --asset_id +""" + +# [START livestream_get_asset] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def get_asset( + project_id: str, location: str, asset_id: str +) -> live_stream_v1.types.Asset: + """Gets an asset. + Args: + project_id: The GCP project ID. + location: The location of the asset. + asset_id: The user-defined asset ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/assets/{asset_id}" + response = client.get_asset(name=name) + print(f"Asset: {response.name}") + + return response + + +# [END livestream_get_asset] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the asset.", + required=True, + ) + parser.add_argument( + "--asset_id", + help="The user-defined asset ID.", + required=True, + ) + args = parser.parse_args() + get_asset( + args.project_id, + args.location, + args.asset_id, + ) diff --git a/video/live-stream/get_channel.py b/video/live-stream/get_channel.py index 47df66d10772..bf9a39f650b9 100644 --- a/video/live-stream/get_channel.py +++ b/video/live-stream/get_channel.py @@ -23,12 +23,15 @@ import argparse +from google.cloud.video import live_stream_v1 from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) -def get_channel(project_id: str, location: str, channel_id: str) -> str: +def get_channel( + project_id: str, location: str, channel_id: str +) -> live_stream_v1.types.Channel: """Gets a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/get_channel_event.py b/video/live-stream/get_channel_event.py index 9a70563e58c4..59adc03ebcae 100644 --- a/video/live-stream/get_channel_event.py +++ b/video/live-stream/get_channel_event.py @@ -24,6 +24,7 @@ import argparse +from google.cloud.video import live_stream_v1 from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) @@ -31,7 +32,7 @@ def get_channel_event( project_id: str, location: str, channel_id: str, event_id: str -) -> str: +) -> live_stream_v1.types.Event: """Gets a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/get_input.py b/video/live-stream/get_input.py index d840cb4e79be..21cdbbbdd56d 100644 --- a/video/live-stream/get_input.py +++ b/video/live-stream/get_input.py @@ -23,12 +23,15 @@ import argparse +from google.cloud.video import live_stream_v1 from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) -def get_input(project_id: str, location: str, input_id: str) -> str: +def get_input( + project_id: str, location: str, input_id: str +) -> live_stream_v1.types.Input: """Gets an input. Args: project_id: The GCP project ID. diff --git a/video/live-stream/get_pool.py b/video/live-stream/get_pool.py new file mode 100644 index 000000000000..db56c1181759 --- /dev/null +++ b/video/live-stream/get_pool.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for getting a pool. +Example usage: + python get_pool.py --project_id --location --pool_id +""" + +# [START livestream_get_pool] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) + + +def get_pool(project_id: str, location: str, pool_id: str) -> live_stream_v1.types.Pool: + """Gets a pool. + Args: + project_id: The GCP project ID. + location: The location of the pool. + pool_id: The user-defined pool ID.""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/pools/{pool_id}" + response = client.get_pool(name=name) + print(f"Pool: {response.name}") + + return response + + +# [END livestream_get_pool] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the pool.", + required=True, + ) + parser.add_argument( + "--pool_id", + help="The user-defined pool ID.", + required=True, + ) + args = parser.parse_args() + get_pool( + args.project_id, + args.location, + args.pool_id, + ) diff --git a/video/live-stream/input_test.py b/video/live-stream/input_test.py index a0224b4f4d56..63f7b02ec836 100644 --- a/video/live-stream/input_test.py +++ b/video/live-stream/input_test.py @@ -16,6 +16,7 @@ import uuid from google.api_core.exceptions import FailedPrecondition, NotFound +from google.protobuf import empty_pb2 as empty import pytest import create_input @@ -49,23 +50,19 @@ def test_input_operations(capsys: pytest.fixture) -> None: # Tests - create_input.create_input(project_name, location, input_id) - out, _ = capsys.readouterr() - assert input_name_project_id in out + response = create_input.create_input(project_name, location, input_id) + assert input_name_project_id in response.name list_inputs.list_inputs(project_name, location) out, _ = capsys.readouterr() assert input_name_project_id in out response = update_input.update_input(project_name, location, input_id) - out, _ = capsys.readouterr() - assert input_name_project_id in out + assert input_name_project_id in response.name assert response.preprocessing_config.crop.top_pixels == 5 - get_input.get_input(project_name, location, input_id) - out, _ = capsys.readouterr() - assert input_name_project_id in out + response = get_input.get_input(project_name, location, input_id) + assert input_name_project_id in response.name - delete_input.delete_input(project_name, location, input_id) - out, _ = capsys.readouterr() - assert "Deleted input" in out + response = delete_input.delete_input(project_name, location, input_id) + assert response == empty.Empty() diff --git a/video/live-stream/list_assets.py b/video/live-stream/list_assets.py new file mode 100644 index 000000000000..7136cab5822c --- /dev/null +++ b/video/live-stream/list_assets.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for listing all assets in a location. +Example usage: + python list_assets.py --project_id --location +""" + +# [START livestream_list_assets] + +import argparse + +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, + pagers, +) + + +def list_assets(project_id: str, location: str) -> pagers.ListAssetsPager: + """Lists all assets in a location. + Args: + project_id: The GCP project ID. + location: The location of the assets.""" + + client = LivestreamServiceClient() + + parent = f"projects/{project_id}/locations/{location}" + page_result = client.list_assets(parent=parent) + print("Assets:") + + responses = [] + for response in page_result: + print(response.name) + responses.append(response) + + return responses + + +# [END livestream_list_assets] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the assets.", + required=True, + ) + args = parser.parse_args() + list_assets( + args.project_id, + args.location, + ) diff --git a/video/live-stream/list_channel_events.py b/video/live-stream/list_channel_events.py index 54d60b9dbe5c..ab3cfc961dcc 100644 --- a/video/live-stream/list_channel_events.py +++ b/video/live-stream/list_channel_events.py @@ -25,10 +25,13 @@ from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, + pagers, ) -def list_channel_events(project_id: str, location: str, channel_id: str) -> list: +def list_channel_events( + project_id: str, location: str, channel_id: str +) -> pagers.ListEventsPager: """Lists all events for a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/list_channels.py b/video/live-stream/list_channels.py index 009f5676d6c5..731c04eda181 100644 --- a/video/live-stream/list_channels.py +++ b/video/live-stream/list_channels.py @@ -25,10 +25,11 @@ from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, + pagers, ) -def list_channels(project_id: str, location: str) -> list: +def list_channels(project_id: str, location: str) -> pagers.ListChannelsPager: """Lists all channels in a location. Args: project_id: The GCP project ID. diff --git a/video/live-stream/list_inputs.py b/video/live-stream/list_inputs.py index d04e3ba21527..e273d7eccc60 100644 --- a/video/live-stream/list_inputs.py +++ b/video/live-stream/list_inputs.py @@ -25,10 +25,11 @@ from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, + pagers, ) -def list_inputs(project_id: str, location: str) -> list: +def list_inputs(project_id: str, location: str) -> pagers.ListInputsPager: """Lists all inputs in a location. Args: project_id: The GCP project ID. diff --git a/video/live-stream/pool_test.py b/video/live-stream/pool_test.py new file mode 100644 index 000000000000..315c327f0201 --- /dev/null +++ b/video/live-stream/pool_test.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import pytest + +import get_pool + +# import update_pool + +project_name = os.environ["GOOGLE_CLOUD_PROJECT"] +location = "us-central1" +pool_id = "default" # only 1 pool supported per location +peered_network = "" + + +def test_pool_operations(capsys: pytest.fixture) -> None: + pool_name_project_id = ( + f"projects/{project_name}/locations/{location}/pools/{pool_id}" + ) + + # All channels must be stopped to update the pool. Pool operations take a + # long time to complete, so don't run this test on the test network. + # response = update_pool.update_pool(project_name, location, pool_id, peered_network) + # assert pool_name_project_id in response.name + # assert response.network_config.peered_network == peered_network + + response = get_pool.get_pool(project_name, location, pool_id) + assert pool_name_project_id in response.name diff --git a/video/live-stream/start_channel.py b/video/live-stream/start_channel.py index 9e05aaa3abba..8bb9204ee98e 100644 --- a/video/live-stream/start_channel.py +++ b/video/live-stream/start_channel.py @@ -23,12 +23,15 @@ import argparse +from google.cloud.video import live_stream_v1 from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) -def start_channel(project_id: str, location: str, channel_id: str) -> None: +def start_channel( + project_id: str, location: str, channel_id: str +) -> live_stream_v1.types.ChannelOperationResponse: """Starts a channel. Args: project_id: The GCP project ID. @@ -39,9 +42,11 @@ def start_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.start_channel(name=name) - operation.result(900) + response = operation.result(900) print("Started channel") + return response + # [END livestream_start_channel] diff --git a/video/live-stream/stop_channel.py b/video/live-stream/stop_channel.py index 6440a8d7a972..c7ccff2ae8bb 100644 --- a/video/live-stream/stop_channel.py +++ b/video/live-stream/stop_channel.py @@ -23,12 +23,15 @@ import argparse +from google.cloud.video import live_stream_v1 from google.cloud.video.live_stream_v1.services.livestream_service import ( LivestreamServiceClient, ) -def stop_channel(project_id: str, location: str, channel_id: str) -> None: +def stop_channel( + project_id: str, location: str, channel_id: str +) -> live_stream_v1.types.ChannelOperationResponse: """Stops a channel. Args: project_id: The GCP project ID. @@ -39,9 +42,11 @@ def stop_channel(project_id: str, location: str, channel_id: str) -> None: name = f"projects/{project_id}/locations/{location}/channels/{channel_id}" operation = client.stop_channel(name=name) - operation.result(600) + response = operation.result(600) print("Stopped channel") + return response + # [END livestream_stop_channel] diff --git a/video/live-stream/update_channel.py b/video/live-stream/update_channel.py index 9bd25deb0cda..b1179433cc18 100644 --- a/video/live-stream/update_channel.py +++ b/video/live-stream/update_channel.py @@ -33,7 +33,7 @@ def update_channel( project_id: str, location: str, channel_id: str, input_id: str -) -> str: +) -> live_stream_v1.types.Channel: """Updates a channel. Args: project_id: The GCP project ID. diff --git a/video/live-stream/update_input.py b/video/live-stream/update_input.py index 64f2dfb19287..04236b0d797a 100644 --- a/video/live-stream/update_input.py +++ b/video/live-stream/update_input.py @@ -31,7 +31,9 @@ from google.protobuf import field_mask_pb2 as field_mask -def update_input(project_id: str, location: str, input_id: str) -> str: +def update_input( + project_id: str, location: str, input_id: str +) -> live_stream_v1.types.Input: """Updates an input. Args: project_id: The GCP project ID. diff --git a/video/live-stream/update_pool.py b/video/live-stream/update_pool.py new file mode 100644 index 000000000000..26d0839520d6 --- /dev/null +++ b/video/live-stream/update_pool.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud Live Stream sample for updating a pool's peered network. +Example usage: + python update_pool.py --project_id --location \ + --pool_id --peered_network +""" + +# [START livestream_update_pool] + +import argparse + +from google.cloud.video import live_stream_v1 +from google.cloud.video.live_stream_v1.services.livestream_service import ( + LivestreamServiceClient, +) +from google.protobuf import field_mask_pb2 as field_mask + + +def update_pool( + project_id: str, location: str, pool_id: str, peered_network: str +) -> live_stream_v1.types.Pool: + """Updates an pool. + Args: + project_id: The GCP project ID. + location: The location of the pool. + pool_id: The user-defined pool ID. + peered_network: The updated peer network (e.g., + 'projects/my-network-project-number/global/networks/my-network-name').""" + + client = LivestreamServiceClient() + + name = f"projects/{project_id}/locations/{location}/pools/{pool_id}" + + pool = live_stream_v1.types.Pool( + name=name, + network_config=live_stream_v1.types.Pool.NetworkConfig( + peered_network=peered_network, + ), + ) + update_mask = field_mask.FieldMask(paths=["network_config"]) + + operation = client.update_pool(pool=pool, update_mask=update_mask) + response = operation.result() + print(f"Updated pool: {response.name}") + + return response + + +# [END livestream_update_pool] + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) + parser.add_argument( + "--location", + help="The location of the pool.", + required=True, + ) + parser.add_argument( + "--pool_id", + help="The user-defined pool ID.", + required=True, + ) + parser.add_argument( + "--peered_network", + help="The updated peer network.", + required=True, + ) + args = parser.parse_args() + update_pool( + args.project_id, + args.location, + args.pool_id, + args.peered_network, + ) From fd63d971a5b685033a66aff50d6799f1c62358bd Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 16 Aug 2023 20:55:08 +0200 Subject: [PATCH 46/55] chore(deps): update dependency google-cloud-video-live-stream to v1.5.1 (#183) --- video/live-stream/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index aee9a2b6364d..9f75faad35ce 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,2 @@ grpcio==1.57.0 -google-cloud-video-live-stream==1.5.0 +google-cloud-video-live-stream==1.5.1 From 1e0894a07e5278b5048f184cbfd5242c1cbb8116 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Mon, 11 Sep 2023 15:50:49 -0700 Subject: [PATCH 47/55] fix licence headers --- video/live-stream/asset_test.py | 2 +- video/live-stream/channel_event_test.py | 2 +- video/live-stream/channel_test.py | 2 +- video/live-stream/create_asset.py | 2 +- video/live-stream/create_channel.py | 2 +- video/live-stream/create_channel_event.py | 2 +- .../create_channel_with_backup_input.py | 2 +- video/live-stream/create_input.py | 2 +- video/live-stream/delete_asset.py | 2 +- video/live-stream/delete_channel.py | 2 +- video/live-stream/delete_channel_event.py | 2 +- video/live-stream/delete_input.py | 2 +- video/live-stream/get_asset.py | 2 +- video/live-stream/get_channel.py | 2 +- video/live-stream/get_channel_event.py | 2 +- video/live-stream/get_input.py | 2 +- video/live-stream/get_pool.py | 2 +- video/live-stream/input_test.py | 2 +- video/live-stream/list_assets.py | 2 +- video/live-stream/list_channel_events.py | 2 +- video/live-stream/list_channels.py | 2 +- video/live-stream/list_inputs.py | 2 +- video/live-stream/pool_test.py | 2 +- video/live-stream/start_channel.py | 2 +- video/live-stream/stop_channel.py | 2 +- video/live-stream/update_channel.py | 2 +- video/live-stream/update_input.py | 2 +- video/live-stream/update_pool.py | 2 +- video/live-stream/utils.py | 14 ++++++++++++++ 29 files changed, 42 insertions(+), 28 deletions(-) diff --git a/video/live-stream/asset_test.py b/video/live-stream/asset_test.py index df6d1d4881c3..857d08fc69ee 100644 --- a/video/live-stream/asset_test.py +++ b/video/live-stream/asset_test.py @@ -1,4 +1,4 @@ -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/channel_event_test.py b/video/live-stream/channel_event_test.py index bb44c9e39202..41c793302425 100644 --- a/video/live-stream/channel_event_test.py +++ b/video/live-stream/channel_event_test.py @@ -1,4 +1,4 @@ -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py index 99416ce9cf71..47790b96db57 100644 --- a/video/live-stream/channel_test.py +++ b/video/live-stream/channel_test.py @@ -1,4 +1,4 @@ -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/create_asset.py b/video/live-stream/create_asset.py index b76e1f52c307..f282eef3f5b8 100644 --- a/video/live-stream/create_asset.py +++ b/video/live-stream/create_asset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/create_channel.py b/video/live-stream/create_channel.py index 41ccab51407b..20c3c3a3e94b 100644 --- a/video/live-stream/create_channel.py +++ b/video/live-stream/create_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/create_channel_event.py b/video/live-stream/create_channel_event.py index c4ac5c1a3bd7..a1cc885f1648 100644 --- a/video/live-stream/create_channel_event.py +++ b/video/live-stream/create_channel_event.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/create_channel_with_backup_input.py b/video/live-stream/create_channel_with_backup_input.py index 0fda7a75f12c..79256385be6d 100644 --- a/video/live-stream/create_channel_with_backup_input.py +++ b/video/live-stream/create_channel_with_backup_input.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/create_input.py b/video/live-stream/create_input.py index 4481ce52c0c6..31d0b9ac33ab 100644 --- a/video/live-stream/create_input.py +++ b/video/live-stream/create_input.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/delete_asset.py b/video/live-stream/delete_asset.py index c5c9c19b5990..1215756bd6a4 100644 --- a/video/live-stream/delete_asset.py +++ b/video/live-stream/delete_asset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/delete_channel.py b/video/live-stream/delete_channel.py index a7ae03f6e509..3f608b241783 100644 --- a/video/live-stream/delete_channel.py +++ b/video/live-stream/delete_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/delete_channel_event.py b/video/live-stream/delete_channel_event.py index 040f712b7d7f..f8f920480318 100644 --- a/video/live-stream/delete_channel_event.py +++ b/video/live-stream/delete_channel_event.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/delete_input.py b/video/live-stream/delete_input.py index 0278082afe4d..c2751196c842 100644 --- a/video/live-stream/delete_input.py +++ b/video/live-stream/delete_input.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/get_asset.py b/video/live-stream/get_asset.py index 66d9b25d367b..a2606eb238eb 100644 --- a/video/live-stream/get_asset.py +++ b/video/live-stream/get_asset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/get_channel.py b/video/live-stream/get_channel.py index bf9a39f650b9..03ee0d19188f 100644 --- a/video/live-stream/get_channel.py +++ b/video/live-stream/get_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/get_channel_event.py b/video/live-stream/get_channel_event.py index 59adc03ebcae..81d01844dd1b 100644 --- a/video/live-stream/get_channel_event.py +++ b/video/live-stream/get_channel_event.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/get_input.py b/video/live-stream/get_input.py index 21cdbbbdd56d..bc4e2d4b468c 100644 --- a/video/live-stream/get_input.py +++ b/video/live-stream/get_input.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/get_pool.py b/video/live-stream/get_pool.py index db56c1181759..8b48e7c1302f 100644 --- a/video/live-stream/get_pool.py +++ b/video/live-stream/get_pool.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/input_test.py b/video/live-stream/input_test.py index 63f7b02ec836..585c3dc7bfae 100644 --- a/video/live-stream/input_test.py +++ b/video/live-stream/input_test.py @@ -1,4 +1,4 @@ -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/list_assets.py b/video/live-stream/list_assets.py index 7136cab5822c..6e5bb4731c95 100644 --- a/video/live-stream/list_assets.py +++ b/video/live-stream/list_assets.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/list_channel_events.py b/video/live-stream/list_channel_events.py index ab3cfc961dcc..cd3c96d6d47f 100644 --- a/video/live-stream/list_channel_events.py +++ b/video/live-stream/list_channel_events.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/list_channels.py b/video/live-stream/list_channels.py index 731c04eda181..d31969c830eb 100644 --- a/video/live-stream/list_channels.py +++ b/video/live-stream/list_channels.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/list_inputs.py b/video/live-stream/list_inputs.py index e273d7eccc60..f72da76a2bde 100644 --- a/video/live-stream/list_inputs.py +++ b/video/live-stream/list_inputs.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/pool_test.py b/video/live-stream/pool_test.py index 315c327f0201..8b157a155034 100644 --- a/video/live-stream/pool_test.py +++ b/video/live-stream/pool_test.py @@ -1,4 +1,4 @@ -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/start_channel.py b/video/live-stream/start_channel.py index 8bb9204ee98e..afcd385b4849 100644 --- a/video/live-stream/start_channel.py +++ b/video/live-stream/start_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/stop_channel.py b/video/live-stream/stop_channel.py index c7ccff2ae8bb..41f641672aa7 100644 --- a/video/live-stream/stop_channel.py +++ b/video/live-stream/stop_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/update_channel.py b/video/live-stream/update_channel.py index b1179433cc18..6bc606005644 100644 --- a/video/live-stream/update_channel.py +++ b/video/live-stream/update_channel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/update_input.py b/video/live-stream/update_input.py index 04236b0d797a..f270d5fe5972 100644 --- a/video/live-stream/update_input.py +++ b/video/live-stream/update_input.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2022 Google Inc. All Rights Reserved. +# Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/update_pool.py b/video/live-stream/update_pool.py index 26d0839520d6..6ed9a4ce3cbd 100644 --- a/video/live-stream/update_pool.py +++ b/video/live-stream/update_pool.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2023 Google Inc. All Rights Reserved. +# Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/video/live-stream/utils.py b/video/live-stream/utils.py index e0221d9c6225..30d34f3c1612 100644 --- a/video/live-stream/utils.py +++ b/video/live-stream/utils.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from google.protobuf import timestamp_pb2 seconds_per_hour = 3600 From 05b57e27c8ec7d6a74d060164c704f165530c1b0 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Tue, 12 Sep 2023 09:12:23 -0700 Subject: [PATCH 48/55] Update video/live-stream/noxfile_config.py Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> --- video/live-stream/noxfile_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/noxfile_config.py b/video/live-stream/noxfile_config.py index 947c76615f41..e7c27af8a303 100644 --- a/video/live-stream/noxfile_config.py +++ b/video/live-stream/noxfile_config.py @@ -22,7 +22,7 @@ TEST_CONFIG_OVERRIDE = { # You can opt out from the test for specific Python versions. - "ignored_versions": [], + "ignored_versions": [2.7], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": True, From 175e262cd99d2370fd6762f86d072546b307caa4 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 10:45:11 -0700 Subject: [PATCH 49/55] update CODEOWNERS and blunderbuss.yml --- .github/CODEOWNERS | 1 + .github/blunderbuss.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 21e6bebf31dd..ae7376b958e4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -107,6 +107,7 @@ /healthcare/**/* @GoogleCloudPlatform/healthcare-life-sciences @GoogleCloudPlatform/python-samples-reviewers /retail/**/* @GoogleCloudPlatform/cloud-retail-team @GoogleCloudPlatform/python-samples-reviewers /billing/**/* @GoogleCloudPlatform/billing-samples-maintainers @GoogleCloudPlatform/python-samples-reviewers +/video/live-stream/* @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/python-samples-reviewers /video/stitcher/* @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/python-samples-reviewers # Deprecated diff --git a/.github/blunderbuss.yml b/.github/blunderbuss.yml index e694c33100c7..26c3c6efb879 100644 --- a/.github/blunderbuss.yml +++ b/.github/blunderbuss.yml @@ -307,6 +307,7 @@ assign_prs_by: - labels: - "api: cloudmedia" - "api: videostitcher" + - "api: videolivestream" to: - GoogleCloudPlatform/cloud-media-team - labels: From e8805778196e8635582e68e2fea707523caae64d Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 10:47:47 -0700 Subject: [PATCH 50/55] restrict requirements.txt by python version --- video/live-stream/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index 9f75faad35ce..a58d64466070 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,2 +1,3 @@ -grpcio==1.57.0 +grpcio==1.41.1; python_version=="2.7" +grpcio==1.57.0; python_version>"3.0" google-cloud-video-live-stream==1.5.1 From 248c234df439d67e01c0fb90f2c9161330a97279 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 10:59:42 -0700 Subject: [PATCH 51/55] skip python version 2.7 --- video/live-stream/noxfile_config.py | 2 +- video/live-stream/requirements.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/video/live-stream/noxfile_config.py b/video/live-stream/noxfile_config.py index e7c27af8a303..16f326e5c6d2 100644 --- a/video/live-stream/noxfile_config.py +++ b/video/live-stream/noxfile_config.py @@ -22,7 +22,7 @@ TEST_CONFIG_OVERRIDE = { # You can opt out from the test for specific Python versions. - "ignored_versions": [2.7], + "ignored_versions": ["2.7"], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": True, diff --git a/video/live-stream/requirements.txt b/video/live-stream/requirements.txt index a58d64466070..9f75faad35ce 100644 --- a/video/live-stream/requirements.txt +++ b/video/live-stream/requirements.txt @@ -1,3 +1,2 @@ -grpcio==1.41.1; python_version=="2.7" -grpcio==1.57.0; python_version>"3.0" +grpcio==1.57.0 google-cloud-video-live-stream==1.5.1 From b58a104d9ea17c40b92485ec806b9028bfa1178d Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 12:04:47 -0700 Subject: [PATCH 52/55] Update video/live-stream/noxfile_config.py Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- video/live-stream/noxfile_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/noxfile_config.py b/video/live-stream/noxfile_config.py index 16f326e5c6d2..7b5773a22a10 100644 --- a/video/live-stream/noxfile_config.py +++ b/video/live-stream/noxfile_config.py @@ -22,7 +22,7 @@ TEST_CONFIG_OVERRIDE = { # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], + "ignored_versions": ["2.7", "3.7", "3.9", "3.10"], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": True, From 62dca4686ab24bcebd84a4bb89ac54b32db05cfa Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 15 Sep 2023 19:07:03 +0000 Subject: [PATCH 53/55] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- video/live-stream/channel_event_test.py | 1 - video/live-stream/channel_test.py | 1 - 2 files changed, 2 deletions(-) diff --git a/video/live-stream/channel_event_test.py b/video/live-stream/channel_event_test.py index 41c793302425..ff3bc1146d1e 100644 --- a/video/live-stream/channel_event_test.py +++ b/video/live-stream/channel_event_test.py @@ -38,7 +38,6 @@ def test_channel_event_operations(capsys: pytest.fixture) -> None: - # Set up event_name_project_id = f"projects/{project_name}/locations/{location}/channels/{channel_id}/events/{event_id}" diff --git a/video/live-stream/channel_test.py b/video/live-stream/channel_test.py index 47790b96db57..8c2fbf20f9b9 100644 --- a/video/live-stream/channel_test.py +++ b/video/live-stream/channel_test.py @@ -43,7 +43,6 @@ def test_channel_operations(capsys: pytest.fixture) -> None: - # Clean up old resources in the test project channel_responses = list_channels.list_channels(project_name, location) From 0e596d52484fa561ba62ec11e434ccd9bf148c47 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 13:01:36 -0700 Subject: [PATCH 54/55] Update video/live-stream/README.md Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- video/live-stream/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/README.md b/video/live-stream/README.md index fb4f05bff3a8..a365382973e8 100644 --- a/video/live-stream/README.md +++ b/video/live-stream/README.md @@ -17,7 +17,7 @@ For more information on authentication, refer to the ## Install Dependencies -1. Clone python-video-live-stream and change directories to the sample directory +1. Clone python-docs-samples repository and change directories to the sample directory you want to use. $ git clone https://github.com/googleapis/python-video-live-stream.git From ab422eda479f127c473d801f10b6d48661dd7bbc Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Fri, 15 Sep 2023 13:01:48 -0700 Subject: [PATCH 55/55] Update video/live-stream/README.md Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- video/live-stream/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/live-stream/README.md b/video/live-stream/README.md index a365382973e8..64f68e8ef5ba 100644 --- a/video/live-stream/README.md +++ b/video/live-stream/README.md @@ -20,7 +20,7 @@ For more information on authentication, refer to the 1. Clone python-docs-samples repository and change directories to the sample directory you want to use. - $ git clone https://github.com/googleapis/python-video-live-stream.git + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git 1. Install [pip](https://pip.pypa.io/) and [virtualenv](https://virtualenv.pypa.io/) if you do not already have them. You