meshtrade 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of meshtrade might be problematic. Click here for more details.

Files changed (155) hide show
  1. buf/validate/validate_pb2.py +450 -0
  2. buf/validate/validate_pb2.pyi +627 -0
  3. meshtrade/common/__init__.py +28 -0
  4. meshtrade/common/config.py +30 -0
  5. meshtrade/common/grpc_client.py +202 -0
  6. meshtrade/compliance/client/v1/__init__.py +65 -7
  7. meshtrade/compliance/client/v1/client_pb2.py +2 -2
  8. meshtrade/compliance/client/v1/client_pb2_grpc.py +4 -0
  9. meshtrade/compliance/client/v1/company_pb2.py +2 -2
  10. meshtrade/compliance/client/v1/company_pb2_grpc.py +4 -0
  11. meshtrade/compliance/client/v1/company_representative_pb2.py +2 -2
  12. meshtrade/compliance/client/v1/company_representative_pb2_grpc.py +4 -0
  13. meshtrade/compliance/client/v1/company_representative_role_pb2.py +2 -2
  14. meshtrade/compliance/client/v1/company_representative_role_pb2_grpc.py +4 -0
  15. meshtrade/compliance/client/v1/fund_pb2.py +2 -2
  16. meshtrade/compliance/client/v1/fund_pb2_grpc.py +4 -0
  17. meshtrade/compliance/client/v1/identification_document_type_pb2.py +2 -2
  18. meshtrade/compliance/client/v1/identification_document_type_pb2_grpc.py +4 -0
  19. meshtrade/compliance/client/v1/industry_classification_pb2.py +2 -2
  20. meshtrade/compliance/client/v1/industry_classification_pb2_grpc.py +4 -0
  21. meshtrade/compliance/client/v1/natural_person_connection_type_pb2.py +2 -2
  22. meshtrade/compliance/client/v1/natural_person_connection_type_pb2_grpc.py +4 -0
  23. meshtrade/compliance/client/v1/natural_person_pb2.py +2 -2
  24. meshtrade/compliance/client/v1/natural_person_pb2_grpc.py +4 -0
  25. meshtrade/compliance/client/v1/pep_status_pb2.py +2 -2
  26. meshtrade/compliance/client/v1/pep_status_pb2_grpc.py +4 -0
  27. meshtrade/compliance/client/v1/service_meshpy.py +186 -0
  28. meshtrade/compliance/client/v1/service_options_meshpy.py +65 -0
  29. meshtrade/compliance/client/v1/service_pb2.py +20 -10
  30. meshtrade/compliance/client/v1/service_pb2.pyi +8 -0
  31. meshtrade/compliance/client/v1/service_pb2_grpc.py +192 -0
  32. meshtrade/compliance/client/v1/source_of_income_and_wealth_pb2.py +2 -2
  33. meshtrade/compliance/client/v1/source_of_income_and_wealth_pb2_grpc.py +4 -0
  34. meshtrade/compliance/client/v1/tax_residency_pb2.py +2 -2
  35. meshtrade/compliance/client/v1/tax_residency_pb2_grpc.py +4 -0
  36. meshtrade/compliance/client/v1/trust_pb2.py +2 -2
  37. meshtrade/compliance/client/v1/trust_pb2_grpc.py +4 -0
  38. meshtrade/compliance/client/v1/verification_status_pb2.py +2 -2
  39. meshtrade/compliance/client/v1/verification_status_pb2_grpc.py +4 -0
  40. meshtrade/iam/api_user/v1/__init__.py +99 -0
  41. meshtrade/iam/api_user/v1/api_credentials.py +156 -0
  42. meshtrade/iam/api_user/v1/api_credentials_pb2.py +42 -0
  43. meshtrade/iam/api_user/v1/api_credentials_pb2.pyi +14 -0
  44. meshtrade/iam/api_user/v1/api_credentials_pb2_grpc.py +4 -0
  45. meshtrade/iam/api_user/v1/api_user_pb2.py +48 -0
  46. meshtrade/iam/api_user/v1/api_user_pb2.pyi +49 -0
  47. meshtrade/iam/api_user/v1/api_user_pb2_grpc.py +4 -0
  48. meshtrade/iam/api_user/v1/service.py +58 -0
  49. meshtrade/iam/api_user/v1/service_meshpy.py +255 -0
  50. meshtrade/iam/api_user/v1/service_options_meshpy.py +65 -0
  51. meshtrade/iam/api_user/v1/service_pb2.py +77 -0
  52. meshtrade/iam/api_user/v1/service_pb2.pyi +63 -0
  53. meshtrade/iam/api_user/v1/service_pb2_grpc.py +458 -0
  54. meshtrade/iam/group/v1/__init__.py +59 -1
  55. meshtrade/iam/group/v1/group_pb2.py +2 -2
  56. meshtrade/iam/group/v1/group_pb2_grpc.py +4 -0
  57. meshtrade/iam/group/v1/service_meshpy.py +187 -0
  58. meshtrade/iam/group/v1/service_options_meshpy.py +65 -0
  59. meshtrade/iam/group/v1/service_pb2.py +22 -6
  60. meshtrade/iam/group/v1/service_pb2.pyi +29 -1
  61. meshtrade/iam/group/v1/service_pb2_grpc.py +170 -0
  62. meshtrade/iam/role/v1/__init__.py +44 -0
  63. meshtrade/iam/role/v1/role.py +23 -0
  64. meshtrade/iam/role/v1/role_pb2.py +40 -0
  65. meshtrade/{option/v1/auth_pb2.pyi → iam/role/v1/role_pb2.pyi} +16 -0
  66. meshtrade/iam/role/v1/role_pb2_grpc.py +4 -0
  67. meshtrade/iam/user/v1/__init__.py +53 -0
  68. meshtrade/iam/user/v1/service_meshpy.py +151 -0
  69. meshtrade/iam/user/v1/service_options_meshpy.py +65 -0
  70. meshtrade/iam/user/v1/service_pb2.py +51 -0
  71. meshtrade/iam/user/v1/service_pb2.pyi +19 -0
  72. meshtrade/iam/user/v1/service_pb2_grpc.py +82 -0
  73. meshtrade/{issuance_hub/instrument/v1/instrument_pb2.py → iam/user/v1/user_pb2.py} +7 -7
  74. meshtrade/iam/user/v1/user_pb2.pyi +15 -0
  75. meshtrade/iam/user/v1/user_pb2_grpc.py +4 -0
  76. meshtrade/ledger/transaction/v1/__init__.py +34 -0
  77. meshtrade/ledger/transaction/v1/transaction_action_pb2.py +2 -2
  78. meshtrade/ledger/transaction/v1/transaction_action_pb2_grpc.py +4 -0
  79. meshtrade/ledger/transaction/v1/transaction_state_pb2.py +2 -2
  80. meshtrade/ledger/transaction/v1/transaction_state_pb2_grpc.py +4 -0
  81. meshtrade/option/v1/__init__.py +36 -4
  82. meshtrade/option/v1/{service_type_pb2.py → method_type_pb2.py} +7 -7
  83. meshtrade/option/v1/method_type_pb2.pyi +17 -0
  84. meshtrade/option/v1/method_type_pb2_grpc.py +4 -0
  85. meshtrade/trading/limit_order/v1/__init__.py +47 -1
  86. meshtrade/trading/limit_order/v1/limit_order_pb2.py +2 -2
  87. meshtrade/trading/limit_order/v1/limit_order_pb2_grpc.py +4 -0
  88. meshtrade/trading/limit_order/v1/service_meshpy.py +151 -0
  89. meshtrade/trading/limit_order/v1/service_options_meshpy.py +65 -0
  90. meshtrade/trading/limit_order/v1/service_pb2.py +10 -6
  91. meshtrade/trading/limit_order/v1/service_pb2.pyi +2 -0
  92. meshtrade/trading/limit_order/v1/service_pb2_grpc.py +78 -0
  93. meshtrade/trading/market_order/v1/__init__.py +53 -0
  94. meshtrade/trading/{direct_order/v1/direct_order_pb2.py → market_order/v1/market_order_pb2.py} +7 -7
  95. meshtrade/trading/{spot/v1/spot_pb2.pyi → market_order/v1/market_order_pb2.pyi} +1 -1
  96. meshtrade/trading/market_order/v1/market_order_pb2_grpc.py +4 -0
  97. meshtrade/trading/market_order/v1/service_meshpy.py +151 -0
  98. meshtrade/trading/market_order/v1/service_options_meshpy.py +65 -0
  99. meshtrade/trading/market_order/v1/service_pb2.py +44 -0
  100. meshtrade/trading/{spot → market_order}/v1/service_pb2.pyi +4 -2
  101. meshtrade/trading/market_order/v1/service_pb2_grpc.py +78 -0
  102. meshtrade/type/v1/__init__.py +89 -50
  103. meshtrade/type/v1/address_pb2.py +2 -2
  104. meshtrade/type/v1/address_pb2_grpc.py +4 -0
  105. meshtrade/type/v1/amount.py +2 -8
  106. meshtrade/type/v1/amount_pb2.py +2 -2
  107. meshtrade/type/v1/amount_pb2_grpc.py +4 -0
  108. meshtrade/type/v1/contact_details_pb2.py +2 -2
  109. meshtrade/type/v1/contact_details_pb2_grpc.py +4 -0
  110. meshtrade/type/v1/date.py +263 -91
  111. meshtrade/type/v1/date_pb2.py +2 -2
  112. meshtrade/type/v1/date_pb2_grpc.py +4 -0
  113. meshtrade/type/v1/decimal_built_in_conversions.py +1 -1
  114. meshtrade/type/v1/decimal_pb2.py +2 -2
  115. meshtrade/type/v1/decimal_pb2_grpc.py +4 -0
  116. meshtrade/type/v1/ledger.py +1 -1
  117. meshtrade/type/v1/ledger_pb2.py +2 -2
  118. meshtrade/type/v1/ledger_pb2_grpc.py +4 -0
  119. meshtrade/type/v1/time_of_day.py +52 -87
  120. meshtrade/type/v1/time_of_day_pb2.py +2 -2
  121. meshtrade/type/v1/time_of_day_pb2_grpc.py +4 -0
  122. meshtrade/type/v1/token_pb2.py +2 -2
  123. meshtrade/type/v1/token_pb2_grpc.py +4 -0
  124. meshtrade/wallet/account/v1/__init__.py +46 -0
  125. meshtrade/wallet/account/v1/account_pb2.py +2 -2
  126. meshtrade/wallet/account/v1/account_pb2_grpc.py +4 -0
  127. meshtrade/wallet/account/v1/service_meshpy.py +204 -0
  128. meshtrade/wallet/account/v1/service_options_meshpy.py +65 -0
  129. meshtrade/wallet/account/v1/service_pb2.py +18 -18
  130. meshtrade/wallet/account/v1/service_pb2.pyi +2 -2
  131. meshtrade/wallet/account/v1/service_pb2_grpc.py +222 -0
  132. meshtrade-0.0.10.dist-info/METADATA +95 -0
  133. meshtrade-0.0.10.dist-info/RECORD +173 -0
  134. {meshtrade-0.0.8.dist-info → meshtrade-0.0.10.dist-info}/top_level.txt +1 -0
  135. meshtrade/issuance_hub/__init__.py +0 -0
  136. meshtrade/issuance_hub/instrument/__init__.py +0 -0
  137. meshtrade/issuance_hub/instrument/v1/__init__.py +0 -11
  138. meshtrade/issuance_hub/instrument/v1/instrument_pb2.pyi +0 -11
  139. meshtrade/issuance_hub/instrument/v1/service_pb2.py +0 -49
  140. meshtrade/issuance_hub/instrument/v1/service_pb2.pyi +0 -46
  141. meshtrade/option/v1/auth_pb2.py +0 -40
  142. meshtrade/option/v1/service_type_pb2.pyi +0 -17
  143. meshtrade/trading/direct_order/__init__.py +0 -0
  144. meshtrade/trading/direct_order/v1/__init__.py +0 -7
  145. meshtrade/trading/direct_order/v1/direct_order_pb2.pyi +0 -11
  146. meshtrade/trading/direct_order/v1/service_pb2.py +0 -40
  147. meshtrade/trading/direct_order/v1/service_pb2.pyi +0 -12
  148. meshtrade/trading/spot/__init__.py +0 -0
  149. meshtrade/trading/spot/v1/__init__.py +0 -7
  150. meshtrade/trading/spot/v1/service_pb2.py +0 -40
  151. meshtrade/trading/spot/v1/spot_pb2.py +0 -37
  152. meshtrade-0.0.8.dist-info/METADATA +0 -35
  153. meshtrade-0.0.8.dist-info/RECORD +0 -113
  154. meshtrade-0.0.8.dist-info/licenses/LICENSE +0 -10
  155. {meshtrade-0.0.8.dist-info → meshtrade-0.0.10.dist-info}/WHEEL +0 -0
@@ -0,0 +1,99 @@
1
+ """Api User v1 package."""
2
+
3
+ # ===================================================================
4
+ # AUTO-GENERATED SECTION - ONLY EDIT BELOW THE CLOSING COMMENT BLOCK
5
+ # ===================================================================
6
+ # This section is automatically managed by protoc-gen-meshpy.
7
+ #
8
+ # DO NOT EDIT ANYTHING IN THIS SECTION MANUALLY!
9
+ # Your changes will be overwritten during code generation.
10
+ #
11
+ # To add custom imports and exports, scroll down to the
12
+ # "MANUAL SECTION" indicated below.
13
+ # ===================================================================
14
+
15
+ # Generated protobuf imports
16
+ from .api_credentials_pb2 import APICredentials
17
+ from .api_user_pb2 import APIUser, APIUserAction, APIUserState
18
+ from .service_pb2 import (
19
+ ActivateApiUserRequest,
20
+ CreateApiUserRequest,
21
+ DeactivateApiUserRequest,
22
+ GetApiUserByKeyHashRequest,
23
+ GetApiUserRequest,
24
+ ListApiUsersRequest,
25
+ ListApiUsersResponse,
26
+ SearchApiUsersRequest,
27
+ SearchApiUsersResponse,
28
+ )
29
+
30
+ # Generated service imports
31
+ from .service_meshpy import (
32
+ ApiUserService,
33
+ ApiUserServiceGRPCClient,
34
+ ApiUserServiceGRPCClientInterface,
35
+ )
36
+ from .service_options_meshpy import ClientOptions
37
+
38
+ # ===================================================================
39
+ # END OF AUTO-GENERATED SECTION
40
+ # ===================================================================
41
+ #
42
+ # MANUAL SECTION - ADD YOUR CUSTOM IMPORTS AND EXPORTS BELOW
43
+ #
44
+ # You can safely add your own imports, functions, classes, and exports
45
+ # in this section. They will be preserved across code generation.
46
+ #
47
+ # Example:
48
+ # from my_custom_module import my_function
49
+ #
50
+ # ===================================================================
51
+
52
+ from meshtrade.common import (
53
+ DEFAULT_GRPC_PORT,
54
+ DEFAULT_GRPC_URL,
55
+ DEFAULT_TLS,
56
+ GRPCClient,
57
+ create_auth_metadata,
58
+ )
59
+
60
+ # Import credentials functions from local module
61
+ from .api_credentials import (
62
+ MESH_API_CREDENTIALS_ENV_VAR,
63
+ api_credentials_from_environment,
64
+ load_api_credentials_from_file,
65
+ )
66
+
67
+ # ===================================================================
68
+ # MODULE EXPORTS
69
+ # ===================================================================
70
+ # Combined auto-generated and manual exports
71
+ __all__ = [
72
+ # Generated exports
73
+ "APICredentials",
74
+ "APIUser",
75
+ "APIUserAction",
76
+ "APIUserState",
77
+ "ActivateApiUserRequest",
78
+ "ApiUserService",
79
+ "ApiUserServiceGRPCClient",
80
+ "ApiUserServiceGRPCClientInterface",
81
+ "ClientOptions",
82
+ "CreateApiUserRequest",
83
+ "DeactivateApiUserRequest",
84
+ "GetApiUserByKeyHashRequest",
85
+ "GetApiUserRequest",
86
+ "ListApiUsersRequest",
87
+ "ListApiUsersResponse",
88
+ "SearchApiUsersRequest",
89
+ "SearchApiUsersResponse",
90
+ # Manual exports
91
+ "DEFAULT_GRPC_PORT",
92
+ "DEFAULT_GRPC_URL",
93
+ "DEFAULT_TLS",
94
+ "GRPCClient",
95
+ "MESH_API_CREDENTIALS_ENV_VAR",
96
+ "api_credentials_from_environment",
97
+ "create_auth_metadata",
98
+ "load_api_credentials_from_file",
99
+ ]
@@ -0,0 +1,156 @@
1
+ """
2
+ API Credentials loading functionality for Meshtrade SDK.
3
+ """
4
+
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+ import platformdirs
10
+
11
+ from .api_credentials_pb2 import APICredentials
12
+
13
+ MESH_API_CREDENTIALS_ENV_VAR = "MESH_API_CREDENTIALS"
14
+
15
+
16
+ def load_api_credentials_from_file(path: str) -> APICredentials:
17
+ """Load API credentials from a JSON file.
18
+
19
+ Args:
20
+ path: Path to the credentials JSON file
21
+
22
+ Returns:
23
+ APICredentials object with loaded credentials
24
+
25
+ Raises:
26
+ FileNotFoundError: If the credentials file doesn't exist
27
+ ValueError: If the credentials file is invalid or missing required fields
28
+ """
29
+ try:
30
+ with open(path) as f:
31
+ data = json.load(f)
32
+ except FileNotFoundError as e:
33
+ raise FileNotFoundError(f"Failed to read API credentials file: {path}") from e
34
+ except json.JSONDecodeError as e:
35
+ raise ValueError(f"Failed to parse API credentials file: {e}") from e
36
+
37
+ api_key = data.get("api_key")
38
+ group = data.get("group")
39
+
40
+ if not api_key:
41
+ raise ValueError("api_key is required in API credentials file")
42
+
43
+ if not group:
44
+ raise ValueError("group is required in API credentials file")
45
+
46
+ if not group.startswith("groups/"):
47
+ raise ValueError(f"group must be in format groups/{{group_id}}, got: {group}")
48
+
49
+ creds = APICredentials()
50
+ creds.api_key = api_key
51
+ creds.group = group
52
+
53
+ return creds
54
+
55
+
56
+ def api_credentials_from_environment() -> APICredentials | None:
57
+ """Load API credentials from the file path specified in MESH_API_CREDENTIALS environment variable.
58
+
59
+ Returns:
60
+ APICredentials object if environment variable is set and file exists, None otherwise
61
+
62
+ Raises:
63
+ ValueError: If the credentials file is invalid
64
+ """
65
+ path = os.getenv(MESH_API_CREDENTIALS_ENV_VAR)
66
+ if not path:
67
+ return None
68
+
69
+ return load_api_credentials_from_file(path)
70
+
71
+
72
+ def default_credentials_path() -> str:
73
+ """
74
+ Calculates the OS-specific default path for Mesh API credentials.
75
+
76
+ This function determines the standard user configuration directory based on
77
+ the operating system's conventions and returns the full path to the
78
+ 'credentials.json' file within a 'mesh' subdirectory. It is a Pythonic
79
+ implementation of the equivalent Go function.
80
+
81
+ The target path is constructed as follows:
82
+ - **Linux**: `$XDG_CONFIG_HOME/mesh/credentials.json` or fallback to `$HOME/.config/mesh/credentials.json`
83
+ - **macOS**: `$HOME/Library/Application Support/mesh/credentials.json`
84
+ - **Windows**: `C:\\Users\\<user>\\AppData\\Roaming\\mesh\\credentials.json`
85
+
86
+ Returns:
87
+ A string representing the full, absolute path to the credentials file.
88
+ If the user's home or config directory cannot be determined, it returns
89
+ an empty string to match the original Go function's behavior.
90
+ """
91
+ try:
92
+ # Use platformdirs to find the appropriate user config directory for the 'mesh' app.
93
+ # This correctly handles all OS-specific paths and environment variables.
94
+ # e.g., on Linux, it returns '~/.config/mesh'
95
+ mesh_config_dir = platformdirs.user_config_dir(appname="mesh")
96
+
97
+ # Use the modern `pathlib` to reliably construct the final file path.
98
+ # The '/' operator is overloaded for joining path components.
99
+ credentials_path = Path(mesh_config_dir) / "credentials.json"
100
+
101
+ # Return the path as a string.
102
+ return str(credentials_path)
103
+
104
+ except Exception as e:
105
+ # If platformdirs raises an error (e.g., HOME directory not found),
106
+ # catch it and return an empty string, mimicking the Go function's
107
+ # behavior on failure.
108
+ print(f"Warning: Could not determine credentials path. Error: {e}")
109
+ return ""
110
+
111
+
112
+ def load_default_credentials() -> APICredentials | None:
113
+ """Load API credentials from the default location if the file exists.
114
+
115
+ Returns:
116
+ APICredentials object if default file exists and is valid, None otherwise
117
+
118
+ Raises:
119
+ ValueError: If the credentials file exists but is invalid
120
+ """
121
+ path = default_credentials_path()
122
+
123
+ # Check if file exists before attempting to load
124
+ if not os.path.isfile(path):
125
+ return None
126
+
127
+ return load_api_credentials_from_file(path)
128
+
129
+
130
+ def find_credentials() -> APICredentials | None:
131
+ """Search for API credentials using the standard discovery hierarchy.
132
+
133
+ Discovery order:
134
+ 1. MESH_API_CREDENTIALS environment variable (if set)
135
+ 2. Default credential file location
136
+ - **Linux**: `$XDG_CONFIG_HOME/mesh/credentials.json` or fallback to `$HOME/.config/mesh/credentials.json`
137
+ - **macOS**: `$HOME/Library/Application Support/mesh/credentials.json`
138
+ - **Windows**: `C:\\Users\\<user>\\AppData\\Roaming\\mesh\\credentials.json`
139
+
140
+ Returns:
141
+ APICredentials object if found using any method, None if no credentials found
142
+
143
+ Raises:
144
+ ValueError: If a credentials file is found but is invalid
145
+ """
146
+ # Try environment variable first (existing behavior)
147
+ creds = api_credentials_from_environment()
148
+ if creds:
149
+ return creds
150
+
151
+ # Try default file location
152
+ creds = load_default_credentials()
153
+ if creds:
154
+ return creds
155
+
156
+ return None
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: meshtrade/iam/api_user/v1/api_credentials.proto
5
+ # Protobuf Python Version: 6.31.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 1,
17
+ '',
18
+ 'meshtrade/iam/api_user/v1/api_credentials.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n/meshtrade/iam/api_user/v1/api_credentials.proto\x12\x19meshtrade.iam.api_user.v1\x1a\x1b\x62uf/validate/validate.proto\"\x81\x05\n\x0e\x41PICredentials\x12\xbd\x02\n\x07\x61pi_key\x18\x01 \x01(\tB\xa3\x02\xbaH\x9f\x02r\x18\x32\x13^[A-Za-z0-9_-]{43}$\x98\x01+\xba\x01u\n\x10\x61pi_key.required\x12Oapi_key is required and must be exactly 43 characters (base64 URL-safe encoded)\x1a\x10size(this) == 43\xba\x01\x89\x01\n\x0e\x61pi_key.format\x12Rapi_key must be base64 URL-safe encoded (43 characters, alphanumeric plus _ and -)\x1a#this.matches(\'^[A-Za-z0-9_-]{43}$\')R\x06\x61piKey\x12\xae\x02\n\x05group\x18\x02 \x01(\tB\x97\x02\xbaH\x93\x02r\x1a\x32\x15^groups/[0-9A-Z]{26}$\x98\x01!\xba\x01Y\n\x0egroup.required\x12\x35group is required and must be in format groups/{ulid}\x1a\x10size(this) == 33\xba\x01\x97\x01\n\x0cgroup.format\x12`group must be in format groups/{ulid} where ulid is a 26-character ULID (uppercase alphanumeric)\x1a%this.matches(\'^groups/[0-9A-Z]{26}$\')R\x05groupBZ\n co.meshtrade.api.iam.api_user.v1Z6github.com/meshtrade/api/go/iam/api_user/v1;api_userv1b\x06proto3')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'meshtrade.iam.api_user.v1.api_credentials_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ _globals['DESCRIPTOR']._loaded_options = None
35
+ _globals['DESCRIPTOR']._serialized_options = b'\n co.meshtrade.api.iam.api_user.v1Z6github.com/meshtrade/api/go/iam/api_user/v1;api_userv1'
36
+ _globals['_APICREDENTIALS'].fields_by_name['api_key']._loaded_options = None
37
+ _globals['_APICREDENTIALS'].fields_by_name['api_key']._serialized_options = b'\272H\237\002r\0302\023^[A-Za-z0-9_-]{43}$\230\001+\272\001u\n\020api_key.required\022Oapi_key is required and must be exactly 43 characters (base64 URL-safe encoded)\032\020size(this) == 43\272\001\211\001\n\016api_key.format\022Rapi_key must be base64 URL-safe encoded (43 characters, alphanumeric plus _ and -)\032#this.matches(\'^[A-Za-z0-9_-]{43}$\')'
38
+ _globals['_APICREDENTIALS'].fields_by_name['group']._loaded_options = None
39
+ _globals['_APICREDENTIALS'].fields_by_name['group']._serialized_options = b'\272H\223\002r\0322\025^groups/[0-9A-Z]{26}$\230\001!\272\001Y\n\016group.required\0225group is required and must be in format groups/{ulid}\032\020size(this) == 33\272\001\227\001\n\014group.format\022`group must be in format groups/{ulid} where ulid is a 26-character ULID (uppercase alphanumeric)\032%this.matches(\'^groups/[0-9A-Z]{26}$\')'
40
+ _globals['_APICREDENTIALS']._serialized_start=108
41
+ _globals['_APICREDENTIALS']._serialized_end=749
42
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,14 @@
1
+ from buf.validate import validate_pb2 as _validate_pb2
2
+ from google.protobuf import descriptor as _descriptor
3
+ from google.protobuf import message as _message
4
+ from typing import ClassVar as _ClassVar, Optional as _Optional
5
+
6
+ DESCRIPTOR: _descriptor.FileDescriptor
7
+
8
+ class APICredentials(_message.Message):
9
+ __slots__ = ("api_key", "group")
10
+ API_KEY_FIELD_NUMBER: _ClassVar[int]
11
+ GROUP_FIELD_NUMBER: _ClassVar[int]
12
+ api_key: str
13
+ group: str
14
+ def __init__(self, api_key: _Optional[str] = ..., group: _Optional[str] = ...) -> None: ...
@@ -0,0 +1,4 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: meshtrade/iam/api_user/v1/api_user.proto
5
+ # Protobuf Python Version: 6.31.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 1,
17
+ '',
18
+ 'meshtrade/iam/api_user/v1/api_user.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n(meshtrade/iam/api_user/v1/api_user.proto\x12\x19meshtrade.iam.api_user.v1\x1a\x1b\x62uf/validate/validate.proto\"\xd9\x06\n\x07\x41PIUser\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\xfd\x02\n\x05owner\x18\x02 \x01(\tB\xe6\x02\xbaH\xe2\x02r4\x10\x01\x32\x30^groups/[a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$\xba\x01[\n\x0eowner.required\x12\x39owner is required and must be in format groups/{group_id}\x1a\x0esize(this) > 0\xba\x01\xca\x01\n\x0cowner.format\x12xowner must be in format groups/{group_id} where group_id contains only alphanumeric characters, underscores, and hyphens\x1a@this.matches(\'^groups/[a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$\')R\x05owner\x12\x16\n\x06owners\x18\x03 \x03(\tR\x06owners\x12\xb1\x01\n\x0c\x64isplay_name\x18\x04 \x01(\tB\x8d\x01\xbaH\x89\x01r\x05\x10\x01\x18\xff\x01\xba\x01\x7f\n\x15\x64isplay_name.required\x12\x41\x64isplay name is required and must be between 1 and 255 characters\x1a#size(this) > 0 && size(this) <= 255R\x0b\x64isplayName\x12\xbe\x01\n\x05state\x18\x05 \x01(\x0e\x32\'.meshtrade.iam.api_user.v1.APIUserStateB\x7f\xbaH|\x82\x01\x02\x10\x01\xba\x01t\n\x0bstate.valid\x12/state must be a valid APIUserState if specified\x1a\x34int(this) == 0 || (int(this) >= 1 && int(this) <= 2)R\x05state\x12\x14\n\x05roles\x18\x06 \x03(\tR\x05roles\x12\x17\n\x07\x61pi_key\x18\x07 \x01(\tR\x06\x61piKey*f\n\x0c\x41PIUserState\x12\x1e\n\x1a\x41PI_USER_STATE_UNSPECIFIED\x10\x00\x12\x19\n\x15\x41PI_USER_STATE_ACTIVE\x10\x01\x12\x1b\n\x17\x41PI_USER_STATE_INACTIVE\x10\x02*\xa6\x01\n\rAPIUserAction\x12\x1f\n\x1b\x41PI_USER_ACTION_UNSPECIFIED\x10\x00\x12\x1c\n\x18\x41PI_USER_ACTION_ACTIVATE\x10\x01\x12\x1e\n\x1a\x41PI_USER_ACTION_DEACTIVATE\x10\x02\x12\x1a\n\x16\x41PI_USER_ACTION_CREATE\x10\x03\x12\x1a\n\x16\x41PI_USER_ACTION_UPDATE\x10\x04\x42Z\n co.meshtrade.api.iam.api_user.v1Z6github.com/meshtrade/api/go/iam/api_user/v1;api_userv1b\x06proto3')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'meshtrade.iam.api_user.v1.api_user_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ _globals['DESCRIPTOR']._loaded_options = None
35
+ _globals['DESCRIPTOR']._serialized_options = b'\n co.meshtrade.api.iam.api_user.v1Z6github.com/meshtrade/api/go/iam/api_user/v1;api_userv1'
36
+ _globals['_APIUSER'].fields_by_name['owner']._loaded_options = None
37
+ _globals['_APIUSER'].fields_by_name['owner']._serialized_options = b'\272H\342\002r4\020\00120^groups/[a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$\272\001[\n\016owner.required\0229owner is required and must be in format groups/{group_id}\032\016size(this) > 0\272\001\312\001\n\014owner.format\022xowner must be in format groups/{group_id} where group_id contains only alphanumeric characters, underscores, and hyphens\032@this.matches(\'^groups/[a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$\')'
38
+ _globals['_APIUSER'].fields_by_name['display_name']._loaded_options = None
39
+ _globals['_APIUSER'].fields_by_name['display_name']._serialized_options = b'\272H\211\001r\005\020\001\030\377\001\272\001\177\n\025display_name.required\022Adisplay name is required and must be between 1 and 255 characters\032#size(this) > 0 && size(this) <= 255'
40
+ _globals['_APIUSER'].fields_by_name['state']._loaded_options = None
41
+ _globals['_APIUSER'].fields_by_name['state']._serialized_options = b'\272H|\202\001\002\020\001\272\001t\n\013state.valid\022/state must be a valid APIUserState if specified\0324int(this) == 0 || (int(this) >= 1 && int(this) <= 2)'
42
+ _globals['_APIUSERSTATE']._serialized_start=960
43
+ _globals['_APIUSERSTATE']._serialized_end=1062
44
+ _globals['_APIUSERACTION']._serialized_start=1065
45
+ _globals['_APIUSERACTION']._serialized_end=1231
46
+ _globals['_APIUSER']._serialized_start=101
47
+ _globals['_APIUSER']._serialized_end=958
48
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,49 @@
1
+ from buf.validate import validate_pb2 as _validate_pb2
2
+ from google.protobuf.internal import containers as _containers
3
+ from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
4
+ from google.protobuf import descriptor as _descriptor
5
+ from google.protobuf import message as _message
6
+ from collections.abc import Iterable as _Iterable
7
+ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
8
+
9
+ DESCRIPTOR: _descriptor.FileDescriptor
10
+
11
+ class APIUserState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
12
+ __slots__ = ()
13
+ API_USER_STATE_UNSPECIFIED: _ClassVar[APIUserState]
14
+ API_USER_STATE_ACTIVE: _ClassVar[APIUserState]
15
+ API_USER_STATE_INACTIVE: _ClassVar[APIUserState]
16
+
17
+ class APIUserAction(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
18
+ __slots__ = ()
19
+ API_USER_ACTION_UNSPECIFIED: _ClassVar[APIUserAction]
20
+ API_USER_ACTION_ACTIVATE: _ClassVar[APIUserAction]
21
+ API_USER_ACTION_DEACTIVATE: _ClassVar[APIUserAction]
22
+ API_USER_ACTION_CREATE: _ClassVar[APIUserAction]
23
+ API_USER_ACTION_UPDATE: _ClassVar[APIUserAction]
24
+ API_USER_STATE_UNSPECIFIED: APIUserState
25
+ API_USER_STATE_ACTIVE: APIUserState
26
+ API_USER_STATE_INACTIVE: APIUserState
27
+ API_USER_ACTION_UNSPECIFIED: APIUserAction
28
+ API_USER_ACTION_ACTIVATE: APIUserAction
29
+ API_USER_ACTION_DEACTIVATE: APIUserAction
30
+ API_USER_ACTION_CREATE: APIUserAction
31
+ API_USER_ACTION_UPDATE: APIUserAction
32
+
33
+ class APIUser(_message.Message):
34
+ __slots__ = ("name", "owner", "owners", "display_name", "state", "roles", "api_key")
35
+ NAME_FIELD_NUMBER: _ClassVar[int]
36
+ OWNER_FIELD_NUMBER: _ClassVar[int]
37
+ OWNERS_FIELD_NUMBER: _ClassVar[int]
38
+ DISPLAY_NAME_FIELD_NUMBER: _ClassVar[int]
39
+ STATE_FIELD_NUMBER: _ClassVar[int]
40
+ ROLES_FIELD_NUMBER: _ClassVar[int]
41
+ API_KEY_FIELD_NUMBER: _ClassVar[int]
42
+ name: str
43
+ owner: str
44
+ owners: _containers.RepeatedScalarFieldContainer[str]
45
+ display_name: str
46
+ state: APIUserState
47
+ roles: _containers.RepeatedScalarFieldContainer[str]
48
+ api_key: str
49
+ def __init__(self, name: _Optional[str] = ..., owner: _Optional[str] = ..., owners: _Optional[_Iterable[str]] = ..., display_name: _Optional[str] = ..., state: _Optional[_Union[APIUserState, str]] = ..., roles: _Optional[_Iterable[str]] = ..., api_key: _Optional[str] = ...) -> None: ...
@@ -0,0 +1,4 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+
@@ -0,0 +1,58 @@
1
+ """
2
+ ApiUserService interface definition.
3
+ """
4
+
5
+ from abc import ABC, abstractmethod
6
+ from datetime import timedelta
7
+
8
+ from .api_user_pb2 import APIUser
9
+ from .service_pb2 import (
10
+ ActivateApiUserRequest,
11
+ CreateApiUserRequest,
12
+ DeactivateApiUserRequest,
13
+ GetApiUserByKeyHashRequest,
14
+ GetApiUserRequest,
15
+ ListApiUsersRequest,
16
+ ListApiUsersResponse,
17
+ SearchApiUsersRequest,
18
+ SearchApiUsersResponse,
19
+ )
20
+
21
+
22
+ class ApiUserService(ABC):
23
+ """Abstract base class defining the ApiUserService interface."""
24
+
25
+ @abstractmethod
26
+ def get_api_user(self, request: GetApiUserRequest, timeout: timedelta | None = None) -> APIUser:
27
+ """Get an API user by name."""
28
+ pass
29
+
30
+ @abstractmethod
31
+ def create_api_user(self, request: CreateApiUserRequest, timeout: timedelta | None = None) -> APIUser:
32
+ """Create a new API user."""
33
+ pass
34
+
35
+ @abstractmethod
36
+ def list_api_users(self, request: ListApiUsersRequest, timeout: timedelta | None = None) -> ListApiUsersResponse:
37
+ """List API users."""
38
+ pass
39
+
40
+ @abstractmethod
41
+ def search_api_users(self, request: SearchApiUsersRequest, timeout: timedelta | None = None) -> SearchApiUsersResponse:
42
+ """Search API users by display name."""
43
+ pass
44
+
45
+ @abstractmethod
46
+ def activate_api_user(self, request: ActivateApiUserRequest, timeout: timedelta | None = None) -> APIUser:
47
+ """Activate an API user."""
48
+ pass
49
+
50
+ @abstractmethod
51
+ def deactivate_api_user(self, request: DeactivateApiUserRequest, timeout: timedelta | None = None) -> APIUser:
52
+ """Deactivate an API user."""
53
+ pass
54
+
55
+ @abstractmethod
56
+ def get_api_user_by_key_hash(self, request: GetApiUserByKeyHashRequest, timeout: timedelta | None = None) -> APIUser:
57
+ """Get an API user by key hash."""
58
+ pass