-
Notifications
You must be signed in to change notification settings - Fork 1
IEBH-353: Sync with the latest changes #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,36 @@ | ||
| name: HDC ci/cd pipeline | ||
|
|
||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| run_tests_hdc: | ||
| uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/run_tests.yml@main | ||
| with: | ||
| min_coverage_percent: 84 | ||
| secrets: inherit | ||
|
|
||
| build_and_publish_hdc: | ||
| needs: [run_tests_hdc] | ||
| uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/build_and_publish.yml@main | ||
| with: | ||
| matrix_config: '["bff-cli"]' | ||
| service_name: 'bff-cli' | ||
| secrets: inherit | ||
|
|
||
| deploy_hdc: | ||
| needs: [build_and_publish_hdc] | ||
| uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/trigger_deployment.yml@main | ||
| with: | ||
| hdc_service_name: 'bff-cli' | ||
| secrets: inherit |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,5 @@ | ||
| # Copyright (C) 2022-Present Indoc Systems | ||
| # | ||
| # Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE, | ||
| # Version 3.0 (the "License") available at https://www.gnu.org/licenses/agpl-3.0.en.html. | ||
| # You may not use this file except in compliance with the License. |
This file contains hidden or 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,41 @@ | ||
| # Copyright (C) 2022-Present Indoc Systems | ||
| # | ||
| # Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE, | ||
| # Version 3.0 (the "License") available at https://www.gnu.org/licenses/agpl-3.0.en.html. | ||
| # You may not use this file except in compliance with the License. | ||
|
|
||
| from typing import Annotated | ||
|
|
||
| from fastapi import Depends | ||
| from fastapi import Request | ||
|
|
||
| from app.components.request.http_client import HTTPClient | ||
| from app.config import SettingsDependency | ||
|
|
||
|
|
||
| class RequestContext: | ||
| def __init__(self, *, request: Request, client_timeout: int, allowed_headers: set[str] | None = None) -> None: | ||
| self.request = request | ||
|
|
||
| self.allowed_headers = allowed_headers or { | ||
| 'forwarded', | ||
| 'x-forwarded-for', | ||
| 'x-userinfo', | ||
| 'authorization', | ||
| 'session-id', | ||
| 'vm-info', | ||
| } | ||
| self.headers = {} | ||
|
|
||
| for key, value in self.request.headers.items(): | ||
| if key in self.allowed_headers: | ||
| self.headers[key] = value | ||
|
|
||
| self.client = HTTPClient(headers=self.headers, timeout=client_timeout) | ||
|
|
||
|
|
||
| def get_request_context(request: Request, settings: SettingsDependency) -> RequestContext: | ||
| return RequestContext(request=request, client_timeout=settings.SERVICE_CLIENT_TIMEOUT) | ||
|
|
||
|
|
||
| RequestContextDependency = Annotated[RequestContext, Depends(get_request_context)] | ||
This file contains hidden or 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,93 @@ | ||
| # Copyright (C) 2022-Present Indoc Systems | ||
| # | ||
| # Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE, | ||
| # Version 3.0 (the "License") available at https://www.gnu.org/licenses/agpl-3.0.en.html. | ||
| # You may not use this file except in compliance with the License. | ||
|
|
||
| from typing import Any | ||
|
|
||
| from httpx import URL | ||
| from httpx import AsyncClient | ||
| from httpx import Response | ||
| from httpx._types import HeaderTypes | ||
| from httpx._types import QueryParamTypes | ||
| from httpx._types import RequestContent | ||
| from httpx._types import RequestData | ||
| from httpx._types import TimeoutTypes | ||
vmoshynskyi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class HTTPClient: | ||
|
|
||
| def __init__(self, *, headers: HeaderTypes, timeout: TimeoutTypes) -> None: | ||
| self.headers = headers | ||
| self.timeout = timeout | ||
|
|
||
| @property | ||
| def client(self) -> AsyncClient: | ||
| return AsyncClient(headers=self.headers, timeout=self.timeout) | ||
vmoshynskyi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async def get( | ||
| self, | ||
| url: URL | str, | ||
| *, | ||
| params: QueryParamTypes | None = None, | ||
| headers: HeaderTypes | None = None, | ||
| ) -> Response: | ||
| async with self.client as client: | ||
| return await client.request('GET', url, params=params, headers=headers) | ||
|
|
||
| async def post( | ||
| self, | ||
| url: URL | str, | ||
| *, | ||
| content: RequestContent | None = None, | ||
| data: RequestData | None = None, | ||
| json: Any | None = None, | ||
| params: QueryParamTypes | None = None, | ||
| headers: HeaderTypes | None = None, | ||
| ) -> Response: | ||
| async with self.client as client: | ||
| return await client.request( | ||
| 'POST', url, content=content, data=data, json=json, params=params, headers=headers | ||
| ) | ||
|
|
||
| async def put( | ||
| self, | ||
| url: URL | str, | ||
| *, | ||
| content: RequestContent | None = None, | ||
| data: RequestData | None = None, | ||
| json: Any | None = None, | ||
| params: QueryParamTypes | None = None, | ||
| headers: HeaderTypes | None = None, | ||
| ) -> Response: | ||
| async with self.client as client: | ||
| return await client.request( | ||
| 'PUT', url, content=content, data=data, json=json, params=params, headers=headers | ||
| ) | ||
|
|
||
| async def patch( | ||
| self, | ||
| url: URL | str, | ||
| *, | ||
| content: RequestContent | None = None, | ||
| data: RequestData | None = None, | ||
| json: Any | None = None, | ||
| params: QueryParamTypes | None = None, | ||
| headers: HeaderTypes | None = None, | ||
| ) -> Response: | ||
| async with self.client as client: | ||
| return await client.request( | ||
| 'PATCH', url, content=content, data=data, json=json, params=params, headers=headers | ||
| ) | ||
|
|
||
| async def delete( | ||
| self, | ||
| url: URL | str, | ||
| *, | ||
| json: Any | None = None, | ||
| params: QueryParamTypes | None = None, | ||
| headers: HeaderTypes | None = None, | ||
| ) -> Response: | ||
| async with self.client as client: | ||
| return await client.request('DELETE', url, json=json, params=params, headers=headers) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.