Exemple #1
0
    def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
        """Modify the field schema entry.

        Args:
            field_schema (Dict[str, Any]):
                The current field schema.
        """

        AnyHttpUrl.__modify_schema__(field_schema)
Exemple #2
0
 def endpoint(self) -> str:
     return AnyHttpUrl.build(
         scheme="http",
         host=self.DIRECTOR_HOST,
         port=f"{self.DIRECTOR_PORT}",
         path=f"/{self.DIRECTOR_V0_VTAG}",
     )
Exemple #3
0
 def endpoint(self) -> str:
     return AnyHttpUrl.build(
         scheme="http",
         host=self.host,
         port=f"{self.port}",
         path=f"/{self.vtag}",
     )
Exemple #4
0
 def _build_url(self, prefix: str) -> str:
     prefix = prefix.upper()
     return AnyHttpUrl.build(
         scheme="http",
         host=getattr(self, f"{prefix}_HOST"),
         port=f"{getattr(self, f'{prefix}_PORT')}",
         path=f"/{getattr(self, f'{prefix}_VTAG')}",
     )
 def autofill_url(cls, v, values):
     if v is None:
         return AnyHttpUrl.build(
             scheme="http",
             host=values["host"],
             port=f"{values['port']}",
             path=f"/{values['vtag']}",
         )
     return v
Exemple #6
0
    def validate(cls, value: Any, field: ModelField,
                 config: BaseConfig) -> furl:
        """Validate and parse the given URL string value.

        Args:
            value (Any):
                The URL provided by a user.
            field (ModelField):
                The field instance the URL is using.
            config (BaseConfig):
                The config instance the URL is in.

        Returns:
            :class:`furl.furl.furl`:
                The furl instance of the given URL string.
        """

        AnyHttpUrl.validate(value, field, config)
        return furl(url=value)
Exemple #7
0
 def format_url(cls, v: AnyHttpUrl):
     return v.rstrip('/') + '/'
Exemple #8
0
 def _validate_api_url(cls, v: AnyHttpUrl) -> AnyHttpUrl:
     return parse_obj_as(AnyHttpUrl, v.rstrip("/"))