mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 03:40:38 +08:00
Identity provider
This commit is contained in:
13
pr_agent/identity_providers/__init__.py
Normal file
13
pr_agent/identity_providers/__init__.py
Normal file
@ -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]()
|
9
pr_agent/identity_providers/default_identity_provider.py
Normal file
9
pr_agent/identity_providers/default_identity_provider.py
Normal file
@ -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
|
18
pr_agent/identity_providers/identity_provider.py
Normal file
18
pr_agent/identity_providers/identity_provider.py
Normal file
@ -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
|
Reference in New Issue
Block a user