From 42182a9ecc44d7f43fdee4b81b7c4dcf13ee68c1 Mon Sep 17 00:00:00 2001 From: David Whittaker <84562015+whitdog47@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:14:16 -0800 Subject: [PATCH] Changing HttpUrl to AnyHttpUrl (#4360) --- src/dispatch/case/type/models.py | 4 ++-- src/dispatch/data/source/models.py | 4 ++-- src/dispatch/incident/models.py | 4 ++-- src/dispatch/incident/type/models.py | 4 ++-- src/dispatch/individual/models.py | 6 +++--- src/dispatch/models.py | 4 ++-- .../plugins/dispatch_atlassian_confluence/config.py | 4 ++-- src/dispatch/plugins/dispatch_jira/plugin.py | 6 +++--- src/dispatch/plugins/dispatch_slack/models.py | 4 ++-- src/dispatch/plugins/generic_workflow/plugin.py | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/dispatch/case/type/models.py b/src/dispatch/case/type/models.py index b09415f1ee56..6fbf64ec4450 100644 --- a/src/dispatch/case/type/models.py +++ b/src/dispatch/case/type/models.py @@ -1,6 +1,6 @@ from typing import List, Optional -from pydantic import Field, validator, HttpUrl +from pydantic import Field, validator, AnyHttpUrl from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String from sqlalchemy.event import listen from sqlalchemy.ext.hybrid import hybrid_method @@ -60,7 +60,7 @@ class Document(DispatchBase): name: NameStr resource_id: Optional[str] = Field(None, nullable=True) resource_type: Optional[str] = Field(None, nullable=True) - weblink: Optional[HttpUrl] = Field(None, nullable=True) + weblink: Optional[AnyHttpUrl] = Field(None, nullable=True) class IncidentType(DispatchBase): diff --git a/src/dispatch/data/source/models.py b/src/dispatch/data/source/models.py index c619de849484..d6f766138af6 100644 --- a/src/dispatch/data/source/models.py +++ b/src/dispatch/data/source/models.py @@ -1,6 +1,6 @@ from typing import Optional, List from datetime import datetime -from pydantic import Field, HttpUrl +from pydantic import Field, AnyHttpUrl from sqlalchemy import ( JSON, @@ -122,7 +122,7 @@ class SourceBase(DispatchBase): size: Optional[int] = Field(None, nullable=True) external_id: Optional[str] = Field(None, nullable=True) aggregated: Optional[bool] = Field(False, nullable=True) - links: Optional[List[HttpUrl]] = [] + links: Optional[List[AnyHttpUrl]] = [] tags: Optional[List[TagRead]] = [] incidents: Optional[List[IncidentRead]] = [] queries: Optional[List[QueryReadMinimal]] = [] diff --git a/src/dispatch/incident/models.py b/src/dispatch/incident/models.py index 4aa801cac3ab..f3fb60281a65 100644 --- a/src/dispatch/incident/models.py +++ b/src/dispatch/incident/models.py @@ -2,7 +2,7 @@ from datetime import datetime from typing import ForwardRef, List, Optional -from pydantic import validator, Field, HttpUrl +from pydantic import validator, Field, AnyHttpUrl from sqlalchemy import Column, DateTime, ForeignKey, Integer, PrimaryKeyConstraint, String, Table from sqlalchemy.ext.hybrid import hybrid_property @@ -263,7 +263,7 @@ class TaskRead(DispatchBase): created_at: Optional[datetime] description: Optional[str] = Field(None, nullable=True) status: TaskStatus = TaskStatus.open - weblink: Optional[HttpUrl] = Field(None, nullable=True) + weblink: Optional[AnyHttpUrl] = Field(None, nullable=True) class TaskReadMinimal(DispatchBase): diff --git a/src/dispatch/incident/type/models.py b/src/dispatch/incident/type/models.py index 4ccd6d6e0519..fc4941555eb1 100644 --- a/src/dispatch/incident/type/models.py +++ b/src/dispatch/incident/type/models.py @@ -1,5 +1,5 @@ from typing import List, Optional -from pydantic import validator, Field, HttpUrl +from pydantic import validator, Field, AnyHttpUrl from dispatch.models import NameStr, PrimaryKey from sqlalchemy import Column, Boolean, ForeignKey, Integer, String, JSON @@ -76,7 +76,7 @@ class Document(DispatchBase): resource_type: Optional[str] = Field(None, nullable=True) resource_id: Optional[str] = Field(None, nullable=True) description: Optional[str] = Field(None, nullable=True) - weblink: Optional[HttpUrl] = Field(None, nullable=True) + weblink: Optional[AnyHttpUrl] = Field(None, nullable=True) # Pydantic models... diff --git a/src/dispatch/individual/models.py b/src/dispatch/individual/models.py index e14d1f7f364e..b5a613922dcf 100644 --- a/src/dispatch/individual/models.py +++ b/src/dispatch/individual/models.py @@ -1,6 +1,6 @@ from datetime import datetime from typing import List, Optional, Union -from pydantic import Field, HttpUrl, validator +from pydantic import Field, AnyHttpUrl, validator from sqlalchemy import Column, ForeignKey, Integer, PrimaryKeyConstraint, String, Table from sqlalchemy.sql.schema import UniqueConstraint @@ -63,7 +63,7 @@ class IndividualContact(Base, ContactMixin, ProjectMixin): class IndividualContactBase(ContactBase): - weblink: Union[HttpUrl, None, str] = Field(None, nullable=True) + weblink: Union[AnyHttpUrl, None, str] = Field(None, nullable=True) mobile_phone: Optional[str] = Field(None, nullable=True) office_phone: Optional[str] = Field(None, nullable=True) title: Optional[str] = Field(None, nullable=True) @@ -71,7 +71,7 @@ class IndividualContactBase(ContactBase): @validator("weblink") def weblink_validator(cls, v): - if v is None or isinstance(v, HttpUrl) or v == "": + if v is None or isinstance(v, AnyHttpUrl) or v == "": return v raise ValueError("weblink is not an empty string or a valid weblink") diff --git a/src/dispatch/models.py b/src/dispatch/models.py index bc46a47cb3df..13368d728601 100644 --- a/src/dispatch/models.py +++ b/src/dispatch/models.py @@ -2,7 +2,7 @@ from datetime import datetime, timedelta from pydantic.fields import Field -from pydantic.networks import EmailStr, HttpUrl +from pydantic.networks import EmailStr, AnyHttpUrl from pydantic import BaseModel from pydantic.types import conint, constr, SecretStr @@ -136,7 +136,7 @@ class EvergreenBase(DispatchBase): class ResourceBase(DispatchBase): resource_type: Optional[str] = Field(None, nullable=True) resource_id: Optional[str] = Field(None, nullable=True) - weblink: Optional[HttpUrl] = Field(None, nullable=True) + weblink: Optional[AnyHttpUrl] = Field(None, nullable=True) class ContactBase(DispatchBase): diff --git a/src/dispatch/plugins/dispatch_atlassian_confluence/config.py b/src/dispatch/plugins/dispatch_atlassian_confluence/config.py index c561b0743632..fca9fe53c27f 100644 --- a/src/dispatch/plugins/dispatch_atlassian_confluence/config.py +++ b/src/dispatch/plugins/dispatch_atlassian_confluence/config.py @@ -1,4 +1,4 @@ -from pydantic import Field, SecretStr, HttpUrl +from pydantic import Field, SecretStr, AnyHttpUrl from enum import Enum from dispatch.config import BaseConfigurationModel @@ -14,7 +14,7 @@ class HostingType(str, Enum): class ConfluenceConfigurationBase(BaseConfigurationModel): """Atlassian Confluence configuration description.""" - api_url: HttpUrl = Field( + api_url: AnyHttpUrl = Field( title="API URL", description="This URL is used for communication with API." ) hosting_type: HostingType = Field( diff --git a/src/dispatch/plugins/dispatch_jira/plugin.py b/src/dispatch/plugins/dispatch_jira/plugin.py index 91378e79e0e2..46e793421b02 100644 --- a/src/dispatch/plugins/dispatch_jira/plugin.py +++ b/src/dispatch/plugins/dispatch_jira/plugin.py @@ -10,7 +10,7 @@ import requests from requests.auth import HTTPBasicAuth -from pydantic import Field, SecretStr, HttpUrl +from pydantic import Field, SecretStr, AnyHttpUrl from jinja2 import Template from jira import JIRA @@ -54,10 +54,10 @@ class JiraConfiguration(BaseConfigurationModel): password: SecretStr = Field( title="Password", description="Password to use to authenticate to Jira API." ) - api_url: HttpUrl = Field( + api_url: AnyHttpUrl = Field( title="API URL", description="This URL is used for communication with API." ) - browser_url: HttpUrl = Field( + browser_url: AnyHttpUrl = Field( title="Browser URL", description="This URL is used to construct browser weblinks." ) diff --git a/src/dispatch/plugins/dispatch_slack/models.py b/src/dispatch/plugins/dispatch_slack/models.py index eb0836d67928..5294c0dd00b2 100644 --- a/src/dispatch/plugins/dispatch_slack/models.py +++ b/src/dispatch/plugins/dispatch_slack/models.py @@ -1,6 +1,6 @@ from typing import Optional, NewType -from pydantic import BaseModel, Field, HttpUrl +from pydantic import BaseModel, Field, AnyHttpUrl from dispatch.enums import DispatchEnum @@ -27,7 +27,7 @@ class TaskMetadata(SubjectMetadata): class MonitorMetadata(SubjectMetadata): - weblink: Optional[HttpUrl] = Field(None, nullable=True) + weblink: Optional[AnyHttpUrl] = Field(None, nullable=True) plugin_instance_id: int diff --git a/src/dispatch/plugins/generic_workflow/plugin.py b/src/dispatch/plugins/generic_workflow/plugin.py index 3e6853d93568..af2dd18c7756 100644 --- a/src/dispatch/plugins/generic_workflow/plugin.py +++ b/src/dispatch/plugins/generic_workflow/plugin.py @@ -33,7 +33,7 @@ import requests import json -from pydantic import Field, SecretStr, HttpUrl +from pydantic import Field, SecretStr, AnyHttpUrl from tenacity import TryAgain, retry, stop_after_attempt, wait_exponential from dispatch.config import BaseConfigurationModel @@ -52,7 +52,7 @@ class GenericWorkflowConfiguration(BaseConfigurationModel): workflow_id, workflow_instance_id, incident_id and incident_name. """ - api_url: HttpUrl = Field( + api_url: AnyHttpUrl = Field( title="API URL", description="This API endpoint to GET or POST workflow info from/to." ) auth_header: SecretStr = Field(