Skip to main content

Extension of pydantic models for HTTP send/recieve

Project description

Pydantic-fetch

Extension of pydantic.BaseModel which supports sending and parsing from HTTP endpoints.

Description

BaseModel is extended with two class functions:

  • fetch to recieve a json payload from an endpoint and validate it as the pydantic model
  • submit to send a pydantic model to an endpoint as a json payload.

Usage

from pydantic_fetch import BaseModel

class User(BaseModel):
  id: str
  name: str


def send_user(endpoint, id: str, name: str):
  user = User(id=id, name=name)
  user.submit(endpoint)


def get_user(endpoint):
  user = User.fetch(endpoint)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic-fetch-0.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_fetch-0.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file pydantic-fetch-0.0.3.tar.gz.

File metadata

  • Download URL: pydantic-fetch-0.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for pydantic-fetch-0.0.3.tar.gz
Algorithm Hash digest
SHA256 28aeb0379b2e99e3138c3465d9b3e3ded9facf9aa931b082e152ed75c8f17aae
MD5 7a2314f1569268d4216949c457f024bc
BLAKE2b-256 cd6408af5187fc2eed8a4c1d1a954e156d330ed7a7dee60702f82e979b6c2343

See more details on using hashes here.

File details

Details for the file pydantic_fetch-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_fetch-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 41594fced7e6ea5fd549993c59b95fed6de03b4b35c24a0fd0ec9feffc4b9bf9
MD5 e3a1e0da80ee111977ae0cb36cc3683b
BLAKE2b-256 0097a567940d9c5f6a58b54d0b24e315d81612a9dd06345e297ad69a26348f3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page