fivetran-connector-sdk 0.7.18.1__py3-none-any.whl → 0.7.23.1__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.
@@ -13,6 +13,7 @@ import traceback
13
13
 
14
14
  from concurrent import futures
15
15
  from datetime import datetime
16
+ from enum import Enum
16
17
  from google.protobuf import timestamp_pb2
17
18
  from zipfile import ZipFile, ZIP_DEFLATED
18
19
 
@@ -38,24 +39,40 @@ TABLES = {}
38
39
 
39
40
 
40
41
  class Logging:
42
+ class Level(Enum):
43
+ FINE = 1
44
+ INFO = 2
45
+ WARNING = 3
46
+ SEVERE = 4
47
+
48
+ LOG_LEVEL = None
49
+
41
50
  @staticmethod
42
- def __log(level: str, message: str):
51
+ def __log(level: Level, message: str):
43
52
  if DEBUGGING:
44
53
  print(message)
45
54
  else:
46
55
  print(f'{{"level":"{level}", "message": "{message}", "message-origin": "connector_sdk"}}')
47
56
 
57
+ @staticmethod
58
+ def fine(message: str):
59
+ if DEBUGGING and Logging.LOG_LEVEL == Logging.Level.FINE:
60
+ Logging.__log(Logging.Level.FINE, message)
61
+
48
62
  @staticmethod
49
63
  def info(message: str):
50
- Logging.__log("INFO", message)
64
+ if Logging.LOG_LEVEL == Logging.Level.INFO:
65
+ Logging.__log(Logging.Level.INFO, message)
51
66
 
52
67
  @staticmethod
53
68
  def warning(message: str):
54
- Logging.__log("WARNING", message)
69
+ if Logging.LOG_LEVEL == Logging.Level.WARNING:
70
+ Logging.__log(Logging.Level.WARNING, message)
55
71
 
56
72
  @staticmethod
57
73
  def severe(message: str):
58
- Logging.__log("SEVERE", message)
74
+ if Logging.LOG_LEVEL == Logging.Level.SEVERE:
75
+ Logging.__log(Logging.Level.SEVERE, message)
59
76
 
60
77
 
61
78
  class Operations:
@@ -295,8 +312,9 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
295
312
  _check_dict(configuration)
296
313
 
297
314
  secrets_list = []
298
- for k, v in configuration.items():
299
- secrets_list.append({"key": k, "value": v})
315
+ if configuration:
316
+ for k, v in configuration.items():
317
+ secrets_list.append({"key": k, "value": v})
300
318
 
301
319
  connection_config = {
302
320
  "schema": connection,
@@ -333,6 +351,9 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
333
351
 
334
352
  @staticmethod
335
353
  def __update_connection(id: str, name: str, group: str, config: dict, deploy_key: str):
354
+ if not config["secrets_list"]:
355
+ del config["secrets_list"]
356
+
336
357
  resp = rq.patch(f"https://api.fivetran.com/v1/connectors/{id}",
337
358
  headers={"Authorization": f"Basic {deploy_key}"},
338
359
  json={
@@ -461,9 +482,14 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
461
482
  os._exit(1)
462
483
 
463
484
  # Call this method to run the connector in production
464
- def run(self, port: int = 50051, configuration: dict = None, state: dict = None) -> grpc.Server:
485
+ def run(self,
486
+ port: int = 50051,
487
+ configuration: dict = None,
488
+ state: dict = None,
489
+ log_level: Logging.Level = Logging.Level.INFO) -> grpc.Server:
465
490
  self.configuration = _check_dict(configuration, True)
466
491
  self.state = _check_dict(state)
492
+ Logging.LOG_LEVEL = log_level
467
493
 
468
494
  server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
469
495
  connector_sdk_pb2_grpc.add_ConnectorServicer_to_server(self, server)
@@ -475,10 +501,16 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
475
501
  server.wait_for_termination()
476
502
 
477
503
  # This method starts both the server and the local testing environment
478
- def debug(self, project_path: str = None, port: int = 50051, configuration: dict = None, state: dict = None) -> bool:
504
+ def debug(self,
505
+ project_path: str = None,
506
+ port: int = 50051,
507
+ configuration: dict = None,
508
+ state: dict = None,
509
+ log_level: Logging.Level = Logging.Level.FINE) -> bool:
479
510
  global DEBUGGING
480
511
  DEBUGGING = True
481
512
 
513
+ Logging.LOG_LEVEL = log_level
482
514
  os_name = self.__get_os_name()
483
515
  tester_root_dir = os.path.join(os.path.expanduser("~"), ROOT_LOCATION)
484
516
  java_exe = self.__java_exe(tester_root_dir, os_name)
@@ -531,7 +563,7 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
531
563
 
532
564
  project_path = os.getcwd() if project_path is None else project_path
533
565
  print(f"Debugging connector at: {project_path}")
534
- server = self.run(port, configuration, state)
566
+ server = self.run(port, configuration, state, log_level=log_level)
535
567
 
536
568
  # Uncomment this to run the tester manually
537
569
  #server.wait_for_termination()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fivetran_connector_sdk
3
- Version: 0.7.18.1
3
+ Version: 0.7.23.1
4
4
  Summary: Build custom connectors on Fivetran platform
5
5
  Author-email: Fivetran <developers@fivetran.com>
6
6
  Project-URL: Homepage, https://fivetran.com/docs/connectors/connector-sdk
@@ -1,4 +1,4 @@
1
- fivetran_connector_sdk/__init__.py,sha256=IIdg6sogef87he8tij10qYJAG9n4S9EJIfJSZoBILQg,32422
1
+ fivetran_connector_sdk/__init__.py,sha256=M__-L8nT-NIHEFVRXLpz3LBQVZgImyN_luVhX2zJQfs,33364
2
2
  fivetran_connector_sdk/protos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  fivetran_connector_sdk/protos/common_pb2.py,sha256=kUwVcyZHgLigNR-KnHZn7dHrlxaMnUXqzprsRx6T72M,6831
4
4
  fivetran_connector_sdk/protos/common_pb2.pyi,sha256=S0hdIzoXyyOKD5cjiGeDDLYpQ9J3LjAvu4rCj1JvJWE,9038
@@ -6,9 +6,9 @@ fivetran_connector_sdk/protos/common_pb2_grpc.py,sha256=1oboBPFxaTEXt9Aw7EAj8gXH
6
6
  fivetran_connector_sdk/protos/connector_sdk_pb2.py,sha256=9Ke_Ti1s0vAeXapfXT-EryrT2-TSGQb8mhs4gxTpUMk,7732
7
7
  fivetran_connector_sdk/protos/connector_sdk_pb2.pyi,sha256=FWYxRgshEF3QDYAE0TM_mv4N2gGvkxCH_uPpxnMc4oA,8406
8
8
  fivetran_connector_sdk/protos/connector_sdk_pb2_grpc.py,sha256=ZfJLp4DW7uP4pFOZ74s_wQ6tD3eIPi-08UfnLwe4tzo,7163
9
- fivetran_connector_sdk-0.7.18.1.dist-info/LICENSE,sha256=Kutp3D0T7HmHuBifKmbw39OZLAL1ckaLRb8u9lyJxE8,1065
10
- fivetran_connector_sdk-0.7.18.1.dist-info/METADATA,sha256=vgrh9es8KnNBY2Z9_3PpV_XD0e3ZNj4TZyp1BBRxkiE,651
11
- fivetran_connector_sdk-0.7.18.1.dist-info/WHEEL,sha256=FZ75kcLy9M91ncbIgG8dnpCncbiKXSRGJ_PFILs6SFg,91
12
- fivetran_connector_sdk-0.7.18.1.dist-info/entry_points.txt,sha256=uQn0KPnFlQmXJfxlk0tifdNsSXWfVlnAFzNqjXZM_xM,57
13
- fivetran_connector_sdk-0.7.18.1.dist-info/top_level.txt,sha256=-_xk2MFY4psIh7jw1lJePMzFb5-vask8_ZtX-UzYWUI,23
14
- fivetran_connector_sdk-0.7.18.1.dist-info/RECORD,,
9
+ fivetran_connector_sdk-0.7.23.1.dist-info/LICENSE,sha256=Kutp3D0T7HmHuBifKmbw39OZLAL1ckaLRb8u9lyJxE8,1065
10
+ fivetran_connector_sdk-0.7.23.1.dist-info/METADATA,sha256=7SdSujAanafdTc4v-lCwGY7-BMkVibhq8snqcs7mOIc,651
11
+ fivetran_connector_sdk-0.7.23.1.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
12
+ fivetran_connector_sdk-0.7.23.1.dist-info/entry_points.txt,sha256=uQn0KPnFlQmXJfxlk0tifdNsSXWfVlnAFzNqjXZM_xM,57
13
+ fivetran_connector_sdk-0.7.23.1.dist-info/top_level.txt,sha256=-_xk2MFY4psIh7jw1lJePMzFb5-vask8_ZtX-UzYWUI,23
14
+ fivetran_connector_sdk-0.7.23.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.0.1)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5