Skip to content

resourceconfig

Pydantic Resource Configuration Data Model.

ResourceConfig (BaseModel) pydantic-model

Resource Strategy Data Configuration.

Important

Either of the pairs of attributes downloadUrl/mediaType or accessUrl/accessService MUST be specified.

Source code in oteapi/models/resourceconfig.py
class ResourceConfig(BaseModel):
    """Resource Strategy Data Configuration.

    Important:
        Either of the pairs of attributes `downloadUrl`/`mediaType` or
        `accessUrl`/`accessService` MUST be specified.

    """

    downloadUrl: Optional[AnyUrl] = Field(
        None,
        description=(
            "Definition: The URL of the downloadable file in a given format. E.g. CSV "
            "file or RDF file.\n\nUsage: `downloadURL` *SHOULD* be used for the URL at"
            " which this distribution is available directly, typically through a HTTPS"
            " GET request or SFTP."
        ),
    )
    mediaType: Optional[str] = Field(
        None,
        description=(
            "The media type of the distribution as defined by IANA "
            "[[IANA-MEDIA-TYPES](https://www.w3.org/TR/vocab-dcat-2/#bib-iana-media-types)]"
            ".\n\nUsage: This property *SHOULD* be used when the media"
            " type of the distribution is defined in IANA "
            "[[IANA-MEDIA-TYPES](https://www.w3.org/TR/vocab-dcat-2/#bib-iana-media-types)]."
        ),
    )
    accessUrl: Optional[AnyUrl] = Field(
        None,
        description=(
            "A URL of the resource that gives access to a distribution of "
            "the dataset. E.g. landing page, feed, SPARQL endpoint.\n\nUsage: "
            "`accessURL` *SHOULD* be used for the URL of a service or location that "
            "can provide access to this distribution, typically through a Web form, "
            "query or API call.\n`downloadURL` is preferred for direct links to "
            "downloadable resources."
        ),
    )
    accessService: Optional[str] = Field(
        None,
        description=(
            "A data service that gives access to the distribution of the dataset."
        ),
    )
    license: Optional[str] = Field(
        None,
        description=(
            "A legal document under which the distribution is made available."
        ),
    )
    accessRights: Optional[str] = Field(
        None,
        description=(
            "A rights statement that concerns how the distribution is accessed."
        ),
    )
    description: Optional[str] = Field(
        None, description="A free-text account of the distribution."
    )
    publisher: Optional[str] = Field(
        None,
        description="The entity responsible for making the resource/item available.",
    )
    configuration: Union[DataCacheConfig, Dict[str, Any]] = Field(
        {},
        description="Resource-specific configuration options given as key/value-pairs.",
    )

    @root_validator
    def ensure_unique_url_pairs(  # pylint: disable=no-self-use
        cls, values: Dict[str, Any]
    ) -> Dict[str, Any]:
        """Ensure either downloadUrl/mediaType or accessUrl/accessService are
        defined.
        It's fine to define them all, but at least one complete pair MUST be
        specified."""
        if not (
            all(values.get(_) for _ in ["downloadUrl", "mediaType"])
            or all(values.get(_) for _ in ["accessUrl", "accessService"])
        ):
            raise ValueError(
                "Either of the pairs of attributes downloadUrl/mediaType or "
                "accessUrl/accessService MUST be specified."
            )
        return values

accessRights: str pydantic-field

A rights statement that concerns how the distribution is accessed.

accessService: str pydantic-field

A data service that gives access to the distribution of the dataset.

accessUrl: AnyUrl pydantic-field

A URL of the resource that gives access to a distribution of the dataset. E.g. landing page, feed, SPARQL endpoint.

Usage: accessURL SHOULD be used for the URL of a service or location that can provide access to this distribution, typically through a Web form, query or API call. downloadURL is preferred for direct links to downloadable resources.

configuration: Union[oteapi.models.datacacheconfig.DataCacheConfig, Dict[str, Any]] pydantic-field

Resource-specific configuration options given as key/value-pairs.

description: str pydantic-field

A free-text account of the distribution.

downloadUrl: AnyUrl pydantic-field

Definition: The URL of the downloadable file in a given format. E.g. CSV file or RDF file.

Usage: downloadURL SHOULD be used for the URL at which this distribution is available directly, typically through a HTTPS GET request or SFTP.

license: str pydantic-field

A legal document under which the distribution is made available.

mediaType: str pydantic-field

The media type of the distribution as defined by IANA [IANA-MEDIA-TYPES].

Usage: This property SHOULD be used when the media type of the distribution is defined in IANA [IANA-MEDIA-TYPES].

publisher: str pydantic-field

The entity responsible for making the resource/item available.

ensure_unique_url_pairs(values) classmethod

Ensure either downloadUrl/mediaType or accessUrl/accessService are defined. It's fine to define them all, but at least one complete pair MUST be specified.

Source code in oteapi/models/resourceconfig.py
@root_validator
def ensure_unique_url_pairs(  # pylint: disable=no-self-use
    cls, values: Dict[str, Any]
) -> Dict[str, Any]:
    """Ensure either downloadUrl/mediaType or accessUrl/accessService are
    defined.
    It's fine to define them all, but at least one complete pair MUST be
    specified."""
    if not (
        all(values.get(_) for _ in ["downloadUrl", "mediaType"])
        or all(values.get(_) for _ in ["accessUrl", "accessService"])
    ):
        raise ValueError(
            "Either of the pairs of attributes downloadUrl/mediaType or "
            "accessUrl/accessService MUST be specified."
        )
    return values
Back to top