Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate code from googleapis/python-video-live-stream #10200

Merged
merged 55 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
077f0da
docs(samples): add code samples (#21)
irataxy Apr 28, 2022
b479bb9
chore(deps): update all dependencies (#33)
renovate-bot Apr 28, 2022
c1acfec
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot Apr 28, 2022
4b51400
ci: try to stop channel again before deleting it in the test (#36)
irataxy Apr 29, 2022
1fda5b3
docs(samples): add sample for creating a channel with a failover back…
irataxy May 3, 2022
02c8682
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot May 3, 2022
73f80ce
chore: remove dependency google-api-python-client in samples (#40)
renovate-bot May 3, 2022
0d2b02c
chore(deps): update dependency grpcio to v1.46.0 (#41)
renovate-bot May 5, 2022
5d01257
chore(deps): update dependency grpcio to v1.46.1 (#44)
renovate-bot May 12, 2022
35a6031
chore(deps): update dependency grpcio to v1.46.3 (#47)
renovate-bot May 22, 2022
bf58dbd
chore(deps): update dependency google-cloud-video-live-stream to v0.1…
renovate-bot May 25, 2022
fc76f67
docs: align channel config with best practices (#71)
irataxy Jun 28, 2022
287fff2
chore(deps): update all dependencies (#70)
renovate-bot Jul 16, 2022
c979dc8
docs(samples): fix timeout for LROs; first call can take up to 10 min…
irataxy Jul 26, 2022
d11988e
docs(samples): fix timeout for create input and start channel LROs; f…
irataxy Jul 29, 2022
49d73e7
chore(deps): update all dependencies (#87)
renovate-bot Aug 2, 2022
2803de6
chore(deps): update all dependencies to v1.0.1 (#90)
renovate-bot Aug 10, 2022
8351519
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot Aug 16, 2022
2767b94
chore(deps): update dependency grpcio to v1.48.1 (#101)
renovate-bot Sep 2, 2022
009a47a
chore(deps): update dependency pytest to v7.1.3 (#106)
renovate-bot Sep 6, 2022
4fff6e3
chore(deps): update dependency grpcio to v1.49.0 (#111)
renovate-bot Sep 16, 2022
e653cdd
chore(deps): update dependency grpcio to v1.49.1 (#112)
renovate-bot Oct 4, 2022
47bb0cc
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot Oct 4, 2022
53e0482
chore(deps): update dependency google-cloud-video-live-stream to v1.0…
renovate-bot Oct 18, 2022
58578e2
chore(deps): update dependency grpcio to v1.50.0 (#119)
renovate-bot Oct 19, 2022
b8fbb35
chore(deps): update dependency pytest to v7.2.0 (#120)
renovate-bot Oct 26, 2022
e9e0524
chore(deps): update dependency grpcio to v1.51.1 (#128)
renovate-bot Dec 15, 2022
637882b
chore(deps): update dependency google-cloud-video-live-stream to v1.1…
renovate-bot Dec 16, 2022
e099ce7
chore(deps): update dependency google-cloud-video-live-stream to v1.2…
renovate-bot Jan 10, 2023
f5f1dad
chore(deps): update dependency pytest to v7.2.1 (#136)
renovate-bot Jan 14, 2023
3199bef
chore(deps): update dependency google-cloud-video-live-stream to v1.2…
renovate-bot Jan 23, 2023
1885872
chore(deps): update all dependencies (#146)
renovate-bot Mar 1, 2023
99a2699
chore(deps): update dependency pytest to v7.2.2 (#149)
renovate-bot Mar 4, 2023
384958c
chore(deps): update all dependencies (#155)
renovate-bot Apr 6, 2023
2c46002
chore(deps): update dependency pytest to v7.3.0 (#156)
renovate-bot Apr 15, 2023
fd8ff02
chore(deps): update dependency pytest to v7.3.1 (#157)
renovate-bot Apr 17, 2023
b55bfb5
chore(deps): update dependency grpcio to v1.54.0 (#158)
renovate-bot Apr 18, 2023
534330c
chore(deps): update dependency grpcio to v1.54.2 (#159)
renovate-bot May 16, 2023
589a8e5
chore(deps): update dependency pytest to v7.3.2 (#163)
renovate-bot Jun 12, 2023
c49577c
chore(deps): update all dependencies (#164)
renovate-bot Jul 5, 2023
454667d
chore(deps): update dependency google-cloud-video-live-stream to v1.4…
renovate-bot Jul 5, 2023
709cae2
chore(deps): update dependency grpcio to v1.56.2 (#173)
renovate-bot Jul 22, 2023
903b4f1
chore(deps): update dependency google-cloud-video-live-stream to v1.5…
renovate-bot Aug 9, 2023
5f2a4b8
chore(deps): update dependency grpcio to v1.57.0 (#181)
renovate-bot Aug 10, 2023
588147f
docs(samples): add samples and tests for pools and assets (#180)
irataxy Aug 11, 2023
fd63d97
chore(deps): update dependency google-cloud-video-live-stream to v1.5…
renovate-bot Aug 16, 2023
1e0894a
fix licence headers
dizcology Sep 11, 2023
05b57e2
Update video/live-stream/noxfile_config.py
dizcology Sep 12, 2023
175e262
update CODEOWNERS and blunderbuss.yml
dizcology Sep 15, 2023
e880577
restrict requirements.txt by python version
dizcology Sep 15, 2023
248c234
skip python version 2.7
dizcology Sep 15, 2023
b58a104
Update video/live-stream/noxfile_config.py
dizcology Sep 15, 2023
62dca46
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Sep 15, 2023
0e596d5
Update video/live-stream/README.md
dizcology Sep 15, 2023
ab422ed
Update video/live-stream/README.md
dizcology Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ assign_prs_by:
- labels:
- "api: cloudmedia"
- "api: videostitcher"
- "api: videolivestream"
to:
- GoogleCloudPlatform/cloud-media-team
- labels:
Expand Down
45 changes: 45 additions & 0 deletions video/live-stream/README.md
Original file line number Diff line number Diff line change
@@ -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-docs-samples repository and change directories to the sample directory
you want to use.

$ 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
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`
64 changes: 64 additions & 0 deletions video/live-stream/asset_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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.

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()
78 changes: 78 additions & 0 deletions video/live-stream/channel_event_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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.
# 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

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
)

start_channel.start_channel(project_name, location, channel_id)

# Tests

response = create_channel_event.create_channel_event(
project_name, location, channel_id, event_id
)
assert event_name_project_id in response.name

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

response = delete_channel_event.delete_channel_event(
project_name, location, channel_id, event_id
)
assert response is None

# Clean up

stop_channel.stop_channel(project_name, location, channel_id)
delete_channel.delete_channel(project_name, location, channel_id)
delete_input.delete_input(project_name, location, input_id)
143 changes: 143 additions & 0 deletions video/live-stream/channel_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# 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.
# 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_channel
import create_channel_with_backup_input
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 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:
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

response = create_channel.create_channel(
project_name, location, channel_id, input_id, output_uri
)
assert channel_name_project_id in response.name

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
)
assert channel_name_project_id in response.name
for input_attachment in response.input_attachments:
assert "updated-input" in input_attachment.key

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()
assert "Started channel" in out

stop_channel.stop_channel(project_name, location, channel_id)
out, _ = capsys.readouterr()
assert "Stopped channel" in out

response = delete_channel.delete_channel(project_name, location, channel_id)
assert response == empty.Empty()

response = create_channel_with_backup_input.create_channel_with_backup_input(
project_name, location, channel_id, input_id, updated_input_id, output_uri
)
assert channel_name_project_id in response.name

# 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)
Loading