cit-pydata 0.0.1.dev10__tar.gz → 0.0.2.dev2__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 (29) hide show
  1. {cit_pydata-0.0.1.dev10/src/cit_pydata.egg-info → cit_pydata-0.0.2.dev2}/PKG-INFO +2 -2
  2. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/pyproject.toml +2 -2
  3. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/aws/api.py +20 -2
  4. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/box/api.py +6 -17
  5. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sql/api.py +7 -7
  6. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/util/api.py +8 -2
  7. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2/src/cit_pydata.egg-info}/PKG-INFO +2 -2
  8. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/LICENSE +0 -0
  9. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/README.md +0 -0
  10. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/setup.cfg +0 -0
  11. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/__init__.py +0 -0
  12. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/aws/__init__.py +0 -0
  13. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/box/__init__.py +0 -0
  14. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/joblog/__init__.py +0 -0
  15. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/joblog/api.py +0 -0
  16. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/marketo/__init__.py +0 -0
  17. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/marketo/api.py +0 -0
  18. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/salesforce/__init__.py +0 -0
  19. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/salesforce/api.py +0 -0
  20. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sfsync/__init__.py +0 -0
  21. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sfsync/api.py +0 -0
  22. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sftp/__init__.py +0 -0
  23. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sftp/api.py +0 -0
  24. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/sql/__init__.py +0 -0
  25. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata/util/__init__.py +0 -0
  26. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata.egg-info/SOURCES.txt +0 -0
  27. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata.egg-info/dependency_links.txt +0 -0
  28. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata.egg-info/requires.txt +0 -0
  29. {cit_pydata-0.0.1.dev10 → cit_pydata-0.0.2.dev2}/src/cit_pydata.egg-info/top_level.txt +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cit-pydata
3
- Version: 0.0.1.dev10
3
+ Version: 0.0.2.dev2
4
4
  Summary: Python clients for commonly used api services including Salesforce, SQL, Marketo, Box, SFSync*, and JobLog*
5
- Author-email: Dionis Wang <dwang@eab.com>, Andrew Fitch <afitch@eab.com>
5
+ Author-email: Dionis Wang <dwang@eab.com>, Andrew Fitch <afitch@eab.com>, Dagim Desta <ddesta@eab.com>
6
6
  Project-URL: Homepage, https://github.com/EAB-IT-DEV/cit-pydata
7
7
  Project-URL: Issues, https://github.com/EAB-IT-DEV/cit-pydata/issues
8
8
  Classifier: Programming Language :: Python :: 3
@@ -4,9 +4,9 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cit-pydata"
7
- version = "0.0.1.dev10"
7
+ version = "0.0.2.dev2"
8
8
  authors = [
9
- { name="Dionis Wang", email="dwang@eab.com" },{ name="Andrew Fitch", email="afitch@eab.com" },
9
+ { name="Dionis Wang", email="dwang@eab.com" },{ name="Andrew Fitch", email="afitch@eab.com" },{ name="Dagim Desta", email="ddesta@eab.com" }
10
10
  ]
11
11
  description = "Python clients for commonly used api services including Salesforce, SQL, Marketo, Box, SFSync*, and JobLog*"
12
12
  readme = "README.md"
@@ -13,10 +13,19 @@ def _get_boto_session(
13
13
  iam_user: str = None,
14
14
  path_to_env_file: str = None,
15
15
  region: str = None,
16
- logger=util_api.get_logger(__name__, "info"),
16
+ logger=util_api.get_logger(__name__, "info")
17
17
  ):
18
+ if logger is None:
19
+ logger = util_api.get_logger(__name__, "info")
20
+
18
21
  if ON_AWS:
19
22
  return boto3.Session()
23
+
24
+ if not environment or not iam_user:
25
+ logger.error(
26
+ "environment and iam_user are required when not running on AWS"
27
+ )
28
+ return None
20
29
 
21
30
  _environment_variable = environment + "_" + iam_user + "_" + "aws_access_key_id"
22
31
  aws_access_key_id = util_api.get_environment_variable(
@@ -71,7 +80,8 @@ class S3Client:
71
80
  log_level: Literal["info", "debug"] = "info",
72
81
  ):
73
82
  self.logger = util_api.get_logger(__name__, log_level)
74
- environment = environment.lower()
83
+ if environment is not None:
84
+ environment = environment.lower()
75
85
 
76
86
  self.session = _get_boto_session(
77
87
  service="s3",
@@ -80,6 +90,10 @@ class S3Client:
80
90
  path_to_env_file=path_to_env_file,
81
91
  logger=self.logger,
82
92
  )
93
+ if self.session is None:
94
+ self.logger.error("Failed to initialize boto3 session")
95
+ self.client = None
96
+ return
83
97
  self.client = self.session.client("s3")
84
98
 
85
99
  def get_object_metadata(self, **kwargs):
@@ -150,6 +164,10 @@ class SSMClient:
150
164
  path_to_env_file=path_to_env_file,
151
165
  logger=self.logger,
152
166
  )
167
+ if self.session is None:
168
+ self.logger.error("Failed to initialize boto3 session")
169
+ self.client = None
170
+ return
153
171
  self.client = self.session.client("ssm")
154
172
 
155
173
  def get_parameter(
@@ -37,27 +37,16 @@ class BoxClient:
37
37
  if not self.client:
38
38
  self._get_client()
39
39
 
40
+ if filter_type not in ("file", "folder", None):
41
+ raise ValueError("filter_type must be 'file', 'folder', or None")
42
+
40
43
  item_id_dict = {}
41
44
  items = self.client.folder(folder_id=folder_id).get_items()
42
45
 
43
- assert filter_type in ["file", "folder", None]
44
- if filter_type == "file":
45
- for item in items:
46
- if item.type == filter_type:
47
- item_id_dict[item.id] = item
48
- elif filter_type == "folder":
49
- for item in items:
50
- if item.type == filter_type:
51
- item_id_dict[item.id] = item
52
- else:
53
- for item in items:
54
- item_id_dict[item.id] = item
55
-
56
46
  for item in items:
57
- if item.type == filter_type:
58
- item_id_dict[item.id] = {"name": item.name, "type": item.type}
59
- else:
60
- item_id_dict[item.id] = {"name": item.name, "type": item.type}
47
+ if filter_type is not None and item.type != filter_type:
48
+ continue
49
+ item_id_dict[item.id] = {"name": item.name, "type": item.type}
61
50
 
62
51
  return item_id_dict
63
52
 
@@ -33,7 +33,6 @@ class SQLClient:
33
33
 
34
34
  self.logger = util_api.get_logger(__name__, "INFO") if not logger else logger
35
35
 
36
- self.base_ssm_parameter_name = conn.get("base_ssm_parameter_name")
37
36
  self.sql_hostname = conn.get("sql_hostname", None)
38
37
  self.sql_instance = conn.get("sql_instance", None)
39
38
  self.sql_user = conn.get("sql_user", None)
@@ -59,8 +58,6 @@ class SQLClient:
59
58
  from urllib.parse import quote
60
59
 
61
60
  try:
62
- _aws_environment = None
63
- _aws_iam_user = None
64
61
  _aws_environment = util_api.get_environment_variable(
65
62
  logger=self.logger, variable_name="aws_auth_environment"
66
63
  )
@@ -76,9 +73,10 @@ class SQLClient:
76
73
  except Exception as e:
77
74
  self.logger.exception(e)
78
75
 
76
+ base_ssm_parameter_name = "/eab-pydata/sql/"
79
77
  if self.sql_instance:
80
78
  sql_password_parameter_name = (
81
- self.base_ssm_parameter_name
79
+ base_ssm_parameter_name
82
80
  + self.sql_hostname
83
81
  + "/"
84
82
  + self.sql_instance
@@ -87,7 +85,7 @@ class SQLClient:
87
85
  )
88
86
  else:
89
87
  sql_password_parameter_name = (
90
- self.base_ssm_parameter_name + self.sql_hostname + "/" + self.sql_user
88
+ base_ssm_parameter_name + self.sql_hostname + "/" + self.sql_user
91
89
  )
92
90
 
93
91
  sql_password = None
@@ -104,7 +102,7 @@ class SQLClient:
104
102
  self.logger.error(
105
103
  f"SQL authentication credential does not exist for server '{self.sql_hostname}' and user '{self.sql_user}'"
106
104
  )
107
- return
105
+ sys.exit(1)
108
106
 
109
107
  engine_connection_string = None
110
108
 
@@ -235,8 +233,10 @@ class SQLClient:
235
233
  self.logger.error(f"Query not supplied")
236
234
 
237
235
  return None
236
+
237
+ from typing import Generator
238
238
 
239
- def stream_dataframe_query(self, query: str, kwargs: dict) -> pd.DataFrame:
239
+ def stream_dataframe_query(self, query: str, kwargs: dict) -> Generator[pd.DataFrame, None, None]:
240
240
  """Returns Pandas DataFrame Iterator from SQL Query
241
241
  Arguments:
242
242
  query - A SQL Select statement
@@ -13,9 +13,12 @@ def encode_base64(value: str):
13
13
  """
14
14
  import base64
15
15
 
16
- binary_value = value.encode("ascii")
16
+ if value is None:
17
+ raise ValueError("value must not be None")
18
+ else:
19
+ binary_value = value.encode("ascii")
17
20
 
18
- return base64.b64encode(binary_value)
21
+ return base64.b64encode(binary_value).decode("ascii")
19
22
 
20
23
 
21
24
  def get_datetime_string():
@@ -125,6 +128,9 @@ def get_environment_variable(
125
128
  if not logger:
126
129
  logger = get_logger()
127
130
 
131
+ if not variable_name:
132
+ raise ValueError("variable_name must be provided")
133
+
128
134
  if ON_AWS and variable_name.startswith("aws"):
129
135
  logger.info(
130
136
  f"Detected on AWS. Skipping retrieval of AWS .env variable {variable_name}"
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cit-pydata
3
- Version: 0.0.1.dev10
3
+ Version: 0.0.2.dev2
4
4
  Summary: Python clients for commonly used api services including Salesforce, SQL, Marketo, Box, SFSync*, and JobLog*
5
- Author-email: Dionis Wang <dwang@eab.com>, Andrew Fitch <afitch@eab.com>
5
+ Author-email: Dionis Wang <dwang@eab.com>, Andrew Fitch <afitch@eab.com>, Dagim Desta <ddesta@eab.com>
6
6
  Project-URL: Homepage, https://github.com/EAB-IT-DEV/cit-pydata
7
7
  Project-URL: Issues, https://github.com/EAB-IT-DEV/cit-pydata/issues
8
8
  Classifier: Programming Language :: Python :: 3