forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from heydevs-io/feat/codelight-firecrawl-data-s…
…ource feat: implement custom add firecrawl datasource
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
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
37 changes: 37 additions & 0 deletions
37
api/controllers/codelight/internal_api/data_source_bearer_auth.py
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,37 @@ | ||
import uuid | ||
from flask_restful import Resource, reqparse | ||
|
||
from controllers.codelight import api | ||
from controllers.console.auth.error import ApiKeyAuthFailedError | ||
from services.auth.api_key_auth_service import ApiKeyAuthService | ||
from controllers.console.setup import setup_required | ||
from controllers.inner_api.wraps import inner_api_only | ||
|
||
|
||
class CodelightApiKeyAuthDataSourceBinding(Resource): | ||
@setup_required | ||
@inner_api_only | ||
def post(self, tenant_id: uuid.UUID): | ||
parser = reqparse.RequestParser() | ||
parser.add_argument( | ||
"category", type=str, required=True, nullable=False, location="json" | ||
) | ||
parser.add_argument( | ||
"provider", type=str, required=True, nullable=False, location="json" | ||
) | ||
parser.add_argument( | ||
"credentials", type=dict, required=True, nullable=False, location="json" | ||
) | ||
args = parser.parse_args() | ||
ApiKeyAuthService.validate_api_key_auth_args(args) | ||
|
||
try: | ||
ApiKeyAuthService.create_provider_auth(tenant_id, args) | ||
except Exception as e: | ||
raise ApiKeyAuthFailedError(str(e)) | ||
return {"result": "success"}, 200 | ||
|
||
|
||
api.add_resource( | ||
CodelightApiKeyAuthDataSourceBinding, "/tenants/<uuid:tenant_id>/data-sources" | ||
) |