Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2025-05-09 "IconikFieldType Update" - version 1.13.0

### Fixed
- Updated `IconikFieldType` enum with the exact field types supported by the Iconik API
- Added missing `string_exact` type and removed unsupported types

### Technical Details
This release updates the `IconikFieldType` enum to match the exact field types accepted by the Iconik API. The update ensures accurate field type validation when creating or updating metadata fields, preventing errors with field type validation.

## 2025-05-09 "ViewField Label Bugfix" - version 1.12.1

### Fixed
Expand Down
31 changes: 22 additions & 9 deletions pythonik/models/metadata/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@
from enum import Enum
from pydantic import BaseModel, HttpUrl


class IconikFieldType(str, Enum):
"""Known Iconik metadata field types based on documentation.
Actual values sent to/received from API.
"""Iconik metadata field types as confirmed by API error messages.
These are the exact values accepted by the Iconik API.
"""
STRING = "string" # General short text
TEXT = "text" # Longer text (potentially multi-line in UI but distinct type)
TEXT_AREA = "text_area" # Explicitly for larger amounts of text data

INTEGER = "integer"
FLOAT = "float"
BOOLEAN = "boolean" # For Yes/No fields
BOOLEAN = "boolean" # For Yes/No fields
STRING = "string" # General short text
STRING_EXACT = "string_exact" # Case-sensitive string matching
TEXT = "text" # Longer text (potentially multi-line in UI)
DATE = "date"
DATETIME = "datetime" # For Date Time fields
DROPDOWN = "drop_down" # For fields with predefined options
EMAIL = "email"
DATETIME = "datetime" # For Date Time fields
TAG_CLOUD = "tag_cloud" # For free-form tag collections
URL = "url"
DROPDOWN = "drop_down" # For fields with predefined options
EMAIL = "email"


class FieldOption(BaseModel):
"""Represents an option for a metadata field (e.g., for dropdowns)."""

label: Optional[str] = None
value: Optional[str] = None


class _FieldConfigurable(BaseModel):
"""Base model for common configurable attributes of metadata fields."""

label: Optional[str] = None
field_type: Optional[IconikFieldType] = None
description: Optional[str] = None
Expand All @@ -47,22 +53,28 @@ class _FieldConfigurable(BaseModel):
external_id: Optional[str] = None
source_url: Optional[HttpUrl] = None


class FieldCreate(_FieldConfigurable):
"""Data Transfer Object for creating a new metadata field."""

name: str
label: str
field_type: IconikFieldType


class FieldUpdate(_FieldConfigurable):
"""
Data Transfer Object for updating an existing metadata field.
All fields are optional to support partial updates.
'name' is specified in the URL path for updates, not in the body.
"""

pass


class Field(_FieldConfigurable):
"""Represents a metadata field as returned by the API."""

id: str
name: str
label: str
Expand All @@ -72,6 +84,7 @@ class Field(_FieldConfigurable):
date_modified: Optional[datetime] = None
mapped_field_name: Optional[str] = None


class FieldResponse(BaseModel):
auto_set: bool
date_created: datetime
Expand Down