Skip to main content

Http client base pydantic, with requests or aiohttp

Project description

pydantic-client

Http client base pydantic, with requests or aiohttp

How to use

from pydantic import BaseModel

from pydantic_client import delete, get, post, put, RequestsClient


class Book(BaseModel):
    name: str
    age: int


class R(RequestsClient):

    @get("/books/{book_id}?query={query}")
    def get_book(self, book_id: int, query: str) -> Book:
        ...

    @post("/books", form_body=True)
    def create_book_form(self, book: Book) -> Book:
        """ will post the form with book"""
        ...

    @put("/books/{book_id}")
    def change_book(self, book_id: int, book: Book) -> Book:
        """will put the json body"""
        ...

    @delete("/books/{book_id}")
    def change_book(self, book_id: int) -> Book:
        ...


my_client = R("http://localhost/v1")
get_book: Book = my_client.get_book(1)

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_client-0.1.3.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

pydantic_client-0.1.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_client-0.1.3.tar.gz.

File metadata

  • Download URL: pydantic_client-0.1.3.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Darwin/19.5.0

File hashes

Hashes for pydantic_client-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dea0276e152f2b206d4d9d1d727308c4d88a3a85d8ae8ba60aacf92eacc685df
MD5 b2f28247657bd4b4e7ec10e45f1b001a
BLAKE2b-256 72da9be23271afdf3b779f8cbeba0d49bfbb04e14c6e02441972397c38d84b1c

See more details on using hashes here.

Provenance

File details

Details for the file pydantic_client-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pydantic_client-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Darwin/19.5.0

File hashes

Hashes for pydantic_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fd72f00c7807facddf3258f9bcf9552b245abae8b37178676d0c964e57d9a601
MD5 d6c75ba00c6f9a0fa92b3cfd2210cb98
BLAKE2b-256 ecc9bb9ca2d253913278369dabfcf42ea3163d1874fe28b3e705909a64cec43c

See more details on using hashes here.

Provenance

Supported by

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