lark-billing 0.0.8__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lark-billing might be problematic. Click here for more details.
- lark/__init__.py +41 -16
- lark/checkout/client.py +8 -4
- lark/checkout/raw_client.py +4 -0
- lark/core/client_wrapper.py +2 -2
- lark/customer_portal/client.py +4 -2
- lark/customer_portal/raw_client.py +2 -0
- lark/pricing_metrics/__init__.py +19 -2
- lark/pricing_metrics/client.py +148 -22
- lark/pricing_metrics/raw_client.py +159 -20
- lark/pricing_metrics/types/__init__.py +14 -1
- lark/pricing_metrics/types/pricing_metric_aggregation.py +69 -1
- lark/rate_cards/client.py +74 -12
- lark/rate_cards/raw_client.py +24 -14
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +1 -1
- lark/subjects/client.py +12 -2
- lark/subscriptions/client.py +4 -2
- lark/subscriptions/raw_client.py +2 -0
- lark/types/__init__.py +23 -13
- lark/types/aggregation.py +45 -1
- lark/types/amount.py +4 -1
- lark/types/billing_state_response.py +9 -2
- lark/types/count_aggregation_pricing_metric_interface.py +4 -0
- lark/types/create_customer_portal_session_response.py +9 -2
- lark/types/create_fixed_rate_request.py +10 -2
- lark/types/create_simple_usage_based_rate_request.py +15 -3
- lark/types/create_subscription_checkout_session_response.py +14 -3
- lark/types/custom_aggregation_pricing_metric_interface.py +26 -0
- lark/types/fixed_rate_interface.py +1 -1
- lark/types/invoice_resource.py +34 -9
- lark/types/last_aggregation_pricing_metric_interface.py +26 -0
- lark/types/{get_pricing_metric_response.py → last_aggregation_pricing_metric_resource.py} +5 -7
- lark/types/{create_usage_event_summary_response.py → max_aggregation_pricing_metric_interface.py} +9 -6
- lark/types/{create_pricing_metric_response.py → max_aggregation_pricing_metric_resource.py} +5 -7
- lark/types/period.py +3 -2
- lark/types/pricing_metric_resource.py +24 -5
- lark/types/pricing_metric_summary_resource.py +43 -0
- lark/types/rate_card_resource.py +36 -7
- lark/types/rate_card_resource_usage_based_rates_item.py +1 -1
- lark/types/simple_usage_based_rate_interface.py +1 -1
- lark/types/subscription_resource.py +39 -8
- lark/types/sum_aggregation_pricing_metric_interface.py +4 -0
- lark/types/sum_aggregation_pricing_metric_resource.py +4 -1
- lark/usage_events/__init__.py +3 -3
- lark/usage_events/client.py +40 -131
- lark/usage_events/raw_client.py +21 -147
- lark/usage_events/types/__init__.py +3 -5
- lark/{types/value.py → usage_events/types/create_usage_event_request_data_value.py} +1 -1
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/METADATA +5 -5
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/RECORD +50 -48
- lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +0 -5
- {lark_billing-0.0.8.dist-info → lark_billing-0.1.0.dist-info}/WHEEL +0 -0
|
@@ -8,11 +8,30 @@ from .aggregation import Aggregation
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class PricingMetricResource(UniversalBaseModel):
|
|
11
|
-
id: str
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
id: str = pydantic.Field()
|
|
12
|
+
"""
|
|
13
|
+
The ID of the pricing metric.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
name: str = pydantic.Field()
|
|
17
|
+
"""
|
|
18
|
+
The name of the pricing metric.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
event_name: str = pydantic.Field()
|
|
22
|
+
"""
|
|
23
|
+
The event name that the pricing metric is computed on.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
aggregation: Aggregation = pydantic.Field()
|
|
27
|
+
"""
|
|
28
|
+
The aggregation function used to compute the value of the pricing metric.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
unit: str = pydantic.Field()
|
|
32
|
+
"""
|
|
33
|
+
The unit of the value computed by the pricing metric.
|
|
34
|
+
"""
|
|
16
35
|
|
|
17
36
|
if IS_PYDANTIC_V2:
|
|
18
37
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .period import Period
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PricingMetricSummaryResource(UniversalBaseModel):
|
|
11
|
+
id: str = pydantic.Field()
|
|
12
|
+
"""
|
|
13
|
+
The ID of the pricing metric summary.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
pricing_metric_id: str = pydantic.Field()
|
|
17
|
+
"""
|
|
18
|
+
The ID of the pricing metric that the summary is for.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
subject_id: str = pydantic.Field()
|
|
22
|
+
"""
|
|
23
|
+
The ID of the subject that the summary is for.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
period: Period = pydantic.Field()
|
|
27
|
+
"""
|
|
28
|
+
The period that the summary is computed over.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: typing.Optional[str] = pydantic.Field(default=None)
|
|
32
|
+
"""
|
|
33
|
+
The computed value of the pricing metric for the period. If the pricing metric does not have any usage events for the period, this will be `null`.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
if IS_PYDANTIC_V2:
|
|
37
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
38
|
+
else:
|
|
39
|
+
|
|
40
|
+
class Config:
|
|
41
|
+
frozen = True
|
|
42
|
+
smart_union = True
|
|
43
|
+
extra = pydantic.Extra.allow
|
lark/types/rate_card_resource.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
import datetime as dt
|
|
3
4
|
import typing
|
|
4
5
|
|
|
5
6
|
import pydantic
|
|
@@ -10,14 +11,42 @@ from .rate_card_resource_usage_based_rates_item import RateCardResourceUsageBase
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class RateCardResource(UniversalBaseModel):
|
|
13
|
-
id: str
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
id: str = pydantic.Field()
|
|
15
|
+
"""
|
|
16
|
+
The ID of the rate card.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
name: str = pydantic.Field()
|
|
20
|
+
"""
|
|
21
|
+
The name of the rate card.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
description: typing.Optional[str] = pydantic.Field(default=None)
|
|
25
|
+
"""
|
|
26
|
+
The description of the rate card.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
usage_based_rates: typing.List[RateCardResourceUsageBasedRatesItem] = pydantic.Field()
|
|
30
|
+
"""
|
|
31
|
+
The usage based rates of the rate card.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
fixed_rates: typing.List[FixedRateInterface] = pydantic.Field()
|
|
35
|
+
"""
|
|
36
|
+
The fixed rates of the rate card.
|
|
37
|
+
"""
|
|
38
|
+
|
|
18
39
|
billing_interval: RateCardResourceBillingInterval
|
|
19
|
-
created_at:
|
|
20
|
-
|
|
40
|
+
created_at: dt.datetime = pydantic.Field()
|
|
41
|
+
"""
|
|
42
|
+
The date and time the rate card was created.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
updated_at: dt.datetime = pydantic.Field()
|
|
46
|
+
"""
|
|
47
|
+
The date and time the rate card was last updated.
|
|
48
|
+
"""
|
|
49
|
+
|
|
21
50
|
metadata: typing.Dict[str, str]
|
|
22
51
|
|
|
23
52
|
if IS_PYDANTIC_V2:
|
|
@@ -13,7 +13,7 @@ class RateCardResourceUsageBasedRatesItem_Simple(UniversalBaseModel):
|
|
|
13
13
|
usage_based_rate_type: typing.Literal["simple"] = "simple"
|
|
14
14
|
id: str
|
|
15
15
|
name: str
|
|
16
|
-
description: str
|
|
16
|
+
description: typing.Optional[str] = None
|
|
17
17
|
price: Price
|
|
18
18
|
included_units: int
|
|
19
19
|
pricing_metric_id: str
|
|
@@ -10,15 +10,46 @@ from .subscription_status import SubscriptionStatus
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class SubscriptionResource(UniversalBaseModel):
|
|
13
|
-
id: str
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
id: str = pydantic.Field()
|
|
14
|
+
"""
|
|
15
|
+
The ID of the subscription.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
subject_id: str = pydantic.Field()
|
|
19
|
+
"""
|
|
20
|
+
The ID of the subject that the subscription is for.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
rate_card_id: str = pydantic.Field()
|
|
24
|
+
"""
|
|
25
|
+
The ID of the rate card of the subscription.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
effective_at: dt.datetime = pydantic.Field()
|
|
29
|
+
"""
|
|
30
|
+
The date and time the subscription became effective.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
cycles_next_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
|
|
34
|
+
"""
|
|
35
|
+
The date and time the next cycle of the subscription will start.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
current_period: typing.Optional[PeriodResource] = pydantic.Field(default=None)
|
|
39
|
+
"""
|
|
40
|
+
The current period of the subscription if it is active.
|
|
41
|
+
"""
|
|
42
|
+
|
|
19
43
|
metadata: typing.Dict[str, str]
|
|
20
|
-
status: SubscriptionStatus
|
|
21
|
-
|
|
44
|
+
status: SubscriptionStatus = pydantic.Field()
|
|
45
|
+
"""
|
|
46
|
+
The status of the subscription.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
cancels_at_end_of_cycle: bool = pydantic.Field()
|
|
50
|
+
"""
|
|
51
|
+
Whether the subscription will be cancelled at the end of the current cycle.
|
|
52
|
+
"""
|
|
22
53
|
|
|
23
54
|
if IS_PYDANTIC_V2:
|
|
24
55
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
@@ -7,6 +7,10 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class SumAggregationPricingMetricInterface(UniversalBaseModel):
|
|
10
|
+
"""
|
|
11
|
+
Computes the sum of the `value_field` over all usage events with the specified `event_name`.
|
|
12
|
+
"""
|
|
13
|
+
|
|
10
14
|
value_field: str = pydantic.Field()
|
|
11
15
|
"""
|
|
12
16
|
Field to sum over.
|
|
@@ -7,7 +7,10 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class SumAggregationPricingMetricResource(UniversalBaseModel):
|
|
10
|
-
value_field: str
|
|
10
|
+
value_field: str = pydantic.Field()
|
|
11
|
+
"""
|
|
12
|
+
The field to sum over.
|
|
13
|
+
"""
|
|
11
14
|
|
|
12
15
|
if IS_PYDANTIC_V2:
|
|
13
16
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
lark/usage_events/__init__.py
CHANGED
|
@@ -6,8 +6,8 @@ import typing
|
|
|
6
6
|
from importlib import import_module
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
|
-
from .types import
|
|
10
|
-
_dynamic_imports: typing.Dict[str, str] = {"
|
|
9
|
+
from .types import CreateUsageEventRequestDataValue
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {"CreateUsageEventRequestDataValue": ".types"}
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def __getattr__(attr_name: str) -> typing.Any:
|
|
@@ -31,4 +31,4 @@ def __dir__():
|
|
|
31
31
|
return sorted(lazy_attrs)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
__all__ = ["
|
|
34
|
+
__all__ = ["CreateUsageEventRequestDataValue"]
|
lark/usage_events/client.py
CHANGED
|
@@ -5,10 +5,8 @@ import typing
|
|
|
5
5
|
|
|
6
6
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
7
7
|
from ..core.request_options import RequestOptions
|
|
8
|
-
from ..types.create_usage_event_summary_response import CreateUsageEventSummaryResponse
|
|
9
|
-
from ..types.period import Period
|
|
10
8
|
from .raw_client import AsyncRawUsageEventsClient, RawUsageEventsClient
|
|
11
|
-
from .types.
|
|
9
|
+
from .types.create_usage_event_request_data_value import CreateUsageEventRequestDataValue
|
|
12
10
|
|
|
13
11
|
# this is used as the default value for optional parameters
|
|
14
12
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -35,7 +33,7 @@ class UsageEventsClient:
|
|
|
35
33
|
idempotency_key: str,
|
|
36
34
|
event_name: str,
|
|
37
35
|
subject_id: str,
|
|
38
|
-
data: typing.Dict[str,
|
|
36
|
+
data: typing.Dict[str, CreateUsageEventRequestDataValue],
|
|
39
37
|
timestamp: typing.Optional[dt.datetime] = OMIT,
|
|
40
38
|
request_options: typing.Optional[RequestOptions] = None,
|
|
41
39
|
) -> typing.Optional[typing.Any]:
|
|
@@ -43,14 +41,19 @@ class UsageEventsClient:
|
|
|
43
41
|
Parameters
|
|
44
42
|
----------
|
|
45
43
|
idempotency_key : str
|
|
44
|
+
The idempotency key for the usage event. This ensures that the same event is not processed multiple times.
|
|
46
45
|
|
|
47
46
|
event_name : str
|
|
47
|
+
The name of the event. This is used by pricing metrics to aggregate usage events.
|
|
48
48
|
|
|
49
49
|
subject_id : str
|
|
50
|
+
The ID of the subject that the usage event is for.
|
|
50
51
|
|
|
51
|
-
data : typing.Dict[str,
|
|
52
|
+
data : typing.Dict[str, CreateUsageEventRequestDataValue]
|
|
53
|
+
The data of the usage event. This should contain any data that is needed to aggregate the usage event.
|
|
52
54
|
|
|
53
55
|
timestamp : typing.Optional[dt.datetime]
|
|
56
|
+
The timestamp of the usage event. It is highly recommended to provide a timestamp. If not provided, the current timestamp will be used.
|
|
54
57
|
|
|
55
58
|
request_options : typing.Optional[RequestOptions]
|
|
56
59
|
Request-specific configuration.
|
|
@@ -62,16 +65,25 @@ class UsageEventsClient:
|
|
|
62
65
|
|
|
63
66
|
Examples
|
|
64
67
|
--------
|
|
68
|
+
import datetime
|
|
69
|
+
|
|
65
70
|
from lark import Lark
|
|
66
71
|
|
|
67
72
|
client = Lark(
|
|
68
73
|
api_key="YOUR_API_KEY",
|
|
69
74
|
)
|
|
70
75
|
client.usage_events.create_usage_event(
|
|
71
|
-
idempotency_key="
|
|
72
|
-
event_name="
|
|
73
|
-
subject_id="
|
|
74
|
-
|
|
76
|
+
idempotency_key="6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
|
|
77
|
+
event_name="compute_hours",
|
|
78
|
+
subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
79
|
+
timestamp=datetime.datetime.fromisoformat(
|
|
80
|
+
"2025-10-31 20:29:47+00:00",
|
|
81
|
+
),
|
|
82
|
+
data={
|
|
83
|
+
"compute_hours": 100,
|
|
84
|
+
"instance_type": "t2.micro",
|
|
85
|
+
"region": "us-east-1",
|
|
86
|
+
},
|
|
75
87
|
)
|
|
76
88
|
"""
|
|
77
89
|
_response = self._raw_client.create_usage_event(
|
|
@@ -84,60 +96,6 @@ class UsageEventsClient:
|
|
|
84
96
|
)
|
|
85
97
|
return _response.data
|
|
86
98
|
|
|
87
|
-
def create_usage_event_summary(
|
|
88
|
-
self,
|
|
89
|
-
*,
|
|
90
|
-
event_name: str,
|
|
91
|
-
subject_id: str,
|
|
92
|
-
period: Period,
|
|
93
|
-
aggregation_type: CreateUsageEventSummaryRequestAggregationType,
|
|
94
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
95
|
-
) -> CreateUsageEventSummaryResponse:
|
|
96
|
-
"""
|
|
97
|
-
Parameters
|
|
98
|
-
----------
|
|
99
|
-
event_name : str
|
|
100
|
-
|
|
101
|
-
subject_id : str
|
|
102
|
-
|
|
103
|
-
period : Period
|
|
104
|
-
|
|
105
|
-
aggregation_type : CreateUsageEventSummaryRequestAggregationType
|
|
106
|
-
|
|
107
|
-
request_options : typing.Optional[RequestOptions]
|
|
108
|
-
Request-specific configuration.
|
|
109
|
-
|
|
110
|
-
Returns
|
|
111
|
-
-------
|
|
112
|
-
CreateUsageEventSummaryResponse
|
|
113
|
-
Successful Response
|
|
114
|
-
|
|
115
|
-
Examples
|
|
116
|
-
--------
|
|
117
|
-
from lark import Lark, Period
|
|
118
|
-
|
|
119
|
-
client = Lark(
|
|
120
|
-
api_key="YOUR_API_KEY",
|
|
121
|
-
)
|
|
122
|
-
client.usage_events.create_usage_event_summary(
|
|
123
|
-
event_name="event_name",
|
|
124
|
-
subject_id="subject_id",
|
|
125
|
-
period=Period(
|
|
126
|
-
start="2024-01-15T09:30:00Z",
|
|
127
|
-
end="2024-01-15T09:30:00Z",
|
|
128
|
-
),
|
|
129
|
-
aggregation_type="sum",
|
|
130
|
-
)
|
|
131
|
-
"""
|
|
132
|
-
_response = self._raw_client.create_usage_event_summary(
|
|
133
|
-
event_name=event_name,
|
|
134
|
-
subject_id=subject_id,
|
|
135
|
-
period=period,
|
|
136
|
-
aggregation_type=aggregation_type,
|
|
137
|
-
request_options=request_options,
|
|
138
|
-
)
|
|
139
|
-
return _response.data
|
|
140
|
-
|
|
141
99
|
|
|
142
100
|
class AsyncUsageEventsClient:
|
|
143
101
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -160,7 +118,7 @@ class AsyncUsageEventsClient:
|
|
|
160
118
|
idempotency_key: str,
|
|
161
119
|
event_name: str,
|
|
162
120
|
subject_id: str,
|
|
163
|
-
data: typing.Dict[str,
|
|
121
|
+
data: typing.Dict[str, CreateUsageEventRequestDataValue],
|
|
164
122
|
timestamp: typing.Optional[dt.datetime] = OMIT,
|
|
165
123
|
request_options: typing.Optional[RequestOptions] = None,
|
|
166
124
|
) -> typing.Optional[typing.Any]:
|
|
@@ -168,14 +126,19 @@ class AsyncUsageEventsClient:
|
|
|
168
126
|
Parameters
|
|
169
127
|
----------
|
|
170
128
|
idempotency_key : str
|
|
129
|
+
The idempotency key for the usage event. This ensures that the same event is not processed multiple times.
|
|
171
130
|
|
|
172
131
|
event_name : str
|
|
132
|
+
The name of the event. This is used by pricing metrics to aggregate usage events.
|
|
173
133
|
|
|
174
134
|
subject_id : str
|
|
135
|
+
The ID of the subject that the usage event is for.
|
|
175
136
|
|
|
176
|
-
data : typing.Dict[str,
|
|
137
|
+
data : typing.Dict[str, CreateUsageEventRequestDataValue]
|
|
138
|
+
The data of the usage event. This should contain any data that is needed to aggregate the usage event.
|
|
177
139
|
|
|
178
140
|
timestamp : typing.Optional[dt.datetime]
|
|
141
|
+
The timestamp of the usage event. It is highly recommended to provide a timestamp. If not provided, the current timestamp will be used.
|
|
179
142
|
|
|
180
143
|
request_options : typing.Optional[RequestOptions]
|
|
181
144
|
Request-specific configuration.
|
|
@@ -188,6 +151,7 @@ class AsyncUsageEventsClient:
|
|
|
188
151
|
Examples
|
|
189
152
|
--------
|
|
190
153
|
import asyncio
|
|
154
|
+
import datetime
|
|
191
155
|
|
|
192
156
|
from lark import AsyncLark
|
|
193
157
|
|
|
@@ -198,10 +162,17 @@ class AsyncUsageEventsClient:
|
|
|
198
162
|
|
|
199
163
|
async def main() -> None:
|
|
200
164
|
await client.usage_events.create_usage_event(
|
|
201
|
-
idempotency_key="
|
|
202
|
-
event_name="
|
|
203
|
-
subject_id="
|
|
204
|
-
|
|
165
|
+
idempotency_key="6b4ef298-4566-427d-b2ca-cd8fbe38ec60",
|
|
166
|
+
event_name="compute_hours",
|
|
167
|
+
subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
168
|
+
timestamp=datetime.datetime.fromisoformat(
|
|
169
|
+
"2025-10-31 20:29:47+00:00",
|
|
170
|
+
),
|
|
171
|
+
data={
|
|
172
|
+
"compute_hours": 100,
|
|
173
|
+
"instance_type": "t2.micro",
|
|
174
|
+
"region": "us-east-1",
|
|
175
|
+
},
|
|
205
176
|
)
|
|
206
177
|
|
|
207
178
|
|
|
@@ -216,65 +187,3 @@ class AsyncUsageEventsClient:
|
|
|
216
187
|
request_options=request_options,
|
|
217
188
|
)
|
|
218
189
|
return _response.data
|
|
219
|
-
|
|
220
|
-
async def create_usage_event_summary(
|
|
221
|
-
self,
|
|
222
|
-
*,
|
|
223
|
-
event_name: str,
|
|
224
|
-
subject_id: str,
|
|
225
|
-
period: Period,
|
|
226
|
-
aggregation_type: CreateUsageEventSummaryRequestAggregationType,
|
|
227
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
228
|
-
) -> CreateUsageEventSummaryResponse:
|
|
229
|
-
"""
|
|
230
|
-
Parameters
|
|
231
|
-
----------
|
|
232
|
-
event_name : str
|
|
233
|
-
|
|
234
|
-
subject_id : str
|
|
235
|
-
|
|
236
|
-
period : Period
|
|
237
|
-
|
|
238
|
-
aggregation_type : CreateUsageEventSummaryRequestAggregationType
|
|
239
|
-
|
|
240
|
-
request_options : typing.Optional[RequestOptions]
|
|
241
|
-
Request-specific configuration.
|
|
242
|
-
|
|
243
|
-
Returns
|
|
244
|
-
-------
|
|
245
|
-
CreateUsageEventSummaryResponse
|
|
246
|
-
Successful Response
|
|
247
|
-
|
|
248
|
-
Examples
|
|
249
|
-
--------
|
|
250
|
-
import asyncio
|
|
251
|
-
|
|
252
|
-
from lark import AsyncLark, Period
|
|
253
|
-
|
|
254
|
-
client = AsyncLark(
|
|
255
|
-
api_key="YOUR_API_KEY",
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
async def main() -> None:
|
|
260
|
-
await client.usage_events.create_usage_event_summary(
|
|
261
|
-
event_name="event_name",
|
|
262
|
-
subject_id="subject_id",
|
|
263
|
-
period=Period(
|
|
264
|
-
start="2024-01-15T09:30:00Z",
|
|
265
|
-
end="2024-01-15T09:30:00Z",
|
|
266
|
-
),
|
|
267
|
-
aggregation_type="sum",
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
asyncio.run(main())
|
|
272
|
-
"""
|
|
273
|
-
_response = await self._raw_client.create_usage_event_summary(
|
|
274
|
-
event_name=event_name,
|
|
275
|
-
subject_id=subject_id,
|
|
276
|
-
period=period,
|
|
277
|
-
aggregation_type=aggregation_type,
|
|
278
|
-
request_options=request_options,
|
|
279
|
-
)
|
|
280
|
-
return _response.data
|