lark-billing 0.0.6__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.

Files changed (167) hide show
  1. lark/__init__.py +522 -0
  2. lark/checkout/__init__.py +4 -0
  3. lark/checkout/client.py +214 -0
  4. lark/checkout/raw_client.py +252 -0
  5. lark/client.py +240 -0
  6. lark/core/__init__.py +105 -0
  7. lark/core/api_error.py +23 -0
  8. lark/core/client_wrapper.py +79 -0
  9. lark/core/datetime_utils.py +28 -0
  10. lark/core/file.py +67 -0
  11. lark/core/force_multipart.py +18 -0
  12. lark/core/http_client.py +543 -0
  13. lark/core/http_response.py +55 -0
  14. lark/core/jsonable_encoder.py +100 -0
  15. lark/core/pydantic_utilities.py +258 -0
  16. lark/core/query_encoder.py +58 -0
  17. lark/core/remove_none_from_dict.py +11 -0
  18. lark/core/request_options.py +35 -0
  19. lark/core/serialization.py +276 -0
  20. lark/errors/__init__.py +34 -0
  21. lark/errors/unprocessable_entity_error.py +11 -0
  22. lark/feature_access/__init__.py +4 -0
  23. lark/feature_access/client.py +102 -0
  24. lark/feature_access/raw_client.py +113 -0
  25. lark/py.typed +0 -0
  26. lark/rate_cards/__init__.py +61 -0
  27. lark/rate_cards/client.py +817 -0
  28. lark/rate_cards/raw_client.py +728 -0
  29. lark/rate_cards/types/__init__.py +63 -0
  30. lark/rate_cards/types/create_rate_card_request_billing_interval.py +5 -0
  31. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +56 -0
  32. lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +58 -0
  33. lark/rate_cards/types/create_rate_card_version_request_version_type.py +5 -0
  34. lark/subjects/__init__.py +4 -0
  35. lark/subjects/client.py +501 -0
  36. lark/subjects/raw_client.py +633 -0
  37. lark/subscriptions/__init__.py +4 -0
  38. lark/subscriptions/client.py +462 -0
  39. lark/subscriptions/raw_client.py +495 -0
  40. lark/types/__init__.py +493 -0
  41. lark/types/aggregation.py +80 -0
  42. lark/types/amount.py +20 -0
  43. lark/types/check_feature_access_request.py +24 -0
  44. lark/types/check_feature_access_response.py +21 -0
  45. lark/types/complete_subscription_checkout_response.py +21 -0
  46. lark/types/count_aggregation_pricing_metric_interface.py +17 -0
  47. lark/types/create_credit_grant_interface.py +27 -0
  48. lark/types/create_credit_grant_interface_expiration.py +27 -0
  49. lark/types/create_credit_pool_request.py +5 -0
  50. lark/types/create_dimension_coordinate_interface.py +20 -0
  51. lark/types/create_dimension_interface.py +20 -0
  52. lark/types/create_dimensional_usage_based_rate_interface.py +32 -0
  53. lark/types/create_fixed_rate_interface.py +28 -0
  54. lark/types/create_pricing_matrix_cell_interface.py +22 -0
  55. lark/types/create_pricing_matrix_interface.py +20 -0
  56. lark/types/create_pricing_metric_interface.py +26 -0
  57. lark/types/create_pricing_plan_request.py +5 -0
  58. lark/types/create_rate_card_response.py +36 -0
  59. lark/types/create_rate_card_response_billing_interval.py +5 -0
  60. lark/types/create_rate_card_response_usage_based_rates_item.py +58 -0
  61. lark/types/create_rate_card_version_response.py +36 -0
  62. lark/types/create_rate_card_version_response_billing_interval.py +5 -0
  63. lark/types/create_rate_card_version_response_usage_based_rates_item.py +59 -0
  64. lark/types/create_simple_usage_based_rate_interface.py +30 -0
  65. lark/types/create_subject_response.py +24 -0
  66. lark/types/create_subscription_checkout_session_response.py +23 -0
  67. lark/types/create_usage_event_summary_response.py +23 -0
  68. lark/types/credit_grant.py +5 -0
  69. lark/types/credit_grant_date_time_expiration_interface.py +19 -0
  70. lark/types/credit_grant_date_time_expiration_resource.py +19 -0
  71. lark/types/credit_grant_duration_expiration_interface.py +21 -0
  72. lark/types/credit_grant_duration_expiration_resource.py +21 -0
  73. lark/types/credit_grant_interface.py +28 -0
  74. lark/types/credit_grant_interface_input_expiration.py +27 -0
  75. lark/types/credit_grant_interface_output_expiration.py +43 -0
  76. lark/types/credit_grant_interface_output_schedule.py +41 -0
  77. lark/types/credit_grant_resource.py +28 -0
  78. lark/types/credit_grant_resource_input_expiration.py +27 -0
  79. lark/types/credit_grant_resource_input_schedule.py +39 -0
  80. lark/types/credit_grant_resource_output_expiration.py +43 -0
  81. lark/types/credit_grant_resource_output_schedule.py +39 -0
  82. lark/types/credit_grant_schedule.py +5 -0
  83. lark/types/credit_grant_schedule_one_time_interface.py +19 -0
  84. lark/types/credit_grant_schedule_one_time_resource.py +17 -0
  85. lark/types/credit_grant_schedule_rate_cycle_start_interface.py +19 -0
  86. lark/types/credit_grant_schedule_rate_cycle_start_resource.py +17 -0
  87. lark/types/credit_grant_subject_granting_config_interface.py +20 -0
  88. lark/types/credit_pool.py +5 -0
  89. lark/types/credit_pool_rollover_config.py +5 -0
  90. lark/types/custom_aggregation_pricing_metric_interface.py +22 -0
  91. lark/types/custom_pricing_metric.py +5 -0
  92. lark/types/custom_unit.py +5 -0
  93. lark/types/custom_unit_amount.py +5 -0
  94. lark/types/dimension.py +5 -0
  95. lark/types/dimension_coordinate.py +5 -0
  96. lark/types/dimension_coordinate_interface.py +20 -0
  97. lark/types/dimension_coordinate_set.py +5 -0
  98. lark/types/dimension_interface.py +20 -0
  99. lark/types/dimensional_rate_matrix.py +5 -0
  100. lark/types/dimensional_rate_matrix_cell.py +5 -0
  101. lark/types/dimensional_usage_based_rate.py +5 -0
  102. lark/types/dimensional_usage_based_rate_input.py +5 -0
  103. lark/types/dimensional_usage_based_rate_interface.py +33 -0
  104. lark/types/feature_access_resource.py +21 -0
  105. lark/types/fixed_rate_interface.py +29 -0
  106. lark/types/flat_price.py +24 -0
  107. lark/types/get_rate_card_response.py +36 -0
  108. lark/types/get_rate_card_response_billing_interval.py +5 -0
  109. lark/types/get_rate_card_response_usage_based_rates_item.py +58 -0
  110. lark/types/grant_credits_request.py +5 -0
  111. lark/types/http_validation_error.py +20 -0
  112. lark/types/last_aggregation_pricing_metric_interface.py +22 -0
  113. lark/types/license_based_rate.py +5 -0
  114. lark/types/license_based_rate_input.py +5 -0
  115. lark/types/list_rate_cards_response.py +21 -0
  116. lark/types/list_subjects_response.py +21 -0
  117. lark/types/list_subscriptions_response.py +21 -0
  118. lark/types/max_aggregation_pricing_metric_interface.py +22 -0
  119. lark/types/monetary_amount.py +5 -0
  120. lark/types/package_price.py +27 -0
  121. lark/types/package_price_rounding_behavior.py +5 -0
  122. lark/types/package_price_wrapper.py +5 -0
  123. lark/types/period.py +22 -0
  124. lark/types/price.py +5 -0
  125. lark/types/pricing_matrix_cell_interface.py +22 -0
  126. lark/types/pricing_matrix_interface.py +20 -0
  127. lark/types/pricing_metric.py +5 -0
  128. lark/types/pricing_metric_interface.py +27 -0
  129. lark/types/pricing_plan.py +5 -0
  130. lark/types/pricing_plan_subscription.py +5 -0
  131. lark/types/pricing_tier.py +5 -0
  132. lark/types/rate_card.py +5 -0
  133. lark/types/rate_card_resource.py +36 -0
  134. lark/types/rate_card_resource_billing_interval.py +5 -0
  135. lark/types/rate_card_resource_usage_based_rates_item.py +58 -0
  136. lark/types/rate_card_version.py +5 -0
  137. lark/types/rate_card_version_input.py +5 -0
  138. lark/types/simple_usage_based_rate.py +5 -0
  139. lark/types/simple_usage_based_rate_input.py +5 -0
  140. lark/types/simple_usage_based_rate_interface.py +31 -0
  141. lark/types/status.py +5 -0
  142. lark/types/subject.py +5 -0
  143. lark/types/subject_granting_config.py +5 -0
  144. lark/types/subject_granting_config_resource.py +20 -0
  145. lark/types/subject_resource.py +24 -0
  146. lark/types/subscription_resource.py +28 -0
  147. lark/types/sum_aggregation_pricing_metric_interface.py +22 -0
  148. lark/types/tiered_price.py +5 -0
  149. lark/types/tiered_price_wrapper.py +5 -0
  150. lark/types/unit.py +5 -0
  151. lark/types/update_pricing_plan_request.py +5 -0
  152. lark/types/update_rate_card_request.py +5 -0
  153. lark/types/update_subscription_request.py +5 -0
  154. lark/types/usage_based_rate.py +5 -0
  155. lark/types/usage_based_rate_input.py +5 -0
  156. lark/types/usage_unit.py +5 -0
  157. lark/types/validation_error.py +22 -0
  158. lark/types/validation_error_loc_item.py +5 -0
  159. lark/usage_events/__init__.py +34 -0
  160. lark/usage_events/client.py +293 -0
  161. lark/usage_events/raw_client.py +318 -0
  162. lark/usage_events/types/__init__.py +36 -0
  163. lark/usage_events/types/create_usage_event_summary_request_aggregation_type.py +5 -0
  164. lark/version.py +3 -0
  165. lark_billing-0.0.6.dist-info/METADATA +188 -0
  166. lark_billing-0.0.6.dist-info/RECORD +167 -0
  167. lark_billing-0.0.6.dist-info/WHEEL +4 -0
@@ -0,0 +1,20 @@
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
+
8
+
9
+ class SubjectGrantingConfigResource(UniversalBaseModel):
10
+ apply_to_self: bool
11
+ apply_to_children: bool
12
+
13
+ if IS_PYDANTIC_V2:
14
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
15
+ else:
16
+
17
+ class Config:
18
+ frozen = True
19
+ smart_union = True
20
+ extra = pydantic.Extra.allow
@@ -0,0 +1,24 @@
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
+
8
+
9
+ class SubjectResource(UniversalBaseModel):
10
+ id: str
11
+ external_id: typing.Optional[str] = None
12
+ name: typing.Optional[str] = None
13
+ email: typing.Optional[str] = None
14
+ parent_subject_id: typing.Optional[str] = None
15
+ metadata: typing.Dict[str, str]
16
+
17
+ if IS_PYDANTIC_V2:
18
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
19
+ else:
20
+
21
+ class Config:
22
+ frozen = True
23
+ smart_union = True
24
+ extra = pydantic.Extra.allow
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ import pydantic
7
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from .status import Status
9
+
10
+
11
+ class SubscriptionResource(UniversalBaseModel):
12
+ id: str
13
+ subject_id: str
14
+ rate_card_id: str
15
+ effective_at: dt.datetime
16
+ cycles_next_at: typing.Optional[dt.datetime] = None
17
+ variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None
18
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None
19
+ status: Status
20
+
21
+ if IS_PYDANTIC_V2:
22
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
23
+ else:
24
+
25
+ class Config:
26
+ frozen = True
27
+ smart_union = True
28
+ extra = pydantic.Extra.allow
@@ -0,0 +1,22 @@
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
+
8
+
9
+ class SumAggregationPricingMetricInterface(UniversalBaseModel):
10
+ value_field: str = pydantic.Field()
11
+ """
12
+ Field to sum over.
13
+ """
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ TieredPrice = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ TieredPriceWrapper = typing.Optional[typing.Any]
lark/types/unit.py ADDED
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ Unit = typing.Union[typing.Literal["hours", "days", "weeks", "months", "years"], typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UpdatePricingPlanRequest = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UpdateRateCardRequest = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UpdateSubscriptionRequest = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UsageBasedRate = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UsageBasedRateInput = typing.Optional[typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UsageUnit = typing.Optional[typing.Any]
@@ -0,0 +1,22 @@
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 .validation_error_loc_item import ValidationErrorLocItem
8
+
9
+
10
+ class ValidationError(UniversalBaseModel):
11
+ loc: typing.List[ValidationErrorLocItem]
12
+ msg: str
13
+ type: str
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ValidationErrorLocItem = typing.Union[str, int]
@@ -0,0 +1,34 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import CreateUsageEventSummaryRequestAggregationType
10
+ _dynamic_imports: typing.Dict[str, str] = {"CreateUsageEventSummaryRequestAggregationType": ".types"}
11
+
12
+
13
+ def __getattr__(attr_name: str) -> typing.Any:
14
+ module_name = _dynamic_imports.get(attr_name)
15
+ if module_name is None:
16
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
17
+ try:
18
+ module = import_module(module_name, __package__)
19
+ if module_name == f".{attr_name}":
20
+ return module
21
+ else:
22
+ return getattr(module, attr_name)
23
+ except ImportError as e:
24
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
25
+ except AttributeError as e:
26
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
27
+
28
+
29
+ def __dir__():
30
+ lazy_attrs = list(_dynamic_imports.keys())
31
+ return sorted(lazy_attrs)
32
+
33
+
34
+ __all__ = ["CreateUsageEventSummaryRequestAggregationType"]
@@ -0,0 +1,293 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
+ from ..core.request_options import RequestOptions
8
+ from ..types.create_usage_event_summary_response import CreateUsageEventSummaryResponse
9
+ from ..types.period import Period
10
+ from .raw_client import AsyncRawUsageEventsClient, RawUsageEventsClient
11
+ from .types.create_usage_event_summary_request_aggregation_type import CreateUsageEventSummaryRequestAggregationType
12
+
13
+ # this is used as the default value for optional parameters
14
+ OMIT = typing.cast(typing.Any, ...)
15
+
16
+
17
+ class UsageEventsClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._raw_client = RawUsageEventsClient(client_wrapper=client_wrapper)
20
+
21
+ @property
22
+ def with_raw_response(self) -> RawUsageEventsClient:
23
+ """
24
+ Retrieves a raw implementation of this client that returns raw responses.
25
+
26
+ Returns
27
+ -------
28
+ RawUsageEventsClient
29
+ """
30
+ return self._raw_client
31
+
32
+ def create_usage_event(
33
+ self,
34
+ *,
35
+ idempotency_key: str,
36
+ event_name: str,
37
+ subject_id: str,
38
+ timestamp: dt.datetime,
39
+ data: typing.Dict[str, typing.Optional[typing.Any]],
40
+ request_options: typing.Optional[RequestOptions] = None,
41
+ ) -> typing.Optional[typing.Any]:
42
+ """
43
+ Parameters
44
+ ----------
45
+ idempotency_key : str
46
+
47
+ event_name : str
48
+
49
+ subject_id : str
50
+
51
+ timestamp : dt.datetime
52
+
53
+ data : typing.Dict[str, typing.Optional[typing.Any]]
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ typing.Optional[typing.Any]
61
+ Successful Response
62
+
63
+ Examples
64
+ --------
65
+ import datetime
66
+
67
+ from lark import Lark
68
+
69
+ client = Lark(
70
+ api_key="YOUR_API_KEY",
71
+ base_url="https://yourhost.com/path/to/api",
72
+ )
73
+ client.usage_events.create_usage_event(
74
+ idempotency_key="idempotency_key",
75
+ event_name="event_name",
76
+ subject_id="subject_id",
77
+ timestamp=datetime.datetime.fromisoformat(
78
+ "2024-01-15 09:30:00+00:00",
79
+ ),
80
+ data={"key": "value"},
81
+ )
82
+ """
83
+ _response = self._raw_client.create_usage_event(
84
+ idempotency_key=idempotency_key,
85
+ event_name=event_name,
86
+ subject_id=subject_id,
87
+ timestamp=timestamp,
88
+ data=data,
89
+ request_options=request_options,
90
+ )
91
+ return _response.data
92
+
93
+ def create_usage_event_summary(
94
+ self,
95
+ *,
96
+ event_name: str,
97
+ subject_id: str,
98
+ period: Period,
99
+ aggregation_type: CreateUsageEventSummaryRequestAggregationType,
100
+ request_options: typing.Optional[RequestOptions] = None,
101
+ ) -> CreateUsageEventSummaryResponse:
102
+ """
103
+ Parameters
104
+ ----------
105
+ event_name : str
106
+
107
+ subject_id : str
108
+
109
+ period : Period
110
+
111
+ aggregation_type : CreateUsageEventSummaryRequestAggregationType
112
+
113
+ request_options : typing.Optional[RequestOptions]
114
+ Request-specific configuration.
115
+
116
+ Returns
117
+ -------
118
+ CreateUsageEventSummaryResponse
119
+ Successful Response
120
+
121
+ Examples
122
+ --------
123
+ from lark import Lark, Period
124
+
125
+ client = Lark(
126
+ api_key="YOUR_API_KEY",
127
+ base_url="https://yourhost.com/path/to/api",
128
+ )
129
+ client.usage_events.create_usage_event_summary(
130
+ event_name="event_name",
131
+ subject_id="subject_id",
132
+ period=Period(
133
+ start="2024-01-15T09:30:00Z",
134
+ end="2024-01-15T09:30:00Z",
135
+ ),
136
+ aggregation_type="sum",
137
+ )
138
+ """
139
+ _response = self._raw_client.create_usage_event_summary(
140
+ event_name=event_name,
141
+ subject_id=subject_id,
142
+ period=period,
143
+ aggregation_type=aggregation_type,
144
+ request_options=request_options,
145
+ )
146
+ return _response.data
147
+
148
+
149
+ class AsyncUsageEventsClient:
150
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
151
+ self._raw_client = AsyncRawUsageEventsClient(client_wrapper=client_wrapper)
152
+
153
+ @property
154
+ def with_raw_response(self) -> AsyncRawUsageEventsClient:
155
+ """
156
+ Retrieves a raw implementation of this client that returns raw responses.
157
+
158
+ Returns
159
+ -------
160
+ AsyncRawUsageEventsClient
161
+ """
162
+ return self._raw_client
163
+
164
+ async def create_usage_event(
165
+ self,
166
+ *,
167
+ idempotency_key: str,
168
+ event_name: str,
169
+ subject_id: str,
170
+ timestamp: dt.datetime,
171
+ data: typing.Dict[str, typing.Optional[typing.Any]],
172
+ request_options: typing.Optional[RequestOptions] = None,
173
+ ) -> typing.Optional[typing.Any]:
174
+ """
175
+ Parameters
176
+ ----------
177
+ idempotency_key : str
178
+
179
+ event_name : str
180
+
181
+ subject_id : str
182
+
183
+ timestamp : dt.datetime
184
+
185
+ data : typing.Dict[str, typing.Optional[typing.Any]]
186
+
187
+ request_options : typing.Optional[RequestOptions]
188
+ Request-specific configuration.
189
+
190
+ Returns
191
+ -------
192
+ typing.Optional[typing.Any]
193
+ Successful Response
194
+
195
+ Examples
196
+ --------
197
+ import asyncio
198
+ import datetime
199
+
200
+ from lark import AsyncLark
201
+
202
+ client = AsyncLark(
203
+ api_key="YOUR_API_KEY",
204
+ base_url="https://yourhost.com/path/to/api",
205
+ )
206
+
207
+
208
+ async def main() -> None:
209
+ await client.usage_events.create_usage_event(
210
+ idempotency_key="idempotency_key",
211
+ event_name="event_name",
212
+ subject_id="subject_id",
213
+ timestamp=datetime.datetime.fromisoformat(
214
+ "2024-01-15 09:30:00+00:00",
215
+ ),
216
+ data={"key": "value"},
217
+ )
218
+
219
+
220
+ asyncio.run(main())
221
+ """
222
+ _response = await self._raw_client.create_usage_event(
223
+ idempotency_key=idempotency_key,
224
+ event_name=event_name,
225
+ subject_id=subject_id,
226
+ timestamp=timestamp,
227
+ data=data,
228
+ request_options=request_options,
229
+ )
230
+ return _response.data
231
+
232
+ async def create_usage_event_summary(
233
+ self,
234
+ *,
235
+ event_name: str,
236
+ subject_id: str,
237
+ period: Period,
238
+ aggregation_type: CreateUsageEventSummaryRequestAggregationType,
239
+ request_options: typing.Optional[RequestOptions] = None,
240
+ ) -> CreateUsageEventSummaryResponse:
241
+ """
242
+ Parameters
243
+ ----------
244
+ event_name : str
245
+
246
+ subject_id : str
247
+
248
+ period : Period
249
+
250
+ aggregation_type : CreateUsageEventSummaryRequestAggregationType
251
+
252
+ request_options : typing.Optional[RequestOptions]
253
+ Request-specific configuration.
254
+
255
+ Returns
256
+ -------
257
+ CreateUsageEventSummaryResponse
258
+ Successful Response
259
+
260
+ Examples
261
+ --------
262
+ import asyncio
263
+
264
+ from lark import AsyncLark, Period
265
+
266
+ client = AsyncLark(
267
+ api_key="YOUR_API_KEY",
268
+ base_url="https://yourhost.com/path/to/api",
269
+ )
270
+
271
+
272
+ async def main() -> None:
273
+ await client.usage_events.create_usage_event_summary(
274
+ event_name="event_name",
275
+ subject_id="subject_id",
276
+ period=Period(
277
+ start="2024-01-15T09:30:00Z",
278
+ end="2024-01-15T09:30:00Z",
279
+ ),
280
+ aggregation_type="sum",
281
+ )
282
+
283
+
284
+ asyncio.run(main())
285
+ """
286
+ _response = await self._raw_client.create_usage_event_summary(
287
+ event_name=event_name,
288
+ subject_id=subject_id,
289
+ period=period,
290
+ aggregation_type=aggregation_type,
291
+ request_options=request_options,
292
+ )
293
+ return _response.data