Skip to content

Commit

Permalink
Remove ProviderName enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Nov 19, 2024
1 parent 9e16e74 commit 1f30369
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 19 deletions.
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/blocks/github/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class Output(GitHubTriggerBase.Output):
)

def __init__(self):
from backend.integrations.providers import ProviderName
from backend.integrations.webhooks.github import GithubWebhookType

example_payload = json.loads(self.EXAMPLE_PAYLOAD_FILE.read_text())
Expand All @@ -111,7 +110,7 @@ def __init__(self):
output_schema=GithubPullRequestTriggerBlock.Output,
# --8<-- [start:example-webhook_config]
webhook_config=BlockWebhookConfig(
provider=ProviderName.GITHUB,
provider="github",
webhook_type=GithubWebhookType.REPO,
resource_format="{repo}",
event_filter_input="events",
Expand Down
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/data/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from prisma.models import AgentBlock
from pydantic import BaseModel

from backend.integrations.providers import ProviderName
from backend.util import json

from .model import CREDENTIALS_FIELD_NAME, ContributorDetails, CredentialsMetaInput
Expand Down Expand Up @@ -189,7 +188,7 @@ class EmptySchema(BlockSchema):

# --8<-- [start:BlockWebhookConfig]
class BlockWebhookConfig(BaseModel):
provider: ProviderName
provider: str
"""The service provider that the webhook connects to"""

webhook_type: str
Expand Down
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/data/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from backend.data.includes import INTEGRATION_WEBHOOK_INCLUDE
from backend.data.queue import AsyncRedisEventBus
from backend.integrations.providers import ProviderName

from .db import BaseDbModel

Expand Down Expand Up @@ -123,7 +122,7 @@ async def delete_webhook(webhook_id: str) -> None:


class WebhookEvent(BaseDbModel):
provider: ProviderName
provider: str
webhook_id: str
event_type: str
payload: dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from .github import GithubWebhooksManager

if TYPE_CHECKING:
from ..providers import ProviderName
from .base import BaseWebhooksManager

# --8<-- [start:WEBHOOK_MANAGERS_BY_NAME]
WEBHOOK_MANAGERS_BY_NAME: dict["ProviderName", type["BaseWebhooksManager"]] = {
WEBHOOK_MANAGERS_BY_NAME: dict[str, type["BaseWebhooksManager"]] = {
handler.PROVIDER_NAME: handler
for handler in [
GithubWebhooksManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from strenum import StrEnum

from backend.data import integrations
from backend.integrations.providers import ProviderName
from backend.util.settings import Config

logger = logging.getLogger(__name__)
Expand All @@ -20,7 +19,7 @@

class BaseWebhooksManager(ABC, Generic[WT]):
# --8<-- [start:BaseWebhooksManager1]
PROVIDER_NAME: ClassVar[ProviderName]
PROVIDER_NAME: ClassVar[str]
# --8<-- [end:BaseWebhooksManager1]

WebhookType: WT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from strenum import StrEnum

from backend.data import integrations
from backend.integrations.providers import ProviderName

from .base import BaseWebhooksManager

Expand All @@ -21,7 +20,7 @@ class GithubWebhookType(StrEnum):


class GithubWebhooksManager(BaseWebhooksManager):
PROVIDER_NAME = ProviderName.GITHUB
PROVIDER_NAME = "github"

WebhookType = GithubWebhookType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from backend.executor.manager import ExecutionManager
from backend.integrations.creds_manager import IntegrationCredentialsManager
from backend.integrations.oauth import HANDLERS_BY_NAME, BaseOAuthHandler
from backend.integrations.providers import ProviderName
from backend.integrations.webhooks import WEBHOOK_MANAGERS_BY_NAME
from backend.util.service import get_service_client
from backend.util.settings import Settings
Expand Down Expand Up @@ -227,9 +226,7 @@ def delete_credentials(
@router.post("/{provider}/webhooks/{webhook_id}/ingress")
async def webhook_ingress_generic(
request: Request,
provider: Annotated[
ProviderName, Path(title="Provider where the webhook was registered")
],
provider: Annotated[str, Path(title="Provider where the webhook was registered")],
webhook_id: Annotated[str, Path(title="Our ID for the webhook")],
):
logger.debug(f"Received {provider} webhook ingress for ID {webhook_id}")
Expand Down Expand Up @@ -267,9 +264,7 @@ async def webhook_ingress_generic(

@router.post("/{provider}/webhooks/{webhook_id}/ping")
async def webhook_ping(
provider: Annotated[
ProviderName, Path(title="Provider where the webhook was registered")
],
provider: Annotated[str, Path(title="Provider where the webhook was registered")],
webhook_id: Annotated[str, Path(title="Our ID for the webhook")],
user_id: Annotated[str, Depends(get_user_id)], # require auth
):
Expand Down

0 comments on commit 1f30369

Please sign in to comment.