clarity-api-sdk-python 0.2.12__tar.gz → 0.2.13__tar.gz

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.
Files changed (18) hide show
  1. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/PKG-INFO +1 -1
  2. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/pyproject.toml +1 -1
  3. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/clarity_api_sdk_python.egg-info/PKG-INFO +1 -1
  4. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/clarity_api_sdk_python.egg-info/SOURCES.txt +1 -0
  5. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/api/session.py +19 -5
  6. clarity_api_sdk_python-0.2.13/src/cti/main_api.py +19 -0
  7. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/README.md +0 -0
  8. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/setup.cfg +0 -0
  9. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/clarity_api_sdk_python.egg-info/dependency_links.txt +0 -0
  10. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/clarity_api_sdk_python.egg-info/requires.txt +0 -0
  11. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/clarity_api_sdk_python.egg-info/top_level.txt +0 -0
  12. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/__init__.py +0 -0
  13. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/api/__init__.py +0 -0
  14. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/api/async_client.py +0 -0
  15. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/api/client.py +0 -0
  16. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/logger/__init__.py +0 -0
  17. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/logger/logger.py +0 -0
  18. {clarity_api_sdk_python-0.2.12 → clarity_api_sdk_python-0.2.13}/src/cti/main.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarity-api-sdk-python
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: A Python SDK to connect to the CTI Clarity API server.
5
5
  Author-email: "Chesapeake Technology Inc." <support@chesapeaketech.com>
6
6
  Project-URL: Homepage, https://github.com/chesapeake-tech/clarity-api-sdk-python
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "clarity-api-sdk-python"
8
- version = "0.2.12"
8
+ version = "0.2.13"
9
9
  authors = [
10
10
  { name="Chesapeake Technology Inc.", email="support@chesapeaketech.com" },
11
11
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarity-api-sdk-python
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: A Python SDK to connect to the CTI Clarity API server.
5
5
  Author-email: "Chesapeake Technology Inc." <support@chesapeaketech.com>
6
6
  Project-URL: Homepage, https://github.com/chesapeake-tech/clarity-api-sdk-python
@@ -7,6 +7,7 @@ src/clarity_api_sdk_python.egg-info/requires.txt
7
7
  src/clarity_api_sdk_python.egg-info/top_level.txt
8
8
  src/cti/__init__.py
9
9
  src/cti/main.py
10
+ src/cti/main_api.py
10
11
  src/cti/api/__init__.py
11
12
  src/cti/api/async_client.py
12
13
  src/cti/api/client.py
@@ -19,12 +19,11 @@ Example:
19
19
  asyncio.run(main())
20
20
 
21
21
  # In other modules
22
- from cti.api.session import async_client
22
+ from cti.api.session import get_async_client
23
23
 
24
24
  async def fetch_data():
25
- if async_client:
26
- response = await async_client.get(...)
27
- return response.json()
25
+ response = await get_async_client().get(...)
26
+ return response.json()
28
27
  """
29
28
 
30
29
  # pylint: disable=global-statement, unnecessary-dunder-call
@@ -32,7 +31,7 @@ Example:
32
31
  from cti.api.async_client import ClarityApiAsyncClient
33
32
 
34
33
  # The singleton instance, initially None.
35
- async_client: ClarityApiAsyncClient | None
34
+ async_client: ClarityApiAsyncClient | None = None
36
35
 
37
36
 
38
37
  async def initialize_async_client() -> None:
@@ -46,6 +45,21 @@ async def initialize_async_client() -> None:
46
45
  async_client = ClarityApiAsyncClient()
47
46
  await async_client.__aenter__()
48
47
 
48
+ def get_async_client() -> ClarityApiAsyncClient:
49
+ """Returns the shared ClarityApiAsyncClient instance.
50
+
51
+ If the client is not initialized, this function initializes it first.
52
+
53
+ Returns:
54
+ ClarityApiAsyncClient: The shared ClarityApiAsyncClient instance.
55
+
56
+ Raises:
57
+ ValueError: If initialize_async_client() has not been called first.
58
+ """
59
+ if async_client is None:
60
+ raise ValueError("initialize_async_client() must be called first to initialize client.")
61
+ return async_client
62
+
49
63
 
50
64
  async def close_async_client() -> None:
51
65
  """Closes the shared ClarityApiAsyncClient instance.
@@ -0,0 +1,19 @@
1
+ """Example"""
2
+
3
+ import asyncio
4
+
5
+ from cti.api.session import get_async_client, close_async_client, initialize_async_client
6
+
7
+ async def main():
8
+ """Example of using the Clarity API asynchronously
9
+ """
10
+ try:
11
+ await initialize_async_client()
12
+ client = get_async_client()
13
+ response = await client.get(url="/api/v1/status")
14
+ print(response.json())
15
+ finally:
16
+ await close_async_client()
17
+
18
+ if __name__ == "__main__":
19
+ asyncio.run(main())