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)

# Create a new dataset
created = HuwiseDataset.create(
    metadata={"default": {"title": {"value": "My New Dataset"}}},
    dataset_id="my-new-dataset",
    is_restricted=False,
    resource_source_url="https://data-bs.ch/stata/fgi/stac/AFBA_Abfuhrzonen.geojson",
    resource_title="my-new-dataset.geojson",
)

# Or let the library build minimal metadata automatically
created2 = HuwiseDataset.create(
    dataset_id="my-easy-dataset",
    title="My Easy Dataset",
    is_restricted=True,
)

Creating datasets (validation and domain templates)

HuwiseDataset.create blocks until the new dataset’s status is idle, so follow-up calls such as field configuration updates are safe immediately afterward.

metadata is optional in this library: if omitted, a minimal payload with default.title is generated from title, then dataset_id, then "Untitled dataset" as a fallback.

Metadata on create is validated by your Huwise domain. Templates and allowed values differ per domain; see Metadata reference for examples (e.g. DCAT-AP-CH codes, theme hashes). If POST /datasets/ returns 400, inspect HuwiseAutomationError.detail from the HTTP layer.

Recommended pattern when domains reject large initial payloads: create with a minimal default.title (and optional dataset_id), then use setters (set_relation, set_dcat_ap_ch_license, etc.) for other templates.

Optional helpers from huwise_utils_py:

  • strip_empty_metadata_values(metadata) — drop {"value": ""}, [], or null field entries before create to avoid sending empty cells the API rejects.
  • assert_non_empty_dataset_id(dataset_id)create already rejects a blank dataset_id when provided; you can reuse this helper in your own pipelines.
from huwise_utils_py import HuwiseDataset, strip_empty_metadata_values

metadata = strip_empty_metadata_values({
    "default": {
        "title": {"value": "My dataset"},
        "description": {"value": ""},
    }
})
created = HuwiseDataset.create(metadata=metadata, dataset_id="my-slug")

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()
tags = dataset.get_tags()

# Custom template fields
publishing_org = dataset.get_custom_field("publizierende_organisation")
model_description = dataset.get_custom_field("geodaten_modellbeschreibung")

# 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)

# Tags (default.tags)
dataset.set_tags(["opendata.swiss", "mobility"], publish=False)

# Custom template fields (custom.*)
dataset.set_custom_field("publizierende_organisation", "Open Data Basel-Stadt", publish=False)
dataset.set_custom_field(
    "geodaten_modellbeschreibung",
    "Vektormodell gemäss kantonalem Schema v2.",
    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()

# Delete dataset
dataset.delete()

Dataset Schema And Field Configuration

dataset = HuwiseDataset.from_id("100123")

# Update dataset-level configuration (PUT /datasets/{uid}/)
dataset.update_configuration(
    dataset_id="renamed-dataset-id",
    is_restricted=True,
)

# Field configuration stack (Dataset fields endpoints)
field_processors = dataset.list_field_configurations(limit=100)
one_processor = dataset.retrieve_field_configuration("pr_qf2hyt")

created_processor = dataset.append_field_configuration({
    "type": "rename",
    "label": "Rename old field",
    "from_name": "old_name",
    "to_name": "new_name",
})

updated_processor = dataset.update_field_configuration(
    created_processor["uid"],
    {
        "type": "rename",
        "label": "Rename old field (updated)",
        "from_name": "old_name",
        "to_name": "new_name",
    },
)

dataset.delete_field_configuration(updated_processor["uid"])

# Resource management
resources = dataset.list_resources(limit=100)

resource = dataset.upsert_http_resource(
    source_url="https://data-bs.ch/stata/fgi/stac/AFBA_Abfuhrzonen.geojson",
    title="100095stac.geojson",
)

dataset.delete_resource(resource["uid"])

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.

Template assumptions and publish behavior

The helper methods for custom fields and tags assume your domain has:

  • custom.<field_key> fields configured in the metadata template (for example custom.publizierende_organisation)
  • a default.tags metadata field for dataset tags

If those fields are not present in your domain template, the API returns an error from the metadata field endpoint.

Setter methods default to publish=True for convenience. For batched updates, set publish=False on each call and publish once at the end.

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)

create(metadata: dict[str, Any] | None = None, *, title: str | None = None, dataset_id: str | None = None, is_restricted: bool | None = None, default_security: DatasetSecurity | None = None, resource_source_url: str | None = None, resource_title: str | None = None, resource_extractor_type: str | None = None, resource_headers: list[dict[str, str]] | None = None, config: HuwiseConfig | None = None) -> Self classmethod

Create a new dataset and return it as a HuwiseDataset instance.

PARAMETER DESCRIPTION
metadata

Optional dataset metadata payload. If omitted, a minimal metadata object is auto-built with default.title.

TYPE: dict[str, Any] | None DEFAULT: None

title

Optional title used when metadata is omitted.

TYPE: str | None DEFAULT: None

dataset_id

Optional human-readable identifier.

TYPE: str | None DEFAULT: None

is_restricted

Optional restriction flag.

TYPE: bool | None DEFAULT: None

default_security

Optional default security ruleset.

TYPE: DatasetSecurity | None DEFAULT: None

resource_source_url

Optional HTTP(S) source URL to upsert as a resource right after dataset creation.

TYPE: str | None DEFAULT: None

resource_title

Optional title used for the created/updated resource.

TYPE: str | None DEFAULT: None

resource_extractor_type

Optional extractor type for the resource.

TYPE: str | None DEFAULT: None

resource_headers

Optional connection headers for the resource.

TYPE: list[dict[str, str]] | None DEFAULT: None

config

Optional HuwiseConfig instance.

TYPE: HuwiseConfig | None DEFAULT: None

RETURNS DESCRIPTION
Self

A HuwiseDataset instance for the created dataset.

RAISES DESCRIPTION
TypeError

If metadata is provided but is not a dictionary.

ValueError

If response does not contain a UID.

Source code in src/huwise_utils_py/dataset.py
@classmethod
def create(
    cls,
    metadata: dict[str, Any] | None = None,
    *,
    title: str | None = None,
    dataset_id: str | None = None,
    is_restricted: bool | None = None,
    default_security: DatasetSecurity | None = None,
    resource_source_url: str | None = None,
    resource_title: str | None = None,
    resource_extractor_type: str | None = None,
    resource_headers: list[dict[str, str]] | None = None,
    config: HuwiseConfig | None = None,
) -> Self:
    """Create a new dataset and return it as a ``HuwiseDataset`` instance.

    Args:
        metadata: Optional dataset metadata payload. If omitted, a minimal
            metadata object is auto-built with ``default.title``.
        title: Optional title used when ``metadata`` is omitted.
        dataset_id: Optional human-readable identifier.
        is_restricted: Optional restriction flag.
        default_security: Optional default security ruleset.
        resource_source_url: Optional HTTP(S) source URL to upsert as a
            resource right after dataset creation.
        resource_title: Optional title used for the created/updated resource.
        resource_extractor_type: Optional extractor type for the resource.
        resource_headers: Optional connection headers for the resource.
        config: Optional HuwiseConfig instance.

    Returns:
        A ``HuwiseDataset`` instance for the created dataset.

    Raises:
        TypeError: If metadata is provided but is not a dictionary.
        ValueError: If response does not contain a UID.
    """
    config = config or HuwiseConfig.from_env()
    client = HttpClient(config)
    payload: DatasetCreatePayload = {
        "metadata": build_create_dataset_metadata(metadata, title=title, dataset_id=dataset_id)
    }

    if dataset_id is not None:
        assert_non_empty_dataset_id(dataset_id)
        payload["dataset_id"] = dataset_id
    if is_restricted is not None:
        payload["is_restricted"] = is_restricted
    if default_security is not None:
        payload["default_security"] = default_security

    response = client.post("/datasets/", json=payload)
    response_data: dict[str, Any] = response.json()
    uid = response_data.get("uid")

    if not isinstance(uid, str) or not uid:
        raise ValueError("Create dataset response does not contain a valid uid")

    logger.info(
        "Created dataset",
        uid=uid,
        dataset_id=dataset_id,
        is_restricted=is_restricted,
    )
    instance = cls(uid=uid, config=config)
    instance._wait_for_idle()
    if resource_source_url is not None:
        instance.upsert_http_resource(
            source_url=resource_source_url,
            title=resource_title,
            extractor_type=resource_extractor_type,
            headers=resource_headers,
        )
    return instance

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

get_custom_field(field_key: str) -> Any

Retrieve a field from the custom template.

PARAMETER DESCRIPTION
field_key

Field key in the custom template.

TYPE: str

RETURNS DESCRIPTION
Any

The stored custom field value or None when missing.

Source code in src/huwise_utils_py/dataset.py
def get_custom_field(self, field_key: str) -> Any:
    """Retrieve a field from the ``custom`` template.

    Args:
        field_key: Field key in the ``custom`` template.

    Returns:
        The stored custom field value or ``None`` when missing.
    """
    normalized_key = self._validate_field_key(field_key)
    return self._get_metadata_value("custom", normalized_key)

get_tags() -> list[str]

Retrieve dataset tags from default.tags.

RETURNS DESCRIPTION
list[str]

List of dataset tags. Returns an empty list if tags are unset.

Source code in src/huwise_utils_py/dataset.py
def get_tags(self) -> list[str]:
    """Retrieve dataset tags from ``default.tags``.

    Returns:
        List of dataset tags. Returns an empty list if tags are unset.
    """
    value = self._get_metadata_value("default", "tags")
    if value is None:
        return []
    if not isinstance(value, list) or not all(isinstance(tag, str) for tag in value):
        raise ValueError("default.tags metadata value must be a list[str]")
    return value

set_title(title: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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, override_remote_value: bool | None = None) -> 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,
        override_remote_value=override_remote_value,
    )

set_description(description: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_keywords(keywords: list[str], *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_language(language: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_publisher(publisher: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

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, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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)
    license_id_payload: dict[str, Any] = {"value": license_id}
    if override_remote_value is not None:
        license_id_payload["override_remote_value"] = override_remote_value
    self._client.put(
        f"/datasets/{self.uid}/metadata/default/license_id/",
        json=license_id_payload,
    )

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

    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, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_dcat_ap_ch_license(license_code: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_created(created: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_issued(issued: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_creator(creator: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

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, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_contact_email(email: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_accrualperiodicity(frequency: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_relation(relation: str, *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_geographic_reference(references: list[str], *, publish: bool = True, override_remote_value: bool | None = None) -> 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,
    override_remote_value: bool | None = None,
) -> 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,
        override_remote_value=override_remote_value,
    )

set_custom_field(field_key: str, value: Any, *, publish: bool = True, override_remote_value: bool | None = None) -> Self

Set a field in the custom metadata template.

PARAMETER DESCRIPTION
field_key

Field key in the custom template.

TYPE: str

value

Value to set for the field. Must be JSON-serializable.

TYPE: Any

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_custom_field(
    self,
    field_key: str,
    value: Any,
    *,
    publish: bool = True,
    override_remote_value: bool | None = None,
) -> Self:
    """Set a field in the ``custom`` metadata template.

    Args:
        field_key: Field key in the ``custom`` template.
        value: Value to set for the field. Must be JSON-serializable.
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    normalized_key = self._validate_field_key(field_key)
    self._ensure_json_serializable(value, value_name="value")
    return self._set_metadata_value(
        "custom",
        normalized_key,
        value,
        publish=publish,
        override_remote_value=override_remote_value,
    )

set_tags(tags: list[str], *, publish: bool = True, override_remote_value: bool | None = None) -> Self

Set dataset tags in default.tags.

PARAMETER DESCRIPTION
tags

List of tag strings (e.g. ["opendata.swiss"]).

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_tags(
    self,
    tags: list[str],
    *,
    publish: bool = True,
    override_remote_value: bool | None = None,
) -> Self:
    """Set dataset tags in ``default.tags``.

    Args:
        tags: List of tag strings (e.g. ``["opendata.swiss"]``).
        publish: Whether to publish after updating.

    Returns:
        Self for method chaining.
    """
    if not isinstance(tags, list):
        raise TypeError("tags must be a list[str]")
    if any(not isinstance(tag, str) or not tag.strip() for tag in tags):
        raise ValueError("tags must contain only non-empty strings")
    self._ensure_json_serializable(tags, value_name="tags")
    return self._set_metadata_value(
        "default",
        "tags",
        tags,
        publish=publish,
        override_remote_value=override_remote_value,
    )

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

delete() -> None

Delete the dataset.

After successful deletion, this instance should no longer be used for API operations that require the dataset to exist.

Source code in src/huwise_utils_py/dataset.py
def delete(self) -> None:
    """Delete the dataset.

    After successful deletion, this instance should no longer be used for
    API operations that require the dataset to exist.
    """
    self._wait_for_idle()
    self._client.delete(f"/datasets/{self.uid}/")
    logger.info("Deleted dataset", uid=self.uid)

update_configuration(*, dataset_id: str | None = None, is_restricted: bool | None = None, default_security: DatasetSecurity | None = None) -> Self

Update dataset-level configuration properties.

PARAMETER DESCRIPTION
dataset_id

Optional new dataset ID.

TYPE: str | None DEFAULT: None

is_restricted

Optional restriction flag.

TYPE: bool | None DEFAULT: None

default_security

Optional default security ruleset.

TYPE: DatasetSecurity | None DEFAULT: None

RETURNS DESCRIPTION
Self

Self for method chaining.

RAISES DESCRIPTION
ValueError

If no configuration field is provided.

Source code in src/huwise_utils_py/dataset.py
def update_configuration(
    self,
    *,
    dataset_id: str | None = None,
    is_restricted: bool | None = None,
    default_security: DatasetSecurity | None = None,
) -> Self:
    """Update dataset-level configuration properties.

    Args:
        dataset_id: Optional new dataset ID.
        is_restricted: Optional restriction flag.
        default_security: Optional default security ruleset.

    Returns:
        Self for method chaining.

    Raises:
        ValueError: If no configuration field is provided.
    """
    payload: DatasetUpdatePayload = {}
    if dataset_id is not None:
        payload["dataset_id"] = dataset_id
    if is_restricted is not None:
        payload["is_restricted"] = is_restricted
    if default_security is not None:
        payload["default_security"] = default_security

    if not payload:
        raise ValueError("At least one configuration field must be provided")

    self._client.put(f"/datasets/{self.uid}/", json=payload)
    logger.info(
        "Updated dataset configuration",
        uid=self.uid,
        dataset_id=dataset_id,
        is_restricted=is_restricted,
        has_default_security=default_security is not None,
    )
    return self

list_field_configurations(*, limit: int | None = None, offset: int | None = None) -> dict[str, Any]

List field configurations for the dataset.

PARAMETER DESCRIPTION
limit

Optional pagination limit.

TYPE: int | None DEFAULT: None

offset

Optional pagination offset.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Any]

Paginated response dictionary with field configurations.

Source code in src/huwise_utils_py/dataset.py
def list_field_configurations(self, *, limit: int | None = None, offset: int | None = None) -> dict[str, Any]:
    """List field configurations for the dataset.

    Args:
        limit: Optional pagination limit.
        offset: Optional pagination offset.

    Returns:
        Paginated response dictionary with field configurations.
    """
    params: dict[str, int] = {}
    if limit is not None:
        params["limit"] = limit
    if offset is not None:
        params["offset"] = offset

    response = self._client.get(f"/datasets/{self.uid}/fields/", params=params or None)
    return response.json()

retrieve_field_configuration(field_uid: str) -> dict[str, Any]

Retrieve one field configuration by UID.

PARAMETER DESCRIPTION
field_uid

Field configuration UID.

TYPE: str

RETURNS DESCRIPTION
dict[str, Any]

Field configuration dictionary.

Source code in src/huwise_utils_py/dataset.py
def retrieve_field_configuration(self, field_uid: str) -> dict[str, Any]:
    """Retrieve one field configuration by UID.

    Args:
        field_uid: Field configuration UID.

    Returns:
        Field configuration dictionary.
    """
    response = self._client.get(f"/datasets/{self.uid}/fields/{field_uid}/")
    return response.json()

append_field_configuration(field_configuration: dict[str, Any]) -> dict[str, Any]

Append a new field configuration processor.

PARAMETER DESCRIPTION
field_configuration

Payload for field configuration creation.

TYPE: dict[str, Any]

RETURNS DESCRIPTION
dict[str, Any]

Created field configuration response.

Source code in src/huwise_utils_py/dataset.py
def append_field_configuration(self, field_configuration: dict[str, Any]) -> dict[str, Any]:
    """Append a new field configuration processor.

    Args:
        field_configuration: Payload for field configuration creation.

    Returns:
        Created field configuration response.
    """
    self._wait_for_idle()
    response = self._client.post(f"/datasets/{self.uid}/fields/", json=field_configuration)
    logger.info("Appended dataset field configuration", uid=self.uid, field_type=field_configuration.get("type"))
    return response.json()

update_field_configuration(field_uid: str, field_configuration: dict[str, Any]) -> dict[str, Any]

Update an existing field configuration processor.

PARAMETER DESCRIPTION
field_uid

Field configuration UID.

TYPE: str

field_configuration

Updated field configuration payload.

TYPE: dict[str, Any]

RETURNS DESCRIPTION
dict[str, Any]

Updated field configuration response.

Source code in src/huwise_utils_py/dataset.py
def update_field_configuration(self, field_uid: str, field_configuration: dict[str, Any]) -> dict[str, Any]:
    """Update an existing field configuration processor.

    Args:
        field_uid: Field configuration UID.
        field_configuration: Updated field configuration payload.

    Returns:
        Updated field configuration response.
    """
    self._wait_for_idle()
    response = self._client.put(f"/datasets/{self.uid}/fields/{field_uid}/", json=field_configuration)
    logger.info(
        "Updated dataset field configuration",
        uid=self.uid,
        field_uid=field_uid,
        field_type=field_configuration.get("type"),
    )
    return response.json()

delete_field_configuration(field_uid: str) -> Self

Delete a field configuration processor.

PARAMETER DESCRIPTION
field_uid

Field configuration UID.

TYPE: str

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def delete_field_configuration(self, field_uid: str) -> Self:
    """Delete a field configuration processor.

    Args:
        field_uid: Field configuration UID.

    Returns:
        Self for method chaining.
    """
    self._wait_for_idle()
    self._client.delete(f"/datasets/{self.uid}/fields/{field_uid}/")
    logger.info("Deleted dataset field configuration", uid=self.uid, field_uid=field_uid)
    return self

list_resources(*, limit: int | None = None, offset: int | None = None) -> dict[str, Any]

List resources for the dataset.

PARAMETER DESCRIPTION
limit

Optional pagination limit.

TYPE: int | None DEFAULT: None

offset

Optional pagination offset.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Any]

Paginated response dictionary with resources.

Source code in src/huwise_utils_py/dataset.py
def list_resources(self, *, limit: int | None = None, offset: int | None = None) -> dict[str, Any]:
    """List resources for the dataset.

    Args:
        limit: Optional pagination limit.
        offset: Optional pagination offset.

    Returns:
        Paginated response dictionary with resources.
    """
    params: dict[str, int] = {}
    if limit is not None:
        params["limit"] = limit
    if offset is not None:
        params["offset"] = offset

    response = self._client.get(f"/datasets/{self.uid}/resources/", params=params or None)
    return response.json()

upsert_http_resource(*, source_url: str, title: str | None = None, extractor_type: str | None = None, headers: list[dict[str, str]] | None = None) -> dict[str, Any]

Create or update a dataset HTTP resource idempotently.

PARAMETER DESCRIPTION
source_url

Absolute HTTP(S) source URL.

TYPE: str

title

Optional resource title.

TYPE: str | None DEFAULT: None

extractor_type

Optional extractor type. Not auto-guessed.

TYPE: str | None DEFAULT: None

headers

Optional connection headers list.

TYPE: list[dict[str, str]] | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Any]

Created or updated resource payload.

Source code in src/huwise_utils_py/dataset.py
def upsert_http_resource(
    self,
    *,
    source_url: str,
    title: str | None = None,
    extractor_type: str | None = None,
    headers: list[dict[str, str]] | None = None,
) -> dict[str, Any]:
    """Create or update a dataset HTTP resource idempotently.

    Args:
        source_url: Absolute HTTP(S) source URL.
        title: Optional resource title.
        extractor_type: Optional extractor type. Not auto-guessed.
        headers: Optional connection headers list.

    Returns:
        Created or updated resource payload.
    """
    connection_url, relative_url = self._normalize_http_source_url(source_url)

    payload: dict[str, Any] = {
        "type": "http",
        "connection": {"url": connection_url},
        "relative_url": relative_url,
    }
    if title is not None:
        payload["title"] = title
    if extractor_type is not None:
        payload["extractor_type"] = extractor_type
    if headers is not None:
        payload["connection"]["headers"] = headers

    existing_resources = self.list_resources(limit=200).get("results", [])
    if not isinstance(existing_resources, list):
        existing_resources = []

    matching_resource: dict[str, Any] | None = None
    for resource in existing_resources:
        if not isinstance(resource, dict):
            continue

        resource_uid = resource.get("uid")
        if not isinstance(resource_uid, str):
            continue

        existing_connection_url, existing_relative_url = self._extract_resource_url_parts(resource)
        url_match = existing_connection_url == connection_url and existing_relative_url == relative_url
        title_match = title is not None and resource.get("title") == title

        if url_match or title_match:
            matching_resource = resource
            break

    self._wait_for_idle()

    if matching_resource is not None:
        resource_uid = matching_resource["uid"]
        response = self._client.put(f"/datasets/{self.uid}/resources/{resource_uid}/", json=payload)
        logger.info(
            "Updated dataset resource",
            uid=self.uid,
            resource_uid=resource_uid,
            connection_url=connection_url,
            relative_url=relative_url,
        )
        return response.json()

    response = self._client.post(f"/datasets/{self.uid}/resources/", json=payload)
    logger.info(
        "Created dataset resource",
        uid=self.uid,
        connection_url=connection_url,
        relative_url=relative_url,
    )
    return response.json()

delete_resource(resource_uid: str) -> Self

Delete a resource by UID.

PARAMETER DESCRIPTION
resource_uid

Resource UID.

TYPE: str

RETURNS DESCRIPTION
Self

Self for method chaining.

Source code in src/huwise_utils_py/dataset.py
def delete_resource(self, resource_uid: str) -> Self:
    """Delete a resource by UID.

    Args:
        resource_uid: Resource UID.

    Returns:
        Self for method chaining.
    """
    self._wait_for_idle()
    self._client.delete(f"/datasets/{self.uid}/resources/{resource_uid}/")
    logger.info("Deleted dataset resource", uid=self.uid, resource_uid=resource_uid)
    return self