Skip to content

HuwiseDataset

Object-oriented interface for dataset operations with method chaining support.

Overview

HuwiseDataset is a dataclass that represents a Huwise dataset and provides:

  • Fluent interface: Chain method calls for cleaner code
  • Dependency injection: Accept custom configuration
  • Type safety: Full type hints for all methods
  • Lazy operations: Control when changes are published

Usage

Creating Instances

from huwise_utils_py import HuwiseDataset

# From a dataset ID
dataset = HuwiseDataset.from_id("100123")

# With custom configuration
from huwise_utils_py import HuwiseConfig

config = HuwiseConfig(api_key="key", domain="custom.domain.com")
dataset = HuwiseDataset.from_id("100123", config=config)

Reading Metadata

# Basic fields
title = dataset.get_title()
description = dataset.get_description()
keywords = dataset.get_keywords()
language = dataset.get_language()
publisher = dataset.get_publisher()
theme = dataset.get_theme()
license_value = dataset.get_license()  # checks internal.license_id, falls back to default.license

# DCAT-AP-CH fields
rights = dataset.get_dcat_ap_ch_rights()
dcat_license = dataset.get_dcat_ap_ch_license()

# DCAT fields
created = dataset.get_created()
issued = dataset.get_issued()          # publication date
creator = dataset.get_creator()
contributor = dataset.get_contributor()
contact_name = dataset.get_contact_name()
contact_email = dataset.get_contact_email()
periodicity = dataset.get_accrualperiodicity()
relation = dataset.get_relation()

# Default template fields
modified = dataset.get_modified()
geo_refs = dataset.get_geographic_reference()

# Get all metadata
metadata = dataset.get_metadata()

Updating Metadata

# Single update (publishes automatically)
dataset.set_title("New Title")

# Update without publishing
dataset.set_title("New Title", publish=False)

# Method chaining
dataset.set_title("Title", publish=False) \
       .set_description("Description", publish=False) \
       .set_keywords(["tag1", "tag2"], publish=False) \
       .publish()

# DCAT-AP-CH fields
dataset.set_dcat_ap_ch_rights(
    "NonCommercialAllowed-CommercialAllowed-ReferenceRequired",
    publish=False,
)
dataset.set_dcat_ap_ch_license("terms_by", publish=False)

# DCAT fields
dataset.set_creator("Data Team", publish=False)
dataset.set_contributor("Open Data Basel-Stadt", publish=False)
dataset.set_contact_name("Data Office", publish=False)
dataset.set_contact_email("data@example.com", publish=False)
dataset.set_issued("2024-06-01", publish=False)
dataset.set_created("2024-06-01T10:00:00Z", publish=False)
dataset.set_accrualperiodicity(
    "http://publications.europa.eu/resource/authority/frequency/DAILY",
    publish=False,
)
dataset.set_relation("https://example.com/related", publish=False)

# Geographic reference
dataset.set_geographic_reference(["ch_40_12"], publish=False)

# Modified date with companion flags
dataset.set_modified(
    "2024-06-01T12:00:00Z",
    updates_on_metadata_change=True,
    updates_on_data_change=False,
    publish=False,
)

dataset.publish()

Dataset Actions

# Publish changes
dataset.publish()

# Unpublish dataset
dataset.unpublish()

# Refresh dataset (re-process)
dataset.refresh()

Method Chaining

All setter methods return self, enabling fluent interfaces:

dataset = HuwiseDataset.from_id("100123")

# Chain all updates, then publish once at the end
dataset.set_title("New Title", publish=False) \
       .set_description("Updated description", publish=False) \
       .set_keywords(["python", "data", "automation"], publish=False) \
       .set_language("en", publish=False) \
       .set_publisher("Open Data Basel-Stadt", publish=False) \
       .set_theme("environment", publish=False) \
       .set_dcat_ap_ch_rights("NonCommercialAllowed-CommercialAllowed-ReferenceRequired", publish=False) \
       .set_dcat_ap_ch_license("terms_by", publish=False) \
       .set_creator("Data Team", publish=False) \
       .set_contact_email("data@example.com", publish=False) \
       .set_geographic_reference(["ch_40_12"], publish=False) \
       .publish()

This is more efficient than calling each setter with publish=True because it only makes one publish API call instead of six.

API Reference

HuwiseDataset(uid: str, config: HuwiseConfig = HuwiseConfig.from_env()) dataclass

Represents a Huwise dataset with metadata operations.

Provides a fluent interface for reading and modifying dataset metadata. Supports method chaining for convenient batch updates.

ATTRIBUTE DESCRIPTION
uid

The unique string identifier of the dataset.

TYPE: str

config

Optional HuwiseConfig (uses default if not provided).

TYPE: HuwiseConfig

Examples:

Create from a dataset ID and modify with method chaining:

dataset = HuwiseDataset.from_id("100123")
dataset.set_title("New Title", publish=False)                .set_description("Description")                .publish()

Read metadata:

dataset = HuwiseDataset.from_id("100123")
title = dataset.get_title()

config: HuwiseConfig = field(default_factory=(HuwiseConfig.from_env)) class-attribute instance-attribute

from_id(dataset_id: str, config: HuwiseConfig | None = None) -> Self classmethod

Create a dataset instance from a numeric dataset ID.

PARAMETER DESCRIPTION
dataset_id

The numeric identifier of the dataset.

TYPE: str

config

Optional HuwiseConfig instance.

TYPE: HuwiseConfig | None DEFAULT: None

RETURNS DESCRIPTION
Self

HuwiseDataset instance with resolved UID.

RAISES DESCRIPTION
IndexError

If no dataset is found with the given ID.

Source code in src/huwise_utils_py/dataset.py
@classmethod
def from_id(cls, dataset_id: str, config: HuwiseConfig | None = None) -> Self:
    """Create a dataset instance from a numeric dataset ID.

    Args:
        dataset_id: The numeric identifier of the dataset.
        config: Optional HuwiseConfig instance.

    Returns:
        HuwiseDataset instance with resolved UID.

    Raises:
        IndexError: If no dataset is found with the given ID.
    """
    config = config or HuwiseConfig.from_env()
    client = HttpClient(config)

    response = client.get("/datasets/", params={"dataset_id": dataset_id})
    uid: str = response.json()["results"][0]["uid"]

    logger.info("Resolved dataset ID to UID", dataset_id=dataset_id, uid=uid)
    return cls(uid=uid, config=config)

get_metadata() -> dict[str, Any]

Retrieve the full metadata of the dataset.

RETURNS DESCRIPTION
dict[str, Any]

Dictionary containing all metadata templates and fields.

Source code in src/huwise_utils_py/dataset.py
def get_metadata(self) -> dict[str, Any]:
    """Retrieve the full metadata of the dataset.

    Returns:
        Dictionary containing all metadata templates and fields.
    """
    response = self._client.get(f"/datasets/{self.uid}")
    metadata: dict[str, Any] = response.json()["metadata"]
    logger.debug("Retrieved metadata", uid=self.uid, templates=list(metadata.keys()))
    return metadata

get_title() -> str | None

Retrieve the dataset title.

RETURNS DESCRIPTION
str | None

The dataset title or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_title(self) -> str | None:
    """Retrieve the dataset title.

    Returns:
        The dataset title or None if not set.
    """
    return self._get_metadata_value("default", "title")

get_description() -> str | None

Retrieve the dataset description.

RETURNS DESCRIPTION
str | None

The dataset description or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_description(self) -> str | None:
    """Retrieve the dataset description.

    Returns:
        The dataset description or None if not set.
    """
    return self._get_metadata_value("default", "description")

get_keywords() -> list[str] | None

Retrieve the dataset keywords.

RETURNS DESCRIPTION
list[str] | None

List of keywords or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_keywords(self) -> list[str] | None:
    """Retrieve the dataset keywords.

    Returns:
        List of keywords or None if not set.
    """
    return self._get_metadata_value("default", "keyword")

get_language() -> str | None

Retrieve the dataset language.

RETURNS DESCRIPTION
str | None

The language code or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_language(self) -> str | None:
    """Retrieve the dataset language.

    Returns:
        The language code or None if not set.
    """
    return self._get_metadata_value("default", "language")

get_publisher() -> str | None

Retrieve the dataset publisher.

RETURNS DESCRIPTION
str | None

The publisher name or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_publisher(self) -> str | None:
    """Retrieve the dataset publisher.

    Returns:
        The publisher name or None if not set.
    """
    return self._get_metadata_value("default", "publisher")

get_theme() -> str | None

Retrieve the dataset theme.

RETURNS DESCRIPTION
str | None

The theme ID or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_theme(self) -> str | None:
    """Retrieve the dataset theme.

    Returns:
        The theme ID or None if not set.
    """
    return self._get_metadata_value("default", "theme_id")

get_license() -> str | None

Retrieve the dataset license.

Checks internal.license_id first (where the platform stores the canonical license ID, e.g. "5sylls5"). Falls back to default.license (human-readable string used by older datasets, e.g. "CC BY").

RETURNS DESCRIPTION
str | None

The license identifier/name, or None if neither field is set.

Source code in src/huwise_utils_py/dataset.py
def get_license(self) -> str | None:
    """Retrieve the dataset license.

    Checks ``internal.license_id`` first (where the platform stores the
    canonical license ID, e.g. ``"5sylls5"``).  Falls back to
    ``default.license`` (human-readable string used by older datasets,
    e.g. ``"CC BY"``).

    Returns:
        The license identifier/name, or None if neither field is set.
    """
    value = self._get_metadata_value("internal", "license_id")
    if value is None:
        value = self._get_metadata_value("default", "license")
    return value

get_custom_view() -> dict[str, Any] | None

Retrieve the dataset custom view configuration.

RETURNS DESCRIPTION
dict[str, Any] | None

Custom view dictionary or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_custom_view(self) -> dict[str, Any] | None:
    """Retrieve the dataset custom view configuration.

    Returns:
        Custom view dictionary or None if not set.
    """
    return self._get_metadata_value("visualization", "custom_view")

get_dcat_ap_ch_rights() -> str | None

Retrieve the DCAT-AP-CH rights statement.

RETURNS DESCRIPTION
str | None

The rights statement string (e.g.

str | None

"NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired")

str | None

or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_dcat_ap_ch_rights(self) -> str | None:
    """Retrieve the DCAT-AP-CH rights statement.

    Returns:
        The rights statement string (e.g.
        ``"NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired"``)
        or None if not set.
    """
    return self._get_metadata_value("dcat_ap_ch", "rights")

get_dcat_ap_ch_license() -> str | None

Retrieve the DCAT-AP-CH license code.

RETURNS DESCRIPTION
str | None

The license code (e.g. "terms_open") or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_dcat_ap_ch_license(self) -> str | None:
    """Retrieve the DCAT-AP-CH license code.

    Returns:
        The license code (e.g. ``"terms_open"``) or None if not set.
    """
    return self._get_metadata_value("dcat_ap_ch", "license")

get_created() -> str | None

Retrieve the dataset creation date (dcat.created).

RETURNS DESCRIPTION
str | None

ISO datetime string or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_created(self) -> str | None:
    """Retrieve the dataset creation date (``dcat.created``).

    Returns:
        ISO datetime string or None if not set.
    """
    return self._get_metadata_value("dcat", "created")

get_issued() -> str | None

Retrieve the dataset publication date (dcat.issued).

RETURNS DESCRIPTION
str | None

ISO datetime string or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_issued(self) -> str | None:
    """Retrieve the dataset publication date (``dcat.issued``).

    Returns:
        ISO datetime string or None if not set.
    """
    return self._get_metadata_value("dcat", "issued")

get_creator() -> str | None

Retrieve the dataset creator.

RETURNS DESCRIPTION
str | None

The creator name or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_creator(self) -> str | None:
    """Retrieve the dataset creator.

    Returns:
        The creator name or None if not set.
    """
    return self._get_metadata_value("dcat", "creator")

get_contributor() -> str | None

Retrieve the dataset contributor.

RETURNS DESCRIPTION
str | None

The contributor name or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_contributor(self) -> str | None:
    """Retrieve the dataset contributor.

    Returns:
        The contributor name or None if not set.
    """
    return self._get_metadata_value("dcat", "contributor")

get_contact_name() -> str | None

Retrieve the dataset contact name.

RETURNS DESCRIPTION
str | None

The contact name or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_contact_name(self) -> str | None:
    """Retrieve the dataset contact name.

    Returns:
        The contact name or None if not set.
    """
    return self._get_metadata_value("dcat", "contact_name")

get_contact_email() -> str | None

Retrieve the dataset contact email.

RETURNS DESCRIPTION
str | None

The contact email address or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_contact_email(self) -> str | None:
    """Retrieve the dataset contact email.

    Returns:
        The contact email address or None if not set.
    """
    return self._get_metadata_value("dcat", "contact_email")

get_accrualperiodicity() -> str | None

Retrieve the dataset accrual periodicity.

RETURNS DESCRIPTION
str | None

EU frequency URI string (e.g.

str | None

"http://publications.europa.eu/resource/authority/frequency/DAILY")

str | None

or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_accrualperiodicity(self) -> str | None:
    """Retrieve the dataset accrual periodicity.

    Returns:
        EU frequency URI string (e.g.
        ``"http://publications.europa.eu/resource/authority/frequency/DAILY"``)
        or None if not set.
    """
    return self._get_metadata_value("dcat", "accrualperiodicity")

get_relation() -> str | None

Retrieve the dataset relation URL.

RETURNS DESCRIPTION
str | None

The relation URL string or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_relation(self) -> str | None:
    """Retrieve the dataset relation URL.

    Returns:
        The relation URL string or None if not set.
    """
    return self._get_metadata_value("dcat", "relation")

get_modified() -> str | None

Retrieve the dataset last-modified date (default.modified).

RETURNS DESCRIPTION
str | None

ISO datetime string or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_modified(self) -> str | None:
    """Retrieve the dataset last-modified date (``default.modified``).

    Returns:
        ISO datetime string or None if not set.
    """
    return self._get_metadata_value("default", "modified")

get_geographic_reference() -> list[str] | None

Retrieve the dataset geographic reference codes.

RETURNS DESCRIPTION
list[str] | None

List of geographic reference codes (e.g.

list[str] | None

["ch_40_12"]) or None if not set.

Source code in src/huwise_utils_py/dataset.py
def get_geographic_reference(self) -> list[str] | None:
    """Retrieve the dataset geographic reference codes.

    Returns:
        List of geographic reference codes (e.g.
        ``["ch_40_12"]``) or None if not set.
    """
    return self._get_metadata_value("default", "geographic_reference")

set_title(title: str, *, publish: bool = True) -> Self

Set the dataset title.

PARAMETER DESCRIPTION
title

The new title for the dataset.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_title(self, title: str, *, publish: bool = True) -> Self:
    """Set the dataset title.

    Args:
        title: The new title for the dataset.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "title", title, publish=publish)

set_description(description: str, *, publish: bool = True) -> Self

Set the dataset description.

PARAMETER DESCRIPTION
description

The new description for the dataset.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_description(self, description: str, *, publish: bool = True) -> Self:
    """Set the dataset description.

    Args:
        description: The new description for the dataset.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "description", description, publish=publish)

set_keywords(keywords: list[str], *, publish: bool = True) -> Self

Set the dataset keywords.

PARAMETER DESCRIPTION
keywords

List of keywords for the dataset.

TYPE: list[str]

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_keywords(self, keywords: list[str], *, publish: bool = True) -> Self:
    """Set the dataset keywords.

    Args:
        keywords: List of keywords for the dataset.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "keyword", keywords, publish=publish)

set_language(language: str, *, publish: bool = True) -> Self

Set the dataset language.

PARAMETER DESCRIPTION
language

Language code (e.g., "en", "de", "fr").

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_language(self, language: str, *, publish: bool = True) -> Self:
    """Set the dataset language.

    Args:
        language: Language code (e.g., "en", "de", "fr").
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "language", language, publish=publish)

set_publisher(publisher: str, *, publish: bool = True) -> Self

Set the dataset publisher.

PARAMETER DESCRIPTION
publisher

Publisher name.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_publisher(self, publisher: str, *, publish: bool = True) -> Self:
    """Set the dataset publisher.

    Args:
        publisher: Publisher name.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "publisher", publisher, publish=publish)

set_theme(theme_id: str, *, publish: bool = True) -> Self

Set the dataset theme.

PARAMETER DESCRIPTION
theme_id

Theme identifier.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_theme(self, theme_id: str, *, publish: bool = True) -> Self:
    """Set the dataset theme.

    Args:
        theme_id: Theme identifier.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "theme_id", theme_id, publish=publish)

set_license(license_id: str, *, license_name: str | None = None, publish: bool = True) -> Self

Set the dataset license.

Uses per-field PUT endpoints to update default.license_id (and optionally default.license) without risking overwrites to other metadata fields. The platform propagates license_id to internal.license_id automatically.

PARAMETER DESCRIPTION
license_id

License identifier (e.g. "5sylls5").

TYPE: str

license_name

Optional human-readable name (e.g. "CC BY 4.0"). If provided, default.license is updated alongside default.license_id.

TYPE: str | None DEFAULT: None

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_license(
    self,
    license_id: str,
    *,
    license_name: str | None = None,
    publish: bool = True,
) -> Self:
    """Set the dataset license.

    Uses per-field ``PUT`` endpoints to update ``default.license_id``
    (and optionally ``default.license``) without risking overwrites to
    other metadata fields.  The platform propagates ``license_id`` to
    ``internal.license_id`` automatically.

    Args:
        license_id: License identifier (e.g. ``"5sylls5"``).
        license_name: Optional human-readable name (e.g. ``"CC BY 4.0"``).
            If provided, ``default.license`` is updated alongside
            ``default.license_id``.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    self._wait_for_idle()

    # Set the writable license_id (platform propagates to internal.license_id)
    self._client.put(
        f"/datasets/{self.uid}/metadata/default/license_id/",
        json={"value": license_id},
    )

    # Optionally set the human-readable license string
    if license_name is not None:
        self._client.put(
            f"/datasets/{self.uid}/metadata/default/license/",
            json={"value": license_name},
        )

    logger.info(
        "Updated license",
        uid=self.uid,
        license_id=license_id,
        license_name=license_name,
    )

    if publish:
        self.publish()

    return self

set_dcat_ap_ch_rights(rights: str, *, publish: bool = True) -> Self

Set the DCAT-AP-CH rights statement.

PARAMETER DESCRIPTION
rights

Rights statement string (e.g. "NonCommercialAllowed-CommercialAllowed-ReferenceRequired"). See the documentation for a full list of valid values.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_dcat_ap_ch_rights(self, rights: str, *, publish: bool = True) -> Self:
    """Set the DCAT-AP-CH rights statement.

    Args:
        rights: Rights statement string (e.g.
            ``"NonCommercialAllowed-CommercialAllowed-ReferenceRequired"``).
            See the documentation for a full list of valid values.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat_ap_ch", "rights", rights, publish=publish)

set_dcat_ap_ch_license(license_code: str, *, publish: bool = True) -> Self

Set the DCAT-AP-CH license code.

PARAMETER DESCRIPTION
license_code

License code (e.g. "terms_open", "terms_by"). See the documentation for a full list of valid values.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_dcat_ap_ch_license(self, license_code: str, *, publish: bool = True) -> Self:
    """Set the DCAT-AP-CH license code.

    Args:
        license_code: License code (e.g. ``"terms_open"``, ``"terms_by"``).
            See the documentation for a full list of valid values.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat_ap_ch", "license", license_code, publish=publish)

set_created(created: str, *, publish: bool = True) -> Self

Set the dataset creation date (dcat.created).

PARAMETER DESCRIPTION
created

ISO datetime string (e.g. "2024-01-15T10:30:00Z").

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_created(self, created: str, *, publish: bool = True) -> Self:
    """Set the dataset creation date (``dcat.created``).

    Args:
        created: ISO datetime string (e.g. ``"2024-01-15T10:30:00Z"``).
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "created", created, publish=publish)

set_issued(issued: str, *, publish: bool = True) -> Self

Set the dataset publication date (dcat.issued).

PARAMETER DESCRIPTION
issued

ISO datetime string (e.g. "2024-01-15").

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_issued(self, issued: str, *, publish: bool = True) -> Self:
    """Set the dataset publication date (``dcat.issued``).

    Args:
        issued: ISO datetime string (e.g. ``"2024-01-15"``).
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "issued", issued, publish=publish)

set_creator(creator: str, *, publish: bool = True) -> Self

Set the dataset creator.

PARAMETER DESCRIPTION
creator

Creator name.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_creator(self, creator: str, *, publish: bool = True) -> Self:
    """Set the dataset creator.

    Args:
        creator: Creator name.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "creator", creator, publish=publish)

set_contributor(contributor: str, *, publish: bool = True) -> Self

Set the dataset contributor.

PARAMETER DESCRIPTION
contributor

Contributor name.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_contributor(self, contributor: str, *, publish: bool = True) -> Self:
    """Set the dataset contributor.

    Args:
        contributor: Contributor name.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "contributor", contributor, publish=publish)

set_contact_name(name: str, *, publish: bool = True) -> Self

Set the dataset contact name.

PARAMETER DESCRIPTION
name

Contact name.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_contact_name(self, name: str, *, publish: bool = True) -> Self:
    """Set the dataset contact name.

    Args:
        name: Contact name.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "contact_name", name, publish=publish)

set_contact_email(email: str, *, publish: bool = True) -> Self

Set the dataset contact email.

PARAMETER DESCRIPTION
email

Contact email address.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_contact_email(self, email: str, *, publish: bool = True) -> Self:
    """Set the dataset contact email.

    Args:
        email: Contact email address.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "contact_email", email, publish=publish)

set_accrualperiodicity(frequency: str, *, publish: bool = True) -> Self

Set the dataset accrual periodicity.

PARAMETER DESCRIPTION
frequency

EU frequency URI string (e.g. "http://publications.europa.eu/resource/authority/frequency/DAILY").

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_accrualperiodicity(self, frequency: str, *, publish: bool = True) -> Self:
    """Set the dataset accrual periodicity.

    Args:
        frequency: EU frequency URI string (e.g.
            ``"http://publications.europa.eu/resource/authority/frequency/DAILY"``).
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "accrualperiodicity", frequency, publish=publish)

set_relation(relation: str, *, publish: bool = True) -> Self

Set the dataset relation URL.

PARAMETER DESCRIPTION
relation

Relation URL string.

TYPE: str

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_relation(self, relation: str, *, publish: bool = True) -> Self:
    """Set the dataset relation URL.

    Args:
        relation: Relation URL string.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("dcat", "relation", relation, publish=publish)

set_geographic_reference(references: list[str], *, publish: bool = True) -> Self

Set the dataset geographic reference codes.

PARAMETER DESCRIPTION
references

List of geographic reference codes (e.g. ["ch_40_12"]). See the documentation for the code format: {country}_{admin_level}_{territory_id}.

TYPE: list[str]

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_geographic_reference(self, references: list[str], *, publish: bool = True) -> Self:
    """Set the dataset geographic reference codes.

    Args:
        references: List of geographic reference codes (e.g.
            ``["ch_40_12"]``).  See the documentation for the code
            format: ``{country}_{admin_level}_{territory_id}``.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    return self._set_metadata_value("default", "geographic_reference", references, publish=publish)

set_modified(modified: str, *, updates_on_metadata_change: bool | None = None, updates_on_data_change: bool | None = None, publish: bool = True) -> Self

Set the dataset last-modified date (default.modified).

Uses per-field PUT endpoints so that each field is updated

PARAMETER DESCRIPTION
modified

ISO datetime string (e.g. "2024-01-15T10:30:00Z").

TYPE: str

updates_on_metadata_change

If given, sets whether the modified date should auto-update when metadata changes.

TYPE: bool | None DEFAULT: None

updates_on_data_change

If given, sets whether the modified date should auto-update when data changes.

TYPE: bool | None DEFAULT: None

publish

Whether to publish after updating.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def set_modified(
    self,
    modified: str,
    *,
    updates_on_metadata_change: bool | None = None,
    updates_on_data_change: bool | None = None,
    publish: bool = True,
) -> Self:
    """Set the dataset last-modified date (``default.modified``).

    Uses per-field ``PUT`` endpoints so that each field is updated

    Args:
        modified: ISO datetime string (e.g. ``"2024-01-15T10:30:00Z"``).
        updates_on_metadata_change: If given, sets whether the modified
            date should auto-update when metadata changes.
        updates_on_data_change: If given, sets whether the modified
            date should auto-update when data changes.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    self._wait_for_idle()

    # Set the modified value
    self._client.put(
        f"/datasets/{self.uid}/metadata/default/modified/",
        json={"value": modified},
    )

    # Optionally set the companion boolean flags
    if updates_on_metadata_change is not None:
        self._client.put(
            f"/datasets/{self.uid}/metadata/default/modified_updates_on_metadata_change/",
            json={"value": updates_on_metadata_change},
        )

    if updates_on_data_change is not None:
        self._client.put(
            f"/datasets/{self.uid}/metadata/default/modified_updates_on_data_change/",
            json={"value": updates_on_data_change},
        )

    logger.info(
        "Updated modified date",
        uid=self.uid,
        modified=modified,
        updates_on_metadata_change=updates_on_metadata_change,
        updates_on_data_change=updates_on_data_change,
    )

    if publish:
        self.publish()

    return self

publish() -> Self

Publish the dataset to make changes visible.

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def publish(self) -> Self:
    """Publish the dataset to make changes visible.

    Returns:
        Self for method chaining.
    """
    self._client.post(f"/datasets/{self.uid}/publish/")
    logger.info("Published dataset", uid=self.uid)
    return self

unpublish() -> Self

Unpublish the dataset.

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def unpublish(self) -> Self:
    """Unpublish the dataset.

    Returns:
        Self for method chaining.
    """
    self._client.post(f"/datasets/{self.uid}/unpublish/")
    logger.info("Unpublished dataset", uid=self.uid)
    return self

refresh() -> Self

Refresh the dataset (re-process data).

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def refresh(self) -> Self:
    """Refresh the dataset (re-process data).

    Returns:
        Self for method chaining.
    """
    self._client.put(f"/datasets/{self.uid}/")
    logger.info("Refreshed dataset", uid=self.uid)
    return self