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
lark/core/__init__.py ADDED
@@ -0,0 +1,105 @@
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 .api_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import jsonable_encoder
16
+ from .pydantic_utilities import (
17
+ IS_PYDANTIC_V2,
18
+ UniversalBaseModel,
19
+ UniversalRootModel,
20
+ parse_obj_as,
21
+ universal_field_validator,
22
+ universal_root_validator,
23
+ update_forward_refs,
24
+ )
25
+ from .query_encoder import encode_query
26
+ from .remove_none_from_dict import remove_none_from_dict
27
+ from .request_options import RequestOptions
28
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
29
+ _dynamic_imports: typing.Dict[str, str] = {
30
+ "ApiError": ".api_error",
31
+ "AsyncClientWrapper": ".client_wrapper",
32
+ "AsyncHttpClient": ".http_client",
33
+ "AsyncHttpResponse": ".http_response",
34
+ "BaseClientWrapper": ".client_wrapper",
35
+ "FieldMetadata": ".serialization",
36
+ "File": ".file",
37
+ "HttpClient": ".http_client",
38
+ "HttpResponse": ".http_response",
39
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
40
+ "RequestOptions": ".request_options",
41
+ "SyncClientWrapper": ".client_wrapper",
42
+ "UniversalBaseModel": ".pydantic_utilities",
43
+ "UniversalRootModel": ".pydantic_utilities",
44
+ "convert_and_respect_annotation_metadata": ".serialization",
45
+ "convert_file_dict_to_httpx_tuples": ".file",
46
+ "encode_query": ".query_encoder",
47
+ "jsonable_encoder": ".jsonable_encoder",
48
+ "parse_obj_as": ".pydantic_utilities",
49
+ "remove_none_from_dict": ".remove_none_from_dict",
50
+ "serialize_datetime": ".datetime_utils",
51
+ "universal_field_validator": ".pydantic_utilities",
52
+ "universal_root_validator": ".pydantic_utilities",
53
+ "update_forward_refs": ".pydantic_utilities",
54
+ "with_content_type": ".file",
55
+ }
56
+
57
+
58
+ def __getattr__(attr_name: str) -> typing.Any:
59
+ module_name = _dynamic_imports.get(attr_name)
60
+ if module_name is None:
61
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
62
+ try:
63
+ module = import_module(module_name, __package__)
64
+ if module_name == f".{attr_name}":
65
+ return module
66
+ else:
67
+ return getattr(module, attr_name)
68
+ except ImportError as e:
69
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
70
+ except AttributeError as e:
71
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
72
+
73
+
74
+ def __dir__():
75
+ lazy_attrs = list(_dynamic_imports.keys())
76
+ return sorted(lazy_attrs)
77
+
78
+
79
+ __all__ = [
80
+ "ApiError",
81
+ "AsyncClientWrapper",
82
+ "AsyncHttpClient",
83
+ "AsyncHttpResponse",
84
+ "BaseClientWrapper",
85
+ "FieldMetadata",
86
+ "File",
87
+ "HttpClient",
88
+ "HttpResponse",
89
+ "IS_PYDANTIC_V2",
90
+ "RequestOptions",
91
+ "SyncClientWrapper",
92
+ "UniversalBaseModel",
93
+ "UniversalRootModel",
94
+ "convert_and_respect_annotation_metadata",
95
+ "convert_file_dict_to_httpx_tuples",
96
+ "encode_query",
97
+ "jsonable_encoder",
98
+ "parse_obj_as",
99
+ "remove_none_from_dict",
100
+ "serialize_datetime",
101
+ "universal_field_validator",
102
+ "universal_root_validator",
103
+ "update_forward_refs",
104
+ "with_content_type",
105
+ ]
lark/core/api_error.py ADDED
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,79 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(
11
+ self,
12
+ *,
13
+ api_key: str,
14
+ headers: typing.Optional[typing.Dict[str, str]] = None,
15
+ base_url: str,
16
+ timeout: typing.Optional[float] = None,
17
+ ):
18
+ self.api_key = api_key
19
+ self._headers = headers
20
+ self._base_url = base_url
21
+ self._timeout = timeout
22
+
23
+ def get_headers(self) -> typing.Dict[str, str]:
24
+ headers: typing.Dict[str, str] = {
25
+ "User-Agent": "lark-billing/0.0.6",
26
+ "X-Fern-Language": "Python",
27
+ "X-Fern-SDK-Name": "lark-billing",
28
+ "X-Fern-SDK-Version": "0.0.6",
29
+ **(self.get_custom_headers() or {}),
30
+ }
31
+ headers["X-API-Key"] = self.api_key
32
+ return headers
33
+
34
+ def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
35
+ return self._headers
36
+
37
+ def get_base_url(self) -> str:
38
+ return self._base_url
39
+
40
+ def get_timeout(self) -> typing.Optional[float]:
41
+ return self._timeout
42
+
43
+
44
+ class SyncClientWrapper(BaseClientWrapper):
45
+ def __init__(
46
+ self,
47
+ *,
48
+ api_key: str,
49
+ headers: typing.Optional[typing.Dict[str, str]] = None,
50
+ base_url: str,
51
+ timeout: typing.Optional[float] = None,
52
+ httpx_client: httpx.Client,
53
+ ):
54
+ super().__init__(api_key=api_key, headers=headers, base_url=base_url, timeout=timeout)
55
+ self.httpx_client = HttpClient(
56
+ httpx_client=httpx_client,
57
+ base_headers=self.get_headers,
58
+ base_timeout=self.get_timeout,
59
+ base_url=self.get_base_url,
60
+ )
61
+
62
+
63
+ class AsyncClientWrapper(BaseClientWrapper):
64
+ def __init__(
65
+ self,
66
+ *,
67
+ api_key: str,
68
+ headers: typing.Optional[typing.Dict[str, str]] = None,
69
+ base_url: str,
70
+ timeout: typing.Optional[float] = None,
71
+ httpx_client: httpx.AsyncClient,
72
+ ):
73
+ super().__init__(api_key=api_key, headers=headers, base_url=base_url, timeout=timeout)
74
+ self.httpx_client = AsyncHttpClient(
75
+ httpx_client=httpx_client,
76
+ base_headers=self.get_headers,
77
+ base_timeout=self.get_timeout,
78
+ base_url=self.get_base_url,
79
+ )
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)
lark/core/file.py ADDED
@@ -0,0 +1,67 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast
4
+
5
+ # File typing inspired by the flexibility of types within the httpx library
6
+ # https://github.com/encode/httpx/blob/master/httpx/_types.py
7
+ FileContent = Union[IO[bytes], bytes, str]
8
+ File = Union[
9
+ # file (or bytes)
10
+ FileContent,
11
+ # (filename, file (or bytes))
12
+ Tuple[Optional[str], FileContent],
13
+ # (filename, file (or bytes), content_type)
14
+ Tuple[Optional[str], FileContent, Optional[str]],
15
+ # (filename, file (or bytes), content_type, headers)
16
+ Tuple[
17
+ Optional[str],
18
+ FileContent,
19
+ Optional[str],
20
+ Mapping[str, str],
21
+ ],
22
+ ]
23
+
24
+
25
+ def convert_file_dict_to_httpx_tuples(
26
+ d: Dict[str, Union[File, List[File]]],
27
+ ) -> List[Tuple[str, File]]:
28
+ """
29
+ The format we use is a list of tuples, where the first element is the
30
+ name of the file and the second is the file object. Typically HTTPX wants
31
+ a dict, but to be able to send lists of files, you have to use the list
32
+ approach (which also works for non-lists)
33
+ https://github.com/encode/httpx/pull/1032
34
+ """
35
+
36
+ httpx_tuples = []
37
+ for key, file_like in d.items():
38
+ if isinstance(file_like, list):
39
+ for file_like_item in file_like:
40
+ httpx_tuples.append((key, file_like_item))
41
+ else:
42
+ httpx_tuples.append((key, file_like))
43
+ return httpx_tuples
44
+
45
+
46
+ def with_content_type(*, file: File, default_content_type: str) -> File:
47
+ """
48
+ This function resolves to the file's content type, if provided, and defaults
49
+ to the default_content_type value if not.
50
+ """
51
+ if isinstance(file, tuple):
52
+ if len(file) == 2:
53
+ filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
54
+ return (filename, content, default_content_type)
55
+ elif len(file) == 3:
56
+ filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
57
+ out_content_type = file_content_type or default_content_type
58
+ return (filename, content, out_content_type)
59
+ elif len(file) == 4:
60
+ filename, content, file_content_type, headers = cast( # type: ignore
61
+ Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file
62
+ )
63
+ out_content_type = file_content_type or default_content_type
64
+ return (filename, content, out_content_type, headers)
65
+ else:
66
+ raise ValueError(f"Unexpected tuple length: {len(file)}")
67
+ return (None, file, default_content_type)
@@ -0,0 +1,18 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict
4
+
5
+
6
+ class ForceMultipartDict(Dict[str, Any]):
7
+ """
8
+ A dictionary subclass that always evaluates to True in boolean contexts.
9
+
10
+ This is used to force multipart/form-data encoding in HTTP requests even when
11
+ the dictionary is empty, which would normally evaluate to False.
12
+ """
13
+
14
+ def __bool__(self) -> bool:
15
+ return True
16
+
17
+
18
+ FORCE_MULTIPART = ForceMultipartDict()