latitudesh-python-sdk 2.3.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.
Files changed (242) hide show
  1. latitudesh_python_sdk/__init__.py +18 -0
  2. latitudesh_python_sdk/_hooks/__init__.py +5 -0
  3. latitudesh_python_sdk/_hooks/registration.py +13 -0
  4. latitudesh_python_sdk/_hooks/sdkhooks.py +76 -0
  5. latitudesh_python_sdk/_hooks/types.py +113 -0
  6. latitudesh_python_sdk/_version.py +17 -0
  7. latitudesh_python_sdk/apikeys.py +703 -0
  8. latitudesh_python_sdk/basesdk.py +374 -0
  9. latitudesh_python_sdk/billing.py +197 -0
  10. latitudesh_python_sdk/events_sdk.py +298 -0
  11. latitudesh_python_sdk/firewalls_sdk.py +1786 -0
  12. latitudesh_python_sdk/httpclient.py +125 -0
  13. latitudesh_python_sdk/ipaddresses_sdk.py +470 -0
  14. latitudesh_python_sdk/models/__init__.py +3581 -0
  15. latitudesh_python_sdk/models/api_key.py +81 -0
  16. latitudesh_python_sdk/models/apierror.py +40 -0
  17. latitudesh_python_sdk/models/assign_server_virtual_networkop.py +43 -0
  18. latitudesh_python_sdk/models/bandwidth_packages.py +67 -0
  19. latitudesh_python_sdk/models/bandwidth_plan_data.py +72 -0
  20. latitudesh_python_sdk/models/bandwidth_plans.py +26 -0
  21. latitudesh_python_sdk/models/billing_usage.py +249 -0
  22. latitudesh_python_sdk/models/container_plan_data.py +163 -0
  23. latitudesh_python_sdk/models/create_api_key.py +40 -0
  24. latitudesh_python_sdk/models/create_firewall_assignmentop.py +61 -0
  25. latitudesh_python_sdk/models/create_firewallop.py +73 -0
  26. latitudesh_python_sdk/models/create_ipmi_sessionop.py +16 -0
  27. latitudesh_python_sdk/models/create_projectop.py +79 -0
  28. latitudesh_python_sdk/models/create_server_actionop.py +69 -0
  29. latitudesh_python_sdk/models/create_server_out_of_bandop.py +61 -0
  30. latitudesh_python_sdk/models/create_server_reinstallop.py +140 -0
  31. latitudesh_python_sdk/models/create_serverop.py +173 -0
  32. latitudesh_python_sdk/models/create_tagop.py +50 -0
  33. latitudesh_python_sdk/models/create_virtual_machine_actionop.py +63 -0
  34. latitudesh_python_sdk/models/create_virtual_networkop.py +72 -0
  35. latitudesh_python_sdk/models/custom_tag.py +26 -0
  36. latitudesh_python_sdk/models/custom_tag_data.py +54 -0
  37. latitudesh_python_sdk/models/custom_tags.py +26 -0
  38. latitudesh_python_sdk/models/delete_api_keyop.py +16 -0
  39. latitudesh_python_sdk/models/delete_firewall_assignmentop.py +25 -0
  40. latitudesh_python_sdk/models/delete_firewallop.py +18 -0
  41. latitudesh_python_sdk/models/delete_project_ssh_keyop.py +23 -0
  42. latitudesh_python_sdk/models/delete_project_user_dataop.py +23 -0
  43. latitudesh_python_sdk/models/delete_projectop.py +18 -0
  44. latitudesh_python_sdk/models/delete_ssh_keyop.py +16 -0
  45. latitudesh_python_sdk/models/delete_storage_filesystemsop.py +16 -0
  46. latitudesh_python_sdk/models/delete_storage_volumesop.py +16 -0
  47. latitudesh_python_sdk/models/delete_user_dataop.py +16 -0
  48. latitudesh_python_sdk/models/delete_virtual_networks_assignmentsop.py +16 -0
  49. latitudesh_python_sdk/models/delete_vpn_sessionop.py +16 -0
  50. latitudesh_python_sdk/models/deploy_config.py +62 -0
  51. latitudesh_python_sdk/models/destroy_serverop.py +31 -0
  52. latitudesh_python_sdk/models/destroy_tagop.py +16 -0
  53. latitudesh_python_sdk/models/destroy_team_memberop.py +18 -0
  54. latitudesh_python_sdk/models/destroy_virtual_machineop.py +16 -0
  55. latitudesh_python_sdk/models/destroy_virtual_networkop.py +18 -0
  56. latitudesh_python_sdk/models/event_data.py +98 -0
  57. latitudesh_python_sdk/models/events.py +26 -0
  58. latitudesh_python_sdk/models/filesystem_data.py +57 -0
  59. latitudesh_python_sdk/models/firewall.py +26 -0
  60. latitudesh_python_sdk/models/firewall_assignment_data.py +50 -0
  61. latitudesh_python_sdk/models/firewall_assignments.py +29 -0
  62. latitudesh_python_sdk/models/firewall_data.py +75 -0
  63. latitudesh_python_sdk/models/firewall_server.py +36 -0
  64. latitudesh_python_sdk/models/firewalls.py +26 -0
  65. latitudesh_python_sdk/models/get_all_firewall_assignmentsop.py +51 -0
  66. latitudesh_python_sdk/models/get_bandwidth_plansop.py +62 -0
  67. latitudesh_python_sdk/models/get_billing_usageop.py +46 -0
  68. latitudesh_python_sdk/models/get_containers_planop.py +18 -0
  69. latitudesh_python_sdk/models/get_eventsop.py +126 -0
  70. latitudesh_python_sdk/models/get_firewall_assignmentsop.py +53 -0
  71. latitudesh_python_sdk/models/get_firewallop.py +18 -0
  72. latitudesh_python_sdk/models/get_ipop.py +33 -0
  73. latitudesh_python_sdk/models/get_ipsop.py +120 -0
  74. latitudesh_python_sdk/models/get_planop.py +16 -0
  75. latitudesh_python_sdk/models/get_plans_operating_systemop.py +54 -0
  76. latitudesh_python_sdk/models/get_plansop.py +125 -0
  77. latitudesh_python_sdk/models/get_project_ssh_keyop.py +37 -0
  78. latitudesh_python_sdk/models/get_project_ssh_keysop.py +33 -0
  79. latitudesh_python_sdk/models/get_project_user_dataop.py +38 -0
  80. latitudesh_python_sdk/models/get_project_users_dataop.py +46 -0
  81. latitudesh_python_sdk/models/get_projectsop.py +105 -0
  82. latitudesh_python_sdk/models/get_regionop.py +18 -0
  83. latitudesh_python_sdk/models/get_regionsop.py +42 -0
  84. latitudesh_python_sdk/models/get_role_idop.py +16 -0
  85. latitudesh_python_sdk/models/get_rolesop.py +54 -0
  86. latitudesh_python_sdk/models/get_server_deploy_configop.py +18 -0
  87. latitudesh_python_sdk/models/get_server_out_of_bandop.py +18 -0
  88. latitudesh_python_sdk/models/get_serverop.py +33 -0
  89. latitudesh_python_sdk/models/get_serversop.py +185 -0
  90. latitudesh_python_sdk/models/get_ssh_keyop.py +30 -0
  91. latitudesh_python_sdk/models/get_ssh_keysop.py +31 -0
  92. latitudesh_python_sdk/models/get_storage_filesystemsop.py +22 -0
  93. latitudesh_python_sdk/models/get_storage_volumeop.py +32 -0
  94. latitudesh_python_sdk/models/get_storage_volumesop.py +35 -0
  95. latitudesh_python_sdk/models/get_team_membersop.py +42 -0
  96. latitudesh_python_sdk/models/get_traffic_consumptionop.py +49 -0
  97. latitudesh_python_sdk/models/get_traffic_quotaop.py +20 -0
  98. latitudesh_python_sdk/models/get_user_dataop.py +31 -0
  99. latitudesh_python_sdk/models/get_user_profileop.py +19 -0
  100. latitudesh_python_sdk/models/get_users_dataop.py +44 -0
  101. latitudesh_python_sdk/models/get_virtual_networkop.py +32 -0
  102. latitudesh_python_sdk/models/get_virtual_networks_assignmentsop.py +72 -0
  103. latitudesh_python_sdk/models/get_virtual_networksop.py +69 -0
  104. latitudesh_python_sdk/models/get_vpn_sessionsop.py +70 -0
  105. latitudesh_python_sdk/models/index_virtual_machineop.py +31 -0
  106. latitudesh_python_sdk/models/ip_address.py +122 -0
  107. latitudesh_python_sdk/models/ip_addresses.py +15 -0
  108. latitudesh_python_sdk/models/ipmi_session.py +53 -0
  109. latitudesh_python_sdk/models/latitudesherror.py +30 -0
  110. latitudesh_python_sdk/models/list_firewallsop.py +49 -0
  111. latitudesh_python_sdk/models/membership.py +63 -0
  112. latitudesh_python_sdk/models/no_response_error.py +17 -0
  113. latitudesh_python_sdk/models/operating_system_data.py +65 -0
  114. latitudesh_python_sdk/models/operating_systems.py +26 -0
  115. latitudesh_python_sdk/models/out_of_band_connection.py +88 -0
  116. latitudesh_python_sdk/models/patch_current_teamop.py +91 -0
  117. latitudesh_python_sdk/models/patch_storage_filesystemsop.py +79 -0
  118. latitudesh_python_sdk/models/patch_user_dataop.py +69 -0
  119. latitudesh_python_sdk/models/patch_user_profileop.py +88 -0
  120. latitudesh_python_sdk/models/plan.py +15 -0
  121. latitudesh_python_sdk/models/plan_data.py +210 -0
  122. latitudesh_python_sdk/models/post_api_keyop.py +19 -0
  123. latitudesh_python_sdk/models/post_project_ssh_keyop.py +81 -0
  124. latitudesh_python_sdk/models/post_project_user_dataop.py +68 -0
  125. latitudesh_python_sdk/models/post_ssh_keyop.py +63 -0
  126. latitudesh_python_sdk/models/post_storage_filesystemsop.py +63 -0
  127. latitudesh_python_sdk/models/post_storage_volumes_mountop.py +62 -0
  128. latitudesh_python_sdk/models/post_storage_volumesop.py +63 -0
  129. latitudesh_python_sdk/models/post_team_membersop.py +54 -0
  130. latitudesh_python_sdk/models/post_teamop.py +67 -0
  131. latitudesh_python_sdk/models/post_user_dataop.py +50 -0
  132. latitudesh_python_sdk/models/post_vpn_sessionop.py +63 -0
  133. latitudesh_python_sdk/models/project.py +131 -0
  134. latitudesh_python_sdk/models/project_include.py +75 -0
  135. latitudesh_python_sdk/models/projects.py +15 -0
  136. latitudesh_python_sdk/models/put_project_ssh_keyop.py +87 -0
  137. latitudesh_python_sdk/models/put_project_user_dataop.py +76 -0
  138. latitudesh_python_sdk/models/put_ssh_keyop.py +80 -0
  139. latitudesh_python_sdk/models/put_vpn_sessionop.py +16 -0
  140. latitudesh_python_sdk/models/region.py +50 -0
  141. latitudesh_python_sdk/models/region_resource_data.py +37 -0
  142. latitudesh_python_sdk/models/regions.py +50 -0
  143. latitudesh_python_sdk/models/responsevalidationerror.py +27 -0
  144. latitudesh_python_sdk/models/role.py +26 -0
  145. latitudesh_python_sdk/models/role_data.py +35 -0
  146. latitudesh_python_sdk/models/security.py +25 -0
  147. latitudesh_python_sdk/models/server.py +26 -0
  148. latitudesh_python_sdk/models/server_action.py +52 -0
  149. latitudesh_python_sdk/models/server_data.py +280 -0
  150. latitudesh_python_sdk/models/server_exit_rescue_modeop.py +16 -0
  151. latitudesh_python_sdk/models/server_lockop.py +16 -0
  152. latitudesh_python_sdk/models/server_region_resource_data.py +40 -0
  153. latitudesh_python_sdk/models/server_rescue.py +22 -0
  154. latitudesh_python_sdk/models/server_schedule_deletion.py +44 -0
  155. latitudesh_python_sdk/models/server_schedule_deletionop.py +16 -0
  156. latitudesh_python_sdk/models/server_start_rescue_modeop.py +16 -0
  157. latitudesh_python_sdk/models/server_unlockop.py +16 -0
  158. latitudesh_python_sdk/models/server_unschedule_deletionop.py +16 -0
  159. latitudesh_python_sdk/models/servers.py +26 -0
  160. latitudesh_python_sdk/models/show_virtual_machineop.py +16 -0
  161. latitudesh_python_sdk/models/ssh_key_data.py +55 -0
  162. latitudesh_python_sdk/models/ssh_keys.py +26 -0
  163. latitudesh_python_sdk/models/storage_plan_data.py +47 -0
  164. latitudesh_python_sdk/models/storage_plans.py +26 -0
  165. latitudesh_python_sdk/models/team.py +74 -0
  166. latitudesh_python_sdk/models/team_include.py +43 -0
  167. latitudesh_python_sdk/models/team_members.py +51 -0
  168. latitudesh_python_sdk/models/teams.py +26 -0
  169. latitudesh_python_sdk/models/traffic.py +133 -0
  170. latitudesh_python_sdk/models/traffic_quota.py +106 -0
  171. latitudesh_python_sdk/models/update_api_key.py +48 -0
  172. latitudesh_python_sdk/models/update_api_keyop.py +41 -0
  173. latitudesh_python_sdk/models/update_firewallop.py +89 -0
  174. latitudesh_python_sdk/models/update_plans_bandwidthop.py +50 -0
  175. latitudesh_python_sdk/models/update_projectop.py +95 -0
  176. latitudesh_python_sdk/models/update_server_deploy_configop.py +122 -0
  177. latitudesh_python_sdk/models/update_serverop.py +85 -0
  178. latitudesh_python_sdk/models/update_tagop.py +74 -0
  179. latitudesh_python_sdk/models/update_virtual_networkop.py +67 -0
  180. latitudesh_python_sdk/models/user.py +59 -0
  181. latitudesh_python_sdk/models/user_data.py +26 -0
  182. latitudesh_python_sdk/models/user_data_properties.py +46 -0
  183. latitudesh_python_sdk/models/user_include.py +52 -0
  184. latitudesh_python_sdk/models/user_team.py +61 -0
  185. latitudesh_python_sdk/models/user_teams.py +26 -0
  186. latitudesh_python_sdk/models/user_update.py +37 -0
  187. latitudesh_python_sdk/models/virtual_machine.py +29 -0
  188. latitudesh_python_sdk/models/virtual_machine_attributes.py +115 -0
  189. latitudesh_python_sdk/models/virtual_machine_payload.py +47 -0
  190. latitudesh_python_sdk/models/virtual_machine_plans.py +181 -0
  191. latitudesh_python_sdk/models/virtual_network.py +26 -0
  192. latitudesh_python_sdk/models/virtual_network_assignment.py +29 -0
  193. latitudesh_python_sdk/models/virtual_network_assignment_data.py +65 -0
  194. latitudesh_python_sdk/models/virtual_network_assignments.py +29 -0
  195. latitudesh_python_sdk/models/virtual_network_data.py +114 -0
  196. latitudesh_python_sdk/models/virtual_networks.py +26 -0
  197. latitudesh_python_sdk/models/volume_data.py +111 -0
  198. latitudesh_python_sdk/models/vpn_session_data_with_password.py +77 -0
  199. latitudesh_python_sdk/models/vpn_session_with_password.py +18 -0
  200. latitudesh_python_sdk/operatingsystems_sdk.py +238 -0
  201. latitudesh_python_sdk/plans.py +1304 -0
  202. latitudesh_python_sdk/privatenetworks.py +1612 -0
  203. latitudesh_python_sdk/projects_sdk.py +830 -0
  204. latitudesh_python_sdk/py.typed +1 -0
  205. latitudesh_python_sdk/regions_sdk.py +398 -0
  206. latitudesh_python_sdk/roles.py +398 -0
  207. latitudesh_python_sdk/sdk.py +264 -0
  208. latitudesh_python_sdk/sdkconfiguration.py +50 -0
  209. latitudesh_python_sdk/servers_sdk.py +3414 -0
  210. latitudesh_python_sdk/sshkeys_sdk.py +1882 -0
  211. latitudesh_python_sdk/storage.py +1651 -0
  212. latitudesh_python_sdk/tags.py +715 -0
  213. latitudesh_python_sdk/teams_sdk.py +527 -0
  214. latitudesh_python_sdk/teamsmembers.py +576 -0
  215. latitudesh_python_sdk/traffic_sdk.py +357 -0
  216. latitudesh_python_sdk/types/__init__.py +21 -0
  217. latitudesh_python_sdk/types/basemodel.py +39 -0
  218. latitudesh_python_sdk/userdata_sdk.py +1888 -0
  219. latitudesh_python_sdk/userprofile.py +531 -0
  220. latitudesh_python_sdk/utils/__init__.py +200 -0
  221. latitudesh_python_sdk/utils/annotations.py +79 -0
  222. latitudesh_python_sdk/utils/datetimes.py +23 -0
  223. latitudesh_python_sdk/utils/enums.py +74 -0
  224. latitudesh_python_sdk/utils/eventstreaming.py +248 -0
  225. latitudesh_python_sdk/utils/forms.py +234 -0
  226. latitudesh_python_sdk/utils/headers.py +136 -0
  227. latitudesh_python_sdk/utils/logger.py +27 -0
  228. latitudesh_python_sdk/utils/metadata.py +118 -0
  229. latitudesh_python_sdk/utils/queryparams.py +217 -0
  230. latitudesh_python_sdk/utils/requestbodies.py +66 -0
  231. latitudesh_python_sdk/utils/retries.py +281 -0
  232. latitudesh_python_sdk/utils/security.py +192 -0
  233. latitudesh_python_sdk/utils/serializers.py +249 -0
  234. latitudesh_python_sdk/utils/unmarshal_json_response.py +38 -0
  235. latitudesh_python_sdk/utils/url.py +155 -0
  236. latitudesh_python_sdk/utils/values.py +137 -0
  237. latitudesh_python_sdk/virtualmachines.py +941 -0
  238. latitudesh_python_sdk/vpnsessions.py +715 -0
  239. latitudesh_python_sdk-2.3.0.dist-info/METADATA +787 -0
  240. latitudesh_python_sdk-2.3.0.dist-info/RECORD +242 -0
  241. latitudesh_python_sdk-2.3.0.dist-info/WHEEL +4 -0
  242. latitudesh_python_sdk-2.3.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,374 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .sdkconfiguration import SDKConfiguration
4
+ import httpx
5
+ from latitudesh_python_sdk import models, utils
6
+ from latitudesh_python_sdk._hooks import (
7
+ AfterErrorContext,
8
+ AfterSuccessContext,
9
+ BeforeRequestContext,
10
+ )
11
+ from latitudesh_python_sdk.utils import (
12
+ RetryConfig,
13
+ SerializedRequestBody,
14
+ get_body_content,
15
+ )
16
+ from typing import Callable, List, Mapping, Optional, Tuple
17
+ from urllib.parse import parse_qs, urlparse
18
+
19
+
20
+ class BaseSDK:
21
+ sdk_configuration: SDKConfiguration
22
+ parent_ref: Optional[object] = None
23
+ """
24
+ Reference to the root SDK instance, if any. This will prevent it from
25
+ being garbage collected while there are active streams.
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ sdk_config: SDKConfiguration,
31
+ parent_ref: Optional[object] = None,
32
+ ) -> None:
33
+ self.sdk_configuration = sdk_config
34
+ self.parent_ref = parent_ref
35
+
36
+ def _get_url(self, base_url, url_variables):
37
+ sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
38
+
39
+ if base_url is None:
40
+ base_url = sdk_url
41
+
42
+ if url_variables is None:
43
+ url_variables = sdk_variables
44
+
45
+ return utils.template_url(base_url, url_variables)
46
+
47
+ def _build_request_async(
48
+ self,
49
+ method,
50
+ path,
51
+ base_url,
52
+ url_variables,
53
+ request,
54
+ request_body_required,
55
+ request_has_path_params,
56
+ request_has_query_params,
57
+ user_agent_header,
58
+ accept_header_value,
59
+ _globals=None,
60
+ security=None,
61
+ timeout_ms: Optional[int] = None,
62
+ get_serialized_body: Optional[
63
+ Callable[[], Optional[SerializedRequestBody]]
64
+ ] = None,
65
+ url_override: Optional[str] = None,
66
+ http_headers: Optional[Mapping[str, str]] = None,
67
+ allow_empty_value: Optional[List[str]] = None,
68
+ ) -> httpx.Request:
69
+ client = self.sdk_configuration.async_client
70
+ return self._build_request_with_client(
71
+ client,
72
+ method,
73
+ path,
74
+ base_url,
75
+ url_variables,
76
+ request,
77
+ request_body_required,
78
+ request_has_path_params,
79
+ request_has_query_params,
80
+ user_agent_header,
81
+ accept_header_value,
82
+ _globals,
83
+ security,
84
+ timeout_ms,
85
+ get_serialized_body,
86
+ url_override,
87
+ http_headers,
88
+ allow_empty_value,
89
+ )
90
+
91
+ def _build_request(
92
+ self,
93
+ method,
94
+ path,
95
+ base_url,
96
+ url_variables,
97
+ request,
98
+ request_body_required,
99
+ request_has_path_params,
100
+ request_has_query_params,
101
+ user_agent_header,
102
+ accept_header_value,
103
+ _globals=None,
104
+ security=None,
105
+ timeout_ms: Optional[int] = None,
106
+ get_serialized_body: Optional[
107
+ Callable[[], Optional[SerializedRequestBody]]
108
+ ] = None,
109
+ url_override: Optional[str] = None,
110
+ http_headers: Optional[Mapping[str, str]] = None,
111
+ allow_empty_value: Optional[List[str]] = None,
112
+ ) -> httpx.Request:
113
+ client = self.sdk_configuration.client
114
+ return self._build_request_with_client(
115
+ client,
116
+ method,
117
+ path,
118
+ base_url,
119
+ url_variables,
120
+ request,
121
+ request_body_required,
122
+ request_has_path_params,
123
+ request_has_query_params,
124
+ user_agent_header,
125
+ accept_header_value,
126
+ _globals,
127
+ security,
128
+ timeout_ms,
129
+ get_serialized_body,
130
+ url_override,
131
+ http_headers,
132
+ allow_empty_value,
133
+ )
134
+
135
+ def _build_request_with_client(
136
+ self,
137
+ client,
138
+ method,
139
+ path,
140
+ base_url,
141
+ url_variables,
142
+ request,
143
+ request_body_required,
144
+ request_has_path_params,
145
+ request_has_query_params,
146
+ user_agent_header,
147
+ accept_header_value,
148
+ _globals=None,
149
+ security=None,
150
+ timeout_ms: Optional[int] = None,
151
+ get_serialized_body: Optional[
152
+ Callable[[], Optional[SerializedRequestBody]]
153
+ ] = None,
154
+ url_override: Optional[str] = None,
155
+ http_headers: Optional[Mapping[str, str]] = None,
156
+ allow_empty_value: Optional[List[str]] = None,
157
+ ) -> httpx.Request:
158
+ query_params = {}
159
+
160
+ url = url_override
161
+ if url is None:
162
+ url = utils.generate_url(
163
+ self._get_url(base_url, url_variables),
164
+ path,
165
+ request if request_has_path_params else None,
166
+ _globals if request_has_path_params else None,
167
+ )
168
+
169
+ query_params = utils.get_query_params(
170
+ request if request_has_query_params else None,
171
+ _globals if request_has_query_params else None,
172
+ allow_empty_value,
173
+ )
174
+ else:
175
+ # Pick up the query parameter from the override so they can be
176
+ # preserved when building the request later on (necessary as of
177
+ # httpx 0.28).
178
+ parsed_override = urlparse(str(url_override))
179
+ query_params = parse_qs(parsed_override.query, keep_blank_values=True)
180
+
181
+ headers = utils.get_headers(request, _globals)
182
+ headers["Accept"] = accept_header_value
183
+ headers[user_agent_header] = self.sdk_configuration.user_agent
184
+
185
+ if security is not None:
186
+ if callable(security):
187
+ security = security()
188
+ security = utils.get_security_from_env(security, models.Security)
189
+ if security is not None:
190
+ security_headers, security_query_params = utils.get_security(security)
191
+ headers = {**headers, **security_headers}
192
+ query_params = {**query_params, **security_query_params}
193
+
194
+ serialized_request_body = SerializedRequestBody()
195
+ if get_serialized_body is not None:
196
+ rb = get_serialized_body()
197
+ if request_body_required and rb is None:
198
+ raise ValueError("request body is required")
199
+
200
+ if rb is not None:
201
+ serialized_request_body = rb
202
+
203
+ if (
204
+ serialized_request_body.media_type is not None
205
+ and serialized_request_body.media_type
206
+ not in (
207
+ "multipart/form-data",
208
+ "multipart/mixed",
209
+ )
210
+ ):
211
+ headers["content-type"] = serialized_request_body.media_type
212
+
213
+ if http_headers is not None:
214
+ for header, value in http_headers.items():
215
+ headers[header] = value
216
+
217
+ timeout = timeout_ms / 1000 if timeout_ms is not None else None
218
+
219
+ return client.build_request(
220
+ method,
221
+ url,
222
+ params=query_params,
223
+ content=serialized_request_body.content,
224
+ data=serialized_request_body.data,
225
+ files=serialized_request_body.files,
226
+ headers=headers,
227
+ timeout=timeout,
228
+ )
229
+
230
+ def do_request(
231
+ self,
232
+ hook_ctx,
233
+ request,
234
+ error_status_codes,
235
+ stream=False,
236
+ retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
237
+ ) -> httpx.Response:
238
+ client = self.sdk_configuration.client
239
+ logger = self.sdk_configuration.debug_logger
240
+
241
+ hooks = self.sdk_configuration.__dict__["_hooks"]
242
+
243
+ def do():
244
+ http_res = None
245
+ try:
246
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
247
+ logger.debug(
248
+ "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
249
+ req.method,
250
+ req.url,
251
+ req.headers,
252
+ get_body_content(req),
253
+ )
254
+
255
+ if client is None:
256
+ raise ValueError("client is required")
257
+
258
+ http_res = client.send(req, stream=stream)
259
+ except Exception as e:
260
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
261
+ if e is not None:
262
+ logger.debug("Request Exception", exc_info=True)
263
+ raise e
264
+
265
+ if http_res is None:
266
+ logger.debug("Raising no response SDK error")
267
+ raise models.NoResponseError("No response received")
268
+
269
+ logger.debug(
270
+ "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
271
+ http_res.status_code,
272
+ http_res.url,
273
+ http_res.headers,
274
+ "<streaming response>" if stream else http_res.text,
275
+ )
276
+
277
+ if utils.match_status_codes(error_status_codes, http_res.status_code):
278
+ result, err = hooks.after_error(
279
+ AfterErrorContext(hook_ctx), http_res, None
280
+ )
281
+ if err is not None:
282
+ logger.debug("Request Exception", exc_info=True)
283
+ raise err
284
+ if result is not None:
285
+ http_res = result
286
+ else:
287
+ logger.debug("Raising unexpected SDK error")
288
+ raise models.APIError("Unexpected error occurred", http_res)
289
+
290
+ return http_res
291
+
292
+ if retry_config is not None:
293
+ http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
294
+ else:
295
+ http_res = do()
296
+
297
+ if not utils.match_status_codes(error_status_codes, http_res.status_code):
298
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
299
+
300
+ return http_res
301
+
302
+ async def do_request_async(
303
+ self,
304
+ hook_ctx,
305
+ request,
306
+ error_status_codes,
307
+ stream=False,
308
+ retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
309
+ ) -> httpx.Response:
310
+ client = self.sdk_configuration.async_client
311
+ logger = self.sdk_configuration.debug_logger
312
+
313
+ hooks = self.sdk_configuration.__dict__["_hooks"]
314
+
315
+ async def do():
316
+ http_res = None
317
+ try:
318
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
319
+ logger.debug(
320
+ "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
321
+ req.method,
322
+ req.url,
323
+ req.headers,
324
+ get_body_content(req),
325
+ )
326
+
327
+ if client is None:
328
+ raise ValueError("client is required")
329
+
330
+ http_res = await client.send(req, stream=stream)
331
+ except Exception as e:
332
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
333
+ if e is not None:
334
+ logger.debug("Request Exception", exc_info=True)
335
+ raise e
336
+
337
+ if http_res is None:
338
+ logger.debug("Raising no response SDK error")
339
+ raise models.NoResponseError("No response received")
340
+
341
+ logger.debug(
342
+ "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
343
+ http_res.status_code,
344
+ http_res.url,
345
+ http_res.headers,
346
+ "<streaming response>" if stream else http_res.text,
347
+ )
348
+
349
+ if utils.match_status_codes(error_status_codes, http_res.status_code):
350
+ result, err = hooks.after_error(
351
+ AfterErrorContext(hook_ctx), http_res, None
352
+ )
353
+ if err is not None:
354
+ logger.debug("Request Exception", exc_info=True)
355
+ raise err
356
+ if result is not None:
357
+ http_res = result
358
+ else:
359
+ logger.debug("Raising unexpected SDK error")
360
+ raise models.APIError("Unexpected error occurred", http_res)
361
+
362
+ return http_res
363
+
364
+ if retry_config is not None:
365
+ http_res = await utils.retry_async(
366
+ do, utils.Retries(retry_config[0], retry_config[1])
367
+ )
368
+ else:
369
+ http_res = await do()
370
+
371
+ if not utils.match_status_codes(error_status_codes, http_res.status_code):
372
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
373
+
374
+ return http_res
@@ -0,0 +1,197 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from latitudesh_python_sdk import models, utils
5
+ from latitudesh_python_sdk._hooks import HookContext
6
+ from latitudesh_python_sdk.types import OptionalNullable, UNSET
7
+ from latitudesh_python_sdk.utils import get_security_from_env
8
+ from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import List, Mapping, Optional
10
+
11
+
12
+ class Billing(BaseSDK):
13
+ def list_usage(
14
+ self,
15
+ *,
16
+ filter_project: str,
17
+ filter_products: Optional[List[str]] = None,
18
+ filter_plan: Optional[str] = None,
19
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
20
+ server_url: Optional[str] = None,
21
+ timeout_ms: Optional[int] = None,
22
+ http_headers: Optional[Mapping[str, str]] = None,
23
+ ) -> models.BillingUsage:
24
+ r"""List Billing Usage
25
+
26
+ Returns the billing usage of a project
27
+
28
+
29
+ :param filter_project:
30
+ :param filter_products: Allows to filter the billing usage for specific products. It accepts an array of product ids.
31
+
32
+ :param filter_plan: Accepts a plan name and allows to filter the usage for that plan.
33
+
34
+ :param retries: Override the default retry configuration for this method
35
+ :param server_url: Override the default server URL for this method
36
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
37
+ :param http_headers: Additional headers to set or replace on requests.
38
+ """
39
+ base_url = None
40
+ url_variables = None
41
+ if timeout_ms is None:
42
+ timeout_ms = self.sdk_configuration.timeout_ms
43
+
44
+ if server_url is not None:
45
+ base_url = server_url
46
+ else:
47
+ base_url = self._get_url(base_url, url_variables)
48
+
49
+ request = models.GetBillingUsageRequest(
50
+ filter_products=filter_products,
51
+ filter_plan=filter_plan,
52
+ filter_project=filter_project,
53
+ )
54
+
55
+ req = self._build_request(
56
+ method="GET",
57
+ path="/billing/usage",
58
+ base_url=base_url,
59
+ url_variables=url_variables,
60
+ request=request,
61
+ request_body_required=False,
62
+ request_has_path_params=False,
63
+ request_has_query_params=True,
64
+ user_agent_header="user-agent",
65
+ accept_header_value="application/vnd.api+json",
66
+ http_headers=http_headers,
67
+ security=self.sdk_configuration.security,
68
+ allow_empty_value=None,
69
+ timeout_ms=timeout_ms,
70
+ )
71
+
72
+ if retries == UNSET:
73
+ if self.sdk_configuration.retry_config is not UNSET:
74
+ retries = self.sdk_configuration.retry_config
75
+
76
+ retry_config = None
77
+ if isinstance(retries, utils.RetryConfig):
78
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
79
+
80
+ http_res = self.do_request(
81
+ hook_ctx=HookContext(
82
+ config=self.sdk_configuration,
83
+ base_url=base_url or "",
84
+ operation_id="get-billing-usage",
85
+ oauth2_scopes=None,
86
+ security_source=get_security_from_env(
87
+ self.sdk_configuration.security, models.Security
88
+ ),
89
+ ),
90
+ request=req,
91
+ error_status_codes=["4XX", "5XX"],
92
+ retry_config=retry_config,
93
+ )
94
+
95
+ if utils.match_response(http_res, "200", "application/vnd.api+json"):
96
+ return unmarshal_json_response(models.BillingUsage, http_res)
97
+ if utils.match_response(http_res, "4XX", "*"):
98
+ http_res_text = utils.stream_to_text(http_res)
99
+ raise models.APIError("API error occurred", http_res, http_res_text)
100
+ if utils.match_response(http_res, "5XX", "*"):
101
+ http_res_text = utils.stream_to_text(http_res)
102
+ raise models.APIError("API error occurred", http_res, http_res_text)
103
+
104
+ raise models.APIError("Unexpected response received", http_res)
105
+
106
+ async def list_usage_async(
107
+ self,
108
+ *,
109
+ filter_project: str,
110
+ filter_products: Optional[List[str]] = None,
111
+ filter_plan: Optional[str] = None,
112
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
113
+ server_url: Optional[str] = None,
114
+ timeout_ms: Optional[int] = None,
115
+ http_headers: Optional[Mapping[str, str]] = None,
116
+ ) -> models.BillingUsage:
117
+ r"""List Billing Usage
118
+
119
+ Returns the billing usage of a project
120
+
121
+
122
+ :param filter_project:
123
+ :param filter_products: Allows to filter the billing usage for specific products. It accepts an array of product ids.
124
+
125
+ :param filter_plan: Accepts a plan name and allows to filter the usage for that plan.
126
+
127
+ :param retries: Override the default retry configuration for this method
128
+ :param server_url: Override the default server URL for this method
129
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
130
+ :param http_headers: Additional headers to set or replace on requests.
131
+ """
132
+ base_url = None
133
+ url_variables = None
134
+ if timeout_ms is None:
135
+ timeout_ms = self.sdk_configuration.timeout_ms
136
+
137
+ if server_url is not None:
138
+ base_url = server_url
139
+ else:
140
+ base_url = self._get_url(base_url, url_variables)
141
+
142
+ request = models.GetBillingUsageRequest(
143
+ filter_products=filter_products,
144
+ filter_plan=filter_plan,
145
+ filter_project=filter_project,
146
+ )
147
+
148
+ req = self._build_request_async(
149
+ method="GET",
150
+ path="/billing/usage",
151
+ base_url=base_url,
152
+ url_variables=url_variables,
153
+ request=request,
154
+ request_body_required=False,
155
+ request_has_path_params=False,
156
+ request_has_query_params=True,
157
+ user_agent_header="user-agent",
158
+ accept_header_value="application/vnd.api+json",
159
+ http_headers=http_headers,
160
+ security=self.sdk_configuration.security,
161
+ allow_empty_value=None,
162
+ timeout_ms=timeout_ms,
163
+ )
164
+
165
+ if retries == UNSET:
166
+ if self.sdk_configuration.retry_config is not UNSET:
167
+ retries = self.sdk_configuration.retry_config
168
+
169
+ retry_config = None
170
+ if isinstance(retries, utils.RetryConfig):
171
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
172
+
173
+ http_res = await self.do_request_async(
174
+ hook_ctx=HookContext(
175
+ config=self.sdk_configuration,
176
+ base_url=base_url or "",
177
+ operation_id="get-billing-usage",
178
+ oauth2_scopes=None,
179
+ security_source=get_security_from_env(
180
+ self.sdk_configuration.security, models.Security
181
+ ),
182
+ ),
183
+ request=req,
184
+ error_status_codes=["4XX", "5XX"],
185
+ retry_config=retry_config,
186
+ )
187
+
188
+ if utils.match_response(http_res, "200", "application/vnd.api+json"):
189
+ return unmarshal_json_response(models.BillingUsage, http_res)
190
+ if utils.match_response(http_res, "4XX", "*"):
191
+ http_res_text = await utils.stream_to_text_async(http_res)
192
+ raise models.APIError("API error occurred", http_res, http_res_text)
193
+ if utils.match_response(http_res, "5XX", "*"):
194
+ http_res_text = await utils.stream_to_text_async(http_res)
195
+ raise models.APIError("API error occurred", http_res, http_res_text)
196
+
197
+ raise models.APIError("Unexpected response received", http_res)