Skip to content

Commit

Permalink
fix(vdp): fix create/update connection input parameters (#230)
Browse files Browse the repository at this point in the history
Because

- protobuf definition types for connection should be encapsulated for
better DX

This commit

- encapsulate protobuf definition types for connection
  • Loading branch information
joremysh authored Oct 14, 2024
1 parent 033ca6c commit f3d0bec
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions instill/clients/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,9 +1408,40 @@ def get_connection(
@grpc_handler
def create_connection(
self,
connection: integration_interface.Connection,
namespace_id: str,
integration_id: str,
connection_id: str,
scopes: Optional[List[str]] = None,
identity: Optional[str] = None,
setup: Optional[dict] = None,
o_auth_access_details: Optional[dict] = None,
is_oauth: bool = False,
async_enabled: bool = False,
) -> integration_interface.CreateNamespaceConnectionResponse:
if scopes is None:
scopes = []
connection = integration_interface.Connection(
namespace_id=namespace_id,
integration_id=integration_id,
id=connection_id,
identity=identity,
scopes=scopes,
)

if setup is None:
setup = {}
connection.setup.update(setup)
if o_auth_access_details is None:
o_auth_access_details = {}
connection.o_auth_access_details.update(o_auth_access_details)

if is_oauth:
connection.method = integration_interface.Connection.Method.METHOD_OAUTH
else:
connection.method = (
integration_interface.Connection.Method.METHOD_DICTIONARY
)

if async_enabled:
return RequestFactory(
method=self.host.async_client.CreateNamespaceConnection,
Expand All @@ -1431,9 +1462,40 @@ def create_connection(
@grpc_handler
def update_connection(
self,
connection: integration_interface.Connection,
namespace_id: str,
integration_id: str,
connection_id: str,
scopes: Optional[List[str]] = None,
identity: Optional[str] = None,
setup: Optional[dict] = None,
o_auth_access_details: Optional[dict] = None,
is_oauth: bool = False,
async_enabled: bool = False,
) -> integration_interface.UpdateNamespaceConnectionResponse:
if scopes is None:
scopes = []
connection = integration_interface.Connection(
namespace_id=namespace_id,
integration_id=integration_id,
id=connection_id,
scopes=scopes,
identity=identity,
)

if setup is None:
setup = {}
connection.setup.update(setup)
if o_auth_access_details is None:
o_auth_access_details = {}
connection.o_auth_access_details.update(o_auth_access_details)

if is_oauth:
connection.method = integration_interface.Connection.Method.METHOD_OAUTH
else:
connection.method = (
integration_interface.Connection.Method.METHOD_DICTIONARY
)

if async_enabled:
return RequestFactory(
method=self.host.async_client.UpdateNamespaceConnection,
Expand Down

0 comments on commit f3d0bec

Please sign in to comment.