Skip to content
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

Add default internal networks for each service #639

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- Enable internal network names for each service [#638](https://github.com/IN-CORE/pyincore/issues/638)


## [1.20.1] - 2024-11-01

### Fixed
Expand Down
27 changes: 21 additions & 6 deletions pyincore/dataservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,27 @@ class DataService:

def __init__(self, client: IncoreClient):
self.client = client
self.base_url = urljoin(client.service_url, "data/api/datasets/")
self.files_url = urljoin(client.service_url, "data/api/files/")
self.base_earthquake_url = urljoin(
client.service_url, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(client.service_url, "hazard/api/tornadoes/")

if self.client.internal:
longshuicy marked this conversation as resolved.
Show resolved Hide resolved
self.base_url = urljoin(
pyglobals.INCORE_INTERNAL_DATA_API_URL, "data/api/datasets/"
)
self.base_earthquake_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/tornadoes/"
)
self.files_url = urljoin(
pyglobals.INCORE_INTERNAL_DATA_API_URL, "data/api/files/"
)
else:
self.base_url = urljoin(client.service_url, "data/api/datasets/")
self.base_earthquake_url = urljoin(
client.service_url, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(client.service_url, "hazard/api/tornadoes/")
self.files_url = urljoin(client.service_url, "data/api/files/")

@forbid_offline
def get_dataset_metadata(self, dataset_id: str, timeout=(30, 600), **kwargs):
Expand Down
7 changes: 6 additions & 1 deletion pyincore/dfr3service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ class Dfr3Service:

def __init__(self, client: IncoreClient):
self.client = client
self.base_mapping_url = urljoin(client.service_url, "dfr3/api/mappings/")
if self.client.internal:
self.base_mapping_url = urljoin(
pyglobals.INCORE_INTERNAL_DFR3_API_URL, "dfr3/api/mappings/"
)
else:
self.base_mapping_url = urljoin(client.service_url, "dfr3/api/mappings/")

@forbid_offline
def get_dfr3_set(self, dfr3_id: str, timeout=(30, 600), **kwargs):
Expand Down
12 changes: 9 additions & 3 deletions pyincore/fragilityservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pyincore.decorators import forbid_offline
from pyincore.dfr3service import Dfr3Service
from pyincore.utils import return_http_response
import pyincore.globals as pyglobals


class FragilityService(Dfr3Service):
Expand All @@ -23,9 +24,14 @@ class FragilityService(Dfr3Service):

def __init__(self, client: IncoreClient):
self.client = client
self.base_dfr3_url = urllib.parse.urljoin(
client.service_url, "dfr3/api/fragilities/"
)
if self.client.internal:
self.base_dfr3_url = urllib.parse.urljoin(
pyglobals.INCORE_INTERNAL_DFR3_API_URL, "dfr3/api/fragilities/"
)
else:
self.base_dfr3_url = urllib.parse.urljoin(
client.service_url, "dfr3/api/fragilities/"
)

super(FragilityService, self).__init__(client)

Expand Down
6 changes: 6 additions & 0 deletions pyincore/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
INCORE_API_DEV_URL = "https://incore-dev.ncsa.illinois.edu"

INCORE_INTERNAL_API_URL = "http://localhost:8080"
INCORE_INTERNAL_DFR3_API_URL = "http://incore-svc-dfr3:8888"
INCORE_INTERNAL_DATA_API_URL = "http://incore-svc-data:8888"
INCORE_INTERNAL_HAZARD_API_URL = "http://incore-svc-hazard:8888"
INCORE_INTERNAL_SEMANTIC_API_URL = "http://incore-svc-sema:8888"
INCORE_INTERNAL_SPACE_API_URL = "http://incore-svc-space:8888"
INCORE_INTERNAL_PROJECT_API_URL = "http://incore-svc-project:8888"

KEYCLOAK_AUTH_PATH = "/auth/realms/In-core/protocol/openid-connect/token"
KEYCLOAK_USERINFO_PATH = "/auth/realms/In-core/protocol/openid-connect/userinfo"
Expand Down
43 changes: 33 additions & 10 deletions pyincore/hazardservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,39 @@ class HazardService:
def __init__(self, client: IncoreClient):
self.client = client

self.base_earthquake_url = urljoin(
client.service_url, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(client.service_url, "hazard/api/tornadoes/")
self.base_tsunami_url = urljoin(client.service_url, "hazard/api/tsunamis/")
self.base_hurricane_url = urljoin(client.service_url, "hazard/api/hurricanes/")
self.base_hurricanewf_url = urljoin(
client.service_url, "hazard/api/hurricaneWindfields/"
)
self.base_flood_url = urljoin(client.service_url, "hazard/api/floods/")
if self.client.internal:
self.base_earthquake_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/tornadoes/"
)
self.base_tsunami_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/tsunamis/"
)
self.base_hurricane_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/hurricanes/"
)
self.base_hurricanewf_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL,
"hazard/api/hurricaneWindfields/",
)
self.base_flood_url = urljoin(
pyglobals.INCORE_INTERNAL_HAZARD_API_URL, "hazard/api/floods/"
)
else:
self.base_earthquake_url = urljoin(
client.service_url, "hazard/api/earthquakes/"
)
self.base_tornado_url = urljoin(client.service_url, "hazard/api/tornadoes/")
self.base_tsunami_url = urljoin(client.service_url, "hazard/api/tsunamis/")
self.base_hurricane_url = urljoin(
client.service_url, "hazard/api/hurricanes/"
)
self.base_hurricanewf_url = urljoin(
client.service_url, "hazard/api/hurricaneWindfields/"
)
self.base_flood_url = urljoin(client.service_url, "hazard/api/floods/")

@forbid_offline
def get_earthquake_hazard_metadata_list(
Expand Down
12 changes: 9 additions & 3 deletions pyincore/repairservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pyincore import IncoreClient
from pyincore.decorators import forbid_offline
from pyincore.dfr3service import Dfr3Service
import pyincore.globals as pyglobals


class RepairService(Dfr3Service):
Expand All @@ -22,9 +23,14 @@ class RepairService(Dfr3Service):

def __init__(self, client: IncoreClient):
self.client = client
self.base_dfr3_url = urllib.parse.urljoin(
client.service_url, "dfr3/api/repairs/"
)
if self.client.internal:
self.base_dfr3_url = urllib.parse.urljoin(
pyglobals.INCORE_INTERNAL_DFR3_API_URL, "dfr3/api/repairs/"
)
else:
self.base_dfr3_url = urllib.parse.urljoin(
client.service_url, "dfr3/api/repairs/"
)

super(RepairService, self).__init__(client)

Expand Down
8 changes: 7 additions & 1 deletion pyincore/restorationservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyincore.decorators import forbid_offline
from pyincore.dfr3service import Dfr3Service
from pyincore.utils import return_http_response
import pyincore.globals as pyglobals


class RestorationService(Dfr3Service):
Expand All @@ -21,7 +22,12 @@ class RestorationService(Dfr3Service):

def __init__(self, client: IncoreClient):
self.client = client
self.base_dfr3_url = urljoin(client.service_url, "dfr3/api/restorations/")
if self.client.internal:
self.base_dfr3_url = urljoin(
pyglobals.INCORE_INTERNAL_DFR3_API_URL, "dfr3/api/restorations/"
)
else:
self.base_dfr3_url = urljoin(client.service_url, "dfr3/api/restorations/")

super(RestorationService, self).__init__(client)

Expand Down
7 changes: 6 additions & 1 deletion pyincore/semanticservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class SemanticService:

def __init__(self, client: IncoreClient):
self.client = client
self.base_url = urljoin(client.service_url, "semantics/api/types")
if self.client.internal:
self.base_url = urljoin(
pyglobals.INCORE_INTERNAL_SEMANTIC_API_URL, "semantics/api/types"
)
else:
self.base_url = urljoin(client.service_url, "semantics/api/types")

@forbid_offline
def get_all_semantic_types(
Expand Down
7 changes: 6 additions & 1 deletion pyincore/spaceservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ class SpaceService:

def __init__(self, client: IncoreClient):
self.client = client
self.base_space_url = urljoin(client.service_url, "space/api/spaces/")
if self.client.internal:
self.base_space_url = urljoin(
pyglobals.INCORE_INTERNAL_SPACE_API_URL, "space/api/spaces/"
)
else:
self.base_space_url = urljoin(client.service_url, "space/api/spaces/")

@forbid_offline
def create_space(self, space_json, timeout=(30, 600), **kwargs):
Expand Down
Loading