gfwapiclient.http.models.request
¶
Global Fishing Watch (GFW) API Python Client - HTTP Request Models.
Module Contents¶
Classes¶
Base model for handling HTTP query parameters. |
|
Base model for handling HTTP request bodies. |
Data¶
API¶
- gfwapiclient.http.models.request.__all__ = ['RequestBody', 'RequestParams', '_RequestBodyT', '_RequestParamsT']¶
- class gfwapiclient.http.models.request.RequestParams(/, **data: typing.Any)¶
Bases:
gfwapiclient.base.models.BaseModel
Base model for handling HTTP query parameters.
This model serializes query parameters into different formats, including indexed lists (e.g., field[0]=value1), comma-separated lists (e.g., field=value1,value2), etc.
- Attributes:
- indexed_fields (ClassVar[Optional[List[str]]]):
A list of field aliases that should be serialized as indexed list parameters (e.g., field[0]=value1, field[1]=value2).
- comma_separated_fields (ClassVar[Optional[List[str]]]):
A list of field aliases that should be serialized as comma-separated parameters (e.g., field=value1,value2,value3).
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- to_query_params(**kwargs: Any) Dict[str, Any] ¶
Convert a RequestParams instance to a dictionary-compactible HTTP query parameters.
This method serializes the model’s fields according to the specified formats (indexed, comma-separated, or standard) and returns a dictionary that can be used as query parameters in an HTTP request.
- Args:
- **kwargs (Any):
Additional arguments passed to the model_dump method to customize the serialization process.
- Returns:
- Dict[str, Any]:
A dictionary representing HTTP query parameters.
- gfwapiclient.http.models.request._RequestParamsT = 'TypeVar(...)'¶
- class gfwapiclient.http.models.request.RequestBody(/, **data: typing.Any)¶
Bases:
gfwapiclient.base.models.BaseModel
Base model for handling HTTP request bodies.
This model serializes request bodies into a JSON-compatible dictionary, ensuring proper handling of null values and field aliases.
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- to_json_body(**kwargs: Any) Dict[str, Any] ¶
Converts the RequestBody instance to a JSON-compatible HTTP request body.
This method serializes the model’s fields into a dictionary suitable for use as the JSON body of an HTTP request. It handles options to customize the serialization process.
- Args:
- **kwargs (Any):
Additional arguments passed to the model_dump method to customize the serialization process.
- Returns:
- Dict[str, Any]:
A dictionary representing the JSON body of the HTTP request.
- gfwapiclient.http.models.request._RequestBodyT = 'TypeVar(...)'¶