Skip to content

Commit

Permalink
fix snake case generation of class fields (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel authored Sep 16, 2024
1 parent 377f142 commit 5653562
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 42 deletions.
32 changes: 26 additions & 6 deletions getstream/chat/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ def upload_image(
json=json,
)

def update_member_partial(
self,
user_id: str,
type: str,
id: str,
unset: Optional[List[str]] = None,
set: Optional[Dict[str, object]] = None,
) -> StreamResponse[UpdateMemberPartialResponse]:
path_params = {
"user_id": user_id,
"type": type,
"id": id,
}
json = build_body_dict(unset=unset, set=set)

return self.patch(
"/api/v2/chat/channels/{type}/{id}/member/{user_id}",
UpdateMemberPartialResponse,
path_params=path_params,
json=json,
)

def send_message(
self,
type: str,
Expand Down Expand Up @@ -723,7 +745,7 @@ def get_export_channels_status(
)

def query_members(
self, payload: Optional[QueryMembersRequest] = None
self, payload: Optional[QueryMembersPayload] = None
) -> StreamResponse[MembersResponse]:
query_params = build_query_param(payload=payload)

Expand Down Expand Up @@ -1049,7 +1071,7 @@ def get_replies(
)

def query_message_flags(
self, payload: Optional[QueryMessageFlagsRequest] = None
self, payload: Optional[QueryMessageFlagsPayload] = None
) -> StreamResponse[QueryMessageFlagsResponse]:
query_params = build_query_param(payload=payload)

Expand Down Expand Up @@ -1333,7 +1355,7 @@ def query_poll_votes(
)

def query_banned_users(
self, payload: Optional[QueryBannedUsersRequest] = None
self, payload: Optional[QueryBannedUsersPayload] = None
) -> StreamResponse[QueryBannedUsersResponse]:
query_params = build_query_param(payload=payload)

Expand All @@ -1344,7 +1366,7 @@ def query_banned_users(
)

def search(
self, payload: Optional[SearchRequest] = None
self, payload: Optional[SearchPayload] = None
) -> StreamResponse[SearchResponse]:
query_params = build_query_param(payload=payload)

Expand Down Expand Up @@ -1379,13 +1401,11 @@ def query_threads(
def get_thread(
self,
message_id: str,
connection_id: Optional[str] = None,
reply_limit: Optional[int] = None,
participant_limit: Optional[int] = None,
member_limit: Optional[int] = None,
) -> StreamResponse[GetThreadResponse]:
query_params = build_query_param(
connection_id=connection_id,
reply_limit=reply_limit,
participant_limit=participant_limit,
member_limit=member_limit,
Expand Down
117 changes: 81 additions & 36 deletions getstream/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,15 @@ class CallSessionResponse(DataClassJsonMixin):
encoder=encode_datetime,
decoder=datetime_from_unix_ns,
mm_field=fields.DateTime(format="iso"),
),
)
)

missed_by: "Dict[str, datetime]" = dc_field(
metadata=dc_config(
field_name="ended_at",
field_name="missed_by",
encoder=encode_datetime,
decoder=datetime_from_unix_ns,
mm_field=fields.DateTime(format="iso"),
),
)
)
participants_count_by_role: "Dict[str, int]" = dc_field(
metadata=dc_config(field_name="participants_count_by_role")
Expand All @@ -1006,7 +1005,7 @@ class CallSessionResponse(DataClassJsonMixin):
encoder=encode_datetime,
decoder=datetime_from_unix_ns,
mm_field=fields.DateTime(format="iso"),
),
)
)
ended_at: Optional[datetime] = dc_field(
default=None,
Expand Down Expand Up @@ -1620,6 +1619,7 @@ class ChannelMember(DataClassJsonMixin):
mm_field=fields.DateTime(format="iso"),
)
)
custom: Dict[str, object] = dc_field(metadata=dc_config(field_name="custom"))
ban_expires: Optional[datetime] = dc_field(
default=None,
metadata=dc_config(
Expand Down Expand Up @@ -1697,6 +1697,7 @@ class ChannelMemberResponse(DataClassJsonMixin):
mm_field=fields.DateTime(format="iso"),
)
)
custom: Dict[str, object] = dc_field(metadata=dc_config(field_name="custom"))
ban_expires: Optional[datetime] = dc_field(
default=None,
metadata=dc_config(
Expand Down Expand Up @@ -1924,7 +1925,7 @@ class ChannelStateResponse(DataClassJsonMixin):
watcher_count: Optional[int] = dc_field(
default=None, metadata=dc_config(field_name="watcher_count")
)
pending_messages: "Optional[List[Optional[PendingMessage]]]" = dc_field(
pending_messages: "Optional[List[Optional[PendingMessageResponse]]]" = dc_field(
default=None, metadata=dc_config(field_name="pending_messages")
)
read: "Optional[List[ReadStateResponse]]" = dc_field(
Expand Down Expand Up @@ -1970,7 +1971,7 @@ class ChannelStateResponseFields(DataClassJsonMixin):
watcher_count: Optional[int] = dc_field(
default=None, metadata=dc_config(field_name="watcher_count")
)
pending_messages: "Optional[List[Optional[PendingMessage]]]" = dc_field(
pending_messages: "Optional[List[Optional[PendingMessageResponse]]]" = dc_field(
default=None, metadata=dc_config(field_name="pending_messages")
)
read: "Optional[List[ReadStateResponse]]" = dc_field(
Expand Down Expand Up @@ -2302,7 +2303,7 @@ class ConfigResponse(DataClassJsonMixin):
automod_toxicity_config: "Optional[AutomodToxicityConfig]" = dc_field(
default=None, metadata=dc_config(field_name="automod_toxicity_config")
)
aws_rek_og_nition_config: "Optional[AWSRekognitionConfig]" = dc_field(
aws_rekognition_config: "Optional[AWSRekognitionConfig]" = dc_field(
default=None, metadata=dc_config(field_name="aws_rekognition_config")
)
block_list_config: "Optional[BlockListConfig]" = dc_field(
Expand All @@ -2311,9 +2312,12 @@ class ConfigResponse(DataClassJsonMixin):
bodyguard_config: "Optional[BodyguardConfig]" = dc_field(
default=None, metadata=dc_config(field_name="bodyguard_config")
)
go_og_le_vision_config: "Optional[GoogleVisionConfig]" = dc_field(
google_vision_config: "Optional[GoogleVisionConfig]" = dc_field(
default=None, metadata=dc_config(field_name="google_vision_config")
)
velocity_filter_config: "Optional[VelocityFilterConfig]" = dc_field(
default=None, metadata=dc_config(field_name="velocity_filter_config")
)


@dataclass
Expand All @@ -2324,7 +2328,7 @@ class Coordinates(DataClassJsonMixin):

@dataclass
class Count(DataClassJsonMixin):
app_roximate: bool = dc_field(metadata=dc_config(field_name="approximate"))
approximate: bool = dc_field(metadata=dc_config(field_name="approximate"))
value: int = dc_field(metadata=dc_config(field_name="value"))


Expand Down Expand Up @@ -3047,9 +3051,7 @@ class EgressRTMPResponse(DataClassJsonMixin):
@dataclass
class EgressResponse(DataClassJsonMixin):
broadcasting: bool = dc_field(metadata=dc_config(field_name="broadcasting"))
rtmp_s: "List[EgressRTMPResponse]" = dc_field(
metadata=dc_config(field_name="rtmps")
)
rtmps: "List[EgressRTMPResponse]" = dc_field(metadata=dc_config(field_name="rtmps"))
hls: "Optional[EgressHLSResponse]" = dc_field(
default=None, metadata=dc_config(field_name="hls")
)
Expand Down Expand Up @@ -4468,7 +4470,7 @@ class MOSStats(DataClassJsonMixin):
average_score: float = dc_field(metadata=dc_config(field_name="average_score"))
max_score: float = dc_field(metadata=dc_config(field_name="max_score"))
min_score: float = dc_field(metadata=dc_config(field_name="min_score"))
hist_og_ram_duration_seconds: "List[float]" = dc_field(
histogram_duration_seconds: "List[float]" = dc_field(
metadata=dc_config(field_name="histogram_duration_seconds")
)

Expand Down Expand Up @@ -5240,15 +5242,6 @@ class ModerationActionConfig(DataClassJsonMixin):

@dataclass
class ModerationPayload(DataClassJsonMixin):
created_at: Optional[datetime] = dc_field(
default=None,
metadata=dc_config(
field_name="created_at",
encoder=encode_datetime,
decoder=datetime_from_unix_ns,
mm_field=fields.DateTime(format="iso"),
),
)
images: Optional[List[str]] = dc_field(
default=None, metadata=dc_config(field_name="images")
)
Expand Down Expand Up @@ -5577,17 +5570,17 @@ class PaginationParams(DataClassJsonMixin):


@dataclass
class PendingMessage(DataClassJsonMixin):
channel: "Optional[Channel]" = dc_field(
class PendingMessageResponse(DataClassJsonMixin):
channel: "Optional[ChannelResponse]" = dc_field(
default=None, metadata=dc_config(field_name="channel")
)
message: "Optional[Message]" = dc_field(
message: "Optional[MessageResponse]" = dc_field(
default=None, metadata=dc_config(field_name="message")
)
metadata: "Optional[Dict[str, str]]" = dc_field(
default=None, metadata=dc_config(field_name="metadata")
)
user: "Optional[UserObject]" = dc_field(
user: "Optional[UserResponse]" = dc_field(
default=None, metadata=dc_config(field_name="user")
)

Expand Down Expand Up @@ -6210,7 +6203,7 @@ class PushProviderResponse(DataClassJsonMixin):


@dataclass
class QueryBannedUsersRequest(DataClassJsonMixin):
class QueryBannedUsersPayload(DataClassJsonMixin):
filter_conditions: Dict[str, object] = dc_field(
metadata=dc_config(field_name="filter_conditions")
)
Expand Down Expand Up @@ -6389,7 +6382,7 @@ class QueryFeedModerationTemplatesResponse(DataClassJsonMixin):


@dataclass
class QueryMembersRequest(DataClassJsonMixin):
class QueryMembersPayload(DataClassJsonMixin):
type: str = dc_field(metadata=dc_config(field_name="type"))
filter_conditions: Dict[str, object] = dc_field(
metadata=dc_config(field_name="filter_conditions")
Expand All @@ -6416,7 +6409,7 @@ class QueryMembersRequest(DataClassJsonMixin):


@dataclass
class QueryMessageFlagsRequest(DataClassJsonMixin):
class QueryMessageFlagsPayload(DataClassJsonMixin):
limit: Optional[int] = dc_field(
default=None, metadata=dc_config(field_name="limit")
)
Expand Down Expand Up @@ -6495,7 +6488,7 @@ class QueryModerationLogsRequest(DataClassJsonMixin):
@dataclass
class QueryModerationLogsResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
l_og_s: "List[ActionLogResponse]" = dc_field(metadata=dc_config(field_name="logs"))
logs: "List[ActionLogResponse]" = dc_field(metadata=dc_config(field_name="logs"))
next: Optional[str] = dc_field(default=None, metadata=dc_config(field_name="next"))
prev: Optional[str] = dc_field(default=None, metadata=dc_config(field_name="prev"))

Expand Down Expand Up @@ -7219,7 +7212,7 @@ class ScreensharingSettingsResponse(DataClassJsonMixin):


@dataclass
class SearchRequest(DataClassJsonMixin):
class SearchPayload(DataClassJsonMixin):
filter_conditions: Dict[str, object] = dc_field(
metadata=dc_config(field_name="filter_conditions")
)
Expand Down Expand Up @@ -8521,7 +8514,7 @@ class UpdateChannelPartialRequest(DataClassJsonMixin):
@dataclass
class UpdateChannelPartialResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
members: "List[Optional[ChannelMemberResponse]]" = dc_field(
members: "List[ChannelMemberResponse]" = dc_field(
metadata=dc_config(field_name="members")
)
channel: "Optional[ChannelResponse]" = dc_field(
Expand Down Expand Up @@ -8788,6 +8781,24 @@ class UpdateExternalStorageResponse(DataClassJsonMixin):
type: str = dc_field(metadata=dc_config(field_name="type"))


@dataclass
class UpdateMemberPartialRequest(DataClassJsonMixin):
unset: Optional[List[str]] = dc_field(
default=None, metadata=dc_config(field_name="unset")
)
set: Optional[Dict[str, object]] = dc_field(
default=None, metadata=dc_config(field_name="set")
)


@dataclass
class UpdateMemberPartialResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
channel_member: "Optional[ChannelMemberResponse]" = dc_field(
default=None, metadata=dc_config(field_name="channel_member")
)


@dataclass
class UpdateMessagePartialRequest(DataClassJsonMixin):
skip_enrich_url: Optional[bool] = dc_field(
Expand Down Expand Up @@ -8996,7 +9007,7 @@ class UpsertConfigRequest(DataClassJsonMixin):
automod_toxicity_config: "Optional[AutomodToxicityConfig]" = dc_field(
default=None, metadata=dc_config(field_name="automod_toxicity_config")
)
aws_rek_og_nition_config: "Optional[AWSRekognitionConfig]" = dc_field(
aws_rekognition_config: "Optional[AWSRekognitionConfig]" = dc_field(
default=None, metadata=dc_config(field_name="aws_rekognition_config")
)
block_list_config: "Optional[BlockListConfig]" = dc_field(
Expand All @@ -9005,9 +9016,12 @@ class UpsertConfigRequest(DataClassJsonMixin):
bodyguard_config: "Optional[BodyguardConfig]" = dc_field(
default=None, metadata=dc_config(field_name="bodyguard_config")
)
go_og_le_vision_config: "Optional[GoogleVisionConfig]" = dc_field(
google_vision_config: "Optional[GoogleVisionConfig]" = dc_field(
default=None, metadata=dc_config(field_name="google_vision_config")
)
velocity_filter_config: "Optional[VelocityFilterConfig]" = dc_field(
default=None, metadata=dc_config(field_name="velocity_filter_config")
)


@dataclass
Expand Down Expand Up @@ -9384,6 +9398,7 @@ class UserSessionStats(DataClassJsonMixin):
max_freezes_duration_seconds: int = dc_field(
metadata=dc_config(field_name="max_freezes_duration_seconds")
)
min_event_ts: int = dc_field(metadata=dc_config(field_name="min_event_ts"))
packet_loss_fraction: float = dc_field(
metadata=dc_config(field_name="packet_loss_fraction")
)
Expand All @@ -9400,7 +9415,7 @@ class UserSessionStats(DataClassJsonMixin):
session_id: str = dc_field(metadata=dc_config(field_name="session_id"))
total_pixels_in: int = dc_field(metadata=dc_config(field_name="total_pixels_in"))
total_pixels_out: int = dc_field(metadata=dc_config(field_name="total_pixels_out"))
bro_ws_er: Optional[str] = dc_field(
browser: Optional[str] = dc_field(
default=None, metadata=dc_config(field_name="browser")
)
browser_version: Optional[str] = dc_field(
Expand Down Expand Up @@ -9538,6 +9553,36 @@ class UserStats(DataClassJsonMixin):
)


@dataclass
class VelocityFilterConfig(DataClassJsonMixin):
enabled: Optional[bool] = dc_field(
default=None, metadata=dc_config(field_name="enabled")
)
rule: "Optional[List[VelocityFilterConfigRule]]" = dc_field(
default=None, metadata=dc_config(field_name="rule")
)


@dataclass
class VelocityFilterConfigRule(DataClassJsonMixin):
action: str = dc_field(metadata=dc_config(field_name="action"))
ip_ban: Optional[bool] = dc_field(
default=None, metadata=dc_config(field_name="ip_ban")
)
shadow_ban: Optional[bool] = dc_field(
default=None, metadata=dc_config(field_name="shadow_ban")
)
timeout: Optional[datetime] = dc_field(
default=None,
metadata=dc_config(
field_name="timeout",
encoder=encode_datetime,
decoder=datetime_from_unix_ns,
mm_field=fields.DateTime(format="iso"),
),
)


@dataclass
class VideoQuality(DataClassJsonMixin):
usage_type: Optional[str] = dc_field(
Expand Down

0 comments on commit 5653562

Please sign in to comment.