From 28af14bd3f0349efea90bb50d92d9dafb80125ec Mon Sep 17 00:00:00 2001 From: <> Date: Wed, 29 Nov 2023 09:53:51 +0000 Subject: [PATCH] Deployed 02d9211 with MkDocs version: 1.5.3 --- .nojekyll | 0 404.html | 1017 + advanced/customization/index.html | 1244 + advanced/functions/index.html | 1236 + advanced/ogc_features_server/index.html | 1155 + advanced/ogc_tiles_server/index.html | 1156 + api/tipg/collections/index.html | 5701 +++ api/tipg/database/index.html | 1138 + api/tipg/dependencies/index.html | 1609 + api/tipg/errors/index.html | 3035 ++ api/tipg/factory/index.html | 2239 + api/tipg/filter/evaluate/index.html | 1911 + api/tipg/filter/filters/index.html | 2040 + api/tipg/middleware/index.html | 1236 + api/tipg/model/index.html | 39472 ++++++++++++++++ api/tipg/resources/enums/index.html | 1233 + api/tipg/resources/response/index.html | 1911 + api/tipg/settings/index.html | 13649 ++++++ assets/images/favicon.png | Bin 0 -> 1870 bytes assets/javascripts/bundle.cd18aaf1.min.js | 29 + assets/javascripts/bundle.cd18aaf1.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++ .../workers/search.f886a092.min.js | 42 + .../workers/search.f886a092.min.js.map | 7 + assets/stylesheets/main.fad675c6.min.css | 1 + assets/stylesheets/main.fad675c6.min.css.map | 1 + assets/stylesheets/palette.356b1318.min.css | 1 + .../stylesheets/palette.356b1318.min.css.map | 1 + benchmark.html | 292 + contributing/index.html | 1069 + img/favicon.ico | Bin 0 -> 3170 bytes img/logo.png | Bin 0 -> 5147 bytes index.html | 1443 + release-notes/index.html | 2039 + search/search_index.json | 1 + sitemap.xml | 3 + sitemap.xml.gz | Bin 0 -> 127 bytes user_guide/configuration/index.html | 1448 + user_guide/endpoints/index.html | 2182 + user_guide/factories/index.html | 1673 + 73 files changed, 98422 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 advanced/customization/index.html create mode 100644 advanced/functions/index.html create mode 100644 advanced/ogc_features_server/index.html create mode 100644 advanced/ogc_tiles_server/index.html create mode 100644 api/tipg/collections/index.html create mode 100644 api/tipg/database/index.html create mode 100644 api/tipg/dependencies/index.html create mode 100644 api/tipg/errors/index.html create mode 100644 api/tipg/factory/index.html create mode 100644 api/tipg/filter/evaluate/index.html create mode 100644 api/tipg/filter/filters/index.html create mode 100644 api/tipg/middleware/index.html create mode 100644 api/tipg/model/index.html create mode 100644 api/tipg/resources/enums/index.html create mode 100644 api/tipg/resources/response/index.html create mode 100644 api/tipg/settings/index.html create mode 100644 assets/images/favicon.png create mode 100644 assets/javascripts/bundle.cd18aaf1.min.js create mode 100644 assets/javascripts/bundle.cd18aaf1.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js create mode 100644 assets/javascripts/workers/search.f886a092.min.js.map create mode 100644 assets/stylesheets/main.fad675c6.min.css create mode 100644 assets/stylesheets/main.fad675c6.min.css.map create mode 100644 assets/stylesheets/palette.356b1318.min.css create mode 100644 assets/stylesheets/palette.356b1318.min.css.map create mode 100644 benchmark.html create mode 100644 contributing/index.html create mode 100644 img/favicon.ico create mode 100644 img/logo.png create mode 100644 index.html create mode 100644 release-notes/index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 user_guide/configuration/index.html create mode 100644 user_guide/endpoints/index.html create mode 100644 user_guide/factories/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/404.html b/404.html new file mode 100644 index 00000000..eb4b9f5f --- /dev/null +++ b/404.html @@ -0,0 +1,1017 @@ + + + +
+ + + + + + + + + + + + + + + + +Tipg
is designed to be fully customizable, in respect to the OGC standard. This page aims to show some example of customizations.
While Tipg
provides a default application tipg.main:app
, users can easily create their own FastAPI application and register the OGC API endpoints using the endpoint factories provided by Tipg
.
from contextlib import asynccontextmanager
+from tipg.database import close_db_connection, connect_to_db
+from tipg.collections import register_collection_catalog
+from tipg.errors import DEFAULT_STATUS_CODES, add_exception_handlers
+from tipg.factory import OGCFeaturesFactory
+from tipg.settings import PostgresSettings
+
+from fastapi import FastAPI
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ """FastAPI Lifespan
+
+ - Create DB connection POOL and `register` the custom tipg SQL function within `pg_temp`
+ - Create the collection_catalog
+ - Close the connection pool when closing the application
+
+ """
+ await connect_to_db(
+ app,
+ settings=PostgresSettings(database_url="postgres://...."),
+ schemas=["public"],
+ )
+ await register_collection_catalog(app, schemas=["public"])
+
+ yield
+
+ await close_db_connection(app)
+
+
+app = FastAPI(openapi_url="/api", docs_url="/api.html", lifespan=lifespan)
+
+endpoints = OGCFeaturesFactory(with_common=True)
+app.include_router(endpoints.router, tags=["OGC Features API"])
+
+add_exception_handlers(app, DEFAULT_STATUS_CODES)
+
The default HTML
responses are generated using Jinja HTML templates.
You can override part or a complete list of templates and then provide TIPG_TEMPLATE_DIRECTORY
environment to tell the tipg
application to first look in the provided directory for HTML templates.
When building custom tipg
application you can set the templates
attribute of the Endpoints
Factory.
from fastapi import FastAPI
+import jinja2
+
+from tipg.factory import Endpoints
+
+app = FastAPI(openapi_url="/api", docs_url="/api.html")
+
+templates_location = (
+ [
+ jinja2.FileSystemLoader("{PATH TO YOUR CUSTOM TEMPLATE DIRECTORY}"),
+ jinja2.PackageLoader("tipg", "templates"), # Fallback to default's tipg templates
+ ]
+)
+
+templates = Jinja2Templates(
+ directory="",
+ loader=jinja2.ChoiceLoader(templates_location),
+) # type: ignore
+
+ogc_api = Endpoints(templates=templates)
+app.include_router(ogc_api.router)
+
Example:
+In eoAPI
, we use a custom logo by overriding the header.html
: github.com/developmentseed/eoAPI/blob/8a3b3de4e82499994fec022229ac3be70bbc1388/runtime/eoapi/vector/eoapi/vector/templates/header.html
tipg
support SQL functional layers (see Functions).
Functions
will be either found by tipg
at startup within the specified schemas or by registering them dynamically to the pg_temp
schema when creating the Database connection.
To register
custom SQL functions, user can set TIPG_CUSTOM_SQL_DIRECTORY
environment variable when using tipg
demo application or set user_sql_files
option in tipg.db.connect_to_db.
from tipg.database import connect_to_db
+from tipg.collections import register_collection_catalog
+from tipg.settings import PostgresSettings
+
+postgres_settings = PostgresSettings()
+
+app = FastAPI()
+
+@app.on_event("startup")
+async def startup_event() -> None:
+ """Connect to database on startup."""
+ await connect_to_db(
+ app,
+ settings=postgres_settings,
+ schemas=["public"],
+ user_sql_files="tests/fixtures/functions", # <----
+ )
+ await register_collection_catalog(
+ app,
+ schemas=["public"],
+ exclude_function_schemas=["public"],
+ )
+
TIPG_DB_EXCLUDE_FUNCTION_SCHEMAS='["public"]' TIPG_CUSTOM_SQL_DIRECTORY=tests/fixtures/functions uvicorn tipg.main:app --port 8000 --reload
+
curl -s http://127.0.0.1:8000/collections\?f\=json | jq -r '.collections[].id' | grep "pg_temp"
+pg_temp.landsat_centroids
+pg_temp.hexagons_g
+pg_temp.hexagons
+pg_temp.squares
+pg_temp.landsat
+
SQL Functions
are any procedural functions defined in the database that match the following criteria:
SETOF
RECORD
must include typed OUT definitions in the function signatureIN
and OUT
) must be namedgeometry
will be usable as Features and Vector Tiles, those that do not, will be available to return json/csvSQL Function
arguments will be exposed to the items API as query parameters. Any argument that does not have a default will be required and will return an error if not set as a query parameter. Functions should have a unique name. Function overloading by argument type is not currently supported.
If a function is defined to have z
, x
, or y
parameters, those will be filled from the path parameters in requests to Tile endpoints. If a function has a bounds
parameter, that will be populated by the Tile bounding box in requests to Tile endpoints. All other arguments will be filled from query parameters matching the name of the argument and cast to the appropriate types.
At startup, tipg
application will look for any SQL functions with the above signature and then get displayed as Collections
:
curl -s http://127.0.0.1:8000/collections\?f\=json | jq -r '.collections[].id' | grep "public.st_"
+public.st_squaregrid
+public.st_hexagongrid
+public.st_subdivide
+
Note: By default, tipg
should find st_squaregrid
, st_hexagongrid
, and st_subdivide
functions when using the public
schema from PostGIS
Important
+SQL Functions
can be pre-existent in the database, or you can tell tipg
to register SQL code dynamically to the pg_temp
schema at startup, see customization
With geometry
input:
CREATE FUNCTION hexagons(
+ IN size int DEFAULT 10,
+ IN bounds geometry DEFAULT 'srid=4326;POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))'::geometry,
+ OUT geom geometry,
+ OUT i integer,
+ OUT j integer
+) RETURNS SETOF RECORD AS $$
+ SELECT * FROM st_hexagongrid(size, bounds);
+$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
+
Only returning geometries:
+CREATE FUNCTION hexagons(
+ IN size int DEFAULT 10,
+ IN bounds geometry DEFAULT 'srid=4326;POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))'::geometry,
+ OUT geom geometry,
+) RETURNS SETOF geometry AS $$
+ SELECT geom FROM st_hexagongrid(size, bounds);
+$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
+
With x
, y
, z
input:
CREATE FUNCTION landsat(
+ IN z int,
+ IN x int,
+ IN y int,
+ IN p int default 0,
+ OUT path_row text,
+ OUT grid_path int,
+ OUT grid_row int,
+ OUT geom geometry
+) RETURNS SETOF RECORD AS $$
+ SELECT pr as path_row, path as grid_path, row AS grid_row, geom FROM public.landsat_wrs WHERE path = p AND ST_Intersects(geom, ST_Transform(ST_TileEnvelope(z, x, y), 4326));
+$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;
+
curl -s http://127.0.0.1:8000/collections/pg_temp.landsat/queryables?f=schemajson | jq
+
+{
+ "title": "pg_temp.landsat",
+ "properties": {
+ "geom": {
+ "$ref": "https://geojson.org/schema/Geometry.json"
+ },
+ "grid_path": {
+ "name": "grid_path",
+ "type": "number"
+ },
+ "grid_row": {
+ "name": "grid_row",
+ "type": "number"
+ },
+ "path_row": {
+ "name": "path_row",
+ "type": "string"
+ }
+ },
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "http://127.0.0.1:8000/collections/pg_temp.landsat/queryables?f=schemajson"
+}
+
CREATE OR REPLACE VIEW landsat_centroids AS
+SELECT ogc_fid, pr, st_pointonsurface(geom) as geom, path, row
+FROM public.landsat_wrs;
+
curl -s http://127.0.0.1:8000/collections/pg_temp.landsat_centroids/queryables?f=schemajson | jq
+{
+ "title": "pg_temp.landsat_centroids",
+ "properties": {
+ "geom": {
+ "$ref": "https://geojson.org/schema/Geometry.json"
+ },
+ "ogc_fid": {
+ "name": "ogc_fid",
+ "type": "number"
+ },
+ "path": {
+ "name": "path",
+ "type": "number"
+ },
+ "pr": {
+ "name": "pr",
+ "type": "string"
+ },
+ "row": {
+ "name": "row",
+ "type": "number"
+ }
+ },
+ "type": "object",
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "http://127.0.0.1:8000/collections/pg_temp.landsat_centroids/queryables?f=schemajson"
+}
+
TiPg
default application comes with both OGC Tiles and Features endpoints but some users might just want one or the other. TiPg
is built around the notion of endpoints factories which then makes easy to build custom applications with the desired set of endpoints.
The code below shows how to create a simple OGC Features service.
+"""OGC Features service."""
+
+from contextlib import asynccontextmanager
+
+import jinja2
+
+from tipg.collections import register_collection_catalog
+from tipg.database import close_db_connection, connect_to_db
+from tipg.errors import DEFAULT_STATUS_CODES, add_exception_handlers
+from tipg.factory import OGCFeaturesFactory
+from tipg.middleware import CacheControlMiddleware, CatalogUpdateMiddleware
+from tipg.settings import CustomSQLSettings, DatabaseSettings, PostgresSettings
+
+from fastapi import FastAPI
+
+from starlette.middleware.cors import CORSMiddleware
+from starlette.templating import Jinja2Templates
+from starlette_cramjam.middleware import CompressionMiddleware
+
+postgres_settings = PostgresSettings()
+db_settings = DatabaseSettings()
+custom_sql_settings = CustomSQLSettings()
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ """FastAPI Lifespan."""
+ # Create Connection Pool
+ await connect_to_db(
+ app,
+ settings=postgres_settings,
+ schemas=db_settings.schemas,
+ user_sql_files=custom_sql_settings.sql_files,
+ )
+
+ # Register Collection Catalog
+ await register_collection_catalog(
+ app,
+ schemas=db_settings.schemas,
+ tables=db_settings.tables,
+ exclude_tables=db_settings.exclude_tables,
+ exclude_table_schemas=db_settings.exclude_table_schemas,
+ functions=db_settings.functions,
+ exclude_functions=db_settings.exclude_functions,
+ exclude_function_schemas=db_settings.exclude_function_schemas,
+ spatial=db_settings.only_spatial_tables,
+ )
+
+ yield
+
+ # Close the Connection Pool
+ await close_db_connection(app)
+
+
+app = FastAPI(
+ title="TiPG Features Server",
+ openapi_url="/api",
+ docs_url="/api.html",
+ lifespan=lifespan,
+)
+
+templates = Jinja2Templates(
+ directory="", # we need to set a dummy directory variable, see https://github.com/encode/starlette/issues/1214
+ loader=jinja2.ChoiceLoader([jinja2.PackageLoader("tipg", "templates")]),
+) # type: ignore
+
+ogc_features = OGCFeaturesFactory(
+ title="TiPG Features Server",
+ templates=templates,
+ with_common=True,
+)
+app.include_router(ogc_features.router)
+
+app.add_middleware(
+ CORSMiddleware,
+ allow_origins=["*"],
+ allow_credentials=True,
+ allow_methods=["GET"],
+ allow_headers=["*"],
+)
+app.add_middleware(CacheControlMiddleware, cachecontrol="public, max-age=3600")
+app.add_middleware(CompressionMiddleware)
+app.add_middleware(
+ CatalogUpdateMiddleware,
+ func=register_collection_catalog,
+ ttl=300,
+ schemas=db_settings.schemas,
+ tables=db_settings.tables,
+ exclude_tables=db_settings.exclude_tables,
+ exclude_table_schemas=db_settings.exclude_table_schemas,
+ functions=db_settings.functions,
+ exclude_functions=db_settings.exclude_functions,
+ exclude_function_schemas=db_settings.exclude_function_schemas,
+ spatial=db_settings.only_spatial_tables,
+)
+
+add_exception_handlers(app, DEFAULT_STATUS_CODES)
+
+
+@app.get(
+ "/healthz",
+ description="Health Check.",
+ summary="Health Check.",
+ operation_id="healthCheck",
+ tags=["Health Check"],
+)
+def ping():
+ """Health check."""
+ return {"ping": "pong!"}
+
TiPg
default application comes with both OGC Tiles and Features endpoints but some users might just want one or the other. TiPg
is built around the notion of endpoints factories which then makes easy to build custom applications with the desired set of endpoints.
The code below shows how to create a simple OGC Vector tiles service.
+"""OGC Vector Tiles service."""
+
+from contextlib import asynccontextmanager
+
+import jinja2
+
+from tipg.collections import register_collection_catalog
+from tipg.database import close_db_connection, connect_to_db
+from tipg.errors import DEFAULT_STATUS_CODES, add_exception_handlers
+from tipg.factory import OGCTilesFactory
+from tipg.middleware import CacheControlMiddleware, CatalogUpdateMiddleware
+from tipg.settings import CustomSQLSettings, DatabaseSettings, PostgresSettings
+
+from fastapi import FastAPI
+
+from starlette.middleware.cors import CORSMiddleware
+from starlette.templating import Jinja2Templates
+from starlette_cramjam.middleware import CompressionMiddleware
+
+postgres_settings = PostgresSettings()
+db_settings = DatabaseSettings()
+custom_sql_settings = CustomSQLSettings()
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ """FastAPI Lifespan."""
+ # Create Connection Pool
+ await connect_to_db(
+ app,
+ settings=postgres_settings,
+ schemas=db_settings.schemas,
+ user_sql_files=custom_sql_settings.sql_files,
+ )
+
+ # Register Collection Catalog
+ await register_collection_catalog(
+ app,
+ schemas=db_settings.schemas,
+ tables=db_settings.tables,
+ exclude_tables=db_settings.exclude_tables,
+ exclude_table_schemas=db_settings.exclude_table_schemas,
+ functions=db_settings.functions,
+ exclude_functions=db_settings.exclude_functions,
+ exclude_function_schemas=db_settings.exclude_function_schemas,
+ spatial=db_settings.only_spatial_tables,
+ )
+
+ yield
+
+ # Close the Connection Pool
+ await close_db_connection(app)
+
+
+app = FastAPI(
+ title="TiPG Vector Tiles Server",
+ openapi_url="/api",
+ docs_url="/api.html",
+ lifespan=lifespan,
+)
+
+templates = Jinja2Templates(
+ directory="", # we need to set a dummy directory variable, see https://github.com/encode/starlette/issues/1214
+ loader=jinja2.ChoiceLoader([jinja2.PackageLoader("tipg", "templates")]),
+) # type: ignore
+
+ogc_tiles = OGCTilesFactory(
+ title="TiPG Vector Tiles Server",
+ templates=templates,
+ with_common=True,
+ with_viewer=True,
+)
+app.include_router(ogc_tiles.router)
+
+app.add_middleware(
+ CORSMiddleware,
+ allow_origins=["*"],
+ allow_credentials=True,
+ allow_methods=["GET"],
+ allow_headers=["*"],
+)
+app.add_middleware(CacheControlMiddleware, cachecontrol="public, max-age=3600")
+app.add_middleware(CompressionMiddleware)
+app.add_middleware(
+ CatalogUpdateMiddleware,
+ func=register_collection_catalog,
+ ttl=300,
+ schemas=db_settings.schemas,
+ tables=db_settings.tables,
+ exclude_tables=db_settings.exclude_tables,
+ exclude_table_schemas=db_settings.exclude_table_schemas,
+ functions=db_settings.functions,
+ exclude_functions=db_settings.exclude_functions,
+ exclude_function_schemas=db_settings.exclude_function_schemas,
+ spatial=db_settings.only_spatial_tables,
+)
+
+add_exception_handlers(app, DEFAULT_STATUS_CODES)
+
+
+@app.get(
+ "/healthz",
+ description="Health Check.",
+ summary="Health Check.",
+ operation_id="healthCheck",
+ tags=["Health Check"],
+)
+def ping():
+ """Health check."""
+ return {"ping": "pong!"}
+
tipg.dbmodel: database events.
+features_settings
+
geojson_schema
+
mvt_settings
+
def debug_query(
+ q,
+ *p
+)
+
Utility to print raw statement to use for debugging.
+def get_collection_index(
+ db_pool: buildpg.asyncpg.BuildPgPool,
+ schemas: Union[List[str], NoneType] = None,
+ tables: Union[List[str], NoneType] = None,
+ exclude_tables: Union[List[str], NoneType] = None,
+ exclude_table_schemas: Union[List[str], NoneType] = None,
+ functions: Union[List[str], NoneType] = None,
+ exclude_functions: Union[List[str], NoneType] = None,
+ exclude_function_schemas: Union[List[str], NoneType] = None,
+ spatial: bool = True,
+ spatial_extent: bool = True,
+ datetime_extent: bool = True
+) -> tipg.collections.Catalog
+
Fetch Table and Functions index.
+def register_collection_catalog(
+ app: fastapi.applications.FastAPI,
+ **kwargs: Any
+) -> None
+
Register Table catalog.
+class Catalog(
+ /,
+ *args,
+ **kwargs
+)
+
Internal Collection Catalog.
+def clear(
+ ...
+)
+
D.clear() -> None. Remove all items from D.
+def copy(
+ ...
+)
+
D.copy() -> a shallow copy of D
+def fromkeys(
+ iterable,
+ value=None,
+ /
+)
+
Create a new dictionary with keys from iterable and values set to value.
+def get(
+ self,
+ key,
+ default=None,
+ /
+)
+
Return the value for key if key is in the dictionary, else default.
+def items(
+ ...
+)
+
D.items() -> a set-like object providing a view on D's items
+def keys(
+ ...
+)
+
D.keys() -> a set-like object providing a view on D's keys
+def pop(
+ ...
+)
+
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
+If key is not found, d is returned if given, otherwise KeyError is raised
+def popitem(
+ self,
+ /
+)
+
Remove and return a (key, value) pair as a 2-tuple.
+Pairs are returned in LIFO (last-in, first-out) order. +Raises KeyError if the dict is empty.
+def setdefault(
+ self,
+ key,
+ default=None,
+ /
+)
+
Insert key with a value of default if key is not in the dictionary.
+Return the value for key if key is in the dictionary, else default.
+def update(
+ ...
+)
+
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
+If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] +If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v +In either case, this is followed by: for k in F: D[k] = F[k]
+def values(
+ ...
+)
+
D.values() -> an object providing a view on D's values
+class Collection(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Model for DB Table and Function.
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
bounds
+
Return spatial bounds from collection extent.
+crs
+
Return crs of set geometry column.
+datetime_columns
+
Return datetime columns.
+dt_bounds
+
Return temporal bounds from collection extent.
+extent
+
Return extent.
+geometry_columns
+
Return geometry columns.
+id_column_info
+
Return Column for a unique identifier.
+model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+queryables
+
Return the queryables.
+def columns(
+ self,
+ properties: Union[List[str], NoneType] = None
+) -> List[str]
+
Return table columns optionally filtered to only include columns from properties.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def features(
+ self,
+ pool: buildpg.asyncpg.BuildPgPool,
+ *,
+ ids_filter: Union[List[str], NoneType] = None,
+ bbox_filter: Union[List[float], NoneType] = None,
+ datetime_filter: Union[List[str], NoneType] = None,
+ properties_filter: Union[List[Tuple[str, str]], NoneType] = None,
+ cql_filter: Union[ForwardRef('Node'), pygeofilter.values.Geometry, pygeofilter.values.Envelope, datetime.date, datetime.datetime, datetime.timedelta, pygeofilter.values.Interval, bool, float, int, str, list, NoneType] = None,
+ sortby: Union[str, NoneType] = None,
+ properties: Union[List[str], NoneType] = None,
+ geom: Union[str, NoneType] = None,
+ dt: Union[str, NoneType] = None,
+ limit: Union[int, NoneType] = None,
+ offset: Union[int, NoneType] = None,
+ bbox_only: Union[bool, NoneType] = None,
+ simplify: Union[float, NoneType] = None,
+ geom_as_wkt: bool = False,
+ function_parameters: Union[Dict[str, str], NoneType] = None
+) -> tipg.collections.ItemList
+
Build and run Pg query.
+def get_column(
+ self,
+ property_name: str
+) -> Union[tipg.collections.Column, NoneType]
+
Return column info.
+def get_datetime_column(
+ self,
+ name: Union[str, NoneType] = None
+) -> Union[tipg.collections.Column, NoneType]
+
Return the Column for either the passed in tstz column or the first tstz column.
+def get_geometry_column(
+ self,
+ name: Union[str, NoneType] = None
+) -> Union[tipg.collections.Column, NoneType]
+
Return the name of the first geometry column.
+def get_tile(
+ self,
+ *,
+ pool: buildpg.asyncpg.BuildPgPool,
+ tms: morecantile.models.TileMatrixSet,
+ tile: morecantile.commons.Tile,
+ ids_filter: Union[List[str], NoneType] = None,
+ bbox_filter: Union[List[float], NoneType] = None,
+ datetime_filter: Union[List[str], NoneType] = None,
+ properties_filter: Union[List[Tuple[str, str]], NoneType] = None,
+ function_parameters: Union[Dict[str, str], NoneType] = None,
+ cql_filter: Union[ForwardRef('Node'), pygeofilter.values.Geometry, pygeofilter.values.Envelope, datetime.date, datetime.datetime, datetime.timedelta, pygeofilter.values.Interval, bool, float, int, str, list, NoneType] = None,
+ sortby: Union[str, NoneType] = None,
+ properties: Union[List[str], NoneType] = None,
+ geom: Union[str, NoneType] = None,
+ dt: Union[str, NoneType] = None,
+ limit: Union[int, NoneType] = None
+)
+
Build query to get Vector Tile.
+def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class CollectionList(
+ /,
+ *args,
+ **kwargs
+)
+
Collections.
+def clear(
+ ...
+)
+
D.clear() -> None. Remove all items from D.
+def copy(
+ ...
+)
+
D.copy() -> a shallow copy of D
+def fromkeys(
+ iterable,
+ value=None,
+ /
+)
+
Create a new dictionary with keys from iterable and values set to value.
+def get(
+ self,
+ key,
+ default=None,
+ /
+)
+
Return the value for key if key is in the dictionary, else default.
+def items(
+ ...
+)
+
D.items() -> a set-like object providing a view on D's items
+def keys(
+ ...
+)
+
D.keys() -> a set-like object providing a view on D's keys
+def pop(
+ ...
+)
+
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
+If key is not found, d is returned if given, otherwise KeyError is raised
+def popitem(
+ self,
+ /
+)
+
Remove and return a (key, value) pair as a 2-tuple.
+Pairs are returned in LIFO (last-in, first-out) order. +Raises KeyError if the dict is empty.
+def setdefault(
+ self,
+ key,
+ default=None,
+ /
+)
+
Insert key with a value of default if key is not in the dictionary.
+Return the value for key if key is in the dictionary, else default.
+def update(
+ ...
+)
+
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
+If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] +If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v +In either case, this is followed by: for k in F: D[k] = F[k]
+def values(
+ ...
+)
+
D.values() -> an object providing a view on D's values
+class Column(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Model for database Column.
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def sridbounds_default(
+ values
+)
+
Set default bounds and srid when this is a function.
+def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
is_datetime
+
Returns true if this property is a datetime column.
+is_geometry
+
Returns true if this property is a geometry column.
+json_type
+
Return JSON field type.
+model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Feature(
+ /,
+ *args,
+ **kwargs
+)
+
Simple Feature model.
+def clear(
+ ...
+)
+
D.clear() -> None. Remove all items from D.
+def copy(
+ ...
+)
+
D.copy() -> a shallow copy of D
+def fromkeys(
+ iterable,
+ value=None,
+ /
+)
+
Create a new dictionary with keys from iterable and values set to value.
+def get(
+ self,
+ key,
+ default=None,
+ /
+)
+
Return the value for key if key is in the dictionary, else default.
+def items(
+ ...
+)
+
D.items() -> a set-like object providing a view on D's items
+def keys(
+ ...
+)
+
D.keys() -> a set-like object providing a view on D's keys
+def pop(
+ ...
+)
+
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
+If key is not found, d is returned if given, otherwise KeyError is raised
+def popitem(
+ self,
+ /
+)
+
Remove and return a (key, value) pair as a 2-tuple.
+Pairs are returned in LIFO (last-in, first-out) order. +Raises KeyError if the dict is empty.
+def setdefault(
+ self,
+ key,
+ default=None,
+ /
+)
+
Insert key with a value of default if key is not in the dictionary.
+Return the value for key if key is in the dictionary, else default.
+def update(
+ ...
+)
+
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
+If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] +If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v +In either case, this is followed by: for k in F: D[k] = F[k]
+def values(
+ ...
+)
+
D.values() -> an object providing a view on D's values
+class ItemList(
+ /,
+ *args,
+ **kwargs
+)
+
Items.
+def clear(
+ ...
+)
+
D.clear() -> None. Remove all items from D.
+def copy(
+ ...
+)
+
D.copy() -> a shallow copy of D
+def fromkeys(
+ iterable,
+ value=None,
+ /
+)
+
Create a new dictionary with keys from iterable and values set to value.
+def get(
+ self,
+ key,
+ default=None,
+ /
+)
+
Return the value for key if key is in the dictionary, else default.
+def items(
+ ...
+)
+
D.items() -> a set-like object providing a view on D's items
+def keys(
+ ...
+)
+
D.keys() -> a set-like object providing a view on D's keys
+def pop(
+ ...
+)
+
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
+If key is not found, d is returned if given, otherwise KeyError is raised
+def popitem(
+ self,
+ /
+)
+
Remove and return a (key, value) pair as a 2-tuple.
+Pairs are returned in LIFO (last-in, first-out) order. +Raises KeyError if the dict is empty.
+def setdefault(
+ self,
+ key,
+ default=None,
+ /
+)
+
Insert key with a value of default if key is not in the dictionary.
+Return the value for key if key is in the dictionary, else default.
+def update(
+ ...
+)
+
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
+If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] +If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v +In either case, this is followed by: for k in F: D[k] = F[k]
+def values(
+ ...
+)
+
D.values() -> an object providing a view on D's values
+class Parameter(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Model for PostGIS function parameters.
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def sridbounds_default(
+ values
+)
+
Set default bounds and srid when this is a function.
+def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
is_datetime
+
Returns true if this property is a datetime column.
+is_geometry
+
Returns true if this property is a geometry column.
+json_type
+
Return JSON field type.
+model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+ + + + + + +tipg.db: database events.
+DB_CATALOG_FILE
+
def close_db_connection(
+ app: fastapi.applications.FastAPI
+) -> None
+
Close connection.
+def connect_to_db(
+ app: fastapi.applications.FastAPI,
+ settings: Union[tipg.settings.PostgresSettings, NoneType] = None,
+ schemas: Union[List[str], NoneType] = None,
+ user_sql_files: Union[List[pathlib.Path], NoneType] = None,
+ **kwargs
+) -> None
+
Connect.
+class connection_factory(
+ schemas: Union[List[str], NoneType] = None,
+ user_sql_files: Union[List[pathlib.Path], NoneType] = None
+)
+
Connection creation.
+ + + + + + +tipg dependencies.
+FilterLang
+
ItemResponseType
+
ItemsResponseType
+
QueryablesResponseType
+
ResponseType
+
VectorResponseType
+
VectorType
+
tms_settings
+
def CollectionParams(
+ request: starlette.requests.Request,
+ collectionId: typing_extensions.Annotated[str, Path(PydanticUndefined)]
+) -> tipg.collections.Collection
+
Return Layer Object.
+def CollectionsParams(
+ request: starlette.requests.Request,
+ bbox_filter: typing_extensions.Annotated[Union[List[float], NoneType], Depends(bbox_query)],
+ datetime_filter: typing_extensions.Annotated[Union[List[str], NoneType], Depends(datetime_query)],
+ type_filter: typing_extensions.Annotated[Union[Literal['Function', 'Table'], NoneType], Query(PydanticUndefined)] = None,
+ limit: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None,
+ offset: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None
+) -> tipg.collections.CollectionList
+
Return Collections Catalog.
+def ItemOutputType(
+ request: starlette.requests.Request,
+ f: typing_extensions.Annotated[Union[Literal['geojson', 'html', 'json'], NoneType], Query(PydanticUndefined)] = None
+) -> Union[tipg.resources.enums.MediaType, NoneType]
+
Output MediaType: geojson, json or html.
+def ItemsOutputType(
+ request: starlette.requests.Request,
+ f: typing_extensions.Annotated[Union[Literal['geojson', 'html', 'json', 'csv', 'geojsonseq', 'ndjson'], NoneType], Query(PydanticUndefined)] = None
+) -> Union[tipg.resources.enums.MediaType, NoneType]
+
Output MediaType: geojson, html, json, csv, geojsonseq, ndjson.
+def OutputType(
+ request: starlette.requests.Request,
+ f: typing_extensions.Annotated[Union[Literal['json', 'html'], NoneType], Query(PydanticUndefined)] = None
+) -> Union[tipg.resources.enums.MediaType, NoneType]
+
Output MediaType: json or html.
+def QueryablesOutputType(
+ request: starlette.requests.Request,
+ f: typing_extensions.Annotated[Union[Literal['schemajson', 'html'], NoneType], Query(PydanticUndefined)] = None
+) -> Union[tipg.resources.enums.MediaType, NoneType]
+
Output MediaType: schemajson or html.
+def TileParams(
+ z: typing_extensions.Annotated[int, Path(PydanticUndefined)],
+ x: typing_extensions.Annotated[int, Path(PydanticUndefined)],
+ y: typing_extensions.Annotated[int, Path(PydanticUndefined)]
+) -> morecantile.commons.Tile
+
Tile parameters.
+def accept_media_type(
+ accept: str,
+ mediatypes: List[tipg.resources.enums.MediaType]
+) -> Union[tipg.resources.enums.MediaType, NoneType]
+
Return MediaType based on accept header and available mediatype.
+Links: +- www.w3.org/Protocols/rfc2616/rfc2616-sec14.html +- developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
+def bbox_query(
+ bbox: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None
+) -> Union[List[float], NoneType]
+
BBox dependency.
+def datetime_query(
+ datetime: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None
+) -> Union[List[str], NoneType]
+
Datetime dependency.
+def filter_query(
+ query: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None,
+ filter_lang: typing_extensions.Annotated[Union[Literal['cql2-text', 'cql2-json'], NoneType], Query(PydanticUndefined)] = None
+) -> Union[ForwardRef('Node'), pygeofilter.values.Geometry, pygeofilter.values.Envelope, datetime.date, datetime.datetime, datetime.timedelta, pygeofilter.values.Interval, bool, float, int, str, list, NoneType]
+
Parse Filter Query.
+def function_parameters_query(
+ request: starlette.requests.Request,
+ collection: tipg.collections.Collection
+) -> Dict[str, str]
+
Get parameters for function layers.
+def ids_query(
+ ids: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None
+) -> Union[List[str], NoneType]
+
Ids dependency.
+def properties_filter_query(
+ request: starlette.requests.Request,
+ collection: tipg.collections.Collection
+) -> List[Tuple[str, str]]
+
Get properties to filter on excluding reserved keys.
+def properties_query(
+ properties: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None
+) -> Union[List[str], NoneType]
+
Return property list.
+def s_intersects(
+ bbox: List[float],
+ spatial_extent: List[float]
+) -> bool
+
Check if bbox intersects with spatial extent.
+def sortby_query(
+ sortby: typing_extensions.Annotated[Union[str, NoneType], Query(PydanticUndefined)] = None
+)
+
Sortby dependency.
+def t_intersects(
+ interval: List[str],
+ temporal_extent: List[str]
+) -> bool
+
Check if dates intersect with temporal extent.
+ + + + + + +tipg.errors: Error classes.
+DEFAULT_STATUS_CODES
+
logger
+
def add_exception_handlers(
+ app: fastapi.applications.FastAPI,
+ status_codes: Dict[Type[Exception], int]
+) -> None
+
Add exception handlers to the FastAPI app.
+def exception_handler_factory(
+ status_code: int
+) -> Callable
+
Create a FastAPI exception handler from a status code.
+class FunctionDirectoryDoesNotExist(
+ /,
+ *args,
+ **kwargs
+)
+
Function Directory Is Set But Does Not Exist.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidBBox(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid bounding box coordinates.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidDatetime(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid datetime.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidDatetimeColumnName(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid datetime column name.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidGeometryColumnName(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid geometry column name.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidLimit(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid Limit.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class InvalidPropertyName(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid property/column name.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class MissingCollectionCatalog(
+ /,
+ *args,
+ **kwargs
+)
+
collection_catalog
not registered in the application state.
args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class MissingDatetimeColumn(
+ /,
+ *args,
+ **kwargs
+)
+
Table has no datetime column.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class MissingFunctionParameter(
+ /,
+ *args,
+ **kwargs
+)
+
Missing Function Parameter.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class MissingGeometryColumn(
+ /,
+ *args,
+ **kwargs
+)
+
Table has no geometry column.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class NoPrimaryKey(
+ /,
+ *args,
+ **kwargs
+)
+
Table has no primary key.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class NotFound(
+ /,
+ *args,
+ **kwargs
+)
+
Invalid table name.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+class TiPgError(
+ /,
+ *args,
+ **kwargs
+)
+
Base exception class.
+args
+
def with_traceback(
+ ...
+)
+
Exception.with_traceback(tb) --
+set self.traceback to tb and return self.
+ + + + + + +tipg.factory: router factories.
+COMMON_CONFORMS
+
DEFAULT_TEMPLATES
+
FEATURES_CONFORMS
+
TILES_CONFORMS
+
features_settings
+
mvt_settings
+
tms_settings
+
def create_csv_rows(
+ data: Iterable[Dict]
+) -> Generator[str, NoneType, NoneType]
+
Creates an iterator that returns lines of csv from an iterable of dicts.
+def create_html_response(
+ request: starlette.requests.Request,
+ data: str,
+ templates: starlette.templating.Jinja2Templates,
+ template_name: str,
+ router_prefix: Union[str, NoneType] = None
+) -> starlette.templating._TemplateResponse
+
Create Template response.
+class Endpoints(
+ router: fastapi.routing.APIRouter = <factory>,
+ collection_dependency: Callable[..., tipg.collections.Collection] = <function CollectionParams at 0x7fe4f0d904c0>,
+ router_prefix: str = '',
+ templates: starlette.templating.Jinja2Templates = <starlette.templating.Jinja2Templates object at 0x7fe4f0d58eb0>,
+ with_common: bool = True,
+ title: str = 'OGC API',
+ collections_dependency: Callable[..., tipg.collections.CollectionList] = <function CollectionsParams at 0x7fe4f0d90550>,
+ supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'CDB1GlobalGrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/CDB1GlobalGrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'GNOSISGlobalGrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/GNOSISGlobalGrid.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'WebMercatorQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WebMercatorQuad.json'), 'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json')}),
+ with_tiles_viewer: bool = True
+)
+
OGC Features and Tiles Endpoints Factory.
+router_prefix
+
supported_tms
+
templates
+
title
+
with_common
+
with_tiles_viewer
+
conforms_to
+
Endpoints conformances.
+def collection_dependency(
+ request: starlette.requests.Request,
+ collectionId: typing_extensions.Annotated[str, Path(PydanticUndefined)]
+) -> tipg.collections.Collection
+
Return Layer Object.
+def collections_dependency(
+ request: starlette.requests.Request,
+ bbox_filter: typing_extensions.Annotated[Union[List[float], NoneType], Depends(bbox_query)],
+ datetime_filter: typing_extensions.Annotated[Union[List[str], NoneType], Depends(datetime_query)],
+ type_filter: typing_extensions.Annotated[Union[Literal['Function', 'Table'], NoneType], Query(PydanticUndefined)] = None,
+ limit: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None,
+ offset: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None
+) -> tipg.collections.CollectionList
+
Return Collections Catalog.
+def links(
+ self,
+ request: starlette.requests.Request
+) -> List[tipg.model.Link]
+
List of available links.
+def register_routes(
+ self
+)
+
Register factory Routes.
+def url_for(
+ self,
+ request: starlette.requests.Request,
+ name: str,
+ **path_params: Any
+) -> str
+
Return full url (with prefix) for a specific handler.
+class EndpointsFactory(
+ router: fastapi.routing.APIRouter = <factory>,
+ collection_dependency: Callable[..., tipg.collections.Collection] = <function CollectionParams at 0x7fe4f0d904c0>,
+ router_prefix: str = '',
+ templates: starlette.templating.Jinja2Templates = <starlette.templating.Jinja2Templates object at 0x7fe4f0d58eb0>,
+ with_common: bool = True,
+ title: str = 'OGC API'
+)
+
Endpoints Factory.
+router_prefix
+
templates
+
title
+
with_common
+
conforms_to
+
Endpoints conformances.
+def collection_dependency(
+ request: starlette.requests.Request,
+ collectionId: typing_extensions.Annotated[str, Path(PydanticUndefined)]
+) -> tipg.collections.Collection
+
Return Layer Object.
+def links(
+ self,
+ request: starlette.requests.Request
+) -> List[tipg.model.Link]
+
Register factory Routes.
+def register_routes(
+ self
+)
+
Register factory Routes.
+def url_for(
+ self,
+ request: starlette.requests.Request,
+ name: str,
+ **path_params: Any
+) -> str
+
Return full url (with prefix) for a specific handler.
+class OGCFeaturesFactory(
+ router: fastapi.routing.APIRouter = <factory>,
+ collection_dependency: Callable[..., tipg.collections.Collection] = <function CollectionParams at 0x7fe4f0d904c0>,
+ router_prefix: str = '',
+ templates: starlette.templating.Jinja2Templates = <starlette.templating.Jinja2Templates object at 0x7fe4f0d58eb0>,
+ with_common: bool = True,
+ title: str = 'OGC API',
+ collections_dependency: Callable[..., tipg.collections.CollectionList] = <function CollectionsParams at 0x7fe4f0d90550>
+)
+
OGC Features Endpoints Factory.
+router_prefix
+
templates
+
title
+
with_common
+
conforms_to
+
Factory conformances.
+def collection_dependency(
+ request: starlette.requests.Request,
+ collectionId: typing_extensions.Annotated[str, Path(PydanticUndefined)]
+) -> tipg.collections.Collection
+
Return Layer Object.
+def collections_dependency(
+ request: starlette.requests.Request,
+ bbox_filter: typing_extensions.Annotated[Union[List[float], NoneType], Depends(bbox_query)],
+ datetime_filter: typing_extensions.Annotated[Union[List[str], NoneType], Depends(datetime_query)],
+ type_filter: typing_extensions.Annotated[Union[Literal['Function', 'Table'], NoneType], Query(PydanticUndefined)] = None,
+ limit: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None,
+ offset: typing_extensions.Annotated[Union[int, NoneType], Query(PydanticUndefined)] = None
+) -> tipg.collections.CollectionList
+
Return Collections Catalog.
+def links(
+ self,
+ request: starlette.requests.Request
+) -> List[tipg.model.Link]
+
OGC Features API links.
+def register_routes(
+ self
+)
+
Register OGC Features endpoints.
+def url_for(
+ self,
+ request: starlette.requests.Request,
+ name: str,
+ **path_params: Any
+) -> str
+
Return full url (with prefix) for a specific handler.
+class OGCTilesFactory(
+ router: fastapi.routing.APIRouter = <factory>,
+ collection_dependency: Callable[..., tipg.collections.Collection] = <function CollectionParams at 0x7fe4f0d904c0>,
+ router_prefix: str = '',
+ templates: starlette.templating.Jinja2Templates = <starlette.templating.Jinja2Templates object at 0x7fe4f0d58eb0>,
+ with_common: bool = True,
+ title: str = 'OGC API',
+ supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'CDB1GlobalGrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/CDB1GlobalGrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'GNOSISGlobalGrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/GNOSISGlobalGrid.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'WebMercatorQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WebMercatorQuad.json'), 'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json')}),
+ with_viewer: bool = True
+)
+
OGC Tiles Endpoints Factory.
+router_prefix
+
supported_tms
+
templates
+
title
+
with_common
+
with_viewer
+
conforms_to
+
Factory conformances.
+def collection_dependency(
+ request: starlette.requests.Request,
+ collectionId: typing_extensions.Annotated[str, Path(PydanticUndefined)]
+) -> tipg.collections.Collection
+
Return Layer Object.
+def links(
+ self,
+ request: starlette.requests.Request
+) -> List[tipg.model.Link]
+
OGC Tiles API links.
+def register_routes(
+ self
+)
+
Register OGC Tiles endpoints.
+def url_for(
+ self,
+ request: starlette.requests.Request,
+ name: str,
+ **path_params: Any
+) -> str
+
Return full url (with prefix) for a specific handler.
+ + + + + + +tipg.filter.evaluate.
+LITERALS
+
def to_filter(
+ ast,
+ field_mapping=None
+)
+
Helper function to translate ECQL AST to Django Query expressions.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
ast | +:class:Node |
+the abstract syntax tree | +None | +
field_mapping | +None | +a dict mapping from the filter name to the Django field lookup. | +None | +
mapping_choices | +None | +a dict mapping field lookups to choices. | +None | +
Returns:
+Type | +Description | +
---|---|
:class:django.db.models.Q |
+a Django query object | +
class BuildPGEvaluator(
+ field_mapping
+)
+
Base class for AST evaluators.
+handler_map
+
def adopt(
+ self,
+ node,
+ *sub_args
+)
+
Interface function for a last resort when trying to evaluate a node
+and no handler was found.
+def adopt_result(
+ self,
+ result: Any
+) -> Any
+
Interface function for adopting the final evaluation result
+if necessary. Default is no-op.
+def arithmetic(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def attribute(
+ self,
+ node
+)
+
def bbox(
+ self,
+ node,
+ lhs
+)
+
def between(
+ self,
+ node,
+ lhs,
+ low,
+ high
+)
+
def combination(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def comparison(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def envelope(
+ self,
+ node
+)
+
def evaluate(
+ self,
+ node: Union[ForwardRef('Node'), pygeofilter.values.Geometry, pygeofilter.values.Envelope, datetime.date, datetime.datetime, datetime.timedelta, pygeofilter.values.Interval, bool, float, int, str, list],
+ adopt_result: bool = True
+) -> Any
+
Recursive function to evaluate an abstract syntax tree.
+For every node in the walked syntax tree, its registered handler
+is called with the node as first parameter and all pre-evaluated
+child nodes as star-arguments.
+When no handler was found for a given node, the adopt
function
+is called with the node and its arguments, which by default raises
+an NotImplementedError
.
def function(
+ self,
+ node,
+ *arguments
+)
+
def geometry(
+ self,
+ node
+)
+
def in_(
+ self,
+ node,
+ lhs,
+ *options
+)
+
def interval(
+ self,
+ node,
+ start,
+ end
+)
+
def like(
+ self,
+ node,
+ lhs
+)
+
def literal(
+ self,
+ node
+)
+
def not_(
+ self,
+ node,
+ sub
+)
+
def null(
+ self,
+ node,
+ lhs
+)
+
def spatial_distance(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def spatial_operation(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def spatial_pattern(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
def temporal(
+ self,
+ node,
+ lhs,
+ rhs
+)
+
tipg.filter.filters
+UNITS_LOOKUP
+
def attribute(
+ name: str,
+ fields: List[str]
+)
+
Create an attribute lookup expression using a field mapping dictionary.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
name | +None | +the field filter name | +None | +
field_mapping | +None | +the dictionary to use as a lookup. | +None | +
def bbox(
+ lhs,
+ minx,
+ miny,
+ maxx,
+ maxy,
+ crs: int = 4326
+)
+
Create a bounding box filter for the given spatial attribute.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +None | +the field to compare | +None | +
minx | +None | +the lower x part of the bbox | +None | +
miny | +None | +the lower y part of the bbox | +None | +
maxx | +None | +the upper x part of the bbox | +None | +
maxy | +None | +the upper y part of the bbox | +None | +
crs | +None | +the CRS the bbox is expressed in | +None | +
Returns:
+Type | +Description | +
---|---|
None | +a comparison expression object | +
def bbox_to_wkt(
+ bbox: List[float],
+ srid: int = 4326
+) -> str
+
Return WKT representation of a BBOX.
+def between(
+ lhs,
+ low,
+ high,
+ negate=False
+)
+
Create a filter to match elements that have a value within a certain range.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +None | +the field to compare | +None | +
low | +None | +the lower value of the range | +None | +
high | +None | +the upper value of the range | +None | +
not_ | +None | +whether the range shall be inclusive (the default) or exclusive | +None | +
Returns:
+Type | +Description | +
---|---|
None | +a comparison expression object | +
def combine(
+ sub_filters,
+ combinator: str = 'AND'
+)
+
Combine filters using a logical combinator
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sub_filters | +None | +the filters to combine | +None | +
combinator | +None | +a string: "AND" / "OR" | +None | +
Returns:
+Type | +Description | +
---|---|
None | +the combined filter | +
def func(
+ name,
+ *args
+)
+
Return results of running SQL function with arguments.
+def isnull(
+ lhs
+)
+
null value.
+def like(
+ lhs,
+ rhs,
+ case=False,
+ negate=False
+)
+
Create a filter to filter elements according to a string attribute using wildcard expressions.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +None | +the field to compare | +None | +
rhs | +None | +the wildcard pattern: a string containing any number of '%' characters as wildcards. | +None | +
case | +None | +whether the lookup shall be done case sensitively or not | +None | +
not_ | +None | +whether the range shall be inclusive (the default) or exclusive | +None | +
Returns:
+Type | +Description | +
---|---|
None | +a comparison expression object | +
def literal(
+ value
+)
+
literal value.
+def negate(
+ sub_filter
+)
+
Negate a filter, opposing its meaning.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sub_filter | +None | +the filter to negate | +None | +
Returns:
+Type | +Description | +
---|---|
None | +the negated filter | +
def parse_geometry(
+ geom: Dict[str, Any]
+) -> str
+
Parse geometry object and return WKT.
+def quote_ident(
+ s: str
+) -> str
+
quote.
+def runop(
+ lhs,
+ rhs=None,
+ op: str = '=',
+ negate: bool = False
+)
+
Compare a filter with an expression using a comparison operation.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +None | +the field to compare | +None | +
rhs | +None | +the filter expression | +None | +
op | +None | +a string denoting the operation. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +a comparison expression object | +
def spatial(
+ lhs,
+ rhs,
+ op,
+ pattern=None,
+ distance=None,
+ units=None
+)
+
Create a spatial filter for the given spatial attribute.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +None | +the field to compare | +None | +
rhs | +None | +the time instant or time span to use as a filter | +None | +
op | +None | +the comparison operation. one of "INTERSECTS" , "DISJOINT" , `"CONTAINS", "WITHIN", "TOUCHES", "CROSSES", "OVERLAPS", "EQUALS", "RELATE", "DWITHIN", "BEYOND"`` |
+None | +
pattern | +None | +the spatial relation pattern | +None | +
distance | +None | +the distance value for distance based lookups: "DWITHIN" and "BEYOND" |
+None | +
units | +None | +the units the distance is expressed in | +None | +
Returns:
+Type | +Description | +
---|---|
None | +a comparison expression object | +
def temporal(
+ lhs,
+ time_or_period,
+ op
+)
+
Create a temporal filter for the given temporal attribute.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lhs | +:class:django.db.models.F |
+the field to compare | +None | +
time_or_period | +:class:datetime.datetime or a tuple of two datetimes or a tuple of one datetime and one :class:datetime.timedelta |
+the time instant or time span to use as a filter | +None | +
op | +str | +the comparison operation. one of "BEFORE" , "BEFORE OR DURING" , "DURING" , "DURING OR AFTER" , "AFTER" . |
+None | +
Returns:
+Type | +Description | +
---|---|
:class:django.db.models.Q |
+a comparison expression object | +
class Operator(
+ operator: str = None
+)
+
Filter Operators.
+OPERATORS
+
tipg middlewares.
+class CacheControlMiddleware(
+ app: Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[NoneType]]], Awaitable[NoneType]],
+ cachecontrol: Union[str, NoneType] = None,
+ cachecontrol_max_http_code: Union[int, NoneType] = 500,
+ exclude_path: Union[Set[str], NoneType] = None
+)
+
MiddleWare to add CacheControl in response headers.
+class CatalogUpdateFunc(
+ *args,
+ **kwargs
+)
+
Catalog update function protocol.
+class CatalogUpdateMiddleware(
+ app: Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[NoneType]]], Awaitable[NoneType]],
+ *,
+ func: tipg.middleware.CatalogUpdateFunc,
+ ttl: int = 300,
+ **kwargs: Any
+)
+
Middleware to update the catalog cache.
+ + + + + + +tipg models.
+AccessConstraints
+
Type
+
class BoundingBox(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
BoundingBox model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/2DBoundingBox.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Collection(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Collection model.
+Note: CRS
is the list of CRS supported by the service not the CRS of the collection
Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/collection.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Collections(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Collections model.
+Ref: beta.schemas.opengis.net/ogcapi/common/part2/0.1/collections/openapi/schemas/collections.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Conformance(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Conformance model.
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/confClasses.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Extent(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Extent model.
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/extent.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class GeospatialData(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Geospatial model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/geospatialData.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Item(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Item model
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/featureGeoJSON.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def set_geometry(
+ geometry: Any
+) -> Any
+
set geometry from geo interface or input
+def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
def validate_bbox(
+ bbox: 'Optional[BBox]'
+) -> 'Optional[BBox]'
+
Validate BBox values are ordered correctly.
+model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def clean_model(
+ self,
+ serializer: 'Any',
+ info: 'SerializationInfo'
+) -> 'Dict[str, Any]'
+
Custom Model serializer to match the GeoJSON specification.
+Used to remove fields which are optional but cannot be null values.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Items(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Items model
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/featureCollectionGeoJSON.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
def validate_bbox(
+ bbox: 'Optional[BBox]'
+) -> 'Optional[BBox]'
+
Validate BBox values are ordered correctly.
+model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def clean_model(
+ self,
+ serializer: 'Any',
+ info: 'SerializationInfo'
+) -> 'Dict[str, Any]'
+
Custom Model serializer to match the GeoJSON specification.
+Used to remove fields which are optional but cannot be null values.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def json_seq(
+ self,
+ **kwargs
+)
+
return a GeoJSON sequence representation.
+def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Landing(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Landing page model.
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/landingPage.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class LayerJSON(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
github.com/mapbox/tilejson-spec/tree/master/3.0.0#33-vector_layers
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Link(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Link model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/common-core/link.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Properties(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Properties model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/propertiesSchema.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class PropertiesSchema(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
PropertiesSchema model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/propertiesSchema.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Queryables(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Queryables model.
+Ref: docs.ogc.org/DRAFTS/19-079r1.html#filter-queryables
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Spatial(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Spatial Extent model.
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/extent.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Style(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Style model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/style.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class StyleJSON(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Simple Mapbox/Maplibre Style JSON model.
+Based on docs.mapbox.com/help/glossary/style/
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class Temporal(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
Temporal Extent model.
+Ref: schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/extent.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileJSON(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileJSON model.
+Based on github.com/mapbox/tilejson-spec/tree/master/2.2.0
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def compute_center(
+ self
+)
+
Compute center if it does not exist.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileMatrixLimits(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
The limits for an individual tile matrix of a TileSet's TileMatrixSet, as defined in the OGC 2D TileMatrixSet and TileSet Metadata Standard
+Based on github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/tileMatrixLimits.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileMatrixSetLink(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileMatrixSetLink model.
+Based on docs.opengeospatial.org/per/19-069.html#_tilematrixsets
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileMatrixSetList(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileMatrixSetList model.
+Based on docs.opengeospatial.org/per/19-069.html#_tilematrixsets
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileMatrixSetRef(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileMatrixSetRef model.
+Based on docs.opengeospatial.org/per/19-069.html#_tilematrixsets
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TilePoint(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TilePoint model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/tilePoint.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileSet(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileSet model.
+Based on github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/tileSet.yaml
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TileSetList(
+ __pydantic_self__,
+ **data: 'Any'
+)
+
TileSetList model.
+Based on docs.ogc.org/is/20-057/20-057.html#toc34
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TimeStamp(
+ __pydantic_self__,
+ root: 'RootModelRootType' = PydanticUndefined,
+ **data
+)
+
TimeStamp model.
+Ref: github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/common-geodata/timeStamp.yaml
+Code generated using koxudaxi/datamodel-code-generator
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ root: 'RootModelRootType',
+ _fields_set: 'set[str] | None' = None
+) -> 'Model'
+
Create a new model using the provided root object and update fields set.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
root | +None | +The root object of the model. | +None | +
_fields_set | +None | +The set of fields to be updated. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The new model. | +
Raises:
+Type | +Description | +
---|---|
NotImplemented | +If the model is not a subclass of RootModel . |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+ + + + + + +tipg enums.
+class MediaType(
+ /,
+ *args,
+ **kwargs
+)
+
Responses Media types formerly known as MIME types.
+csv
+
geojson
+
geojsonseq
+
html
+
json
+
mvt
+
name
+
ndjson
+
openapi30_json
+
openapi30_yaml
+
pbf
+
schemajson
+
text
+
value
+
xml
+
tipg custom responses.
+def default(
+ obj
+)
+
Instruct orjson what to do with types it does not natively serialize
+class GeoJSONResponse(
+ content: Any,
+ status_code: int = 200,
+ headers: Union[Dict[str, str], NoneType] = None,
+ media_type: Union[str, NoneType] = None,
+ background: Union[starlette.background.BackgroundTask, NoneType] = None
+)
+
GeoJSON Response
+charset
+
media_type
+
headers
+
def delete_cookie(
+ self,
+ key: str,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
def init_headers(
+ self,
+ headers: Union[Mapping[str, str], NoneType] = None
+) -> None
+
def render(
+ self,
+ content: Any
+) -> bytes
+
Render the content into a JSON response using orjson
+def set_cookie(
+ self,
+ key: str,
+ value: str = '',
+ max_age: Union[int, NoneType] = None,
+ expires: Union[datetime.datetime, str, int, NoneType] = None,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
class ORJSONResponse(
+ content: Any,
+ status_code: int = 200,
+ headers: Union[Dict[str, str], NoneType] = None,
+ media_type: Union[str, NoneType] = None,
+ background: Union[starlette.background.BackgroundTask, NoneType] = None
+)
+
Custom response handler for using orjson
+charset
+
media_type
+
headers
+
def delete_cookie(
+ self,
+ key: str,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
def init_headers(
+ self,
+ headers: Union[Mapping[str, str], NoneType] = None
+) -> None
+
def render(
+ self,
+ content: Any
+) -> bytes
+
Render the content into a JSON response using orjson
+def set_cookie(
+ self,
+ key: str,
+ value: str = '',
+ max_age: Union[int, NoneType] = None,
+ expires: Union[datetime.datetime, str, int, NoneType] = None,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
class SchemaJSONResponse(
+ content: Any,
+ status_code: int = 200,
+ headers: Union[Dict[str, str], NoneType] = None,
+ media_type: Union[str, NoneType] = None,
+ background: Union[starlette.background.BackgroundTask, NoneType] = None
+)
+
Schema Response
+charset
+
media_type
+
headers
+
def delete_cookie(
+ self,
+ key: str,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
def init_headers(
+ self,
+ headers: Union[Mapping[str, str], NoneType] = None
+) -> None
+
def render(
+ self,
+ content: Any
+) -> bytes
+
Render the content into a JSON response using orjson
+def set_cookie(
+ self,
+ key: str,
+ value: str = '',
+ max_age: Union[int, NoneType] = None,
+ expires: Union[datetime.datetime, str, int, NoneType] = None,
+ path: str = '/',
+ domain: Union[str, NoneType] = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: Union[Literal['lax', 'strict', 'none'], NoneType] = 'lax'
+) -> None
+
tipg config.
+class APISettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
API settings
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_cors_origin(
+ v
+)
+
Parse CORS origins.
+def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class CustomSQLSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
TiPg Custom SQL settings.
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+sql_files
+
return a list of SQL files within the custom sql directory.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class DatabaseSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
TiPg Database settings.
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class FeaturesSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
TiPG Items settings
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def max_default(
+ self
+)
+
Set default bounds and srid when this is a function.
+def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class MVTSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
TiPG MVT settings
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class PostgresSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
Postgres connection settings.
+Name | +Type | +Description | +Default | +
---|---|---|---|
postgres_user | +None | +postgres username. | +None | +
postgres_pass | +None | +postgres password. | +None | +
postgres_host | +None | +hostname for the connection. | +None | +
postgres_port | +None | +database port. | +None | +
postgres_dbname | +None | +database name. | +None | +
model_config
+
model_fields
+
def assemble_db_connection(
+ v: Union[str, NoneType],
+ info: pydantic_core.core_schema.ValidationInfo
+) -> typing_extensions.Annotated[pydantic_core._pydantic_core.MultiHostUrl, UrlConstraints(max_length=None, allowed_schemes=['postgres', 'postgresql', 'postgresql+asyncpg', 'postgresql+pg8000', 'postgresql+psycopg', 'postgresql+psycopg2', 'postgresql+psycopg2cffi', 'postgresql+py-postgresql', 'postgresql+pygresql'], host_required=True, default_host=None, default_port=None, default_path=None)]
+
Validate db url settings.
+def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TMSSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
TiPG TMS settings
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+class TableConfig(
+ /,
+ *args,
+ **kwargs
+)
+
Configuration to add table options with env variables.
+def clear(
+ ...
+)
+
D.clear() -> None. Remove all items from D.
+def copy(
+ ...
+)
+
D.copy() -> a shallow copy of D
+def fromkeys(
+ iterable,
+ value=None,
+ /
+)
+
Create a new dictionary with keys from iterable and values set to value.
+def get(
+ self,
+ key,
+ default=None,
+ /
+)
+
Return the value for key if key is in the dictionary, else default.
+def items(
+ ...
+)
+
D.items() -> a set-like object providing a view on D's items
+def keys(
+ ...
+)
+
D.keys() -> a set-like object providing a view on D's keys
+def pop(
+ ...
+)
+
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
+If key is not found, d is returned if given, otherwise KeyError is raised
+def popitem(
+ self,
+ /
+)
+
Remove and return a (key, value) pair as a 2-tuple.
+Pairs are returned in LIFO (last-in, first-out) order. +Raises KeyError if the dict is empty.
+def setdefault(
+ self,
+ key,
+ default=None,
+ /
+)
+
Insert key with a value of default if key is not in the dictionary.
+Return the value for key if key is in the dictionary, else default.
+def update(
+ ...
+)
+
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
+If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] +If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v +In either case, this is followed by: for k in F: D[k] = F[k]
+def values(
+ ...
+)
+
D.values() -> an object providing a view on D's values
+class TableSettings(
+ __pydantic_self__,
+ _case_sensitive: 'bool | None' = None,
+ _env_prefix: 'str | None' = None,
+ _env_file: 'DotenvType | None' = PosixPath('.'),
+ _env_file_encoding: 'str | None' = None,
+ _env_nested_delimiter: 'str | None' = None,
+ _secrets_dir: 'str | Path | None' = None,
+ **values: 'Any'
+)
+
Table configuration settings
+model_config
+
model_fields
+
def construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
def from_orm(
+ obj: 'Any'
+) -> 'Model'
+
def model_construct(
+ _fields_set: 'set[str] | None' = None,
+ **values: 'Any'
+) -> 'Model'
+
Creates a new instance of the Model
class with validated data.
Creates a new model setting __dict__
and __pydantic_fields_set__
from trusted or pre-validated data.
+Default values are respected, but no other validation is performed.
+Behaves as if Config.extra = 'allow'
was set since it adds all passed values
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
_fields_set | +None | +The set of field names accepted for the Model instance. | +None | +
values | +None | +Trusted or pre-validated data dictionary. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A new instance of the Model class with validated data. |
+
def model_json_schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>,
+ mode: 'JsonSchemaMode' = 'validation'
+) -> 'dict[str, Any]'
+
Generates a JSON schema for a model class.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
by_alias | +None | +Whether to use attribute aliases or not. | +None | +
ref_template | +None | +The reference template. | +None | +
schema_generator | +None | +To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema with your desired modifications |
+None | +
mode | +None | +The mode in which to generate the schema. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The JSON schema for the given model class. | +
def model_parametrized_name(
+ params: 'tuple[type[Any], ...]'
+) -> 'str'
+
Compute the class name for parametrizations of generic classes.
+This method can be overridden to achieve a custom naming scheme for generic BaseModels.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params | +None | +Tuple of types of the class. Given a generic classModel with 2 type variables and a concrete model Model[str, int] ,the value (str, int) would be passed to params . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +String representing the new class where params are passed to cls as type variables. |
+
Raises:
+Type | +Description | +
---|---|
TypeError | +Raised when trying to generate concrete names for non-generic models. | +
def model_rebuild(
+ *,
+ force: 'bool' = False,
+ raise_errors: 'bool' = True,
+ _parent_namespace_depth: 'int' = 2,
+ _types_namespace: 'dict[str, Any] | None' = None
+) -> 'bool | None'
+
Try to rebuild the pydantic-core schema for the model.
+This may be necessary when one of the annotations is a ForwardRef which could not be resolved during +the initial attempt to build the schema, and automatic rebuilding fails.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
force | +None | +Whether to force the rebuilding of the model schema, defaults to False . |
+None | +
raise_errors | +None | +Whether to raise errors, defaults to True . |
+None | +
_parent_namespace_depth | +None | +The depth level of the parent namespace, defaults to 2. | +None | +
_types_namespace | +None | +The types namespace, defaults to None . |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +Returns None if the schema is already "complete" and rebuilding was not required.If rebuilding was required, returns True if rebuilding was successful, otherwise False . |
+
def model_validate(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ from_attributes: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate a pydantic model instance.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object to validate. | +None | +
strict | +None | +Whether to raise an exception on invalid fields. | +None | +
from_attributes | +None | +Whether to extract data from object attributes. | +None | +
context | +None | +Additional context to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated model instance. | +
Raises:
+Type | +Description | +
---|---|
ValidationError | +If the object could not be validated. | +
def model_validate_json(
+ json_data: 'str | bytes | bytearray',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/json/#json-parsing
+Validate the given JSON data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
json_data | +None | +The JSON data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
Raises:
+Type | +Description | +
---|---|
ValueError | +If json_data is not a JSON string. |
+
def model_validate_strings(
+ obj: 'Any',
+ *,
+ strict: 'bool | None' = None,
+ context: 'dict[str, Any] | None' = None
+) -> 'Model'
+
Validate the given object contains string data against the Pydantic model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
obj | +None | +The object contains string data to validate. | +None | +
strict | +None | +Whether to enforce types strictly. | +None | +
context | +None | +Extra variables to pass to the validator. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +The validated Pydantic model. | +
def parse_file(
+ path: 'str | Path',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def parse_obj(
+ obj: 'Any'
+) -> 'Model'
+
def parse_raw(
+ b: 'str | bytes',
+ *,
+ content_type: 'str | None' = None,
+ encoding: 'str' = 'utf8',
+ proto: 'DeprecatedParseProtocol | None' = None,
+ allow_pickle: 'bool' = False
+) -> 'Model'
+
def schema(
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}'
+) -> 'typing.Dict[str, Any]'
+
def schema_json(
+ *,
+ by_alias: 'bool' = True,
+ ref_template: 'str' = '#/$defs/{model}',
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def settings_customise_sources(
+ settings_cls: 'type[BaseSettings]',
+ init_settings: 'PydanticBaseSettingsSource',
+ env_settings: 'PydanticBaseSettingsSource',
+ dotenv_settings: 'PydanticBaseSettingsSource',
+ file_secret_settings: 'PydanticBaseSettingsSource'
+) -> 'tuple[PydanticBaseSettingsSource, ...]'
+
Define the sources and their order for loading the settings values.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
settings_cls | +None | +The Settings class. | +None | +
init_settings | +None | +The InitSettingsSource instance. |
+None | +
env_settings | +None | +The EnvSettingsSource instance. |
+None | +
dotenv_settings | +None | +The DotEnvSettingsSource instance. |
+None | +
file_secret_settings | +None | +The SecretsSettingsSource instance. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +A tuple containing the sources and their order for loading the settings values. | +
def update_forward_refs(
+ **localns: 'Any'
+) -> 'None'
+
def validate(
+ value: 'Any'
+) -> 'Model'
+
model_computed_fields
+
Get the computed fields of this model instance.
+model_extra
+
Get extra fields set during validation.
+model_fields_set
+
Returns the set of fields that have been explicitly set on this model instance.
+def copy(
+ self: 'Model',
+ *,
+ include: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None,
+ update: 'typing.Dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Returns a copy of the model.
+Deprecated
+This method is now deprecated; use model_copy
instead.
If you need include
or exclude
, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
+data = {**data, **(update or {})}
+copied = self.model_validate(data)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
include | +None | +Optional set or mapping specifying which fields to include in the copied model. |
+None | +
exclude | +None | +Optional set or mapping specifying which fields to exclude in the copied model. |
+None | +
update | +None | +Optional dictionary of field-value pairs to override field values in the copied model. |
+None | +
deep | +None | +If True, the values of fields that are Pydantic models will be deep copied. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A copy of the model with included, excluded and updated fields as specified. | +
def dict(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False
+) -> 'typing.Dict[str, Any]'
+
def json(
+ self,
+ *,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ encoder: 'typing.Callable[[Any], Any] | None' = PydanticUndefined,
+ models_as_dict: 'bool' = PydanticUndefined,
+ **dumps_kwargs: 'Any'
+) -> 'str'
+
def model_copy(
+ self: 'Model',
+ *,
+ update: 'dict[str, Any] | None' = None,
+ deep: 'bool' = False
+) -> 'Model'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#model_copy
+Returns a copy of the model.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
update | +None | +Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
+None | +
deep | +None | +Set to True to make a deep copy of the model. |
+None | +
Returns:
+Type | +Description | +
---|---|
None | +New model instance. | +
def model_dump(
+ self,
+ *,
+ mode: "Literal[('json', 'python')] | str" = 'python',
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'dict[str, Any]'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump
+Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
mode | +None | +The mode in which to_python should run.If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. |
+None | +
include | +None | +A list of fields to include in the output. | +None | +
exclude | +None | +A list of fields to exclude from the output. | +None | +
by_alias | +None | +Whether to use the field's alias in the dictionary key if defined. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that are set to their default value from the output. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None from the output. |
+None | +
round_trip | +None | +Whether to enable serialization and deserialization round-trip support. | +None | +
warnings | +None | +Whether to log warnings when invalid fields are encountered. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A dictionary representation of the model. | +
def model_dump_json(
+ self,
+ *,
+ indent: 'int | None' = None,
+ include: 'IncEx' = None,
+ exclude: 'IncEx' = None,
+ by_alias: 'bool' = False,
+ exclude_unset: 'bool' = False,
+ exclude_defaults: 'bool' = False,
+ exclude_none: 'bool' = False,
+ round_trip: 'bool' = False,
+ warnings: 'bool' = True
+) -> 'str'
+
Usage docs: docs.pydantic.dev/2.5/concepts/serialization/#modelmodel_dump_json
+Generates a JSON representation of the model using Pydantic's to_json
method.
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
indent | +None | +Indentation to use in the JSON output. If None is passed, the output will be compact. | +None | +
include | +None | +Field(s) to include in the JSON output. Can take either a string or set of strings. | +None | +
exclude | +None | +Field(s) to exclude from the JSON output. Can take either a string or set of strings. | +None | +
by_alias | +None | +Whether to serialize using field aliases. | +None | +
exclude_unset | +None | +Whether to exclude fields that have not been explicitly set. | +None | +
exclude_defaults | +None | +Whether to exclude fields that have the default value. | +None | +
exclude_none | +None | +Whether to exclude fields that have a value of None . |
+None | +
round_trip | +None | +Whether to use serialization/deserialization between JSON and class instance. | +None | +
warnings | +None | +Whether to show any warnings that occurred during serialization. | +None | +
Returns:
+Type | +Description | +
---|---|
None | +A JSON string representation of the model. | +
def model_post_init(
+ self,
+ _BaseModel__context: 'Any'
+) -> 'None'
+
Override this method to perform additional initialization after __init__
and model_construct
.
This is useful if you want to do some validation that requires the entire model to be initialized.
+ + + + + + +{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var $a=/["'&<>]/;Un.exports=Ra;function Ra(e){var t=""+e,r=$a.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i