Skip to content

Commit

Permalink
Merge pull request #10 from PADAS/v0.5.x
Browse files Browse the repository at this point in the history
Adding get_bridge function
  • Loading branch information
chrisdoehring committed May 7, 2021
2 parents ead5b36 + 213da2b commit 95f9c43
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cdip_connector/core/cdip_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@

OAUTH_TOKEN_URL = f'{KEYCLOAK_ISSUER}/protocol/openid-connect/token'
PORTAL_API_ENDPOINT = f'{CDIP_ADMIN_ENDPOINT}/api/v1.0'
PORTAL_API_INBOUND_INTEGRATIONS_ENDPOINT = f'{PORTAL_API_ENDPOINT}/integrations/inbound/configurations'
PORTAL_API_DEVICES_ENDPOINT = f'{PORTAL_API_ENDPOINT}/devices/states'
# PORTAL_API_INBOUND_INTEGRATIONS_ENDPOINT = f'{PORTAL_API_ENDPOINT}/integrations/inbound/configurations'
15 changes: 13 additions & 2 deletions cdip_connector/core/portal_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class PortalApi:
def __init__(self):
self.client_id = cdip_settings.KEYCLOAK_CLIENT_ID
self.client_secret = cdip_settings.KEYCLOAK_CLIENT_SECRET
self.integrations_endpoint = cdip_settings.PORTAL_API_INBOUND_INTEGRATIONS_ENDPOINT
self.integrations_endpoint = f'{cdip_settings.PORTAL_API_ENDPOINT}/integrations/inbound/configurations'
self.device_states_endpoint = f'{cdip_settings.PORTAL_API_ENDPOINT}/devices/states'

self.oauth_token_url = cdip_settings.OAUTH_TOKEN_URL
self.audience = cdip_settings.KEYCLOAK_AUDIENCE
self.portal_api_endpoint = cdip_settings.PORTAL_API_ENDPOINT

self.cached_token = None
self.cached_token_expires_at = datetime.min.replace(tzinfo=pytz.utc)
Expand Down Expand Up @@ -134,11 +137,19 @@ async def update_states_with_dict(self,
inbound_id: UUID,
states_dict: Dict[str, Any]):
headers = await self.get_auth_header(session)
response = await session.post(url=f'{cdip_settings.PORTAL_API_DEVICES_ENDPOINT}/update/{inbound_id}',
response = await session.post(url=f'{self.device_states_endpoint}/update/{inbound_id}',
headers=headers,
json=states_dict)
response.raise_for_status()
text = await response.text()
logger.info(f'update device_states resp: {response.status}')
return text

async def get_bridge_integration(self, session: ClientSession, bridge_id: str):

headers = await self.get_auth_header(session)
response = await session.get(url=f'{cdip_settings.PORTAL_API_ENDPOINT}/integrations/bridges/{bridge_id}',
headers=headers,
json=states_dict)
response.raise_for_status()
return await response.json()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cdip_connector"
version = "0.5.5"
version = "0.5.6"
description = "SMART Integrate Connector Library"
authors = [
"Rohit Chaudhri <rohitc@vulcan.com>",
Expand Down

0 comments on commit 95f9c43

Please sign in to comment.