Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing HttpUrl to AnyHttpUrl #4360

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dispatch/case/type/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/data/source/models.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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]] = []
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/incident/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/incident/type/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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...
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch/individual/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -63,15 +63,15 @@ 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)
external_id: Optional[str] = Field(None, nullable=True)

@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")

Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/plugins/dispatch_atlassian_confluence/config.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch/plugins/dispatch_jira/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
)

Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/plugins/dispatch_slack/models.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/plugins/generic_workflow/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Loading