diff --git a/pr_agent/identity_providers/__init__.py b/pr_agent/identity_providers/__init__.py new file mode 100644 index 00000000..6df37ecb --- /dev/null +++ b/pr_agent/identity_providers/__init__.py @@ -0,0 +1,13 @@ +from pr_agent.config_loader import get_settings +from pr_agent.identity_providers.default_identity_provider import DefaultIdentityProvider + +_IDENTITY_PROVIDERS = { + 'default': DefaultIdentityProvider +} + + +def get_identity_provider(): + identity_provider_id = get_settings().get("CONFIG.IDENTITY_PROVIDER", "default") + if identity_provider_id not in _IDENTITY_PROVIDERS: + raise ValueError(f"Unknown identity provider: {identity_provider_id}") + return _IDENTITY_PROVIDERS[identity_provider_id]() \ No newline at end of file diff --git a/pr_agent/identity_providers/default_identity_provider.py b/pr_agent/identity_providers/default_identity_provider.py new file mode 100644 index 00000000..c542e1c2 --- /dev/null +++ b/pr_agent/identity_providers/default_identity_provider.py @@ -0,0 +1,9 @@ +from pr_agent.identity_providers.identity_provider import Eligibility, IdentityProvider + + +class DefaultIdentityProvider(IdentityProvider): + def verify_eligibility(self, git_provider, git_provider_id, pr_url): + return Eligibility.ELIGIBLE + + def inc_invocation_count(self, git_provider, git_provider_id): + pass diff --git a/pr_agent/identity_providers/identity_provider.py b/pr_agent/identity_providers/identity_provider.py new file mode 100644 index 00000000..58e5f6c6 --- /dev/null +++ b/pr_agent/identity_providers/identity_provider.py @@ -0,0 +1,18 @@ +from abc import ABC, abstractmethod +from enum import Enum + + +class Eligibility(Enum): + NOT_ELIGIBLE = 0 + ELIGIBLE = 1 + TRIAL = 2 + + +class IdentityProvider(ABC): + @abstractmethod + def verify_eligibility(self, git_provider, git_provier_id, pr_url): + pass + + @abstractmethod + def inc_invocation_count(self, git_provider, git_provider_id): + pass