Data Models#

Base Model Classes#

The SGUBaseModel and SGUResponse classes provide the foundation for all data models.

Base model classes for SGU Client.

class sgu_client.models.base.SGUBaseModel(**data)[source]#

Bases: BaseModel

Base model for all SGU data structures.

Parameters:

data (Any)

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.base.SGUResponse(**data)[source]#

Bases: SGUBaseModel

Base response wrapper for SGU API responses.

Parameters:

data (Any)

to_dict()[source]#

Convert to dictionary.

Return type:

dict[str, Any]

to_dataframe(**kwargs) pd.DataFrame#

Convert to pandas DataFrame.

Returns:

DataFrame with the data

Examples

This is an abstract method that must be implemented by subclasses. Use concrete collection classes instead:

>>> from sgu_client import SGUClient
>>> client = SGUClient()
>>> # Use specific collection types like GroundwaterStationCollection
>>> stations = client.levels.observed.get_stations(limit=5)
>>> df = stations.to_dataframe()  # This works!
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Shared Types#

The shared module provides common data structures used across multiple API domains.

GeoJSON Support:

The library provides full GeoJSON geometry support:

Other Shared Types:

  • Link - Hypermedia links in responses

  • CRS - Coordinate reference system metadata

Shared types (like GeoJSON objects)

Bases: SGUBaseModel

A link in a GeoJSON response.

Parameters:

data (Any)

href: str#
rel: str | None#
type: str | None#
title: str | None#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.CRS(**data)[source]#

Bases: SGUBaseModel

Coordinate Reference System.

Parameters:

data (Any)

type: str#
properties: dict[str, Any]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.Point(**data)[source]#

Bases: SGUBaseModel

GeoJSON Point geometry.

Parameters:

data (Any)

type: Literal['Point']#
coordinates: list[float]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.MultiPoint(**data)[source]#

Bases: SGUBaseModel

GeoJSON MultiPoint geometry.

Parameters:

data (Any)

type: Literal['MultiPoint']#
coordinates: list[list[float]]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.LineString(**data)[source]#

Bases: SGUBaseModel

GeoJSON LineString geometry.

Parameters:

data (Any)

type: Literal['LineString']#
coordinates: list[list[float]]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.Polygon(**data)[source]#

Bases: SGUBaseModel

GeoJSON Polygon geometry.

Parameters:

data (Any)

type: Literal['Polygon']#
coordinates: list[list[list[float]]]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sgu_client.models.shared.MultiPolygon(**data)[source]#

Bases: SGUBaseModel

GeoJSON MultiPolygon geometry.

Parameters:

data (Any)

type: Literal['MultiPolygon']#
coordinates: list[list[list[list[float]]]]#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Domain-Specific Models#

For domain-specific data models, see:

Working with Models#

Type Hints Example:

from sgu_client import SGUClient

client = SGUClient()
stations = client.levels.observed.get_stations(limit=5)

# full type hints for IDE autocomplete
for station in stations.features:
    print(f"Station: {station.properties.station_name}")
    print(f"Municipality: {station.properties.municipality}")
    print(f"Coordinates: {station.geometry.coordinates}")

DataFrame Conversion:

# convert to pandas DataFrame (requires pandas)
df = stations.to_dataframe()

# geometry and properties are automatically flattened
print(df.columns)  # station_id, longitude, latitude, municipality, etc.

See Also#

  • Core API - Core client that returns these models

  • Utilities - pandas integration utilities