Skip to content

Add streaming APIs #17

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

Merged
merged 1 commit into from
Feb 3, 2023
Merged
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
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Feature Request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: FabienLavocat
---

**Describe the feature request**

[Please describe what you expect from this feature.]
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/report-an-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug Report
about: Use this template to report an issue.
title: ''
labels: bug
assignees: FabienLavocat
---

**Describe the bug**

[A clear and concise description of what the bug is.]

**Expected Behavior**

[Describe the expected behavior of the feature.]

**Minimalistic code (recommended)**

[Please provide a link to a repository showing specifically the issue. It should only have the minimal footprint of your own implementation - something which does not requires any NDA.]

**Specifications**

- OS: [e.g. Windows, Linux, macOS, ...]
- Version:
- _for each libraries : name -> version_
- [e.g. dolbyio-rest-apis-client 1.8.7]
- [e.g. python 3.10]
- [...]
33 changes: 33 additions & 0 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Package

on:
push:
branches:
- '**'

jobs:
build-package:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Prepare environment 🌎
run: |
# Upgrade pip
python3 -m pip install --upgrade pip
# Install the requirements
python3 -m pip install -r requirements.txt
- name: Run PyLint 🔧
run: |
# Run PyLint
python3 -m pylint client/src/dolbyio_rest_apis cli/src/dolbyio_rest_apis_cli
- name: Build the packages 🔧
run: |
# Build the Python packages
python3 client/setup.py sdist bdist_wheel
python3 cli/setup.py sdist bdist_wheel
57 changes: 27 additions & 30 deletions .github/workflows/publish-package-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
name: Build and Deploy
name: Publish Package

on:
push:
release:
types:
- created
types: [published]

jobs:
build-and-deploy:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Prepare environment 🌎
run: |
# Upgrade pip
python3 -m pip install --upgrade pip
# Install the requirements
python3 -m pip install -r requirements.txt
- name: Prepare environment 🌎
run: |
# Upgrade pip
python3 -m pip install --upgrade pip
# Install the requirements
python3 -m pip install -r requirements.txt
- name: Run PyLint 🔧
run: |
# Run PyLint
python3 -m pylint client/src/dolbyio_rest_apis cli/src/dolbyio_rest_apis_cli
- name: Run PyLint 🔧
run: |
# Run PyLint
python3 -m pylint client/src/dolbyio_rest_apis cli/src/dolbyio_rest_apis_cli
- name: Build the packages 🔧
run: |
# Build the Python packages
python3 client/setup.py sdist bdist_wheel
python3 cli/setup.py sdist bdist_wheel
- name: Build the packages 🔧
run: |
# Build the Python packages
python3 client/setup.py sdist bdist_wheel
python3 cli/setup.py sdist bdist_wheel
- name: Deploy to PyPI 🚀
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: ./.github/actions/gh-action-pypi-publish-1.6.4
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Deploy to PyPI 🚀
uses: ./.github/actions/gh-action-pypi-publish-1.6.4
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Dolby.io REST APIs
[![Build Package](https://github.com/DolbyIO/dolbyio-rest-apis-client-python/actions/workflows/build-package.yml/badge.svg)](https://github.com/DolbyIO/dolbyio-rest-apis-client-python/actions/workflows/build-package.yml)
[![Publish Package](https://github.com/DolbyIO/dolbyio-rest-apis-client-python/actions/workflows/publish-package-to-pypi.yml/badge.svg)](https://github.com/DolbyIO/dolbyio-rest-apis-client-python/actions/workflows/publish-package-to-pypi.yml)
![PyPI](https://img.shields.io/pypi/v/dolbyio-rest-apis)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dolbyio-rest-apis)
[![License](https://img.shields.io/github/license/DolbyIO/dolbyio-rest-apis-client-python)](LICENSE)

This repo contains projects for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
- Command Line Interface utility.
# Dolby.io REST APIs Client for Python

Python wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api), [Streaming](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs. It also contains a Command Line Interface utility.

## Build the builder

2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dolby.io REST APIs CLI
# Dolby.io REST APIs Client for Python - CLI

Command Line Interface utility for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.

41 changes: 39 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dolby.io REST APIs
# Dolby.io REST APIs Client for Python

Python wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs. All the functions are using the async pattern.
Python wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api), [Streaming](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.

## Install this project

@@ -107,6 +107,43 @@ conf = loop.run_until_complete(task)
print(f"Conference created: {conf.id}")
```

## Real-time Streaming Examples

### Create a publish token

```python
import asyncio
from dolbyio_rest_apis.streaming import publish_token
from dolbyio_rest_apis.streaming.models.publish_token import CreatePublishToken, CreateUpdatePublishTokenStream

api_secret = "" # Retrieve your API Secret from the dashboard

create_token = CreatePublishToken('my_token')
create_token.streams.append(CreateUpdatePublishTokenStream('feed1', False))

loop = asyncio.get_event_loop()
task = publish_token.create(api_secret, create_token)
token = loop.run_until_complete(task)

print(token)
```

### Create a subscribe token

```python
const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');

const subscribeToken = await dolbyio.streaming.subscribeToken.create('api_secret', {
label: 'My token',
streams: [
{
streamName: 'feedA',
},
],
});
console.log(subscribeToken);
```

## Media Examples

### Media Input and Output
Empty file.
38 changes: 38 additions & 0 deletions client/src/dolbyio_rest_apis/streaming/cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
dolbyio_rest_apis.streaming.cluster
~~~~~~~~~~~~~~~
This module contains the functions to work with the Cluster APIs.
"""

from dolbyio_rest_apis.streaming.internal.http_context import StreamingHttpContext
from dolbyio_rest_apis.streaming.internal.urls import SAPI_URL
from dolbyio_rest_apis.streaming.models.cluster import ClusterResponse

async def read(
api_secret: str,
) -> ClusterResponse:
async with StreamingHttpContext() as http_context:
json_response = await http_context.requests_get(
api_secret=api_secret,
url=f'{SAPI_URL}/api/cluster',
)

return ClusterResponse(json_response)

async def update(
api_secret: str,
default_cluster: str,
) -> ClusterResponse:
payload = {
'defaultCluster': default_cluster,
}

async with StreamingHttpContext() as http_context:
json_response = await http_context.requests_put(
api_secret=api_secret,
url=f'{SAPI_URL}/api/cluster',
payload=payload,
)

return ClusterResponse(json_response)
Empty file.
Loading