-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'equinor/main' into missing-modules-erro…
…r-handling
- Loading branch information
Showing
72 changed files
with
859 additions
and
678 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
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
30 changes: 0 additions & 30 deletions
30
backend/src/backend/primary/routers/well_completion/router.py
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
backend/src/backend/primary/routers/well_completion/schemas.py
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
backend/src/backend/primary/routers/well_completions/router.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,29 @@ | ||
from typing import Optional | ||
|
||
from fastapi import APIRouter, Depends, HTTPException, Query | ||
|
||
from src.backend.auth.auth_helper import AuthHelper | ||
from src.services.utils.authenticated_user import AuthenticatedUser | ||
|
||
from src.services.sumo_access.well_completions_access import WellCompletionsAccess | ||
from src.services.sumo_access.well_completions_types import WellCompletionsData | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/well_completions_data/") | ||
def get_well_completions_data( | ||
# fmt:off | ||
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user), | ||
case_uuid: str = Query(description="Sumo case uuid"), | ||
ensemble_name: str = Query(description="Ensemble name"), | ||
realization: Optional[int] = Query(None, description="Optional realization to include. If not specified, all realizations will be returned."), | ||
# fmt:on | ||
) -> WellCompletionsData: | ||
access = WellCompletionsAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) | ||
well_completions_data = access.get_well_completions_data(realization=realization) | ||
|
||
if not well_completions_data: | ||
raise HTTPException(status_code=404, detail="Well completions data not found") | ||
|
||
return well_completions_data |
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,39 @@ | ||
import base64 | ||
from typing import Mapping | ||
|
||
# Using the same http client as sumo | ||
import httpx | ||
|
||
|
||
class GraphApiAccess: | ||
def __init__(self, access_token: str): | ||
self._access_token = access_token | ||
|
||
def _make_headers(self) -> Mapping[str, str]: | ||
return {"Authorization": f"Bearer {self._access_token}"} | ||
|
||
async def _request(self, url: str) -> httpx.Response: | ||
async with httpx.AsyncClient() as client: | ||
response = await client.get( | ||
url, | ||
headers=self._make_headers(), | ||
) | ||
return response | ||
|
||
async def get_user_profile_photo(self) -> str | None: | ||
print("entering get_user_profile_photo") | ||
response = await self._request("https://graph.microsoft.com/v1.0/me/photo/$value") | ||
|
||
if response.status_code == 200: | ||
return base64.b64encode(response.content).decode("utf-8") | ||
else: | ||
return None | ||
|
||
async def get_user_info(self) -> Mapping[str, str] | None: | ||
print("entering get_user_info") | ||
response = await self._request("https://graph.microsoft.com/v1.0/me") | ||
|
||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
return None |
70 changes: 0 additions & 70 deletions
70
backend/src/services/sumo_access/well_completion_access.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.