Return models

Frontend models for the experience builder.

This module defines the frontend models that are understood and interpreted by the DASF plugin for the experience builder, see also Return Models.

Frontend implemented models:

BinaryFile(*[, response_type, category, ...])

A binary file that the user can download.

DataSource(*[, response_type])

A feature base record response.

ExternalLink(*[, response_type, category, text])

A link to an external data source.

GeoJson(*[, response_type, renderer, title])

A geojson response

MultipleResponses(*[, response_type])

A combination of multiple return models.

Classes:

CategoricalButton(*[, response_type, ...])

A base model for a categorical button.

EsriFieldType(value)

An enumeration.

GeoJsonData(*, type, features[, crs])

GeoJsonFeature(*, id, type, properties, geometry)

A feature in a GeoJson

RecordSchema(*, fields, name[, idField])

RecordSchemaField(*, name, alias, type)

Functions:

infer_esri_field_type(value)

Infer the EsriFieldType from an existing value.

random_id()

class dasf_exb.return_models.BinaryFile(*, response_type: Literal['categorical_button'] = 'categorical_button', category: str = 'Downloads', text: str | None = None, data: Annotated[bytes, EncodedBytes(encoder=Base64Encoder)], filename: str = 'The name of the file to use for the download', mimetype: str)

Bases: CategoricalButton

A binary file that the user can download.

See also the frontend implementation CategoricalButton

Attributes:

button_title

The title for the button.

data

filename

mimetype

model_config

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

property button_title: str

The title for the button.

category: str
data: Annotated[bytes, EncodedBytes(encoder=Base64Encoder)]
filename: str
mimetype: str
model_config: ClassVar[ConfigDict] = {}

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

response_type: Literal['categorical_button']
text: str | None
class dasf_exb.return_models.CategoricalButton(*, response_type: Literal['categorical_button'] = 'categorical_button', category: str = 'Downloads', text: str | None = None)

Bases: BaseModel

A base model for a categorical button.

Attributes:

button_text

category

model_config

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

response_type

text

property button_text: str
category: str
model_config: ClassVar[ConfigDict] = {}

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

response_type: Literal['categorical_button']
text: str | None
class dasf_exb.return_models.DataSource(*, response_type: Literal['datasource'] = 'datasource', records: List[Dict[str, str | datetime | date | float | int]], name: str)

Bases: BaseModel

A feature base record response.

See also the frontend implementation DataSource

Methods:

generate_datasource_config()

Generate a data source config for the frontend

Attributes:

model_config

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

name

records

response_type

generate_datasource_config() RecordSchema

Generate a data source config for the frontend

This method infers the RecordSchema for the DataSource instance. The record schema can be dumped as JSON and imported to the experience builder frontend to setup the data source. Types of the data source is infered from infer_esri_field_type()

Returns:

The infered schema

Return type:

RecordSchema

model_config: ClassVar[ConfigDict] = {}

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

name: str
records: List[Dict[str, str | datetime | date | float | int]]
response_type: Literal['datasource']
class dasf_exb.return_models.EsriFieldType(value)

Bases: str, Enum

An enumeration.

Attributes:

Blob

Date

Double

GUID

Geometry

GlobalID

Integer

OID

Raster

Single

SmallInteger

String

XML

Blob = 'esriFieldTypeBlob'
Date = 'esriFieldTypeDate'
Double = 'esriFieldTypeDouble'
GUID = 'esriFieldTypeGUID'
Geometry = 'esriFieldTypeGeometry'
GlobalID = 'esriFieldTypeGlobalID'
Integer = 'esriFieldTypeInteger'
OID = 'esriFieldTypeOID'
Raster = 'esriFieldTypeRaster'
Single = 'esriFieldTypeSingle'
SmallInteger = 'esriFieldTypeSmallInteger'
String = 'esriFieldTypeString'
XML = 'esriFieldTypeXML'

Bases: CategoricalButton

A link to an external data source.

See also the frontend implementation CategoricalButton

Attributes:

button_title

The title for the button.

href

model_config

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

property button_title: str

The title for the button.

category: str
href: HttpUrl
model_config: ClassVar[ConfigDict] = {}

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

response_type: Literal['categorical_button']
text: str | None
class dasf_exb.return_models.GeoJson(*, response_type: Literal['geojson'] = 'geojson', data: GeoJsonData, renderer: Dict | None = None, title: str = 'GeoJSON')

Bases: BaseModel

A geojson response

See also the frontend implementation GeoJson

Attributes:

data

model_config

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

renderer

response_type

title

data: GeoJsonData
model_config: ClassVar[ConfigDict] = {}

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

renderer: Dict | None
response_type: Literal['geojson']
title: str
class dasf_exb.return_models.GeoJsonData(*, type: str, features: List[GeoJsonFeature], crs: Dict | None = None)

Bases: BaseModel

Attributes:

crs

features

model_config

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

type

crs: Dict | None
features: List[GeoJsonFeature]
model_config: ClassVar[ConfigDict] = {}

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

type: str
class dasf_exb.return_models.GeoJsonFeature(*, id: str, type: str, properties: ~typing.Dict = <factory>, geometry: ~typing.Dict)

Bases: BaseModel

A feature in a GeoJson

Attributes:

geometry

id

model_config

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

properties

type

geometry: Dict
id: str
model_config: ClassVar[ConfigDict] = {}

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

properties: Dict
type: str
class dasf_exb.return_models.MultipleResponses(*, response_type: Literal['multiple'] = 'multiple', data: List[GeoJson | DataSource | BinaryFile | ExternalLink])

Bases: BaseModel

A combination of multiple return models.

See also the frontend implementation MultipleResponses

Attributes:

data

model_config

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

response_type

data: List[GeoJson | DataSource | BinaryFile | ExternalLink]
model_config: ClassVar[ConfigDict] = {}

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

response_type: Literal['multiple']
class dasf_exb.return_models.RecordSchema(*, fields: List[RecordSchemaField], name: str, idField: str | None = None)

Bases: BaseModel

Attributes:

fields

idField

model_config

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

name

fields: List[RecordSchemaField]
idField: str | None
model_config: ClassVar[ConfigDict] = {}

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

name: str
class dasf_exb.return_models.RecordSchemaField(*, name: str, alias: str, type: EsriFieldType)

Bases: BaseModel

Attributes:

alias

model_config

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

name

type

alias: str
model_config: ClassVar[ConfigDict] = {}

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

name: str
type: EsriFieldType
dasf_exb.return_models.infer_esri_field_type(value: Any) EsriFieldType

Infer the EsriFieldType from an existing value.

Parameters:

value (Any) – The value to infer the type for.

Returns:

The estimated type for the value. If none can be infered, we use a String.

Return type:

EsriFieldType

dasf_exb.return_models.random_id() str