erioon 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
erioon/auth.py ADDED
@@ -0,0 +1,20 @@
1
+ from client import ErioonClient
2
+
3
+ def Auth(credential_string):
4
+ """
5
+ Authenticates a user using a colon-separated email:password string.
6
+
7
+ Parameters:
8
+ - credential_string (str): A string in the format "email:password"
9
+
10
+ Returns:
11
+ - ErioonClient instance: An instance representing the authenticated user.
12
+ If authentication fails, the instance will contain the error message.
13
+
14
+ Example usage:
15
+ >>> from erioon.auth import Auth
16
+ >>> client = Auth("<EMAIL>:<PASSWORD>")
17
+ >>> print(client) # prints user_id if successful or error message if not
18
+ """
19
+ email, password = credential_string.split(":")
20
+ return ErioonClient(email, password)
erioon/client.py ADDED
@@ -0,0 +1,106 @@
1
+ import requests
2
+ from erioon.database import Database
3
+
4
+ class ErioonClient:
5
+ """
6
+ Represents an authenticated Erioon client session.
7
+
8
+ Handles user login via email and password, and stores either the user's ID
9
+ on success or an error message on failure.
10
+
11
+ Usage:
12
+ >>> client = ErioonClient("<EMAIL>:<PASSWORD>")
13
+ """
14
+
15
+ def __init__(self, email, password, base_url="https://sdk.erioon.com"):
16
+ """
17
+ Initializes the client and attempts login.
18
+
19
+ Args:
20
+ email (str): User email address.
21
+ password (str): User password.
22
+ base_url (str): The base URL of the Erioon API.
23
+ """
24
+ self.email = email
25
+ self.password = password
26
+ self.base_url = base_url
27
+ self.user_id = None
28
+ self.error = None
29
+
30
+ try:
31
+ self.user_id = self.login()
32
+ except Exception as e:
33
+ self.error = str(e)
34
+
35
+ def login(self):
36
+ """
37
+ Sends a login request to the Erioon API.
38
+
39
+ Returns:
40
+ str: User ID on successful login.
41
+
42
+ Raises:
43
+ Exception: If the login fails, with the error message from the server.
44
+ """
45
+ url = f"{self.base_url}/login_with_credentials"
46
+ payload = {"email": self.email, "password": self.password}
47
+ headers = {"Content-Type": "application/json"}
48
+
49
+ response = requests.post(url, json=payload, headers=headers)
50
+
51
+ if response.status_code == 200:
52
+ return response.text.strip()
53
+ else:
54
+ raise Exception(response.text.strip())
55
+
56
+ def __str__(self):
57
+ """
58
+ Called when print() or str() is used on the object.
59
+
60
+ Returns:
61
+ str: User ID if authenticated, or error message if not.
62
+ """
63
+ return self.user_id if self.user_id else self.error
64
+
65
+ def __repr__(self):
66
+ """
67
+ Called in developer tools or when inspecting the object.
68
+
69
+ Returns:
70
+ str: Formatted string showing either user ID or error.
71
+ """
72
+ if self.user_id:
73
+ return f"<ErioonClient user_id={self.user_id}>"
74
+ else:
75
+ return f"<ErioonClient error='{self.error}'>"
76
+
77
+ def __getitem__(self, db_id):
78
+ """
79
+ Get a Database object by its ID.
80
+
81
+ Calls the API to retrieve DB metadata and initializes a Database instance.
82
+ """
83
+ if not self.user_id:
84
+ raise ValueError("Client not authenticated. Cannot access database.")
85
+
86
+ payload = {"user_id": self.user_id, "db_id": db_id}
87
+ headers = {"Content-Type": "application/json"}
88
+
89
+ response = requests.post(f"{self.base_url}/db_info", json=payload, headers=headers)
90
+
91
+
92
+ if response.status_code != 200:
93
+ db_error = response.json()
94
+ return db_error["error"]
95
+
96
+ db_info = response.json()
97
+ return Database(db_info)
98
+
99
+ def __str__(self):
100
+ return self.user_id if self.user_id else self.error
101
+
102
+ def __repr__(self):
103
+ if self.user_id:
104
+ return f"<ErioonClient user_id={self.user_id}>"
105
+ else:
106
+ return f"<ErioonClient error='{self.error}'>"
erioon/database.py ADDED
@@ -0,0 +1,17 @@
1
+ import json
2
+
3
+ class Database:
4
+ def __init__(self, metadata):
5
+ self.metadata = metadata
6
+
7
+ def __getitem__(self, collection_id):
8
+ """
9
+ Will return a Collection object (to be implemented in next steps).
10
+ """
11
+ raise NotImplementedError("Collection access not implemented yet.")
12
+
13
+ def __str__(self):
14
+ return json.dumps(self.metadata, indent=4)
15
+
16
+ def __repr__(self):
17
+ return f"{self.metadata}"
@@ -0,0 +1,13 @@
1
+ Copyright 2025-present Erioon SRL.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.2
2
+ Name: erioon
3
+ Version: 0.0.0
4
+ Summary: Erioon SDF for Python
5
+ Author: Zyber Pireci
6
+ Author-email: zyber.pireci@erioon.com
7
+ License: MIT
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: requests
15
+ Requires-Dist: pyodbc
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: license
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ This SDK allows you to interact with all the Erioon resources.
@@ -0,0 +1,8 @@
1
+ erioon/auth.py,sha256=VOsdSWalBuiqvt3PxtR8fMDKgONy4JfTELam1OHRWM0,697
2
+ erioon/client.py,sha256=GNr1q7MM9oxkfWyXFV2wCb78hEIYtIYJc03ziUxQ8Vw,3249
3
+ erioon/database.py,sha256=vGCx3SvVpeEHB2kj54VD637A0fHbgpl9DUxMPzQKNH8,465
4
+ erioon-0.0.0.dist-info/LICENSE,sha256=xwnq3DNlZpQyteOK9HvtHRhMdYviXTTaCDljEodFRnQ,569
5
+ erioon-0.0.0.dist-info/METADATA,sha256=GdyjQF_9D00kOjjs4GqdccxQI6q5iYsd9ot5t_mcnK8,715
6
+ erioon-0.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
+ erioon-0.0.0.dist-info/top_level.txt,sha256=yjKEg85X5Q5ot46IMML_xukvIGG5YfdrLWcemjalItc,7
8
+ erioon-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ erioon