zrok2-build-debugging 22.0.2000008__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.
- test/__init__.py +0 -0
- test/test_access201_response.py +52 -0
- test/test_access_request.py +54 -0
- test/test_access_summary.py +60 -0
- test/test_accesses_list.py +63 -0
- test/test_account_api.py +79 -0
- test/test_add_frontend_grant_request.py +52 -0
- test/test_add_namespace_frontend_mapping_request.py +53 -0
- test/test_add_namespace_grant_request.py +52 -0
- test/test_add_organization_member_request.py +53 -0
- test/test_admin_api.py +199 -0
- test/test_agent_api.py +85 -0
- test/test_auth_user.py +52 -0
- test/test_change_password_request.py +53 -0
- test/test_client_version_check_request.py +51 -0
- test/test_configuration.py +56 -0
- test/test_create_frontend201_response.py +51 -0
- test/test_create_frontend_request.py +55 -0
- test/test_create_identity201_response.py +52 -0
- test/test_create_identity_request.py +51 -0
- test/test_create_namespace201_response.py +51 -0
- test/test_create_namespace_request.py +54 -0
- test/test_create_organization201_response.py +51 -0
- test/test_create_organization_request.py +51 -0
- test/test_create_share_name_request.py +52 -0
- test/test_delete_identity_request.py +51 -0
- test/test_disable_request.py +51 -0
- test/test_enable_request.py +52 -0
- test/test_enroll200_response.py +51 -0
- test/test_enroll_request.py +51 -0
- test/test_environment.py +63 -0
- test/test_environment_and_resources.py +96 -0
- test/test_environment_api.py +43 -0
- test/test_environment_summary.py +60 -0
- test/test_environments_list.py +63 -0
- test/test_frontend.py +59 -0
- test/test_get_sparklines200_response.py +62 -0
- test/test_get_sparklines_request.py +57 -0
- test/test_invite_request.py +52 -0
- test/test_invite_token_generate_request.py +53 -0
- test/test_list_frontend_namespace_mappings200_response_inner.py +54 -0
- test/test_list_frontends200_response_inner.py +58 -0
- test/test_list_memberships200_response.py +56 -0
- test/test_list_memberships200_response_memberships_inner.py +53 -0
- test/test_list_namespaces200_response_inner.py +56 -0
- test/test_list_organization_members200_response.py +55 -0
- test/test_list_organization_members200_response_members_inner.py +52 -0
- test/test_list_organizations200_response.py +55 -0
- test/test_list_organizations200_response_organizations_inner.py +52 -0
- test/test_list_share_namespaces200_response_inner.py +53 -0
- test/test_login_request.py +52 -0
- test/test_metadata_api.py +145 -0
- test/test_metrics.py +59 -0
- test/test_metrics_sample.py +53 -0
- test/test_name.py +56 -0
- test/test_name_selection.py +52 -0
- test/test_overview.py +110 -0
- test/test_overview_names_inner.py +56 -0
- test/test_ping200_response.py +51 -0
- test/test_principal.py +55 -0
- test/test_regenerate_account_token200_response.py +51 -0
- test/test_regenerate_account_token_request.py +51 -0
- test/test_register_request.py +52 -0
- test/test_remote_access_request.py +60 -0
- test/test_remote_share200_response.py +54 -0
- test/test_remote_share_request.py +74 -0
- test/test_remote_status200_response.py +82 -0
- test/test_remote_status200_response_accesses_inner.py +62 -0
- test/test_remote_status200_response_shares_inner.py +64 -0
- test/test_remote_status200_response_shares_inner_failure.py +54 -0
- test/test_remote_unaccess_request.py +52 -0
- test/test_remote_unshare_request.py +52 -0
- test/test_remove_namespace_frontend_mapping_request.py +52 -0
- test/test_remove_organization_member_request.py +52 -0
- test/test_reset_password_request.py +52 -0
- test/test_share.py +67 -0
- test/test_share_api.py +103 -0
- test/test_share_http_healthcheck200_response.py +52 -0
- test/test_share_http_healthcheck_request.py +56 -0
- test/test_share_request.py +75 -0
- test/test_share_response.py +54 -0
- test/test_share_summary.py +62 -0
- test/test_shares_list.py +65 -0
- test/test_spark_data_sample.py +52 -0
- test/test_unaccess_request.py +53 -0
- test/test_unshare_request.py +52 -0
- test/test_update_access_request.py +53 -0
- test/test_update_frontend_request.py +55 -0
- test/test_update_namespace_request.py +55 -0
- test/test_update_share_name_request.py +53 -0
- test/test_update_share_request.py +57 -0
- test/test_verify200_response.py +51 -0
- test/test_verify_request.py +51 -0
- test/test_version_inventory200_response.py +51 -0
- zrok/__init__.py +4 -0
- zrok/_version.py +21 -0
- zrok/access.py +58 -0
- zrok/decor.py +33 -0
- zrok/dialer.py +10 -0
- zrok/environment/__init__.py +1 -0
- zrok/environment/dirs.py +32 -0
- zrok/environment/root.py +182 -0
- zrok/listener.py +29 -0
- zrok/model.py +75 -0
- zrok/overview.py +77 -0
- zrok/proxy.py +203 -0
- zrok/share.py +199 -0
- zrok2_build_debugging-22.0.2000008.dist-info/METADATA +24 -0
- zrok2_build_debugging-22.0.2000008.dist-info/RECORD +213 -0
- zrok2_build_debugging-22.0.2000008.dist-info/WHEEL +5 -0
- zrok2_build_debugging-22.0.2000008.dist-info/top_level.txt +3 -0
- zrok_api/__init__.py +231 -0
- zrok_api/api/__init__.py +10 -0
- zrok_api/api/account_api.py +2261 -0
- zrok_api/api/admin_api.py +7673 -0
- zrok_api/api/agent_api.py +2547 -0
- zrok_api/api/environment_api.py +589 -0
- zrok_api/api/metadata_api.py +5614 -0
- zrok_api/api/share_api.py +3321 -0
- zrok_api/api_client.py +801 -0
- zrok_api/api_response.py +21 -0
- zrok_api/configuration.py +602 -0
- zrok_api/exceptions.py +216 -0
- zrok_api/models/__init__.py +103 -0
- zrok_api/models/access201_response.py +89 -0
- zrok_api/models/access_request.py +93 -0
- zrok_api/models/access_summary.py +105 -0
- zrok_api/models/accesses_list.py +95 -0
- zrok_api/models/add_frontend_grant_request.py +89 -0
- zrok_api/models/add_namespace_frontend_mapping_request.py +91 -0
- zrok_api/models/add_namespace_grant_request.py +89 -0
- zrok_api/models/add_organization_member_request.py +91 -0
- zrok_api/models/auth_user.py +89 -0
- zrok_api/models/change_password_request.py +91 -0
- zrok_api/models/client_version_check_request.py +87 -0
- zrok_api/models/configuration.py +97 -0
- zrok_api/models/create_frontend201_response.py +87 -0
- zrok_api/models/create_frontend_request.py +105 -0
- zrok_api/models/create_identity201_response.py +89 -0
- zrok_api/models/create_identity_request.py +87 -0
- zrok_api/models/create_namespace201_response.py +87 -0
- zrok_api/models/create_namespace_request.py +93 -0
- zrok_api/models/create_organization201_response.py +87 -0
- zrok_api/models/create_organization_request.py +87 -0
- zrok_api/models/create_share_name_request.py +89 -0
- zrok_api/models/delete_identity_request.py +87 -0
- zrok_api/models/disable_request.py +87 -0
- zrok_api/models/enable_request.py +89 -0
- zrok_api/models/enroll200_response.py +87 -0
- zrok_api/models/enroll_request.py +87 -0
- zrok_api/models/environment.py +111 -0
- zrok_api/models/environment_and_resources.py +111 -0
- zrok_api/models/environment_summary.py +105 -0
- zrok_api/models/environments_list.py +95 -0
- zrok_api/models/frontend.py +103 -0
- zrok_api/models/get_sparklines200_response.py +95 -0
- zrok_api/models/get_sparklines_request.py +91 -0
- zrok_api/models/invite_request.py +89 -0
- zrok_api/models/invite_token_generate_request.py +87 -0
- zrok_api/models/list_frontend_namespace_mappings200_response_inner.py +93 -0
- zrok_api/models/list_frontends200_response_inner.py +101 -0
- zrok_api/models/list_memberships200_response.py +95 -0
- zrok_api/models/list_memberships200_response_memberships_inner.py +91 -0
- zrok_api/models/list_namespaces200_response_inner.py +97 -0
- zrok_api/models/list_organization_members200_response.py +95 -0
- zrok_api/models/list_organization_members200_response_members_inner.py +89 -0
- zrok_api/models/list_organizations200_response.py +95 -0
- zrok_api/models/list_organizations200_response_organizations_inner.py +89 -0
- zrok_api/models/list_share_namespaces200_response_inner.py +91 -0
- zrok_api/models/login_request.py +89 -0
- zrok_api/models/metrics.py +101 -0
- zrok_api/models/metrics_sample.py +91 -0
- zrok_api/models/name.py +97 -0
- zrok_api/models/name_selection.py +89 -0
- zrok_api/models/overview.py +117 -0
- zrok_api/models/overview_names_inner.py +97 -0
- zrok_api/models/ping200_response.py +87 -0
- zrok_api/models/principal.py +95 -0
- zrok_api/models/regenerate_account_token200_response.py +87 -0
- zrok_api/models/regenerate_account_token_request.py +87 -0
- zrok_api/models/register_request.py +89 -0
- zrok_api/models/remote_access_request.py +102 -0
- zrok_api/models/remote_share200_response.py +89 -0
- zrok_api/models/remote_share_request.py +141 -0
- zrok_api/models/remote_status200_response.py +105 -0
- zrok_api/models/remote_status200_response_accesses_inner.py +101 -0
- zrok_api/models/remote_status200_response_shares_inner.py +105 -0
- zrok_api/models/remote_status200_response_shares_inner_failure.py +93 -0
- zrok_api/models/remote_unaccess_request.py +89 -0
- zrok_api/models/remote_unshare_request.py +89 -0
- zrok_api/models/remove_namespace_frontend_mapping_request.py +89 -0
- zrok_api/models/remove_organization_member_request.py +89 -0
- zrok_api/models/reset_password_request.py +89 -0
- zrok_api/models/share.py +115 -0
- zrok_api/models/share_http_healthcheck200_response.py +89 -0
- zrok_api/models/share_http_healthcheck_request.py +97 -0
- zrok_api/models/share_request.py +157 -0
- zrok_api/models/share_response.py +89 -0
- zrok_api/models/share_summary.py +105 -0
- zrok_api/models/shares_list.py +95 -0
- zrok_api/models/spark_data_sample.py +89 -0
- zrok_api/models/unaccess_request.py +91 -0
- zrok_api/models/unshare_request.py +89 -0
- zrok_api/models/update_access_request.py +91 -0
- zrok_api/models/update_frontend_request.py +95 -0
- zrok_api/models/update_namespace_request.py +95 -0
- zrok_api/models/update_share_name_request.py +91 -0
- zrok_api/models/update_share_request.py +91 -0
- zrok_api/models/verify200_response.py +87 -0
- zrok_api/models/verify_request.py +87 -0
- zrok_api/models/version_inventory200_response.py +87 -0
- zrok_api/py.typed +0 -0
- zrok_api/rest.py +258 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
zrok
|
|
5
|
+
|
|
6
|
+
zrok client access
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import unittest
|
|
16
|
+
|
|
17
|
+
from zrok_api.models.update_share_name_request import UpdateShareNameRequest
|
|
18
|
+
|
|
19
|
+
class TestUpdateShareNameRequest(unittest.TestCase):
|
|
20
|
+
"""UpdateShareNameRequest unit test stubs"""
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def make_instance(self, include_optional) -> UpdateShareNameRequest:
|
|
29
|
+
"""Test UpdateShareNameRequest
|
|
30
|
+
include_optional is a boolean, when False only required
|
|
31
|
+
params are included, when True both required and
|
|
32
|
+
optional params are included """
|
|
33
|
+
# uncomment below to create an instance of `UpdateShareNameRequest`
|
|
34
|
+
"""
|
|
35
|
+
model = UpdateShareNameRequest()
|
|
36
|
+
if include_optional:
|
|
37
|
+
return UpdateShareNameRequest(
|
|
38
|
+
namespace_token = '',
|
|
39
|
+
name = '',
|
|
40
|
+
reserved = True
|
|
41
|
+
)
|
|
42
|
+
else:
|
|
43
|
+
return UpdateShareNameRequest(
|
|
44
|
+
)
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def testUpdateShareNameRequest(self):
|
|
48
|
+
"""Test UpdateShareNameRequest"""
|
|
49
|
+
# inst_req_only = self.make_instance(include_optional=False)
|
|
50
|
+
# inst_req_and_optional = self.make_instance(include_optional=True)
|
|
51
|
+
|
|
52
|
+
if __name__ == '__main__':
|
|
53
|
+
unittest.main()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
zrok
|
|
5
|
+
|
|
6
|
+
zrok client access
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import unittest
|
|
16
|
+
|
|
17
|
+
from zrok_api.models.update_share_request import UpdateShareRequest
|
|
18
|
+
|
|
19
|
+
class TestUpdateShareRequest(unittest.TestCase):
|
|
20
|
+
"""UpdateShareRequest unit test stubs"""
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def make_instance(self, include_optional) -> UpdateShareRequest:
|
|
29
|
+
"""Test UpdateShareRequest
|
|
30
|
+
include_optional is a boolean, when False only required
|
|
31
|
+
params are included, when True both required and
|
|
32
|
+
optional params are included """
|
|
33
|
+
# uncomment below to create an instance of `UpdateShareRequest`
|
|
34
|
+
"""
|
|
35
|
+
model = UpdateShareRequest()
|
|
36
|
+
if include_optional:
|
|
37
|
+
return UpdateShareRequest(
|
|
38
|
+
share_token = '',
|
|
39
|
+
add_access_grants = [
|
|
40
|
+
''
|
|
41
|
+
],
|
|
42
|
+
remove_access_grants = [
|
|
43
|
+
''
|
|
44
|
+
]
|
|
45
|
+
)
|
|
46
|
+
else:
|
|
47
|
+
return UpdateShareRequest(
|
|
48
|
+
)
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def testUpdateShareRequest(self):
|
|
52
|
+
"""Test UpdateShareRequest"""
|
|
53
|
+
# inst_req_only = self.make_instance(include_optional=False)
|
|
54
|
+
# inst_req_and_optional = self.make_instance(include_optional=True)
|
|
55
|
+
|
|
56
|
+
if __name__ == '__main__':
|
|
57
|
+
unittest.main()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
zrok
|
|
5
|
+
|
|
6
|
+
zrok client access
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import unittest
|
|
16
|
+
|
|
17
|
+
from zrok_api.models.verify200_response import Verify200Response
|
|
18
|
+
|
|
19
|
+
class TestVerify200Response(unittest.TestCase):
|
|
20
|
+
"""Verify200Response unit test stubs"""
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def make_instance(self, include_optional) -> Verify200Response:
|
|
29
|
+
"""Test Verify200Response
|
|
30
|
+
include_optional is a boolean, when False only required
|
|
31
|
+
params are included, when True both required and
|
|
32
|
+
optional params are included """
|
|
33
|
+
# uncomment below to create an instance of `Verify200Response`
|
|
34
|
+
"""
|
|
35
|
+
model = Verify200Response()
|
|
36
|
+
if include_optional:
|
|
37
|
+
return Verify200Response(
|
|
38
|
+
email = ''
|
|
39
|
+
)
|
|
40
|
+
else:
|
|
41
|
+
return Verify200Response(
|
|
42
|
+
)
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def testVerify200Response(self):
|
|
46
|
+
"""Test Verify200Response"""
|
|
47
|
+
# inst_req_only = self.make_instance(include_optional=False)
|
|
48
|
+
# inst_req_and_optional = self.make_instance(include_optional=True)
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
unittest.main()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
zrok
|
|
5
|
+
|
|
6
|
+
zrok client access
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import unittest
|
|
16
|
+
|
|
17
|
+
from zrok_api.models.verify_request import VerifyRequest
|
|
18
|
+
|
|
19
|
+
class TestVerifyRequest(unittest.TestCase):
|
|
20
|
+
"""VerifyRequest unit test stubs"""
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def make_instance(self, include_optional) -> VerifyRequest:
|
|
29
|
+
"""Test VerifyRequest
|
|
30
|
+
include_optional is a boolean, when False only required
|
|
31
|
+
params are included, when True both required and
|
|
32
|
+
optional params are included """
|
|
33
|
+
# uncomment below to create an instance of `VerifyRequest`
|
|
34
|
+
"""
|
|
35
|
+
model = VerifyRequest()
|
|
36
|
+
if include_optional:
|
|
37
|
+
return VerifyRequest(
|
|
38
|
+
register_token = ''
|
|
39
|
+
)
|
|
40
|
+
else:
|
|
41
|
+
return VerifyRequest(
|
|
42
|
+
)
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def testVerifyRequest(self):
|
|
46
|
+
"""Test VerifyRequest"""
|
|
47
|
+
# inst_req_only = self.make_instance(include_optional=False)
|
|
48
|
+
# inst_req_and_optional = self.make_instance(include_optional=True)
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
unittest.main()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
zrok
|
|
5
|
+
|
|
6
|
+
zrok client access
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import unittest
|
|
16
|
+
|
|
17
|
+
from zrok_api.models.version_inventory200_response import VersionInventory200Response
|
|
18
|
+
|
|
19
|
+
class TestVersionInventory200Response(unittest.TestCase):
|
|
20
|
+
"""VersionInventory200Response unit test stubs"""
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def make_instance(self, include_optional) -> VersionInventory200Response:
|
|
29
|
+
"""Test VersionInventory200Response
|
|
30
|
+
include_optional is a boolean, when False only required
|
|
31
|
+
params are included, when True both required and
|
|
32
|
+
optional params are included """
|
|
33
|
+
# uncomment below to create an instance of `VersionInventory200Response`
|
|
34
|
+
"""
|
|
35
|
+
model = VersionInventory200Response()
|
|
36
|
+
if include_optional:
|
|
37
|
+
return VersionInventory200Response(
|
|
38
|
+
controller_version = ''
|
|
39
|
+
)
|
|
40
|
+
else:
|
|
41
|
+
return VersionInventory200Response(
|
|
42
|
+
)
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def testVersionInventory200Response(self):
|
|
46
|
+
"""Test VersionInventory200Response"""
|
|
47
|
+
# inst_req_only = self.make_instance(include_optional=False)
|
|
48
|
+
# inst_req_and_optional = self.make_instance(include_optional=True)
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
unittest.main()
|
zrok/__init__.py
ADDED
zrok/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.29) from
|
|
3
|
+
# revision-control system data, or from the parent directory name of an
|
|
4
|
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
|
+
# of this file.
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
version_json = '''
|
|
10
|
+
{
|
|
11
|
+
"date": "2026-02-03T14:19:30-0500",
|
|
12
|
+
"dirty": false,
|
|
13
|
+
"error": null,
|
|
14
|
+
"full-revisionid": "645ebc9de7858f7e800eb86cf0090f4fdae85f7c",
|
|
15
|
+
"version": "22.0.2000008"
|
|
16
|
+
}
|
|
17
|
+
''' # END VERSION_JSON
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_versions():
|
|
21
|
+
return json.loads(version_json)
|
zrok/access.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from zrok.environment.root import Root
|
|
2
|
+
from zrok_api.models.access_request import AccessRequest
|
|
3
|
+
from zrok_api.models.unaccess_request import UnaccessRequest
|
|
4
|
+
from zrok_api.api import ShareApi
|
|
5
|
+
from zrok import model
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Access():
|
|
9
|
+
root: Root
|
|
10
|
+
request: model.AccessRequest
|
|
11
|
+
access: model.Access
|
|
12
|
+
|
|
13
|
+
def __init__(self, root: Root, request: model.AccessRequest):
|
|
14
|
+
self.root = root
|
|
15
|
+
self.request = request
|
|
16
|
+
|
|
17
|
+
def __enter__(self) -> model.Access:
|
|
18
|
+
self.access = CreateAccess(root=self.root, request=self.request)
|
|
19
|
+
return self.access
|
|
20
|
+
|
|
21
|
+
def __exit__(self, exception_type, exception_value, exception_traceback):
|
|
22
|
+
DeleteAccess(root=self.root, acc=self.access)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def CreateAccess(root: Root, request: model.AccessRequest) -> model.Access:
|
|
26
|
+
if not root.IsEnabled():
|
|
27
|
+
raise Exception("environment is not enabled; enable with 'zrok enable' first!")
|
|
28
|
+
|
|
29
|
+
out = AccessRequest(share_token=request.ShareToken,
|
|
30
|
+
env_zid=root.env.ZitiIdentity)
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
zrok = root.Client()
|
|
34
|
+
except Exception as e:
|
|
35
|
+
raise Exception("error getting zrok client", e)
|
|
36
|
+
try:
|
|
37
|
+
res = ShareApi(zrok).access(body=out)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
raise Exception("unable to create access", e)
|
|
40
|
+
return model.Access(Token=res.frontend_token,
|
|
41
|
+
ShareToken=request.ShareToken,
|
|
42
|
+
BackendMode=res.backend_mode)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def DeleteAccess(root: Root, acc: model.Access):
|
|
46
|
+
req = UnaccessRequest(frontend_token=acc.Token,
|
|
47
|
+
share_token=acc.ShareToken,
|
|
48
|
+
env_zid=root.env.ZitiIdentity)
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
zrok = root.Client()
|
|
52
|
+
except Exception as e:
|
|
53
|
+
raise Exception("error getting zrok client", e)
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
ShareApi(zrok).unaccess(body=req)
|
|
57
|
+
except Exception as e:
|
|
58
|
+
raise Exception("error deleting access", e)
|
zrok/decor.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
import openziti
|
|
3
|
+
from zrok.environment.root import Root
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class Opts:
|
|
8
|
+
root: Root
|
|
9
|
+
shrToken: str
|
|
10
|
+
bindPort: int
|
|
11
|
+
bindHost: str = ""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MonkeyPatch(openziti.monkeypatch):
|
|
15
|
+
def __init__(self, opts: {}, *args, **kwargs):
|
|
16
|
+
zif = opts['cfg'].root.ZitiIdentityNamed(opts['cfg'].root.EnvironmentIdentityName())
|
|
17
|
+
cfg = dict(ztx=openziti.load(zif), service=opts['cfg'].shrToken)
|
|
18
|
+
super(MonkeyPatch, self).__init__(bindings={(opts['cfg'].bindHost, opts['cfg'].bindPort): cfg}, *args, **kwargs)
|
|
19
|
+
|
|
20
|
+
def __enter__(self):
|
|
21
|
+
return self
|
|
22
|
+
|
|
23
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
24
|
+
super(MonkeyPatch, self).__exit__(exc_type, exc_val, exc_tb)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def zrok(opts: {}, *zargs, **zkwargs):
|
|
28
|
+
def zrockify_func(func):
|
|
29
|
+
def zrockified(*args, **kwargs):
|
|
30
|
+
with MonkeyPatch(opts=opts, *zargs, **zkwargs):
|
|
31
|
+
func(*args, **kwargs)
|
|
32
|
+
return zrockified
|
|
33
|
+
return zrockify_func
|
zrok/dialer.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from zrok.environment.root import Root
|
|
2
|
+
import openziti
|
|
3
|
+
from socket import SOCK_STREAM
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def Dialer(shrToken: str, root: Root) -> openziti.zitisock.ZitiSocket:
|
|
7
|
+
openziti.load(root.ZitiIdentityNamed(root.EnvironmentIdentityName()))
|
|
8
|
+
client = openziti.socket(type=SOCK_STREAM)
|
|
9
|
+
client.connect((shrToken, 1))
|
|
10
|
+
return client
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import dirs, root # noqa
|
zrok/environment/dirs.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def rootDir() -> str:
|
|
6
|
+
home = str(Path.home())
|
|
7
|
+
return os.path.join(home, ".zrok")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def metadataFile() -> str:
|
|
11
|
+
zrd = rootDir()
|
|
12
|
+
return os.path.join(zrd, "metadata.json")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def configFile() -> str:
|
|
16
|
+
zrd = rootDir()
|
|
17
|
+
return os.path.join(zrd, "config.json")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def environmentFile() -> str:
|
|
21
|
+
zrd = rootDir()
|
|
22
|
+
return os.path.join(zrd, "environment.json")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def identitiesDir() -> str:
|
|
26
|
+
zrd = rootDir()
|
|
27
|
+
return os.path.join(zrd, "identities")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def identityFile(name: str) -> str:
|
|
31
|
+
idd = identitiesDir()
|
|
32
|
+
return os.path.join(idd, name + ".json")
|
zrok/environment/root.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import NamedTuple
|
|
3
|
+
from .dirs import identityFile, rootDir, configFile, environmentFile, metadataFile
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import zrok_api as zrok
|
|
7
|
+
from zrok_api.configuration import Configuration
|
|
8
|
+
from zrok_api.models.client_version_check_request import ClientVersionCheckRequest
|
|
9
|
+
|
|
10
|
+
V = "v1.0"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class Metadata:
|
|
15
|
+
V: str = ""
|
|
16
|
+
RootPath: str = ""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Config:
|
|
21
|
+
ApiEndpoint: str = ""
|
|
22
|
+
DefaultFrontend: str = ""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Environment:
|
|
27
|
+
Token: str = ""
|
|
28
|
+
ZitiIdentity: str = ""
|
|
29
|
+
ApiEndpoint: str = ""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ApiEndpoint(NamedTuple):
|
|
33
|
+
endpoint: str
|
|
34
|
+
frm: str
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class Root:
|
|
39
|
+
meta: Metadata = field(default_factory=Metadata)
|
|
40
|
+
cfg: Config = field(default_factory=Config)
|
|
41
|
+
env: Environment = field(default_factory=Environment)
|
|
42
|
+
|
|
43
|
+
def HasConfig(self) -> bool:
|
|
44
|
+
return self.cfg != Config()
|
|
45
|
+
|
|
46
|
+
def Client(self) -> zrok.ApiClient:
|
|
47
|
+
apiEndpoint = self.ApiEndpoint()
|
|
48
|
+
|
|
49
|
+
cfg = Configuration()
|
|
50
|
+
cfg.host = apiEndpoint[0] + "/api/v2"
|
|
51
|
+
|
|
52
|
+
# Update: Configure authentication token
|
|
53
|
+
# The token needs to be set with 'key' instead of 'x-token'
|
|
54
|
+
# This matches the securityDefinitions in the OpenAPI spec
|
|
55
|
+
cfg.api_key["key"] = self.env.Token
|
|
56
|
+
|
|
57
|
+
# Create the API client with the configured authentication
|
|
58
|
+
auth_client = zrok.ApiClient(configuration=cfg)
|
|
59
|
+
self.client_version_check(auth_client)
|
|
60
|
+
|
|
61
|
+
return auth_client
|
|
62
|
+
|
|
63
|
+
def ApiEndpoint(self) -> ApiEndpoint:
|
|
64
|
+
apiEndpoint = "https://api-v2.zrok.io"
|
|
65
|
+
frm = "binary"
|
|
66
|
+
|
|
67
|
+
if self.cfg.ApiEndpoint != "":
|
|
68
|
+
apiEndpoint = self.cfg.ApiEndpoint
|
|
69
|
+
frm = "config"
|
|
70
|
+
|
|
71
|
+
env = os.getenv("ZROK_API_ENDPOINT")
|
|
72
|
+
if env != "":
|
|
73
|
+
apiEndpoint = env
|
|
74
|
+
frm = "ZROK_API_ENDPOINT"
|
|
75
|
+
|
|
76
|
+
if self.IsEnabled():
|
|
77
|
+
apiEndpoint = self.env.ApiEndpoint
|
|
78
|
+
frm = "env"
|
|
79
|
+
|
|
80
|
+
return ApiEndpoint(apiEndpoint.rstrip("/"), frm)
|
|
81
|
+
|
|
82
|
+
def IsEnabled(self) -> bool:
|
|
83
|
+
return self.env != Environment()
|
|
84
|
+
|
|
85
|
+
def PublicIdentityName(self) -> str:
|
|
86
|
+
return "public"
|
|
87
|
+
|
|
88
|
+
def EnvironmentIdentityName(self) -> str:
|
|
89
|
+
return "environment"
|
|
90
|
+
|
|
91
|
+
def ZitiIdentityNamed(self, name: str) -> str:
|
|
92
|
+
return identityFile(name)
|
|
93
|
+
|
|
94
|
+
def client_version_check(self, zrock_client):
|
|
95
|
+
"""Check if the client version is compatible with the API."""
|
|
96
|
+
metadata_api = zrok.MetadataApi(zrock_client)
|
|
97
|
+
try:
|
|
98
|
+
# Perform version check using the client_version_check method
|
|
99
|
+
request = ClientVersionCheckRequest(client_version=V)
|
|
100
|
+
response = metadata_api.client_version_check_with_http_info(
|
|
101
|
+
body=request,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Check if the response status code is 200 OK
|
|
105
|
+
if response.status_code != 200:
|
|
106
|
+
raise Exception(f"Client version check failed: Unexpected status code {response.status_code}")
|
|
107
|
+
|
|
108
|
+
# Success case - status code is 200 and empty response body is expected
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
except Exception as e:
|
|
112
|
+
raise Exception(f"Client version check failed: {str(e)}")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def Default() -> Root:
|
|
116
|
+
r = Root()
|
|
117
|
+
root = rootDir()
|
|
118
|
+
r.meta = Metadata(V=V, RootPath=root)
|
|
119
|
+
return r
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def Assert() -> bool:
|
|
123
|
+
exists = __rootExists()
|
|
124
|
+
if exists:
|
|
125
|
+
meta = __loadMetadata()
|
|
126
|
+
return meta.V == V
|
|
127
|
+
return False
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def Load() -> Root:
|
|
131
|
+
r = Root()
|
|
132
|
+
if __rootExists():
|
|
133
|
+
r.meta = __loadMetadata()
|
|
134
|
+
r.cfg = __loadConfig()
|
|
135
|
+
r.env = __loadEnvironment()
|
|
136
|
+
else:
|
|
137
|
+
r = Default()
|
|
138
|
+
return r
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def __rootExists() -> bool:
|
|
142
|
+
mf = metadataFile()
|
|
143
|
+
return os.path.isfile(mf)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def __assertMetadata():
|
|
147
|
+
pass
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def __loadMetadata() -> Metadata:
|
|
151
|
+
mf = metadataFile()
|
|
152
|
+
with open(mf) as f:
|
|
153
|
+
data = json.load(f)
|
|
154
|
+
return Metadata(V=data["v"])
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def __loadConfig() -> Config:
|
|
158
|
+
cf = configFile()
|
|
159
|
+
try:
|
|
160
|
+
with open(cf) as f:
|
|
161
|
+
data = json.load(f)
|
|
162
|
+
return Config(
|
|
163
|
+
ApiEndpoint=data.get("api_endpoint", ""),
|
|
164
|
+
DefaultFrontend=data.get("default_frontend", "")
|
|
165
|
+
)
|
|
166
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
|
167
|
+
return Config(ApiEndpoint="", DefaultFrontend="")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def isEnabled() -> bool:
|
|
171
|
+
ef = environmentFile()
|
|
172
|
+
return os.path.isfile(ef)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def __loadEnvironment() -> Environment:
|
|
176
|
+
ef = environmentFile()
|
|
177
|
+
with open(ef) as f:
|
|
178
|
+
data = json.load(f)
|
|
179
|
+
return Environment(
|
|
180
|
+
Token=data["zrok_token"],
|
|
181
|
+
ZitiIdentity=data["ziti_identity"],
|
|
182
|
+
ApiEndpoint=data["api_endpoint"])
|
zrok/listener.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import openziti
|
|
2
|
+
from zrok.environment.root import Root
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Listener():
|
|
6
|
+
shrToken: str
|
|
7
|
+
root: Root
|
|
8
|
+
__server: openziti.zitisock.ZitiSocket
|
|
9
|
+
|
|
10
|
+
def __init__(self, shrToken: str, root: Root):
|
|
11
|
+
self.shrToken = shrToken
|
|
12
|
+
self.root = root
|
|
13
|
+
ztx = openziti.load(
|
|
14
|
+
self.root.ZitiIdentityNamed(
|
|
15
|
+
self.root.EnvironmentIdentityName()))
|
|
16
|
+
self.__server = ztx.bind(self.shrToken)
|
|
17
|
+
|
|
18
|
+
def __enter__(self) -> openziti.zitisock.ZitiSocket:
|
|
19
|
+
self.listen()
|
|
20
|
+
return self.__server
|
|
21
|
+
|
|
22
|
+
def __exit__(self, exception_type, exception_value, exception_traceback):
|
|
23
|
+
self.close()
|
|
24
|
+
|
|
25
|
+
def listen(self):
|
|
26
|
+
self.__server.listen()
|
|
27
|
+
|
|
28
|
+
def close(self):
|
|
29
|
+
self.__server.close()
|