-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41ad992
commit cebf0c3
Showing
4 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from fastapi import APIRouter | ||
from fastapi import HTTPException | ||
from fastapi import Security | ||
from loguru import logger | ||
|
||
from app.auth.utils import AuthHandler | ||
from app.connectors.shuffle.schema.integrations import IntegrationRequest | ||
from app.connectors.shuffle.services.integrations import execute_integration | ||
|
||
shuffle_integrations_router = APIRouter() | ||
|
||
@shuffle_integrations_router.post( | ||
"/execute", | ||
description="Execute a Shuffle Integration.", | ||
dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))], | ||
) | ||
async def execute_integration_route(request: IntegrationRequest): | ||
""" | ||
Execute a workflow. | ||
Args: | ||
request (IntegrationRequest): The request object containing the workflow ID. | ||
Returns: | ||
dict: The response containing the execution ID. | ||
""" | ||
logger.info("Executing workflow") | ||
return await execute_integration(request) |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Any | ||
from typing import Dict | ||
from typing import List | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
from pydantic import Field | ||
|
||
class IntegrationRequest(BaseModel): | ||
app_name: str = Field(..., description="The name of the application", example="PagerDuty") | ||
category: str = Field(..., description="The category of the application", example="cases") | ||
label: str = Field(..., description="The label of the application", example="create_ticket") | ||
fields: Optional[List[Dict[str, Any]]] = Field( | ||
[], | ||
description="The fields of the application", | ||
example=[ | ||
{"key": "title", "value": "This is the title"}, | ||
{"key": "description", "value": "This is the description"}, | ||
{"key": "source", "value": "Shuffle"}, | ||
], | ||
) | ||
skip_workflow: Optional[bool] = Field( | ||
False, | ||
description="Skip the workflow", | ||
example=True, | ||
) |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import asyncio | ||
from typing import List | ||
|
||
from fastapi import HTTPException | ||
from loguru import logger | ||
|
||
from app.connectors.shuffle.schema.integrations import IntegrationRequest | ||
from app.connectors.shuffle.utils.universal import send_get_request | ||
from app.connectors.shuffle.utils.universal import send_post_request | ||
|
||
|
||
async def execute_integration(request: IntegrationRequest) -> dict: | ||
""" | ||
Execute a workflow. | ||
Args: | ||
request (IntegrationRequest): The request object containing the workflow ID. | ||
Returns: | ||
dict: The response containing the execution ID. | ||
""" | ||
logger.info(f"Executing integration: {request}") | ||
response = await send_post_request("/api/v1/apps/categories/run", request.dict()) | ||
logger.info(f"Integration executed: {response}") |
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