143 lines
3.7 KiB
Python
143 lines
3.7 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
from ..types import UNSET, Unset
|
|
from typing import cast
|
|
|
|
|
|
|
|
|
|
|
|
|
|
T = TypeVar("T", bound="WebhookReceiverRequest")
|
|
|
|
|
|
|
|
@_attrs_define
|
|
class WebhookReceiverRequest:
|
|
""" Request body for webhook receiver endpoint
|
|
|
|
Attributes:
|
|
payload (Any):
|
|
headers (Any | None | Unset):
|
|
source_ip (None | str | Unset): Optional source IP address
|
|
user_agent (None | str | Unset): Optional user agent
|
|
"""
|
|
|
|
payload: Any
|
|
headers: Any | None | Unset = UNSET
|
|
source_ip: None | str | Unset = UNSET
|
|
user_agent: None | str | Unset = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
|
|
|
|
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
payload = self.payload
|
|
|
|
headers: Any | None | Unset
|
|
if isinstance(self.headers, Unset):
|
|
headers = UNSET
|
|
else:
|
|
headers = self.headers
|
|
|
|
source_ip: None | str | Unset
|
|
if isinstance(self.source_ip, Unset):
|
|
source_ip = UNSET
|
|
else:
|
|
source_ip = self.source_ip
|
|
|
|
user_agent: None | str | Unset
|
|
if isinstance(self.user_agent, Unset):
|
|
user_agent = UNSET
|
|
else:
|
|
user_agent = self.user_agent
|
|
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update({
|
|
"payload": payload,
|
|
})
|
|
if headers is not UNSET:
|
|
field_dict["headers"] = headers
|
|
if source_ip is not UNSET:
|
|
field_dict["source_ip"] = source_ip
|
|
if user_agent is not UNSET:
|
|
field_dict["user_agent"] = user_agent
|
|
|
|
return field_dict
|
|
|
|
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
payload = d.pop("payload")
|
|
|
|
def _parse_headers(data: object) -> Any | None | Unset:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Any | None | Unset, data)
|
|
|
|
headers = _parse_headers(d.pop("headers", UNSET))
|
|
|
|
|
|
def _parse_source_ip(data: object) -> None | str | Unset:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(None | str | Unset, data)
|
|
|
|
source_ip = _parse_source_ip(d.pop("source_ip", UNSET))
|
|
|
|
|
|
def _parse_user_agent(data: object) -> None | str | Unset:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(None | str | Unset, data)
|
|
|
|
user_agent = _parse_user_agent(d.pop("user_agent", UNSET))
|
|
|
|
|
|
webhook_receiver_request = cls(
|
|
payload=payload,
|
|
headers=headers,
|
|
source_ip=source_ip,
|
|
user_agent=user_agent,
|
|
)
|
|
|
|
|
|
webhook_receiver_request.additional_properties = d
|
|
return webhook_receiver_request
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|