api-to-dataframe 0.1.0__tar.gz → 1.0.0__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.
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/PKG-INFO +1 -1
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/pyproject.toml +1 -1
- api_to_dataframe-1.0.0/src/api_to_dataframe/__init__.py +2 -0
- api_to_dataframe-1.0.0/src/api_to_dataframe/common/utils/retry_strategies.py +9 -0
- api_to_dataframe-1.0.0/src/api_to_dataframe/controller/client_builder.py +20 -0
- api_to_dataframe-1.0.0/src/api_to_dataframe/models/get_data.py +24 -0
- api_to_dataframe-1.0.0/src/api_to_dataframe/models/retainer.py +15 -0
- api_to_dataframe-1.0.0/src/api_to_dataframe/views/dataframe_metrics.py +0 -0
- api_to_dataframe-0.1.0/src/api_to_dataframe/__init__.py +0 -1
- api_to_dataframe-0.1.0/src/api_to_dataframe/main.py +0 -22
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/LICENSE +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/README.md +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/common/__init__.py +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/common/utils/__init__.py +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/config/config.py +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/controller/__init__.py +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/models/__init__.py +0 -0
- {api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/views/__init__.py +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
|
|
2
|
+
from api_to_dataframe.models.get_data import GetData
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ClientBuilder:
|
|
6
|
+
def __init__(self, endpoint: str, retry_strategy: RetryStrategies = RetryStrategies.NoRetryStrategy):
|
|
7
|
+
if endpoint == "":
|
|
8
|
+
raise ValueError("::: endpoint param is mandatory :::")
|
|
9
|
+
else:
|
|
10
|
+
self.endpoint = endpoint
|
|
11
|
+
self.retry_strategy = retry_strategy
|
|
12
|
+
|
|
13
|
+
def get_api_data(self):
|
|
14
|
+
response = GetData.get_response(self.endpoint, self.retry_strategy)
|
|
15
|
+
return response
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def api_to_dataframe(response: dict):
|
|
19
|
+
df = GetData.to_dataframe(response)
|
|
20
|
+
return df
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class GetData:
|
|
8
|
+
@staticmethod
|
|
9
|
+
def get_response(endpoint: str, RetryStrategies: RetryStrategies):
|
|
10
|
+
response = requests.get(endpoint)
|
|
11
|
+
|
|
12
|
+
if response.ok:
|
|
13
|
+
return response.json()
|
|
14
|
+
else:
|
|
15
|
+
raise ConnectionError(response.status_code)
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def to_dataframe(response):
|
|
19
|
+
df = pd.DataFrame(response)
|
|
20
|
+
if df.empty:
|
|
21
|
+
raise ValueError("::: DataFrame is empty :::")
|
|
22
|
+
else:
|
|
23
|
+
return df
|
|
24
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Retainer:
|
|
5
|
+
@staticmethod
|
|
6
|
+
def strategy(retry_strategy: RetryStrategies = RetryStrategies.NoRetryStrategy):
|
|
7
|
+
if retry_strategy == RetryStrategies.NoRetryStrategy:
|
|
8
|
+
print("::: NoRetryStrategy :::")
|
|
9
|
+
elif retry_strategy == RetryStrategies.LinearStrategy:
|
|
10
|
+
print("::: LinearStrategy :::")
|
|
11
|
+
elif retry_strategy == RetryStrategies.ExponentialStrategy:
|
|
12
|
+
print("::: ExponentialStrategy :::")
|
|
13
|
+
elif retry_strategy == RetryStrategies.CustomStrategy:
|
|
14
|
+
print("::: CustomStrategy :::")
|
|
15
|
+
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from api_to_dataframe.main import ClientBuilder
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import pandas as pd
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ClientBuilder:
|
|
6
|
-
def __init__(self, endpoint: str):
|
|
7
|
-
if endpoint == "":
|
|
8
|
-
raise ValueError("::: endpoint param is mandatory :::")
|
|
9
|
-
else:
|
|
10
|
-
self.endpoint = endpoint
|
|
11
|
-
|
|
12
|
-
def _response_to_json(self):
|
|
13
|
-
response = requests.get(self.endpoint)
|
|
14
|
-
|
|
15
|
-
if response.ok:
|
|
16
|
-
return response.json()
|
|
17
|
-
else:
|
|
18
|
-
raise ConnectionError(response.status_code)
|
|
19
|
-
|
|
20
|
-
def to_dataframe(self):
|
|
21
|
-
df = pd.DataFrame([self._response_to_json()])
|
|
22
|
-
return df
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/common/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{api_to_dataframe-0.1.0 → api_to_dataframe-1.0.0}/src/api_to_dataframe/controller/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|