Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 22 additions & 33 deletions video/stitcher/cdn_key_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import uuid

from google.protobuf import empty_pb2 as empty
from google.protobuf import timestamp_pb2
import pytest

Expand Down Expand Up @@ -55,7 +56,7 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:

# Media CDN key tests

create_cdn_key.create_cdn_key(
response = create_cdn_key.create_cdn_key(
project_id,
location,
media_cdn_key_id,
Expand All @@ -64,8 +65,7 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:
media_cdn_private_key,
False,
)
out, _ = capsys.readouterr()
assert media_cdn_key_id in out
assert media_cdn_key_id in response.name

list_cdn_keys.list_cdn_keys(project_id, location)
out, _ = capsys.readouterr()
Expand All @@ -82,21 +82,18 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:
updated_media_cdn_private_key,
False,
)
out, _ = capsys.readouterr()
assert media_cdn_key_id in out
assert media_cdn_key_id in response.name
assert updated_hostname in response.hostname

get_cdn_key.get_cdn_key(project_id, location, media_cdn_key_id)
out, _ = capsys.readouterr()
assert media_cdn_key_id in out
response = get_cdn_key.get_cdn_key(project_id, location, media_cdn_key_id)
assert media_cdn_key_id in response.name

delete_cdn_key.delete_cdn_key(project_id, location, media_cdn_key_id)
out, _ = capsys.readouterr()
assert "Deleted CDN key" in out
response = delete_cdn_key.delete_cdn_key(project_id, location, media_cdn_key_id)
assert response == empty.Empty()

# Cloud CDN key tests

create_cdn_key.create_cdn_key(
response = create_cdn_key.create_cdn_key(
project_id,
location,
cloud_cdn_key_id,
Expand All @@ -105,8 +102,7 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:
cloud_cdn_private_key,
True,
)
out, _ = capsys.readouterr()
assert cloud_cdn_key_id in out
assert cloud_cdn_key_id in response.name

list_cdn_keys.list_cdn_keys(project_id, location)
out, _ = capsys.readouterr()
Expand All @@ -123,29 +119,25 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:
updated_cloud_cdn_private_key,
True,
)
out, _ = capsys.readouterr()
assert cloud_cdn_key_id in out
assert cloud_cdn_key_id in response.name
assert updated_hostname in response.hostname

get_cdn_key.get_cdn_key(project_id, location, cloud_cdn_key_id)
out, _ = capsys.readouterr()
assert cloud_cdn_key_id in out
response = get_cdn_key.get_cdn_key(project_id, location, cloud_cdn_key_id)
assert cloud_cdn_key_id in response.name

delete_cdn_key.delete_cdn_key(project_id, location, cloud_cdn_key_id)
out, _ = capsys.readouterr()
assert "Deleted CDN key" in out
response = delete_cdn_key.delete_cdn_key(project_id, location, cloud_cdn_key_id)
assert response == empty.Empty()

# Akamai CDN key tests

create_cdn_key_akamai.create_cdn_key_akamai(
response = create_cdn_key_akamai.create_cdn_key_akamai(
project_id,
location,
akamai_cdn_key_id,
hostname,
akamai_key,
)
out, _ = capsys.readouterr()
assert akamai_cdn_key_id in out
assert akamai_cdn_key_id in response.name

list_cdn_keys.list_cdn_keys(project_id, location)
out, _ = capsys.readouterr()
Expand All @@ -160,14 +152,11 @@ def test_cdn_key_operations(capsys: pytest.fixture) -> None:
updated_hostname,
updated_akamai_key,
)
out, _ = capsys.readouterr()
assert akamai_cdn_key_id in out
assert akamai_cdn_key_id in response.name
assert updated_hostname in response.hostname

get_cdn_key.get_cdn_key(project_id, location, akamai_cdn_key_id)
out, _ = capsys.readouterr()
assert akamai_cdn_key_id in out
response = get_cdn_key.get_cdn_key(project_id, location, akamai_cdn_key_id)
assert akamai_cdn_key_id in response.name

delete_cdn_key.delete_cdn_key(project_id, location, akamai_cdn_key_id)
out, _ = capsys.readouterr()
assert "Deleted CDN key" in out
response = delete_cdn_key.delete_cdn_key(project_id, location, akamai_cdn_key_id)
assert response == empty.Empty()
5 changes: 4 additions & 1 deletion video/stitcher/create_cdn_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_cdn_key(
key_name: str,
private_key: str,
is_cloud_cdn: bool,
) -> str:
) -> stitcher_v1.types.CdnKey:
"""Creates a Cloud CDN or Media CDN key.
Args:
project_id: The GCP project ID.
Expand All @@ -54,6 +54,9 @@ def create_cdn_key(
See https://cloud.google.com/video-stitcher/docs/how-to/managing-cdn-keys#create-private-key-media-cdn
for more information. For a Cloud CDN key, this is a base64-encoded string secret.
is_cloud_cdn: If true, create a Cloud CDN key. If false, create a Media CDN key.

Returns:
The CDN key resource.
"""

client = VideoStitcherServiceClient()
Expand Down
8 changes: 6 additions & 2 deletions video/stitcher/create_cdn_key_akamai.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ def create_cdn_key_akamai(
cdn_key_id: str,
hostname: str,
akamai_token_key: str,
) -> str:
) -> stitcher_v1.types.CdnKey:
"""Creates an Akamai CDN key.
Args:
project_id: The GCP project ID.
location: The location in which to create the CDN key.
cdn_key_id: The user-defined CDN key ID.
hostname: The hostname to which this CDN key applies.
akamai_token_key: A base64-encoded string token key."""
akamai_token_key: A base64-encoded string token key.

Returns:
The CDN key resource.
"""

client = VideoStitcherServiceClient()

Expand Down
6 changes: 5 additions & 1 deletion video/stitcher/create_live_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_live_config(
live_stream_uri: str,
ad_tag_uri: str,
slate_id: str,
) -> str:
) -> stitcher_v1.types.LiveConfig:
"""Creates a live config.
Args:
project_id: The GCP project ID.
Expand All @@ -49,6 +49,9 @@ def create_live_config(
manifest (.mpd) file or an M3U playlist manifest (.m3u8) file.
ad_tag_uri: Uri of the ad tag.
slate_id: The user-defined slate ID of the default slate to use when no slates are specified in an ad break's message.

Returns:
The live config resource.
"""

client = VideoStitcherServiceClient()
Expand All @@ -60,6 +63,7 @@ def create_live_config(
source_uri=live_stream_uri,
ad_tag_uri=ad_tag_uri,
ad_tracking="SERVER",
stitching_policy="CUT_CURRENT",
default_slate=default_slate,
)

Expand Down
10 changes: 8 additions & 2 deletions video/stitcher/create_live_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@
)


def create_live_session(project_id: str, location: str, live_config_id: str) -> str:
def create_live_session(
project_id: str, location: str, live_config_id: str
) -> stitcher_v1.types.LiveSession:
"""Creates a live session. Live sessions are ephemeral resources that expire
after a few minutes.
Args:
project_id: The GCP project ID.
location: The location in which to create the session.
live_config_id: The user-defined live config ID."""
live_config_id: The user-defined live config ID.

Returns:
The live session resource.
"""

client = VideoStitcherServiceClient()

Expand Down
7 changes: 6 additions & 1 deletion video/stitcher/create_slate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@
)


def create_slate(project_id: str, location: str, slate_id: str, slate_uri: str) -> str:
def create_slate(
project_id: str, location: str, slate_id: str, slate_uri: str
) -> stitcher_v1.types.Slate:
"""Creates a slate.
Args:
project_id: The GCP project ID.
location: The location in which to create the slate.
slate_id: The user-defined slate ID.
slate_uri: Uri of the video slate; must be an MP4 video with at least one audio track.

Returns:
The slate resource.
"""

client = VideoStitcherServiceClient()
Expand Down
8 changes: 6 additions & 2 deletions video/stitcher/create_vod_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@

def create_vod_session(
project_id: str, location: str, source_uri: str, ad_tag_uri: str
) -> str:
) -> stitcher_v1.types.VodSession:
"""Creates a VOD session. VOD sessions are ephemeral resources that expire
after a few hours.
Args:
project_id: The GCP project ID.
location: The location in which to create the session.
source_uri: Uri of the media to stitch; this URI must reference either an MPEG-DASH
manifest (.mpd) file or an M3U playlist manifest (.m3u8) file.
ad_tag_uri: Uri of the ad tag."""
ad_tag_uri: Uri of the ad tag.

Returns:
The VOD session resource.
"""

client = VideoStitcherServiceClient()

Expand Down
3 changes: 2 additions & 1 deletion video/stitcher/delete_cdn_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty


def delete_cdn_key(project_id: str, location: str, cdn_key_id: str) -> str:
def delete_cdn_key(project_id: str, location: str, cdn_key_id: str) -> empty.Empty:
"""Deletes a CDN key.
Args:
project_id: The GCP project ID.
Expand Down
5 changes: 4 additions & 1 deletion video/stitcher/delete_live_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty


def delete_live_config(project_id: str, location: str, live_config_id: str) -> str:
def delete_live_config(
project_id: str, location: str, live_config_id: str
) -> empty.Empty:
"""Deletes a live config.
Args:
project_id: The GCP project ID.
Expand Down
3 changes: 2 additions & 1 deletion video/stitcher/delete_slate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty


def delete_slate(project_id: str, location: str, slate_id: str) -> str:
def delete_slate(project_id: str, location: str, slate_id: str) -> empty.Empty:
"""Deletes a slate.
Args:
project_id: The GCP project ID.
Expand Down
11 changes: 9 additions & 2 deletions video/stitcher/get_cdn_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@

import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)


def get_cdn_key(project_id: str, location: str, cdn_key_id: str) -> str:
def get_cdn_key(
project_id: str, location: str, cdn_key_id: str
) -> stitcher_v1.types.CdnKey:
"""Gets a CDN key.
Args:
project_id: The GCP project ID.
location: The location of the CDN key.
cdn_key_id: The user-defined CDN key ID."""
cdn_key_id: The user-defined CDN key ID.

Returns:
The CDN key resource.
"""

client = VideoStitcherServiceClient()

Expand Down
9 changes: 7 additions & 2 deletions video/stitcher/get_live_ad_tag_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@

import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)


def get_live_ad_tag_detail(
project_id: str, location: str, session_id: str, ad_tag_detail_id: str
) -> str:
) -> stitcher_v1.types.LiveAdTagDetail:
"""Gets the specified ad tag detail for a live session.
Args:
project_id: The GCP project ID.
location: The location of the session.
session_id: The ID of the live session.
ad_tag_detail_id: The ID of the ad tag details."""
ad_tag_detail_id: The ID of the ad tag details.

Returns:
The live ad tag detail resource.
"""

client = VideoStitcherServiceClient()

Expand Down
11 changes: 9 additions & 2 deletions video/stitcher/get_live_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@

import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
VideoStitcherServiceClient,
)


def get_live_config(project_id: str, location: str, live_config_id: str) -> str:
def get_live_config(
project_id: str, location: str, live_config_id: str
) -> stitcher_v1.types.LiveConfig:
"""Gets a live config.
Args:
project_id: The GCP project ID.
location: The location of the live config.
live_config_id: The user-defined live config ID."""
live_config_id: The user-defined live config ID.

Returns:
The live config resource.
"""

client = VideoStitcherServiceClient()

Expand Down
Loading