Skip to content

Commit

Permalink
feat: renaming to STRM Privacy
Browse files Browse the repository at this point in the history
renamed streammachine to strmprivacy

BREAKING CHANGE: streammachine -> strmprivacy
  • Loading branch information
trietsch committed Nov 10, 2021
1 parent 326351a commit bd877d1
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
run: |
twine upload dist/*
env:
TWINE_USERNAME: ${{secrets.TWINE_USERNAME}}
TWINE_PASSWORD: ${{secrets.TWINE_PASSWORD}}
TWINE_USERNAME: ${{secrets.PYPI_USERNAME}}
TWINE_PASSWORD: ${{secrets.PYPI_PASSWORD}}
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

### Features

* common 1.0.0 ([2ea3dee](https://github.com/streammachineio/python-driver/commit/2ea3deec45cc1d7802e81fecea0910c0c6688f3a))
* force 1.0.0 release ([3f16564](https://github.com/streammachineio/python-driver/commit/3f1656490a68c3ce859c57b187c993318ef647ce))
* updated to get_strm_schema_ref ([e8024ef](https://github.com/streammachineio/python-driver/commit/e8024ef7ee65aef455c5b7dfe0d804066368c1bc))
* common 1.0.0 ([2ea3dee](https://github.com/strmprivacy/python-driver/commit/2ea3deec45cc1d7802e81fecea0910c0c6688f3a))
* force 1.0.0 release ([3f16564](https://github.com/strmprivacy/python-driver/commit/3f1656490a68c3ce859c57b187c993318ef647ce))
* updated to get_strm_schema_ref ([e8024ef](https://github.com/strmprivacy/python-driver/commit/e8024ef7ee65aef455c5b7dfe0d804066368c1bc))
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Python Driver for Stream Machine
# Python Driver for STRM Privacy

[![PyPi][pypi-version-image]][pypi-version-link]
![Python Versions][python-versions-image]


See the matching [examples](https://github.com/streammachineio/driver-examples) in order to use the Python driver.
See the matching [examples](https://github.com/strmprivacy/driver-examples) in order to use the Python driver.

## Need help?

See our [documentation](https://docs.streammachine.io) or [reach out to us](https://docs.streammachine.io/docs/0.1.0/contact/index.html).
See our [documentation](https://docs.strmprivacy.io) or [reach out to us](https://docs.strmprivacy.io/docs/0.1.0/contact/index.html).

[pypi-version-image]: https://img.shields.io/pypi/v/streammachine-driver.svg
[pypi-version-link]: https://pypi.org/project/streammachine-driver/
[python-versions-image]: https://img.shields.io/pypi/pyversions/streammachine-driver.svg
[pypi-version-image]: https://img.shields.io/pypi/v/strmprivacy-driver.svg
[pypi-version-link]: https://pypi.org/project/strmprivacy-driver/
[python-versions-image]: https://img.shields.io/pypi/pyversions/strmprivacy-driver.svg
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
},
{
"files": [
"streammachine/driver/__init__.py"
"strmprivacy/driver/__init__.py"
],
"from": "__version__\\s?=\\s?'.*'",
"to": "__version__ = '${nextRelease.version}'",
"results": [
{
"file": "streammachine/driver/__init__.py",
"file": "strmprivacy/driver/__init__.py",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
Expand All @@ -70,7 +70,7 @@
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}",
"assets": [
"setup.py",
"streammachine/driver/__init__.py",
"strmprivacy/driver/__init__.py",
"CHANGELOG.md"
]
}
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ avro-json-serializer==1.0.3
avro-python3>=1.10.0
aiohttp-sse-client>=0.2.0
janus>=0.5.0
streammachine-schemas-common==1.0.0
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
author="Stream Machine B.V.",
author_email='apis@streammachine.io',
author_email='apis@strmprivacy.io',
python_requires='>=3.6',
classifiers=[
'Programming Language :: Python :: 3.6',
Expand All @@ -17,9 +17,8 @@
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
],
description="Python driver for interacting with Stream Machine.",
description="Python driver for interacting with STRM Privacy.",
install_requires=[
"streammachine-schemas-common==1.0.0",
"requests>=2.24.0",
"aiohttp>=3.6.2",
"avro-python3>=1.10.0",
Expand All @@ -36,10 +35,10 @@
],
long_description=readme,
include_package_data=True,
keywords='streammachine api client driver',
name='streammachine-driver',
packages=find_namespace_packages(include=['streammachine.*']),
namespace_packages=["streammachine"],
keywords='strmprivacy api client driver',
name='strmprivacy-driver',
packages=find_namespace_packages(include=['strmprivacy.*']),
namespace_packages=["strmprivacy"],
setup_requires=[],
version='1.0.0',
zip_safe=False,
Expand Down
1 change: 0 additions & 1 deletion streammachine/driver/client/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
__author__ = """Stream Machine B.V."""
__email__ = 'apis@streammachine.io'
__email__ = 'apis@strmprivacy.io'
__version__ = '1.0.0'

from .client import StreamMachineClient
from streammachine.schemas.common import StreamMachineEvent
from .client import StrmPrivacyClient
from .domain.config import ClientConfig
from .serializer import SerializationType
from .util import current_time_millis
1 change: 1 addition & 0 deletions strmprivacy/driver/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .client import StrmPrivacyClient
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AuthService(object):

def __init__(self, purpose: str, billing_id: str, client_id: str, client_secret: str, config: ClientConfig):
"""
Service responsible for ensuring the validity of access tokens for the Stream Machine Client
Service responsible for ensuring the validity of access tokens for the StrmPrivacyClient
:param purpose: for which is the AuthService initialized
:param billing_id: unique customer identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
from .sender import SenderService
from ..domain import ClientConfig
from ..serializer import SerializationType
from streammachine.schemas.common import StreamMachineEvent


class StreamMachineClient(object):
class StrmPrivacyClient(object):
def __init__(self, billing_id: str, client_id: str, client_secret: str, config: ClientConfig):
"""
Class to interact with Stream Machine. For each stream, a separate instance of `StreamMachineClient`
Class to interact with STRM Privacy. For each stream, a separate instance of `StrmPrivacyClient`
is required.
:param billing_id: unique customer identifier
Expand All @@ -25,7 +24,7 @@ async def start_timers(self):
await self._sender_service.start_timer()
await self._receiver_service.start_timer()

async def send(self, event: StreamMachineEvent, serialization_type: SerializationType) -> str:
async def send(self, event, serialization_type: SerializationType) -> str:
return await self._sender_service.asend(event, serialization_type)

async def start_receiving_ws(self, as_json: bool, consumer: Callable[[Any], Any]):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from aiohttp import ClientSession

from .auth import AuthService
from ..domain import StreamMachineEventDTO
from ..domain import StrmPrivacyEventDTO
from ..domain.config import ClientConfig


Expand All @@ -25,7 +25,7 @@ async def start_timer(self):
await self.auth_service.start()

async def asend(self, event, serialization_type) -> str:
dto = StreamMachineEventDTO(event, serialization_type)
dto = StrmPrivacyEventDTO(event, serialization_type)
headers = {
'Authorization': f'Bearer {self.auth_service.get_access_token()}',
'Content-Type': 'application/octet-stream',
Expand All @@ -41,7 +41,7 @@ async def asend(self, event, serialization_type) -> str:

if response.status != 204:
self._logger.error(
f"Error while sending event to Stream Machine ({self._config.gateway_uri}), response status = {response.status}, response: {response_text}")
f"Error while sending event to STRM Privacy ({self._config.gateway_uri}), response status = {response.status}, response: {response_text}")
return response.status

async def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import janus

from .. import StreamMachineClient, SerializationType
from .. import StrmPrivacyClient, SerializationType
from ..domain.config import ClientConfig


Expand Down Expand Up @@ -36,7 +36,7 @@ def run(self):

async def async_start(self, billing_id, client_id, client_secret):
self._queue = janus.Queue()
client = StreamMachineClient(billing_id, client_id, client_secret, self._config)
client = StrmPrivacyClient(billing_id, client_id, client_secret, self._config)
await client.start_timers() # for the re-authorization jwt timer
while True:
event, serialization_type = await self._queue.async_q.get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .domain import StreamMachineEventDTO
from .domain import StrmPrivacyEventDTO
from .base import JsonSerializable
from .config import ClientConfig
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class ClientConfig(object):
def __init__(self, log_level=logging.INFO, **kwargs):
self._log_level = log_level
self._gateway_protocol = kwargs.get("gateway_protocol", "https")
self._gateway_host = kwargs.get("gateway_host", "in.strm.services")
self._gateway_host = kwargs.get("gateway_host", "events.strmprivacy.io")
self._gateway_endpoint = kwargs.get("gateway_endpoint", "/event")
self._egress_protocol = kwargs.get("egress_protocol", "https")
self._egress_host = kwargs.get("egress_host", "out.strm.services")
self._egress_host = kwargs.get("egress_host", "websocket.strmprivacy.io")
self._egress_endpoint = kwargs.get("egress_endpoint", "/ws")
self._egress_health_endpoint = kwargs.get("egress_health_endpoint", "/is-alive")
self._sts_protocol = kwargs.get("sts_protocol", "https")
self._sts_host = kwargs.get("sts_host", "auth.strm.services")
self._sts_host = kwargs.get("sts_host", "sts.strmprivacy.io")
self._sts_auth_endpoint = kwargs.get("sts_auth_endpoint", "/auth")
self._sts_refresh_endpoint = kwargs.get("sts_refresh_endpoint", "/refresh")
self._sts_refresh_interval = kwargs.get("sts_refresh_interval", 3300)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from dataclasses import dataclass

from streammachine.schemas.common import StreamMachineEvent

from ..serializer import SerializationType, SerializationProvider
from ..serializer.type import UnsupportedSerializationTypeException


@dataclass
class StreamMachineEventDTO(object):
event: StreamMachineEvent
class StrmPrivacyEventDTO(object):
event: object
serialization_type: SerializationType

def get_schema_ref(self) -> str:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
from avro.schema import Schema
from avro_json_serializer import AvroJsonSerializer
from jsonschema import validate
from streammachine.schemas.common import StreamMachineEvent

from .type import SerializationType, UnsupportedSerializationTypeException


class EventSerializer(ABC):
@abstractmethod
def serialize(self, event: StreamMachineEvent, serialization_type: SerializationType) -> bytes:
def serialize(self, event, serialization_type: SerializationType) -> bytes:
pass


Expand All @@ -25,7 +24,7 @@ def __init__(self, schema: Schema):
self._schema: Schema = schema
self._serializer: Union[DatumWriter, AvroJsonSerializer] = None

def serialize(self, event: StreamMachineEvent, serialization_type: SerializationType) -> bytes:
def serialize(self, event, serialization_type: SerializationType) -> bytes:
if serialization_type is SerializationType.AVRO_BINARY:
return self._serialize_avro_binary(event)
elif serialization_type is SerializationType.AVRO_JSON:
Expand Down Expand Up @@ -57,7 +56,7 @@ class JsonSerializer(EventSerializer):
def __init__(self, schema: dict):
self._schema = schema

def serialize(self, event: StreamMachineEvent, _: SerializationType) -> str:
def serialize(self, event, _: SerializationType) -> str:
validate(dataclasses.asdict(event), self._schema)

return json.dumps(event, cls=JsonSerializer.Encoder)
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions test/driver/test_client.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import asyncio
import asyncio
import json
import re
import unittest

import responses

from strm.driver import SerializationType, StreamMachineClient, ClientConfig
from strmprivacy.driver import SerializationType, StrmPrivacyClient, ClientConfig
from test.test_util import TestData


class StreamMachineClientTest(unittest.TestCase):
class StrmPrivacyClientTest(unittest.TestCase):
_BILLING_ID = "robin5"
_CLIENT_ID = "8xkz4x63rfqfvc5b97oq2ej1gzidqa"
_CLIENT_SECRET = "4NZD3#cWeGG_X0FpR%kfGwKJNQJLBZ"
Expand All @@ -22,15 +22,15 @@ class StreamMachineClientTest(unittest.TestCase):

# @responses.activate
def test_send_events(self):
StreamMachineClientTest.setup_auth_mockserver()
StrmPrivacyClientTest.setup_auth_mockserver()

for parameters in StreamMachineClientTest._PARAMETERS:
for parameters in StrmPrivacyClientTest._PARAMETERS:
with self.subTest(msg=parameters['name']):
# Given an event
client = StreamMachineClient(
StreamMachineClientTest._BILLING_ID,
StreamMachineClientTest._CLIENT_ID,
StreamMachineClientTest._CLIENT_SECRET,
client = StrmPrivacyClient(
StrmPrivacyClientTest._BILLING_ID,
StrmPrivacyClientTest._CLIENT_ID,
StrmPrivacyClientTest._CLIENT_SECRET,
ClientConfig()
)
event = parameters['event']
Expand All @@ -46,7 +46,7 @@ def test_send_events(self):
self.assertEqual("ok", response)

def test_receive_events(self):
client = StreamMachineClient(
client = StrmPrivacyClient(
'robin5',
'7vbcwbpdf6maj8uffp5mo7743yaazz',
'iS@yD8Dq5@OAFTDdMs&hGOjWHD%aOI',
Expand Down
11 changes: 5 additions & 6 deletions test/test_util.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from strm.driver import current_time_millis
from strm.driver.domain import StreamMachineEvent
from strm.schema.avro.io.streammachine.schema.avro.strm_avro.v1 import StrmEvent
from strm.schema.json import SchemaJsonEvent, StrmMeta, Customer
from strmprivacy.driver import current_time_millis
from strmprivacy.schema.avro.io.streammachine.schema.avro.strm_avro.v1 import StrmEvent
from strmprivacy.schema.json import SchemaJsonEvent, StrmMeta, Customer


class TestData(object):
@staticmethod
def create_avro_event() -> StreamMachineEvent:
def create_avro_event():
event = StrmEvent()
event.abtests = ["abc"]
event.customer.id = "integration-test"
Expand All @@ -20,7 +19,7 @@ def create_avro_event() -> StreamMachineEvent:
return event

@staticmethod
def create_json_event() -> StreamMachineEvent:
def create_json_event():
return SchemaJsonEvent(
strmMeta=(StrmMeta(
schemaId="schema_json",
Expand Down

0 comments on commit bd877d1

Please sign in to comment.