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.
- latitudesh_python_sdk/__init__.py +18 -0
- latitudesh_python_sdk/_hooks/__init__.py +5 -0
- latitudesh_python_sdk/_hooks/registration.py +13 -0
- latitudesh_python_sdk/_hooks/sdkhooks.py +76 -0
- latitudesh_python_sdk/_hooks/types.py +113 -0
- latitudesh_python_sdk/_version.py +17 -0
- latitudesh_python_sdk/apikeys.py +703 -0
- latitudesh_python_sdk/basesdk.py +374 -0
- latitudesh_python_sdk/billing.py +197 -0
- latitudesh_python_sdk/events_sdk.py +298 -0
- latitudesh_python_sdk/firewalls_sdk.py +1786 -0
- latitudesh_python_sdk/httpclient.py +125 -0
- latitudesh_python_sdk/ipaddresses_sdk.py +470 -0
- latitudesh_python_sdk/models/__init__.py +3581 -0
- latitudesh_python_sdk/models/api_key.py +81 -0
- latitudesh_python_sdk/models/apierror.py +40 -0
- latitudesh_python_sdk/models/assign_server_virtual_networkop.py +43 -0
- latitudesh_python_sdk/models/bandwidth_packages.py +67 -0
- latitudesh_python_sdk/models/bandwidth_plan_data.py +72 -0
- latitudesh_python_sdk/models/bandwidth_plans.py +26 -0
- latitudesh_python_sdk/models/billing_usage.py +249 -0
- latitudesh_python_sdk/models/container_plan_data.py +163 -0
- latitudesh_python_sdk/models/create_api_key.py +40 -0
- latitudesh_python_sdk/models/create_firewall_assignmentop.py +61 -0
- latitudesh_python_sdk/models/create_firewallop.py +73 -0
- latitudesh_python_sdk/models/create_ipmi_sessionop.py +16 -0
- latitudesh_python_sdk/models/create_projectop.py +79 -0
- latitudesh_python_sdk/models/create_server_actionop.py +69 -0
- latitudesh_python_sdk/models/create_server_out_of_bandop.py +61 -0
- latitudesh_python_sdk/models/create_server_reinstallop.py +140 -0
- latitudesh_python_sdk/models/create_serverop.py +173 -0
- latitudesh_python_sdk/models/create_tagop.py +50 -0
- latitudesh_python_sdk/models/create_virtual_machine_actionop.py +63 -0
- latitudesh_python_sdk/models/create_virtual_networkop.py +72 -0
- latitudesh_python_sdk/models/custom_tag.py +26 -0
- latitudesh_python_sdk/models/custom_tag_data.py +54 -0
- latitudesh_python_sdk/models/custom_tags.py +26 -0
- latitudesh_python_sdk/models/delete_api_keyop.py +16 -0
- latitudesh_python_sdk/models/delete_firewall_assignmentop.py +25 -0
- latitudesh_python_sdk/models/delete_firewallop.py +18 -0
- latitudesh_python_sdk/models/delete_project_ssh_keyop.py +23 -0
- latitudesh_python_sdk/models/delete_project_user_dataop.py +23 -0
- latitudesh_python_sdk/models/delete_projectop.py +18 -0
- latitudesh_python_sdk/models/delete_ssh_keyop.py +16 -0
- latitudesh_python_sdk/models/delete_storage_filesystemsop.py +16 -0
- latitudesh_python_sdk/models/delete_storage_volumesop.py +16 -0
- latitudesh_python_sdk/models/delete_user_dataop.py +16 -0
- latitudesh_python_sdk/models/delete_virtual_networks_assignmentsop.py +16 -0
- latitudesh_python_sdk/models/delete_vpn_sessionop.py +16 -0
- latitudesh_python_sdk/models/deploy_config.py +62 -0
- latitudesh_python_sdk/models/destroy_serverop.py +31 -0
- latitudesh_python_sdk/models/destroy_tagop.py +16 -0
- latitudesh_python_sdk/models/destroy_team_memberop.py +18 -0
- latitudesh_python_sdk/models/destroy_virtual_machineop.py +16 -0
- latitudesh_python_sdk/models/destroy_virtual_networkop.py +18 -0
- latitudesh_python_sdk/models/event_data.py +98 -0
- latitudesh_python_sdk/models/events.py +26 -0
- latitudesh_python_sdk/models/filesystem_data.py +57 -0
- latitudesh_python_sdk/models/firewall.py +26 -0
- latitudesh_python_sdk/models/firewall_assignment_data.py +50 -0
- latitudesh_python_sdk/models/firewall_assignments.py +29 -0
- latitudesh_python_sdk/models/firewall_data.py +75 -0
- latitudesh_python_sdk/models/firewall_server.py +36 -0
- latitudesh_python_sdk/models/firewalls.py +26 -0
- latitudesh_python_sdk/models/get_all_firewall_assignmentsop.py +51 -0
- latitudesh_python_sdk/models/get_bandwidth_plansop.py +62 -0
- latitudesh_python_sdk/models/get_billing_usageop.py +46 -0
- latitudesh_python_sdk/models/get_containers_planop.py +18 -0
- latitudesh_python_sdk/models/get_eventsop.py +126 -0
- latitudesh_python_sdk/models/get_firewall_assignmentsop.py +53 -0
- latitudesh_python_sdk/models/get_firewallop.py +18 -0
- latitudesh_python_sdk/models/get_ipop.py +33 -0
- latitudesh_python_sdk/models/get_ipsop.py +120 -0
- latitudesh_python_sdk/models/get_planop.py +16 -0
- latitudesh_python_sdk/models/get_plans_operating_systemop.py +54 -0
- latitudesh_python_sdk/models/get_plansop.py +125 -0
- latitudesh_python_sdk/models/get_project_ssh_keyop.py +37 -0
- latitudesh_python_sdk/models/get_project_ssh_keysop.py +33 -0
- latitudesh_python_sdk/models/get_project_user_dataop.py +38 -0
- latitudesh_python_sdk/models/get_project_users_dataop.py +46 -0
- latitudesh_python_sdk/models/get_projectsop.py +105 -0
- latitudesh_python_sdk/models/get_regionop.py +18 -0
- latitudesh_python_sdk/models/get_regionsop.py +42 -0
- latitudesh_python_sdk/models/get_role_idop.py +16 -0
- latitudesh_python_sdk/models/get_rolesop.py +54 -0
- latitudesh_python_sdk/models/get_server_deploy_configop.py +18 -0
- latitudesh_python_sdk/models/get_server_out_of_bandop.py +18 -0
- latitudesh_python_sdk/models/get_serverop.py +33 -0
- latitudesh_python_sdk/models/get_serversop.py +185 -0
- latitudesh_python_sdk/models/get_ssh_keyop.py +30 -0
- latitudesh_python_sdk/models/get_ssh_keysop.py +31 -0
- latitudesh_python_sdk/models/get_storage_filesystemsop.py +22 -0
- latitudesh_python_sdk/models/get_storage_volumeop.py +32 -0
- latitudesh_python_sdk/models/get_storage_volumesop.py +35 -0
- latitudesh_python_sdk/models/get_team_membersop.py +42 -0
- latitudesh_python_sdk/models/get_traffic_consumptionop.py +49 -0
- latitudesh_python_sdk/models/get_traffic_quotaop.py +20 -0
- latitudesh_python_sdk/models/get_user_dataop.py +31 -0
- latitudesh_python_sdk/models/get_user_profileop.py +19 -0
- latitudesh_python_sdk/models/get_users_dataop.py +44 -0
- latitudesh_python_sdk/models/get_virtual_networkop.py +32 -0
- latitudesh_python_sdk/models/get_virtual_networks_assignmentsop.py +72 -0
- latitudesh_python_sdk/models/get_virtual_networksop.py +69 -0
- latitudesh_python_sdk/models/get_vpn_sessionsop.py +70 -0
- latitudesh_python_sdk/models/index_virtual_machineop.py +31 -0
- latitudesh_python_sdk/models/ip_address.py +122 -0
- latitudesh_python_sdk/models/ip_addresses.py +15 -0
- latitudesh_python_sdk/models/ipmi_session.py +53 -0
- latitudesh_python_sdk/models/latitudesherror.py +30 -0
- latitudesh_python_sdk/models/list_firewallsop.py +49 -0
- latitudesh_python_sdk/models/membership.py +63 -0
- latitudesh_python_sdk/models/no_response_error.py +17 -0
- latitudesh_python_sdk/models/operating_system_data.py +65 -0
- latitudesh_python_sdk/models/operating_systems.py +26 -0
- latitudesh_python_sdk/models/out_of_band_connection.py +88 -0
- latitudesh_python_sdk/models/patch_current_teamop.py +91 -0
- latitudesh_python_sdk/models/patch_storage_filesystemsop.py +79 -0
- latitudesh_python_sdk/models/patch_user_dataop.py +69 -0
- latitudesh_python_sdk/models/patch_user_profileop.py +88 -0
- latitudesh_python_sdk/models/plan.py +15 -0
- latitudesh_python_sdk/models/plan_data.py +210 -0
- latitudesh_python_sdk/models/post_api_keyop.py +19 -0
- latitudesh_python_sdk/models/post_project_ssh_keyop.py +81 -0
- latitudesh_python_sdk/models/post_project_user_dataop.py +68 -0
- latitudesh_python_sdk/models/post_ssh_keyop.py +63 -0
- latitudesh_python_sdk/models/post_storage_filesystemsop.py +63 -0
- latitudesh_python_sdk/models/post_storage_volumes_mountop.py +62 -0
- latitudesh_python_sdk/models/post_storage_volumesop.py +63 -0
- latitudesh_python_sdk/models/post_team_membersop.py +54 -0
- latitudesh_python_sdk/models/post_teamop.py +67 -0
- latitudesh_python_sdk/models/post_user_dataop.py +50 -0
- latitudesh_python_sdk/models/post_vpn_sessionop.py +63 -0
- latitudesh_python_sdk/models/project.py +131 -0
- latitudesh_python_sdk/models/project_include.py +75 -0
- latitudesh_python_sdk/models/projects.py +15 -0
- latitudesh_python_sdk/models/put_project_ssh_keyop.py +87 -0
- latitudesh_python_sdk/models/put_project_user_dataop.py +76 -0
- latitudesh_python_sdk/models/put_ssh_keyop.py +80 -0
- latitudesh_python_sdk/models/put_vpn_sessionop.py +16 -0
- latitudesh_python_sdk/models/region.py +50 -0
- latitudesh_python_sdk/models/region_resource_data.py +37 -0
- latitudesh_python_sdk/models/regions.py +50 -0
- latitudesh_python_sdk/models/responsevalidationerror.py +27 -0
- latitudesh_python_sdk/models/role.py +26 -0
- latitudesh_python_sdk/models/role_data.py +35 -0
- latitudesh_python_sdk/models/security.py +25 -0
- latitudesh_python_sdk/models/server.py +26 -0
- latitudesh_python_sdk/models/server_action.py +52 -0
- latitudesh_python_sdk/models/server_data.py +280 -0
- latitudesh_python_sdk/models/server_exit_rescue_modeop.py +16 -0
- latitudesh_python_sdk/models/server_lockop.py +16 -0
- latitudesh_python_sdk/models/server_region_resource_data.py +40 -0
- latitudesh_python_sdk/models/server_rescue.py +22 -0
- latitudesh_python_sdk/models/server_schedule_deletion.py +44 -0
- latitudesh_python_sdk/models/server_schedule_deletionop.py +16 -0
- latitudesh_python_sdk/models/server_start_rescue_modeop.py +16 -0
- latitudesh_python_sdk/models/server_unlockop.py +16 -0
- latitudesh_python_sdk/models/server_unschedule_deletionop.py +16 -0
- latitudesh_python_sdk/models/servers.py +26 -0
- latitudesh_python_sdk/models/show_virtual_machineop.py +16 -0
- latitudesh_python_sdk/models/ssh_key_data.py +55 -0
- latitudesh_python_sdk/models/ssh_keys.py +26 -0
- latitudesh_python_sdk/models/storage_plan_data.py +47 -0
- latitudesh_python_sdk/models/storage_plans.py +26 -0
- latitudesh_python_sdk/models/team.py +74 -0
- latitudesh_python_sdk/models/team_include.py +43 -0
- latitudesh_python_sdk/models/team_members.py +51 -0
- latitudesh_python_sdk/models/teams.py +26 -0
- latitudesh_python_sdk/models/traffic.py +133 -0
- latitudesh_python_sdk/models/traffic_quota.py +106 -0
- latitudesh_python_sdk/models/update_api_key.py +48 -0
- latitudesh_python_sdk/models/update_api_keyop.py +41 -0
- latitudesh_python_sdk/models/update_firewallop.py +89 -0
- latitudesh_python_sdk/models/update_plans_bandwidthop.py +50 -0
- latitudesh_python_sdk/models/update_projectop.py +95 -0
- latitudesh_python_sdk/models/update_server_deploy_configop.py +122 -0
- latitudesh_python_sdk/models/update_serverop.py +85 -0
- latitudesh_python_sdk/models/update_tagop.py +74 -0
- latitudesh_python_sdk/models/update_virtual_networkop.py +67 -0
- latitudesh_python_sdk/models/user.py +59 -0
- latitudesh_python_sdk/models/user_data.py +26 -0
- latitudesh_python_sdk/models/user_data_properties.py +46 -0
- latitudesh_python_sdk/models/user_include.py +52 -0
- latitudesh_python_sdk/models/user_team.py +61 -0
- latitudesh_python_sdk/models/user_teams.py +26 -0
- latitudesh_python_sdk/models/user_update.py +37 -0
- latitudesh_python_sdk/models/virtual_machine.py +29 -0
- latitudesh_python_sdk/models/virtual_machine_attributes.py +115 -0
- latitudesh_python_sdk/models/virtual_machine_payload.py +47 -0
- latitudesh_python_sdk/models/virtual_machine_plans.py +181 -0
- latitudesh_python_sdk/models/virtual_network.py +26 -0
- latitudesh_python_sdk/models/virtual_network_assignment.py +29 -0
- latitudesh_python_sdk/models/virtual_network_assignment_data.py +65 -0
- latitudesh_python_sdk/models/virtual_network_assignments.py +29 -0
- latitudesh_python_sdk/models/virtual_network_data.py +114 -0
- latitudesh_python_sdk/models/virtual_networks.py +26 -0
- latitudesh_python_sdk/models/volume_data.py +111 -0
- latitudesh_python_sdk/models/vpn_session_data_with_password.py +77 -0
- latitudesh_python_sdk/models/vpn_session_with_password.py +18 -0
- latitudesh_python_sdk/operatingsystems_sdk.py +238 -0
- latitudesh_python_sdk/plans.py +1304 -0
- latitudesh_python_sdk/privatenetworks.py +1612 -0
- latitudesh_python_sdk/projects_sdk.py +830 -0
- latitudesh_python_sdk/py.typed +1 -0
- latitudesh_python_sdk/regions_sdk.py +398 -0
- latitudesh_python_sdk/roles.py +398 -0
- latitudesh_python_sdk/sdk.py +264 -0
- latitudesh_python_sdk/sdkconfiguration.py +50 -0
- latitudesh_python_sdk/servers_sdk.py +3414 -0
- latitudesh_python_sdk/sshkeys_sdk.py +1882 -0
- latitudesh_python_sdk/storage.py +1651 -0
- latitudesh_python_sdk/tags.py +715 -0
- latitudesh_python_sdk/teams_sdk.py +527 -0
- latitudesh_python_sdk/teamsmembers.py +576 -0
- latitudesh_python_sdk/traffic_sdk.py +357 -0
- latitudesh_python_sdk/types/__init__.py +21 -0
- latitudesh_python_sdk/types/basemodel.py +39 -0
- latitudesh_python_sdk/userdata_sdk.py +1888 -0
- latitudesh_python_sdk/userprofile.py +531 -0
- latitudesh_python_sdk/utils/__init__.py +200 -0
- latitudesh_python_sdk/utils/annotations.py +79 -0
- latitudesh_python_sdk/utils/datetimes.py +23 -0
- latitudesh_python_sdk/utils/enums.py +74 -0
- latitudesh_python_sdk/utils/eventstreaming.py +248 -0
- latitudesh_python_sdk/utils/forms.py +234 -0
- latitudesh_python_sdk/utils/headers.py +136 -0
- latitudesh_python_sdk/utils/logger.py +27 -0
- latitudesh_python_sdk/utils/metadata.py +118 -0
- latitudesh_python_sdk/utils/queryparams.py +217 -0
- latitudesh_python_sdk/utils/requestbodies.py +66 -0
- latitudesh_python_sdk/utils/retries.py +281 -0
- latitudesh_python_sdk/utils/security.py +192 -0
- latitudesh_python_sdk/utils/serializers.py +249 -0
- latitudesh_python_sdk/utils/unmarshal_json_response.py +38 -0
- latitudesh_python_sdk/utils/url.py +155 -0
- latitudesh_python_sdk/utils/values.py +137 -0
- latitudesh_python_sdk/virtualmachines.py +941 -0
- latitudesh_python_sdk/vpnsessions.py +715 -0
- latitudesh_python_sdk-2.3.0.dist-info/METADATA +787 -0
- latitudesh_python_sdk-2.3.0.dist-info/RECORD +242 -0
- latitudesh_python_sdk-2.3.0.dist-info/WHEEL +4 -0
- latitudesh_python_sdk-2.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from jsonpath import JSONPath
|
|
5
|
+
from latitudesh_python_sdk import models, utils
|
|
6
|
+
from latitudesh_python_sdk._hooks import HookContext
|
|
7
|
+
from latitudesh_python_sdk.types import OptionalNullable, UNSET
|
|
8
|
+
from latitudesh_python_sdk.utils import get_security_from_env
|
|
9
|
+
from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
|
|
10
|
+
from typing import Any, Dict, List, Mapping, Optional, Union
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Roles(BaseSDK):
|
|
14
|
+
def list(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
page_size: Optional[int] = 20,
|
|
18
|
+
page_number: Optional[int] = 1,
|
|
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
|
+
) -> Optional[models.GetRolesResponse]:
|
|
24
|
+
r"""List all Roles
|
|
25
|
+
|
|
26
|
+
Returns a list of all roles that can be assigned to users
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
:param page_size: Number of items to return per page
|
|
30
|
+
:param page_number: Page number to return (starts at 1)
|
|
31
|
+
:param retries: Override the default retry configuration for this method
|
|
32
|
+
:param server_url: Override the default server URL for this method
|
|
33
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
34
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
35
|
+
"""
|
|
36
|
+
base_url = None
|
|
37
|
+
url_variables = None
|
|
38
|
+
if timeout_ms is None:
|
|
39
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
40
|
+
|
|
41
|
+
if server_url is not None:
|
|
42
|
+
base_url = server_url
|
|
43
|
+
else:
|
|
44
|
+
base_url = self._get_url(base_url, url_variables)
|
|
45
|
+
|
|
46
|
+
request = models.GetRolesRequest(
|
|
47
|
+
page_size=page_size,
|
|
48
|
+
page_number=page_number,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
req = self._build_request(
|
|
52
|
+
method="GET",
|
|
53
|
+
path="/roles",
|
|
54
|
+
base_url=base_url,
|
|
55
|
+
url_variables=url_variables,
|
|
56
|
+
request=request,
|
|
57
|
+
request_body_required=False,
|
|
58
|
+
request_has_path_params=False,
|
|
59
|
+
request_has_query_params=True,
|
|
60
|
+
user_agent_header="user-agent",
|
|
61
|
+
accept_header_value="application/vnd.api+json",
|
|
62
|
+
http_headers=http_headers,
|
|
63
|
+
security=self.sdk_configuration.security,
|
|
64
|
+
allow_empty_value=None,
|
|
65
|
+
timeout_ms=timeout_ms,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if retries == UNSET:
|
|
69
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
70
|
+
retries = self.sdk_configuration.retry_config
|
|
71
|
+
|
|
72
|
+
retry_config = None
|
|
73
|
+
if isinstance(retries, utils.RetryConfig):
|
|
74
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
75
|
+
|
|
76
|
+
http_res = self.do_request(
|
|
77
|
+
hook_ctx=HookContext(
|
|
78
|
+
config=self.sdk_configuration,
|
|
79
|
+
base_url=base_url or "",
|
|
80
|
+
operation_id="get-roles",
|
|
81
|
+
oauth2_scopes=None,
|
|
82
|
+
security_source=get_security_from_env(
|
|
83
|
+
self.sdk_configuration.security, models.Security
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
request=req,
|
|
87
|
+
error_status_codes=["4XX", "5XX"],
|
|
88
|
+
retry_config=retry_config,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def next_func() -> Optional[models.GetRolesResponse]:
|
|
92
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
93
|
+
page = request.page_number if not request.page_number is None else 1
|
|
94
|
+
next_page = page + 1
|
|
95
|
+
|
|
96
|
+
if not http_res.text:
|
|
97
|
+
return None
|
|
98
|
+
results = JSONPath("$.data").parse(body)
|
|
99
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
100
|
+
return None
|
|
101
|
+
limit = request.page_size if not request.page_size is None else 20
|
|
102
|
+
if len(results[0]) < limit:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
return self.list(
|
|
106
|
+
page_size=page_size,
|
|
107
|
+
page_number=next_page,
|
|
108
|
+
retries=retries,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
if utils.match_response(http_res, "200", "application/vnd.api+json"):
|
|
112
|
+
return models.GetRolesResponse(
|
|
113
|
+
result=unmarshal_json_response(models.GetRolesResponseBody, http_res),
|
|
114
|
+
next=next_func,
|
|
115
|
+
)
|
|
116
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
117
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
118
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
119
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
120
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
121
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
122
|
+
|
|
123
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
124
|
+
|
|
125
|
+
async def list_async(
|
|
126
|
+
self,
|
|
127
|
+
*,
|
|
128
|
+
page_size: Optional[int] = 20,
|
|
129
|
+
page_number: Optional[int] = 1,
|
|
130
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
131
|
+
server_url: Optional[str] = None,
|
|
132
|
+
timeout_ms: Optional[int] = None,
|
|
133
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
134
|
+
) -> Optional[models.GetRolesResponse]:
|
|
135
|
+
r"""List all Roles
|
|
136
|
+
|
|
137
|
+
Returns a list of all roles that can be assigned to users
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
:param page_size: Number of items to return per page
|
|
141
|
+
:param page_number: Page number to return (starts at 1)
|
|
142
|
+
:param retries: Override the default retry configuration for this method
|
|
143
|
+
:param server_url: Override the default server URL for this method
|
|
144
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
145
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
146
|
+
"""
|
|
147
|
+
base_url = None
|
|
148
|
+
url_variables = None
|
|
149
|
+
if timeout_ms is None:
|
|
150
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
151
|
+
|
|
152
|
+
if server_url is not None:
|
|
153
|
+
base_url = server_url
|
|
154
|
+
else:
|
|
155
|
+
base_url = self._get_url(base_url, url_variables)
|
|
156
|
+
|
|
157
|
+
request = models.GetRolesRequest(
|
|
158
|
+
page_size=page_size,
|
|
159
|
+
page_number=page_number,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
req = self._build_request_async(
|
|
163
|
+
method="GET",
|
|
164
|
+
path="/roles",
|
|
165
|
+
base_url=base_url,
|
|
166
|
+
url_variables=url_variables,
|
|
167
|
+
request=request,
|
|
168
|
+
request_body_required=False,
|
|
169
|
+
request_has_path_params=False,
|
|
170
|
+
request_has_query_params=True,
|
|
171
|
+
user_agent_header="user-agent",
|
|
172
|
+
accept_header_value="application/vnd.api+json",
|
|
173
|
+
http_headers=http_headers,
|
|
174
|
+
security=self.sdk_configuration.security,
|
|
175
|
+
allow_empty_value=None,
|
|
176
|
+
timeout_ms=timeout_ms,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
if retries == UNSET:
|
|
180
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
181
|
+
retries = self.sdk_configuration.retry_config
|
|
182
|
+
|
|
183
|
+
retry_config = None
|
|
184
|
+
if isinstance(retries, utils.RetryConfig):
|
|
185
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
186
|
+
|
|
187
|
+
http_res = await self.do_request_async(
|
|
188
|
+
hook_ctx=HookContext(
|
|
189
|
+
config=self.sdk_configuration,
|
|
190
|
+
base_url=base_url or "",
|
|
191
|
+
operation_id="get-roles",
|
|
192
|
+
oauth2_scopes=None,
|
|
193
|
+
security_source=get_security_from_env(
|
|
194
|
+
self.sdk_configuration.security, models.Security
|
|
195
|
+
),
|
|
196
|
+
),
|
|
197
|
+
request=req,
|
|
198
|
+
error_status_codes=["4XX", "5XX"],
|
|
199
|
+
retry_config=retry_config,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
def next_func() -> Optional[models.GetRolesResponse]:
|
|
203
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
204
|
+
page = request.page_number if not request.page_number is None else 1
|
|
205
|
+
next_page = page + 1
|
|
206
|
+
|
|
207
|
+
if not http_res.text:
|
|
208
|
+
return None
|
|
209
|
+
results = JSONPath("$.data").parse(body)
|
|
210
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
211
|
+
return None
|
|
212
|
+
limit = request.page_size if not request.page_size is None else 20
|
|
213
|
+
if len(results[0]) < limit:
|
|
214
|
+
return None
|
|
215
|
+
|
|
216
|
+
return self.list(
|
|
217
|
+
page_size=page_size,
|
|
218
|
+
page_number=next_page,
|
|
219
|
+
retries=retries,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if utils.match_response(http_res, "200", "application/vnd.api+json"):
|
|
223
|
+
return models.GetRolesResponse(
|
|
224
|
+
result=unmarshal_json_response(models.GetRolesResponseBody, http_res),
|
|
225
|
+
next=next_func,
|
|
226
|
+
)
|
|
227
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
228
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
229
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
230
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
231
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
232
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
233
|
+
|
|
234
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
235
|
+
|
|
236
|
+
def get(
|
|
237
|
+
self,
|
|
238
|
+
*,
|
|
239
|
+
role_id: str,
|
|
240
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
241
|
+
server_url: Optional[str] = None,
|
|
242
|
+
timeout_ms: Optional[int] = None,
|
|
243
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
244
|
+
) -> models.Role:
|
|
245
|
+
r"""Retrieve Role
|
|
246
|
+
|
|
247
|
+
:param role_id:
|
|
248
|
+
:param retries: Override the default retry configuration for this method
|
|
249
|
+
:param server_url: Override the default server URL for this method
|
|
250
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
251
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
252
|
+
"""
|
|
253
|
+
base_url = None
|
|
254
|
+
url_variables = None
|
|
255
|
+
if timeout_ms is None:
|
|
256
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
257
|
+
|
|
258
|
+
if server_url is not None:
|
|
259
|
+
base_url = server_url
|
|
260
|
+
else:
|
|
261
|
+
base_url = self._get_url(base_url, url_variables)
|
|
262
|
+
|
|
263
|
+
request = models.GetRoleIDRequest(
|
|
264
|
+
role_id=role_id,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
req = self._build_request(
|
|
268
|
+
method="GET",
|
|
269
|
+
path="/roles/{role_id}",
|
|
270
|
+
base_url=base_url,
|
|
271
|
+
url_variables=url_variables,
|
|
272
|
+
request=request,
|
|
273
|
+
request_body_required=False,
|
|
274
|
+
request_has_path_params=True,
|
|
275
|
+
request_has_query_params=True,
|
|
276
|
+
user_agent_header="user-agent",
|
|
277
|
+
accept_header_value="application/vnd.api+json",
|
|
278
|
+
http_headers=http_headers,
|
|
279
|
+
security=self.sdk_configuration.security,
|
|
280
|
+
allow_empty_value=None,
|
|
281
|
+
timeout_ms=timeout_ms,
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
if retries == UNSET:
|
|
285
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
286
|
+
retries = self.sdk_configuration.retry_config
|
|
287
|
+
|
|
288
|
+
retry_config = None
|
|
289
|
+
if isinstance(retries, utils.RetryConfig):
|
|
290
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
291
|
+
|
|
292
|
+
http_res = self.do_request(
|
|
293
|
+
hook_ctx=HookContext(
|
|
294
|
+
config=self.sdk_configuration,
|
|
295
|
+
base_url=base_url or "",
|
|
296
|
+
operation_id="get-role-id",
|
|
297
|
+
oauth2_scopes=None,
|
|
298
|
+
security_source=get_security_from_env(
|
|
299
|
+
self.sdk_configuration.security, models.Security
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
request=req,
|
|
303
|
+
error_status_codes=["4XX", "5XX"],
|
|
304
|
+
retry_config=retry_config,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
if utils.match_response(http_res, "200", "application/vnd.api+json"):
|
|
308
|
+
return unmarshal_json_response(models.Role, http_res)
|
|
309
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
310
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
311
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
312
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
313
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
314
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
315
|
+
|
|
316
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
317
|
+
|
|
318
|
+
async def get_async(
|
|
319
|
+
self,
|
|
320
|
+
*,
|
|
321
|
+
role_id: str,
|
|
322
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
323
|
+
server_url: Optional[str] = None,
|
|
324
|
+
timeout_ms: Optional[int] = None,
|
|
325
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
326
|
+
) -> models.Role:
|
|
327
|
+
r"""Retrieve Role
|
|
328
|
+
|
|
329
|
+
:param role_id:
|
|
330
|
+
:param retries: Override the default retry configuration for this method
|
|
331
|
+
:param server_url: Override the default server URL for this method
|
|
332
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
333
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
334
|
+
"""
|
|
335
|
+
base_url = None
|
|
336
|
+
url_variables = None
|
|
337
|
+
if timeout_ms is None:
|
|
338
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
339
|
+
|
|
340
|
+
if server_url is not None:
|
|
341
|
+
base_url = server_url
|
|
342
|
+
else:
|
|
343
|
+
base_url = self._get_url(base_url, url_variables)
|
|
344
|
+
|
|
345
|
+
request = models.GetRoleIDRequest(
|
|
346
|
+
role_id=role_id,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
req = self._build_request_async(
|
|
350
|
+
method="GET",
|
|
351
|
+
path="/roles/{role_id}",
|
|
352
|
+
base_url=base_url,
|
|
353
|
+
url_variables=url_variables,
|
|
354
|
+
request=request,
|
|
355
|
+
request_body_required=False,
|
|
356
|
+
request_has_path_params=True,
|
|
357
|
+
request_has_query_params=True,
|
|
358
|
+
user_agent_header="user-agent",
|
|
359
|
+
accept_header_value="application/vnd.api+json",
|
|
360
|
+
http_headers=http_headers,
|
|
361
|
+
security=self.sdk_configuration.security,
|
|
362
|
+
allow_empty_value=None,
|
|
363
|
+
timeout_ms=timeout_ms,
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
if retries == UNSET:
|
|
367
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
368
|
+
retries = self.sdk_configuration.retry_config
|
|
369
|
+
|
|
370
|
+
retry_config = None
|
|
371
|
+
if isinstance(retries, utils.RetryConfig):
|
|
372
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
373
|
+
|
|
374
|
+
http_res = await self.do_request_async(
|
|
375
|
+
hook_ctx=HookContext(
|
|
376
|
+
config=self.sdk_configuration,
|
|
377
|
+
base_url=base_url or "",
|
|
378
|
+
operation_id="get-role-id",
|
|
379
|
+
oauth2_scopes=None,
|
|
380
|
+
security_source=get_security_from_env(
|
|
381
|
+
self.sdk_configuration.security, models.Security
|
|
382
|
+
),
|
|
383
|
+
),
|
|
384
|
+
request=req,
|
|
385
|
+
error_status_codes=["4XX", "5XX"],
|
|
386
|
+
retry_config=retry_config,
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
if utils.match_response(http_res, "200", "application/vnd.api+json"):
|
|
390
|
+
return unmarshal_json_response(models.Role, http_res)
|
|
391
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
392
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
393
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
394
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
395
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
396
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
397
|
+
|
|
398
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
|
|
5
|
+
from .sdkconfiguration import SDKConfiguration
|
|
6
|
+
from .utils.logger import Logger, get_default_logger
|
|
7
|
+
from .utils.retries import RetryConfig
|
|
8
|
+
import httpx
|
|
9
|
+
import importlib
|
|
10
|
+
from latitudesh_python_sdk import models, utils
|
|
11
|
+
from latitudesh_python_sdk._hooks import SDKHooks
|
|
12
|
+
from latitudesh_python_sdk.types import OptionalNullable, UNSET
|
|
13
|
+
import sys
|
|
14
|
+
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast
|
|
15
|
+
import weakref
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from latitudesh_python_sdk.apikeys import APIKeys
|
|
19
|
+
from latitudesh_python_sdk.billing import Billing
|
|
20
|
+
from latitudesh_python_sdk.events_sdk import EventsSDK
|
|
21
|
+
from latitudesh_python_sdk.firewalls_sdk import FirewallsSDK
|
|
22
|
+
from latitudesh_python_sdk.ipaddresses_sdk import IPAddressesSDK
|
|
23
|
+
from latitudesh_python_sdk.operatingsystems_sdk import OperatingSystemsSDK
|
|
24
|
+
from latitudesh_python_sdk.plans import Plans
|
|
25
|
+
from latitudesh_python_sdk.privatenetworks import PrivateNetworks
|
|
26
|
+
from latitudesh_python_sdk.projects_sdk import ProjectsSDK
|
|
27
|
+
from latitudesh_python_sdk.regions_sdk import RegionsSDK
|
|
28
|
+
from latitudesh_python_sdk.roles import Roles
|
|
29
|
+
from latitudesh_python_sdk.servers_sdk import ServersSDK
|
|
30
|
+
from latitudesh_python_sdk.sshkeys_sdk import SSHKeysSDK
|
|
31
|
+
from latitudesh_python_sdk.storage import Storage
|
|
32
|
+
from latitudesh_python_sdk.tags import Tags
|
|
33
|
+
from latitudesh_python_sdk.teams_sdk import TeamsSDK
|
|
34
|
+
from latitudesh_python_sdk.teamsmembers import TeamsMembers
|
|
35
|
+
from latitudesh_python_sdk.traffic_sdk import TrafficSDK
|
|
36
|
+
from latitudesh_python_sdk.userdata_sdk import UserDataSDK
|
|
37
|
+
from latitudesh_python_sdk.userprofile import UserProfile
|
|
38
|
+
from latitudesh_python_sdk.virtualmachines import VirtualMachines
|
|
39
|
+
from latitudesh_python_sdk.vpnsessions import VpnSessions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Latitudesh(BaseSDK):
|
|
43
|
+
r"""Latitude.sh API: The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It allows you to perform the same actions as the Latitude.sh dashboard."""
|
|
44
|
+
|
|
45
|
+
api_keys: "APIKeys"
|
|
46
|
+
billing: "Billing"
|
|
47
|
+
events: "EventsSDK"
|
|
48
|
+
firewalls: "FirewallsSDK"
|
|
49
|
+
ip_addresses: "IPAddressesSDK"
|
|
50
|
+
teams_members: "TeamsMembers"
|
|
51
|
+
operating_systems: "OperatingSystemsSDK"
|
|
52
|
+
plans: "Plans"
|
|
53
|
+
projects: "ProjectsSDK"
|
|
54
|
+
ssh_keys: "SSHKeysSDK"
|
|
55
|
+
user_data: "UserDataSDK"
|
|
56
|
+
regions: "RegionsSDK"
|
|
57
|
+
roles: "Roles"
|
|
58
|
+
servers: "ServersSDK"
|
|
59
|
+
storage: "Storage"
|
|
60
|
+
tags: "Tags"
|
|
61
|
+
teams: "TeamsSDK"
|
|
62
|
+
traffic: "TrafficSDK"
|
|
63
|
+
user_profile: "UserProfile"
|
|
64
|
+
virtual_machines: "VirtualMachines"
|
|
65
|
+
private_networks: "PrivateNetworks"
|
|
66
|
+
vpn_sessions: "VpnSessions"
|
|
67
|
+
_sub_sdk_map = {
|
|
68
|
+
"api_keys": ("latitudesh_python_sdk.apikeys", "APIKeys"),
|
|
69
|
+
"billing": ("latitudesh_python_sdk.billing", "Billing"),
|
|
70
|
+
"events": ("latitudesh_python_sdk.events_sdk", "EventsSDK"),
|
|
71
|
+
"firewalls": ("latitudesh_python_sdk.firewalls_sdk", "FirewallsSDK"),
|
|
72
|
+
"ip_addresses": ("latitudesh_python_sdk.ipaddresses_sdk", "IPAddressesSDK"),
|
|
73
|
+
"teams_members": ("latitudesh_python_sdk.teamsmembers", "TeamsMembers"),
|
|
74
|
+
"operating_systems": (
|
|
75
|
+
"latitudesh_python_sdk.operatingsystems_sdk",
|
|
76
|
+
"OperatingSystemsSDK",
|
|
77
|
+
),
|
|
78
|
+
"plans": ("latitudesh_python_sdk.plans", "Plans"),
|
|
79
|
+
"projects": ("latitudesh_python_sdk.projects_sdk", "ProjectsSDK"),
|
|
80
|
+
"ssh_keys": ("latitudesh_python_sdk.sshkeys_sdk", "SSHKeysSDK"),
|
|
81
|
+
"user_data": ("latitudesh_python_sdk.userdata_sdk", "UserDataSDK"),
|
|
82
|
+
"regions": ("latitudesh_python_sdk.regions_sdk", "RegionsSDK"),
|
|
83
|
+
"roles": ("latitudesh_python_sdk.roles", "Roles"),
|
|
84
|
+
"servers": ("latitudesh_python_sdk.servers_sdk", "ServersSDK"),
|
|
85
|
+
"storage": ("latitudesh_python_sdk.storage", "Storage"),
|
|
86
|
+
"tags": ("latitudesh_python_sdk.tags", "Tags"),
|
|
87
|
+
"teams": ("latitudesh_python_sdk.teams_sdk", "TeamsSDK"),
|
|
88
|
+
"traffic": ("latitudesh_python_sdk.traffic_sdk", "TrafficSDK"),
|
|
89
|
+
"user_profile": ("latitudesh_python_sdk.userprofile", "UserProfile"),
|
|
90
|
+
"virtual_machines": (
|
|
91
|
+
"latitudesh_python_sdk.virtualmachines",
|
|
92
|
+
"VirtualMachines",
|
|
93
|
+
),
|
|
94
|
+
"private_networks": (
|
|
95
|
+
"latitudesh_python_sdk.privatenetworks",
|
|
96
|
+
"PrivateNetworks",
|
|
97
|
+
),
|
|
98
|
+
"vpn_sessions": ("latitudesh_python_sdk.vpnsessions", "VpnSessions"),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
def __init__(
|
|
102
|
+
self,
|
|
103
|
+
bearer: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
|
|
104
|
+
latitude_api_key: Optional[str] = None,
|
|
105
|
+
server_idx: Optional[int] = None,
|
|
106
|
+
server_url: Optional[str] = None,
|
|
107
|
+
url_params: Optional[Dict[str, str]] = None,
|
|
108
|
+
client: Optional[HttpClient] = None,
|
|
109
|
+
async_client: Optional[AsyncHttpClient] = None,
|
|
110
|
+
retry_config: OptionalNullable[RetryConfig] = UNSET,
|
|
111
|
+
timeout_ms: Optional[int] = None,
|
|
112
|
+
debug_logger: Optional[Logger] = None,
|
|
113
|
+
) -> None:
|
|
114
|
+
r"""Instantiates the SDK configuring it with the provided parameters.
|
|
115
|
+
|
|
116
|
+
:param bearer: The bearer required for authentication
|
|
117
|
+
:param latitude_api_key: Allows setting the latitude_api_key variable for url substitution
|
|
118
|
+
:param server_idx: The index of the server to use for all methods
|
|
119
|
+
:param server_url: The server URL to use for all methods
|
|
120
|
+
:param url_params: Parameters to optionally template the server URL with
|
|
121
|
+
:param client: The HTTP client to use for all synchronous methods
|
|
122
|
+
:param async_client: The Async HTTP client to use for all asynchronous methods
|
|
123
|
+
:param retry_config: The retry configuration to use for all supported methods
|
|
124
|
+
:param timeout_ms: Optional request timeout applied to each operation in milliseconds
|
|
125
|
+
"""
|
|
126
|
+
client_supplied = True
|
|
127
|
+
if client is None:
|
|
128
|
+
client = httpx.Client(follow_redirects=True)
|
|
129
|
+
client_supplied = False
|
|
130
|
+
|
|
131
|
+
assert issubclass(
|
|
132
|
+
type(client), HttpClient
|
|
133
|
+
), "The provided client must implement the HttpClient protocol."
|
|
134
|
+
|
|
135
|
+
async_client_supplied = True
|
|
136
|
+
if async_client is None:
|
|
137
|
+
async_client = httpx.AsyncClient(follow_redirects=True)
|
|
138
|
+
async_client_supplied = False
|
|
139
|
+
|
|
140
|
+
if debug_logger is None:
|
|
141
|
+
debug_logger = get_default_logger()
|
|
142
|
+
|
|
143
|
+
assert issubclass(
|
|
144
|
+
type(async_client), AsyncHttpClient
|
|
145
|
+
), "The provided async_client must implement the AsyncHttpClient protocol."
|
|
146
|
+
|
|
147
|
+
security: Any = None
|
|
148
|
+
if callable(bearer):
|
|
149
|
+
# pylint: disable=unnecessary-lambda-assignment
|
|
150
|
+
security = lambda: models.Security(bearer=bearer())
|
|
151
|
+
else:
|
|
152
|
+
security = models.Security(bearer=bearer)
|
|
153
|
+
|
|
154
|
+
if server_url is not None:
|
|
155
|
+
if url_params is not None:
|
|
156
|
+
server_url = utils.template_url(server_url, url_params)
|
|
157
|
+
server_defaults: List[Dict[str, str]] = [
|
|
158
|
+
{
|
|
159
|
+
"latitude_api_key": latitude_api_key or "<insert your api key here>",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"latitude_api_key": latitude_api_key or "<insert your api key here>",
|
|
163
|
+
},
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
BaseSDK.__init__(
|
|
167
|
+
self,
|
|
168
|
+
SDKConfiguration(
|
|
169
|
+
client=client,
|
|
170
|
+
client_supplied=client_supplied,
|
|
171
|
+
async_client=async_client,
|
|
172
|
+
async_client_supplied=async_client_supplied,
|
|
173
|
+
security=security,
|
|
174
|
+
server_url=server_url,
|
|
175
|
+
server_idx=server_idx,
|
|
176
|
+
server_defaults=server_defaults,
|
|
177
|
+
retry_config=retry_config,
|
|
178
|
+
timeout_ms=timeout_ms,
|
|
179
|
+
debug_logger=debug_logger,
|
|
180
|
+
),
|
|
181
|
+
parent_ref=self,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
hooks = SDKHooks()
|
|
185
|
+
|
|
186
|
+
# pylint: disable=protected-access
|
|
187
|
+
self.sdk_configuration.__dict__["_hooks"] = hooks
|
|
188
|
+
|
|
189
|
+
current_server_url, *_ = self.sdk_configuration.get_server_details()
|
|
190
|
+
server_url, self.sdk_configuration.client = hooks.sdk_init(
|
|
191
|
+
current_server_url, client
|
|
192
|
+
)
|
|
193
|
+
if current_server_url != server_url:
|
|
194
|
+
self.sdk_configuration.server_url = server_url
|
|
195
|
+
|
|
196
|
+
weakref.finalize(
|
|
197
|
+
self,
|
|
198
|
+
close_clients,
|
|
199
|
+
cast(ClientOwner, self.sdk_configuration),
|
|
200
|
+
self.sdk_configuration.client,
|
|
201
|
+
self.sdk_configuration.client_supplied,
|
|
202
|
+
self.sdk_configuration.async_client,
|
|
203
|
+
self.sdk_configuration.async_client_supplied,
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
def dynamic_import(self, modname, retries=3):
|
|
207
|
+
for attempt in range(retries):
|
|
208
|
+
try:
|
|
209
|
+
return importlib.import_module(modname)
|
|
210
|
+
except KeyError:
|
|
211
|
+
# Clear any half-initialized module and retry
|
|
212
|
+
sys.modules.pop(modname, None)
|
|
213
|
+
if attempt == retries - 1:
|
|
214
|
+
break
|
|
215
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
216
|
+
|
|
217
|
+
def __getattr__(self, name: str):
|
|
218
|
+
if name in self._sub_sdk_map:
|
|
219
|
+
module_path, class_name = self._sub_sdk_map[name]
|
|
220
|
+
try:
|
|
221
|
+
module = self.dynamic_import(module_path)
|
|
222
|
+
klass = getattr(module, class_name)
|
|
223
|
+
instance = klass(self.sdk_configuration, parent_ref=self)
|
|
224
|
+
setattr(self, name, instance)
|
|
225
|
+
return instance
|
|
226
|
+
except ImportError as e:
|
|
227
|
+
raise AttributeError(
|
|
228
|
+
f"Failed to import module {module_path} for attribute {name}: {e}"
|
|
229
|
+
) from e
|
|
230
|
+
except AttributeError as e:
|
|
231
|
+
raise AttributeError(
|
|
232
|
+
f"Failed to find class {class_name} in module {module_path} for attribute {name}: {e}"
|
|
233
|
+
) from e
|
|
234
|
+
|
|
235
|
+
raise AttributeError(
|
|
236
|
+
f"'{type(self).__name__}' object has no attribute '{name}'"
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
def __dir__(self):
|
|
240
|
+
default_attrs = list(super().__dir__())
|
|
241
|
+
lazy_attrs = list(self._sub_sdk_map.keys())
|
|
242
|
+
return sorted(list(set(default_attrs + lazy_attrs)))
|
|
243
|
+
|
|
244
|
+
def __enter__(self):
|
|
245
|
+
return self
|
|
246
|
+
|
|
247
|
+
async def __aenter__(self):
|
|
248
|
+
return self
|
|
249
|
+
|
|
250
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
251
|
+
if (
|
|
252
|
+
self.sdk_configuration.client is not None
|
|
253
|
+
and not self.sdk_configuration.client_supplied
|
|
254
|
+
):
|
|
255
|
+
self.sdk_configuration.client.close()
|
|
256
|
+
self.sdk_configuration.client = None
|
|
257
|
+
|
|
258
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
259
|
+
if (
|
|
260
|
+
self.sdk_configuration.async_client is not None
|
|
261
|
+
and not self.sdk_configuration.async_client_supplied
|
|
262
|
+
):
|
|
263
|
+
await self.sdk_configuration.async_client.aclose()
|
|
264
|
+
self.sdk_configuration.async_client = None
|