fit#

@fitrequest.decorators.fit.fit(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'GET', json_path: str | None = None) None#

Decorator class for marking methods as FitRequest methods. The decorator’s attributes are a subset of the MethodConfig attributes. Additional attributes are inferred from the function’s signature (e.g., name, async_method, docstring, …)

@fitrequest.decorators.fit.get(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, *, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'GET', json_path: str | None = None) None#

Partial object from the @fit decorator where the request_verb argument is set to GET.

@fitrequest.decorators.fit.put(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, *, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'PUT', json_path: str | None = None) None#

Partial object from the @fit decorator where the request_verb argument is set to PUT.

@fitrequest.decorators.fit.post(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, *, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'POST', json_path: str | None = None) None#

Partial object from the @fit decorator where the request_verb argument is set to POST.

@fitrequest.decorators.fit.patch(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, *, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'PATCH', json_path: str | None = None) None#

Partial object from the @fit decorator where the request_verb argument is set to PATCH.

@fitrequest.decorators.fit.delete(endpoint: str, base_url: str | None = None, save_method: bool = False, raise_for_status: bool = True, *, request_verb: Literal['DELETE', 'GET', 'PATCH', 'POST', 'PUT'] = 'DELETE', json_path: str | None = None) None#

Partial object from the @fit decorator where the request_verb argument is set to DELETE.

Example#

from typing import Any
from fitrequest.decorators import get, put, post, patch, delete, retry
from fitrequest.client import FitRequest


class RestApiClient(FitRequest):
    """Awesome class generated with fitrequest."""

    client_name = 'rest_api'
    base_url = 'https://test.skillcorner.fr'
    method_docstring = 'Calling endpoint: {request_verb.value.upper()} {endpoint}'

    @retry(max_retries=3, on_status='500-600')
    @get(endpoint='/items/{item_id}')
    def get_item(self, item_id: str) -> Any: ...

    @retry(max_retries=3, on_status='500-600')
    @put(endpoint='/items/{item_id}')
    def put_item(self, item_id: str, json: dict) -> Any: ...

    @retry(max_retries=3, on_status='500-600')
    @post(endpoint='/items/{item_id}')
    def post_item(self, item_id: str, json: dict) -> Any: ...

    @retry(max_retries=3, on_status='500-600')
    @patch(endpoint='/items/{item_id}')
    def patch_item(self, item_id: str, json: dict) -> Any: ...

    @retry(max_retries=3, on_status='500-600')
    @delete(endpoint='/items/{item_id}')
    def delete_item(self, item_id: str) -> Any: ...


client_decorated_verbs = RestApiClient()