-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented retrieval of integrations
- Loading branch information
1 parent
95f315c
commit a14dca3
Showing
19 changed files
with
344 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: "3.4" | ||
|
||
services: | ||
|
||
postgres: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
import json | ||
import uuid | ||
from enum import Enum | ||
from typing import Union | ||
|
||
from apps.integrations.db.schemas import IntegrationsSchema | ||
from apps.integrations.loris.domain.loris_integrations import LorisIntegration | ||
from apps.shared.domain import InternalModel | ||
|
||
|
||
class AvailableIntegrations(str, Enum): | ||
LORIS = "LORIS" | ||
FUTURE = "FUTURE" | ||
|
||
|
||
class FutureIntegration(InternalModel): | ||
endpoint: str | ||
api_key: str | ||
|
||
@classmethod | ||
def from_schema(cls, schema: IntegrationsSchema): | ||
new_future_integration_dict = json.loads(schema.configuration.replace("'", '"')) | ||
new_future_integration_dict["api_key"] = "*****" | ||
|
||
new_future_integration = cls( | ||
endpoint=new_future_integration_dict["endpoint"], | ||
api_key=new_future_integration_dict["api_key"], | ||
) | ||
return new_future_integration | ||
|
||
|
||
class Integration(InternalModel): | ||
integration_type: AvailableIntegrations | ||
|
||
|
||
class NewIntegration(InternalModel): | ||
integration_type: AvailableIntegrations | ||
applet_id: uuid.UUID | ||
configuration: Union[LorisIntegration, FutureIntegration] | ||
|
||
@classmethod | ||
def from_schema(cls, schema: IntegrationsSchema): | ||
new_integration = cls( | ||
applet_id=schema.applet_id, integration_type=schema.type, configuration=schema.configuration | ||
) | ||
return new_integration | ||
|
||
|
||
class IntegrationFilter(InternalModel): | ||
integration_types: list[AvailableIntegrations] | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
import uuid | ||
import json | ||
|
||
from apps.integrations.db.schemas import IntegrationsSchema | ||
from apps.integrations.domain import AvailableIntegrations | ||
from apps.shared.domain import InternalModel | ||
|
||
|
||
class IntegrationMeta(InternalModel): | ||
class LorisIntegration(InternalModel): | ||
hostname: str | ||
username: str | ||
password: str | ||
project: str | None | ||
|
||
|
||
class Integrations(InternalModel): | ||
applet_id: uuid.UUID | ||
type: AvailableIntegrations | ||
configuration: IntegrationMeta | ||
project: str | ||
|
||
@classmethod | ||
def from_schema(cls, schema: IntegrationsSchema): | ||
return cls(applet_id=schema.applet_id, type=schema.type, configuration=schema.configuration) | ||
|
||
|
||
class IntegrationsCreate(InternalModel): | ||
applet_id: uuid.UUID | ||
hostname: str | ||
username: str | ||
password: str | ||
new_loris_integration_dict = json.loads(schema.configuration.replace("'", '"')) | ||
new_loris_integration_dict["password"] = "*****" | ||
|
||
new_loris_integration = cls( | ||
hostname=new_loris_integration_dict["hostname"], | ||
username=new_loris_integration_dict["username"], | ||
password=new_loris_integration_dict["password"], | ||
project=new_loris_integration_dict["project"], | ||
) | ||
return new_loris_integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.