diff --git a/open_feature/open_feature_api.py b/open_feature/open_feature_api.py index b86e6f43..e3e4a341 100644 --- a/open_feature/open_feature_api.py +++ b/open_feature/open_feature_api.py @@ -2,6 +2,7 @@ from open_feature.exception.exceptions import GeneralError from open_feature.open_feature_client import OpenFeatureClient +from open_feature.provider.metadata import Metadata from open_feature.provider.no_op_provider import NoOpProvider from open_feature.provider.provider import AbstractProvider @@ -24,3 +25,8 @@ def set_provider(provider: AbstractProvider): def get_provider() -> typing.Optional[AbstractProvider]: global _provider return _provider + + +def get_provider_metadata() -> typing.Optional[Metadata]: + global _provider + return _provider.get_metadata() diff --git a/tests/test_open_feature_api.py b/tests/test_open_feature_api.py index 5926ba4a..af523c20 100644 --- a/tests/test_open_feature_api.py +++ b/tests/test_open_feature_api.py @@ -2,7 +2,13 @@ from open_feature.exception.error_code import ErrorCode from open_feature.exception.exceptions import GeneralError -from open_feature.open_feature_api import get_client, get_provider, set_provider +from open_feature.open_feature_api import ( + get_client, + get_provider, + set_provider, + get_provider_metadata, +) +from open_feature.provider.metadata import Metadata from open_feature.provider.no_op_provider import NoOpProvider @@ -52,3 +58,15 @@ def test_should_return_a_provider_if_setup_correctly(): # Then assert provider assert isinstance(provider, NoOpProvider) + + +def test_should_retrieve_metadata_for_configured_provider(): + # Given + set_provider(NoOpProvider()) + + # When + metadata = get_provider_metadata() + + # Then + assert isinstance(metadata, Metadata) + assert metadata.name == "No-op Provider"