Skip to content

Commit 2348e31

Browse files
add copyrights where applicable and add stubs for OSHConnect
1 parent e10ec1d commit 2348e31

File tree

11 files changed

+142
-5
lines changed

11 files changed

+142
-5
lines changed

oshconnect/__init__.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2+
# ==============================================================================
3+
# Copyright (c) 2024 Botts Innovative Research, Inc.
4+
# Date: 2024/5/28
5+
# Author: Ian Patterson
6+
# Contact Email: ian@botts-inc.com
7+
# ==============================================================================
8+
9+
import base64
10+
import uuid
111
from abc import ABC
212
from dataclasses import dataclass
313
from enum import Enum
@@ -13,10 +23,37 @@ class Endpoints:
1323

1424
@dataclass(kw_only=True)
1525
class Node(ABC):
26+
_id: str
1627
address: str
1728
port: int
1829
endpoints: Endpoints
1930
is_secure: bool
31+
_basic_auth: bytes
32+
33+
def __init__(self, address: str, port: int, is_secure: bool):
34+
self._id = f'node-{uuid.uuid4()}'
35+
self.address = address
36+
self.port = port
37+
self.is_secure = is_secure
38+
self.endpoints = Endpoints()
39+
40+
def get_id(self):
41+
return self._id
42+
43+
def get_address(self):
44+
return self.address
45+
46+
def get_port(self):
47+
return self.port
48+
49+
def get_api_endpoint(self):
50+
return f"http{'s' if self.is_secure else ''}://{self.address}:{self.port}/{self.endpoints.connected_systems}"
51+
52+
def add_basicauth(self, username: str, password: str):
53+
self._basic_auth = base64.b64encode(f"{username}:{password}".encode('utf-8'))
54+
55+
def get_decoded_auth(self):
56+
return self._basic_auth.decode('utf-8')
2057

2158

2259
class TemporalModes(Enum):

oshconnect/datasource/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
# ==============================================================================
3+
# Copyright (c) 2024 Botts Innovative Research, Inc.
4+
# Date: 2024/5/28
5+
# Author: Ian Patterson
6+
# Contact Email: ian@botts-inc.com
7+
# ==============================================================================
8+
19
from enum import Enum
210

311

oshconnect/datasource/datasource.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Copyright (c) 2024 Ian Patterson
2+
#
3+
# Author: Ian Patterson <ian@botts-inc.com>
4+
#
5+
# Contact Email: ian@botts-inc.com
6+
17
from uuid import uuid4
28

39
from oshconnect.datasource import Mode
@@ -44,7 +50,7 @@ def reset(self):
4450
pass
4551

4652
def get_status(self):
47-
pass
53+
return self.status
4854

4955

5056
class DatasourceHandler:

oshconnect/datasource/handler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
# ==============================================================================
3+
# Copyright (c) 2024 Botts Innovative Research, Inc.
4+
# Date: 2024/5/28
5+
# Author: Ian Patterson
6+
# Contact Email: ian@botts-inc.com
7+
# ==============================================================================
8+
19
from abc import ABC, abstractmethod
210

311

oshconnect/datastore/datastore.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ==============================================================================
2+
# Copyright (c) 2024 Botts Innovative Research, Inc.
3+
# Date: 2024/5/28
4+
# Author: Ian Patterson
5+
# Contact Email: ian@botts-inc.com
6+
# ==============================================================================
7+
8+
class DataStore:
9+
def __init__(self):
10+
pass

oshconnect/oshconnect.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,33 @@
55
# Contact email: ian@botts-inc.com
66
# ==============================================================================
77

8+
from conSys4Py.con_sys_api import ConnectedSystemsRequestBuilder, ConnectedSystemAPIRequest
9+
10+
from oshconnect import Node
11+
from oshconnect.datasource.datasource import DataSource
12+
from oshconnect.styling.styling import Styling
13+
from oshconnect.timemanagement.timemanagement import TimeManagement
14+
from oshconnect.datastore.datastore import DataStore
15+
16+
817
class OSHConnect:
9-
datasource: DataSourceAPI
18+
datasource: DataSource
1019
datastore: DataStoreAPI
1120
styling: StylingAPI
12-
timestream: TimeStreamAPI
21+
timestream: TimeManagement
22+
_nodes: list[Node]
23+
_cs_api_builder: ConnectedSystemsRequestBuilder
24+
25+
def __init__(self, **kwargs):
26+
if 'nodes' in kwargs:
27+
self._nodes = kwargs['nodes']
28+
29+
def add_node(self, node: Node):
30+
self._nodes.append(node)
31+
32+
def remove_node(self, node_id: str):
33+
# list of nodes in our node list that do not have the id of the node we want to remove
34+
self._nodes = [node for node in self._nodes if node.get_id() != node_id]
1335

1436
def save_config(self, config: dict):
1537
pass
@@ -56,8 +78,8 @@ def get_visualization_recommendations(self, streams: list):
5678
def discover_datastreams(self, streams: list):
5779
pass
5880

59-
def discover_systems(self, systems: list):
60-
pass
81+
def discover_systems(self):
82+
sys_list = systems.list_all_systems()
6183

6284
def discover_controlstreams(self, streams: list):
6385
pass

oshconnect/styling/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
# ==============================================================================
3+
# Copyright (c) 2024 Botts Innovative Research, Inc.
4+
# Date: 2024/5/28
5+
# Author: Ian Patterson
6+
# Contact Email: ian@botts-inc.com
7+
# ==============================================================================
8+
19
from abc import ABC
210
from typing import Callable
311

oshconnect/styling/styling.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ==============================================================================
2+
# Copyright (c) 2024 Botts Innovative Research, Inc.
3+
# Date: 2024/5/28
4+
# Author: Ian Patterson
5+
# Contact Email: ian@botts-inc.com
6+
# ==============================================================================
7+
8+
class Styling:
9+
10+
def __init__(self):
11+
pass

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ python = "^3.12"
1010
consys4py = { git = "https://github.com/Botts-Innovative-Research/CSAPI4Py.git", branch = "dev" }
1111
oshdatacore = { git = "https://github.com/ChainReaction31/py_osh_data_core.git", branch = "master" }
1212

13+
[tool.poetry.dev-dependencies]
14+
pytest = "^8.2.1"
1315

1416
[build-system]
1517
requires = ["poetry-core"]

tests/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ==============================================================================
2+
# Copyright (c) 2024 Botts Innovative Research, Inc.
3+
# Date: 2024/5/28
4+
# Author: Ian Patterson
5+
# Contact Email: ian@botts-inc.com
6+
# ==============================================================================
7+

0 commit comments

Comments
 (0)