Skip to content

Commit

Permalink
Merge pull request #55 from GetStream/update-call-stats-client
Browse files Browse the repository at this point in the history
[VID-000] Update video stats related endpoints and models
  • Loading branch information
su225 authored Dec 12, 2024
2 parents 18a2a78 + c0a45e7 commit ab60840
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 0 deletions.
209 changes: 209 additions & 0 deletions getstream/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ class BodyguardSeverityRule(DataClassJsonMixin):
severity: str = dc_field(metadata=dc_config(field_name="severity"))


@dataclass
class Bound(DataClassJsonMixin):
inclusive: bool = dc_field(metadata=dc_config(field_name="inclusive"))
value: float = dc_field(metadata=dc_config(field_name="value"))


@dataclass
class BroadcastSettings(DataClassJsonMixin):
enabled: bool = dc_field(metadata=dc_config(field_name="enabled"))
Expand Down Expand Up @@ -829,6 +835,20 @@ class BroadcastSettingsResponse(DataClassJsonMixin):
rtmp: "RTMPSettingsResponse" = dc_field(metadata=dc_config(field_name="rtmp"))


@dataclass
class CallDurationReport(DataClassJsonMixin):
histogram: "List[ReportByHistogramBucket]" = dc_field(
metadata=dc_config(field_name="histogram")
)


@dataclass
class CallDurationReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateCallDurationReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class CallEvent(DataClassJsonMixin):
description: str = dc_field(metadata=dc_config(field_name="description"))
Expand All @@ -854,6 +874,20 @@ class CallIngressResponse(DataClassJsonMixin):
rtmp: "RTMPIngress" = dc_field(metadata=dc_config(field_name="rtmp"))


@dataclass
class CallParticipantCountReport(DataClassJsonMixin):
histogram: "List[ReportByHistogramBucket]" = dc_field(
metadata=dc_config(field_name="histogram")
)


@dataclass
class CallParticipantCountReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateCallParticipantCountReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class CallParticipantResponse(DataClassJsonMixin):
joined_at: datetime = dc_field(
Expand Down Expand Up @@ -1211,6 +1245,9 @@ class CallStatsReportSummaryResponse(DataClassJsonMixin):
mm_field=fields.DateTime(format="iso"),
),
)
min_user_rating: Optional[int] = dc_field(
default=None, metadata=dc_config(field_name="min_user_rating")
)
quality_score: Optional[int] = dc_field(
default=None, metadata=dc_config(field_name="quality_score")
)
Expand Down Expand Up @@ -1306,6 +1343,18 @@ class CallTypeResponse(DataClassJsonMixin):
)


@dataclass
class CallsPerDayReport(DataClassJsonMixin):
count: int = dc_field(metadata=dc_config(field_name="count"))


@dataclass
class CallsPerDayReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateCallsPerDayReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class CampaignChannelTemplate(DataClassJsonMixin):
type: str = dc_field(metadata=dc_config(field_name="type"))
Expand Down Expand Up @@ -3045,6 +3094,44 @@ class CustomCheckResponse(DataClassJsonMixin):
)


@dataclass
class DailyAggregateCallDurationReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "CallDurationReport" = dc_field(metadata=dc_config(field_name="report"))


@dataclass
class DailyAggregateCallParticipantCountReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "CallParticipantCountReport" = dc_field(
metadata=dc_config(field_name="report")
)


@dataclass
class DailyAggregateCallsPerDayReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "CallsPerDayReport" = dc_field(metadata=dc_config(field_name="report"))


@dataclass
class DailyAggregateQualityScoreReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "QualityScoreReport" = dc_field(metadata=dc_config(field_name="report"))


@dataclass
class DailyAggregateSDKUsageReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "SDKUsageReport" = dc_field(metadata=dc_config(field_name="report"))


@dataclass
class DailyAggregateUserFeedbackReportResponse(DataClassJsonMixin):
date: str = dc_field(metadata=dc_config(field_name="date"))
report: "UserFeedbackReport" = dc_field(metadata=dc_config(field_name="report"))


@dataclass
class Data(DataClassJsonMixin):
id: str = dc_field(metadata=dc_config(field_name="id"))
Expand Down Expand Up @@ -4193,6 +4280,9 @@ class GetCallStatsResponse(DataClassJsonMixin):
metadata=dc_config(field_name="participant_report")
)
sfus: "List[SFULocationResponse]" = dc_field(metadata=dc_config(field_name="sfus"))
average_connection_time: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_connection_time")
)
aggregated: "Optional[AggregatedStats]" = dc_field(
default=None, metadata=dc_config(field_name="aggregated")
)
Expand Down Expand Up @@ -6014,6 +6104,22 @@ class MuteUsersResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))


@dataclass
class NetworkMetricsReportResponse(DataClassJsonMixin):
average_connection_time: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_connection_time")
)
average_jitter: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_jitter")
)
average_latency: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_latency")
)
average_time_to_reconnect: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_time_to_reconnect")
)


@dataclass
class NoiseCancellationSettings(DataClassJsonMixin):
mode: str = dc_field(metadata=dc_config(field_name="mode"))
Expand Down Expand Up @@ -6318,6 +6424,12 @@ class PendingMessageResponse(DataClassJsonMixin):
)


@dataclass
class PerSDKUsageReport(DataClassJsonMixin):
total: int = dc_field(metadata=dc_config(field_name="total"))
by_version: "Dict[str, int]" = dc_field(metadata=dc_config(field_name="by_version"))


@dataclass
class Permission(DataClassJsonMixin):
action: str = dc_field(metadata=dc_config(field_name="action"))
Expand Down Expand Up @@ -6938,6 +7050,57 @@ class PushProviderResponse(DataClassJsonMixin):
)


@dataclass
class QualityScoreReport(DataClassJsonMixin):
histogram: "List[ReportByHistogramBucket]" = dc_field(
metadata=dc_config(field_name="histogram")
)


@dataclass
class QualityScoreReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateQualityScoreReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class QueryAggregateCallStatsRequest(DataClassJsonMixin):
_from: Optional[str] = dc_field(default=None, metadata=dc_config(field_name="from"))
to: Optional[str] = dc_field(default=None, metadata=dc_config(field_name="to"))
report_types: Optional[List[str]] = dc_field(
default=None, metadata=dc_config(field_name="report_types")
)


@dataclass
class QueryAggregateCallStatsResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
call_duration_report: "Optional[CallDurationReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="call_duration_report")
)
call_participant_count_report: "Optional[CallParticipantCountReportResponse]" = (
dc_field(
default=None, metadata=dc_config(field_name="call_participant_count_report")
)
)
calls_per_day_report: "Optional[CallsPerDayReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="calls_per_day_report")
)
network_metrics_report: "Optional[NetworkMetricsReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="network_metrics_report")
)
quality_score_report: "Optional[QualityScoreReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="quality_score_report")
)
sdk_usage_report: "Optional[SDKUsageReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="sdk_usage_report")
)
user_feedback_report: "Optional[UserFeedbackReportResponse]" = dc_field(
default=None, metadata=dc_config(field_name="user_feedback_report")
)


@dataclass
class QueryBannedUsersPayload(DataClassJsonMixin):
filter_conditions: Dict[str, object] = dc_field(
Expand Down Expand Up @@ -7848,6 +8011,20 @@ class RecordSettingsResponse(DataClassJsonMixin):
layout: "LayoutSettingsResponse" = dc_field(metadata=dc_config(field_name="layout"))


@dataclass
class ReportByHistogramBucket(DataClassJsonMixin):
category: str = dc_field(metadata=dc_config(field_name="category"))
count: int = dc_field(metadata=dc_config(field_name="count"))
mean: float = dc_field(metadata=dc_config(field_name="mean"))
sum: float = dc_field(metadata=dc_config(field_name="sum"))
lower_bound: "Optional[Bound]" = dc_field(
default=None, metadata=dc_config(field_name="lower_bound")
)
upper_bound: "Optional[Bound]" = dc_field(
default=None, metadata=dc_config(field_name="upper_bound")
)


@dataclass
class Response(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
Expand Down Expand Up @@ -8075,6 +8252,20 @@ class S3Request(DataClassJsonMixin):
)


@dataclass
class SDKUsageReport(DataClassJsonMixin):
per_sdk_usage: "Dict[str, Optional[PerSDKUsageReport]]" = dc_field(
metadata=dc_config(field_name="per_sdk_usage")
)


@dataclass
class SDKUsageReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateSDKUsageReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class SFULocationResponse(DataClassJsonMixin):
datacenter: str = dc_field(metadata=dc_config(field_name="datacenter"))
Expand Down Expand Up @@ -10197,6 +10388,21 @@ class UserCustomEventRequest(DataClassJsonMixin):
)


@dataclass
class UserFeedbackReport(DataClassJsonMixin):
unreported_count: int = dc_field(metadata=dc_config(field_name="unreported_count"))
count_by_rating: "Dict[str, int]" = dc_field(
metadata=dc_config(field_name="count_by_rating")
)


@dataclass
class UserFeedbackReportResponse(DataClassJsonMixin):
daily: "List[DailyAggregateUserFeedbackReportResponse]" = dc_field(
metadata=dc_config(field_name="daily")
)


@dataclass
class UserInfoResponse(DataClassJsonMixin):
id: str = dc_field(metadata=dc_config(field_name="id"))
Expand Down Expand Up @@ -10423,6 +10629,9 @@ 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"))
average_connection_time: Optional[float] = dc_field(
default=None, metadata=dc_config(field_name="average_connection_time")
)
browser: Optional[str] = dc_field(
default=None, metadata=dc_config(field_name="browser")
)
Expand Down
12 changes: 12 additions & 0 deletions getstream/video/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,15 @@ def update_call_type(

def get_edges(self) -> StreamResponse[GetEdgesResponse]:
return self.get("/api/v2/video/edges", GetEdgesResponse)

def query_aggregate_call_stats(
self,
_from: Optional[str] = None,
to: Optional[str] = None,
report_types: Optional[List[str]] = None,
) -> StreamResponse[QueryAggregateCallStatsResponse]:
json = build_body_dict(_from=_from, to=to, report_types=report_types)

return self.post(
"/api/v2/video/stats", QueryAggregateCallStatsResponse, json=json
)

0 comments on commit ab60840

Please sign in to comment.