Skip to content
Closed
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
8 changes: 5 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
/storage/**/* @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/python-samples-reviewers
/storagetransfer/**/* @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/python-samples-reviewers
# ---* Infra DB
/cloud-sql/**/* @GoogleCloudPlatform/infra-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/cloud_tasks/**/* @GoogleCloudPlatform/infra-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/cloud-sql/**/* @GoogleCloudPlatform/infra-db-sdk @GoogleCloudPlatform/python-samples-reviewers
/cloud_tasks/**/* @GoogleCloudPlatform/infra-db-sdk @GoogleCloudPlatform/python-samples-reviewers

# Self-service
# ---* Shared with DEE Teams
Expand All @@ -106,9 +106,11 @@
/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
/iot/**/* @GoogleCloudPlatform/api-iot @GoogleCloudPlatform/python-samples-reviewers
/video/stitcher/* @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/python-samples-reviewers

# Deprecated
/iot/**/* @GoogleCloudPlatform/python-samples-reviewers

# Does not have owner
/blog/**/* @GoogleCloudPlatform/python-samples-reviewers
/iam/api-client/**/* @GoogleCloudPlatform/python-samples-reviewers
Expand Down
2 changes: 1 addition & 1 deletion .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ assign_issues_by:
- labels:
- "api: cloudsql"
to:
- GoogleCloudPlatform/infra-db-dpes
- GoogleCloudPlatform/infra-db-sdk
- labels:
- "api: bigtable"
- "api: datastore"
Expand Down
2 changes: 1 addition & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ branchProtectionRules:
requiredStatusCheckContexts:
- "Kokoro CI - Lint"
- "Kokoro CI - Python 2.7 (App Engine Standard Only)"
- "Kokoro CI - Python 3.7"
- "Kokoro CI - Python 3.8"
- "Kokoro CI - Python 3.11"
- "cla/google"
- "snippet-bot check"
# List of explicit permissions to add (additive only)
Expand Down
5 changes: 5 additions & 0 deletions .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export PATH="${HOME}/.local/bin:${PATH}"
# upgrade pip when needed
pip install --upgrade pip

# Install virtualenv in version 20.21, since version 20.22 no longer supports Python 2.7
if [[ "${RUN_TESTS_SESSION}" == "py-2.7" ]]; then
pip install --user -q virtualenv==20.21
fi

# install nox for testing
pip install --user -q nox

Expand Down
47 changes: 4 additions & 43 deletions iot/api-client/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
# Cloud IoT Core Python Samples
# Deprecation Notice

## DEPRECATION NOTICE
* <h3>Google Cloud IoT Core is <a href="https://cloud.google.com/iot/docs/release-notes#August_16_2022">retired as of August 16, 2023</a>.</h3>

Please see the [release notes](https://cloud.google.com/iot/docs/release-notes) for information on the upcoming deprecation of IoT Core

[![Open in Cloud Shell][shell_img]][shell_link]

[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=iot/api-client/README.md
This folder contains Python samples that demonstrate an overview of the
Google Cloud IoT Core platform.

## Quickstart
1. Install the gCloud CLI as described in [the Cloud IoT Core documentation](https://cloud.google.com/iot/docs/how-tos/getting-started#set_up_the_google_cloud_sdk_and_gcloud).
2. Create a PubSub topic:

gcloud beta pubsub topics create projects/my-iot-project/topics/device-events

3. Add the service account `cloud-iot@system.gserviceaccount.com` with the role `Publisher` to that
PubSub topic from the [Cloud Developer Console](https://console.cloud.google.com)
or by using the helper script in the /scripts folder.

4. Create a registry:

gcloud beta iot registries create my-registry \
--project=my-iot-project \
--region=us-central1 \
--event-pubsub-topic=projects/my-iot-project/topics/device-events

5. Use the `generate_keys.sh` script to generate your signing keys:

./generate_keys.sh

6. Register a device:

gcloud beta iot devices create my-python-device \
--project=my-iot-project \
--region=us-central1 \
--registry=my-registry \
--public-key path=rsa_cert.pem,type=rs256

7. Connect a sample device using the sample app in the `mqtt_example` folder.
8. Learn how to manage devices programmatically with the sample app in the
`manager` folder.
* <h3>Hence, the samples in this directory are archived and are no longer maintained.</h3>

* <h3>If you are customer with an assigned Google Cloud account team, contact your account team for more information.</h3>
5 changes: 1 addition & 4 deletions run/filesystem/gcsfuse_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ echo "Mounting completed."
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app &

# Exit immediately when one of the background processes terminate.
wait -n
exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app
# [END cloudrun_fuse_script]
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
Loading