Skip to content

Commit

Permalink
[FIX] Fix update connection for Hybrid
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 1f88bb113296c35448b4b6a4dc31c88e9a1715ce
  • Loading branch information
mckornfield committed Sep 17, 2024
1 parent c2b0cfb commit 6bfccca
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/gretel_client/_hybrid/connections_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any, Optional, Union

from pydantic.v1 import StrictStr

Expand Down Expand Up @@ -45,15 +45,19 @@ def __init__(
self._creds_encryption = creds_encryption

def _encrypt_creds(
self, create_connection_request: CreateConnectionRequest
) -> CreateConnectionRequest:
if creds := create_connection_request.credentials:
create_connection_request.credentials = None
self,
connection_request: Union[CreateConnectionRequest, UpdateConnectionRequest],
) -> Union[CreateConnectionRequest, UpdateConnectionRequest]:
if creds := connection_request.credentials:
connection_request.credentials = None
project_id = None
if hasattr(connection_request, "project_id"):
project_id = connection_request.project_id
encrypted_creds = self._creds_encryption.apply(
creds, project_guid=create_connection_request.project_id
creds, project_guid=project_id
)
create_connection_request.encrypted_credentials = encrypted_creds
return create_connection_request
connection_request.encrypted_credentials = encrypted_creds
return connection_request

def create_connection(
self,
Expand All @@ -71,6 +75,17 @@ def create_connection_with_http_info(
create_connection_request, **kwargs
)

def update_connection(
self,
connection_id: str,
update_connection_request: UpdateConnectionRequest,
**kwargs,
) -> Connection:
update_connection_request = self._encrypt_creds(update_connection_request)
return super().update_connection(
connection_id, update_connection_request, **kwargs
)

def update_connection_with_http_info(
self,
connection_id: StrictStr,
Expand Down

0 comments on commit 6bfccca

Please sign in to comment.