Skip to content

resource_url

Strategy class for resource/url.

ResourceURLConfig

Bases: ResourceConfig

Resource URL strategy config.

Source code in oteapi/strategies/resource/resource_url.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ResourceURLConfig(ResourceConfig):
    """Resource URL strategy config."""

    resourceType: Literal["resource/url"] = Field(
        "resource/url",
        description=ResourceConfig.model_fields["resourceType"].description,
    )
    downloadUrl: HostlessAnyUrl = Field(
        ...,
        description=ResourceConfig.model_fields["downloadUrl"].description,
    )
    mediaType: str = Field(
        ...,
        description=ResourceConfig.model_fields["mediaType"].description,
    )

downloadUrl: HostlessAnyUrl = Field(..., description=ResourceConfig.model_fields['downloadUrl'].description) class-attribute instance-attribute

mediaType: str = Field(..., description=ResourceConfig.model_fields['mediaType'].description) class-attribute instance-attribute

resourceType: Literal['resource/url'] = Field('resource/url', description=ResourceConfig.model_fields['resourceType'].description) class-attribute instance-attribute

ResourceURLStrategy

Basic resource strategy targeting downloadUrl resources.

Source code in oteapi/strategies/resource/resource_url.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@dataclass
class ResourceURLStrategy:
    """Basic resource strategy targeting downloadUrl resources."""

    resource_config: ResourceURLConfig

    def initialize(self) -> AttrDict:
        """Initialize."""
        return AttrDict()

    def get(self) -> AttrDict:
        """resource distribution."""
        return AttrDict(
            **self.resource_config.model_dump(
                mode="json", exclude_unset=True, exclude={"resourceType"}
            )
        )

resource_config: ResourceURLConfig instance-attribute

get()

resource distribution.

Source code in oteapi/strategies/resource/resource_url.py
45
46
47
48
49
50
51
def get(self) -> AttrDict:
    """resource distribution."""
    return AttrDict(
        **self.resource_config.model_dump(
            mode="json", exclude_unset=True, exclude={"resourceType"}
        )
    )

initialize()

Initialize.

Source code in oteapi/strategies/resource/resource_url.py
41
42
43
def initialize(self) -> AttrDict:
    """Initialize."""
    return AttrDict()