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

adding vcap_services class from frontend #89

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 30 additions & 0 deletions fsd_utils/toggles/vcap_services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import json
from dataclasses import dataclass


@dataclass
class VcapServices(object):

services: dict

@staticmethod
def from_env_json(json_string: str):
json_dict = dict(json.loads(json_string))
vcap_services = VcapServices(services=json_dict)
return vcap_services

def does_service_exist(self, service_key: str) -> bool:
return service_key in self.services.keys()

def get_service_by_name(self, group_key: str, name: str) -> dict:
service_group = self.services.get(group_key)
if service_group:
for service in service_group:
if service.get("name") == name:
return service
raise Exception(f"Service name '{name}' not found")
raise Exception(f"Service group '{group_key}' not found")

def get_service_credentials_value(self, group_key: str, name: str, key: str):
service = self.get_service_by_name(group_key, name)
return service.get("credentials").get(key)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "funding-service-design-utils"
version = "2.0.10"
version = "2.0.11"
authors = [
{ name="DLUHC", email="[email protected]" },
]
Expand Down