microsoft-agents-storage-cosmos 0.6.0.dev8__py3-none-any.whl → 0.6.0.dev10__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.
@@ -20,6 +20,7 @@ from azure.cosmos.partition_key import NonePartitionKeyValue
20
20
  from microsoft_agents.hosting.core.storage import AsyncStorageBase, StoreItem
21
21
  from microsoft_agents.hosting.core.storage._type_aliases import JSON
22
22
  from microsoft_agents.hosting.core.storage.error_handling import ignore_error
23
+ from microsoft_agents.storage.cosmos.errors import storage_errors
23
24
 
24
25
  from .cosmos_db_storage_config import CosmosDBStorageConfig
25
26
  from .key_ops import sanitize_key
@@ -55,7 +56,9 @@ class CosmosDBStorage(AsyncStorageBase):
55
56
  if self._config.url:
56
57
  if not self._config.credential:
57
58
  raise ValueError(
58
- "CosmosDBStorage: Credential is required when using a custom service URL."
59
+ storage_errors.InvalidConfiguration.format(
60
+ "Credential is required when using a custom service URL"
61
+ )
59
62
  )
60
63
  return CosmosClient(
61
64
  account_url=self._config.url, credential=self._config.credential
@@ -89,7 +92,7 @@ class CosmosDBStorage(AsyncStorageBase):
89
92
  ) -> tuple[Union[str, None], Union[StoreItemT, None]]:
90
93
 
91
94
  if key == "":
92
- raise ValueError("CosmosDBStorage: Key cannot be empty.")
95
+ raise ValueError(str(storage_errors.CosmosDbKeyCannotBeEmpty))
93
96
 
94
97
  escaped_key: str = self._sanitize(key)
95
98
  read_item_response: CosmosDict = await ignore_error(
@@ -106,7 +109,7 @@ class CosmosDBStorage(AsyncStorageBase):
106
109
 
107
110
  async def _write_item(self, key: str, item: StoreItem) -> None:
108
111
  if key == "":
109
- raise ValueError("CosmosDBStorage: Key cannot be empty.")
112
+ raise ValueError(str(storage_errors.CosmosDbKeyCannotBeEmpty))
110
113
 
111
114
  escaped_key: str = self._sanitize(key)
112
115
 
@@ -119,7 +122,7 @@ class CosmosDBStorage(AsyncStorageBase):
119
122
 
120
123
  async def _delete_item(self, key: str) -> None:
121
124
  if key == "":
122
- raise ValueError("CosmosDBStorage: Key cannot be empty.")
125
+ raise ValueError(str(storage_errors.CosmosDbKeyCannotBeEmpty))
123
126
 
124
127
  escaped_key: str = self._sanitize(key)
125
128
 
@@ -156,8 +159,9 @@ class CosmosDBStorage(AsyncStorageBase):
156
159
  self._compatability_mode_partition_key = True
157
160
  elif "/id" not in paths:
158
161
  raise Exception(
159
- f"Custom Partition Key Paths are not supported. {self._config.container_id} "
160
- "has a custom Partition Key Path of {paths[0]}."
162
+ storage_errors.InvalidConfiguration.format(
163
+ f"Custom Partition Key Paths are not supported. {self._config.container_id} has a custom Partition Key Path of {paths[0]}."
164
+ )
161
165
  )
162
166
  else:
163
167
  raise err
@@ -2,6 +2,7 @@ import json
2
2
  from typing import Union
3
3
 
4
4
  from azure.core.credentials import TokenCredential
5
+ from microsoft_agents.storage.cosmos.errors import storage_errors
5
6
 
6
7
  from .key_ops import sanitize_key
7
8
 
@@ -69,15 +70,15 @@ class CosmosDBStorageConfig:
69
70
 
70
71
  This is used prior to the creation of the CosmosDBStorage object."""
71
72
  if not config:
72
- raise ValueError("CosmosDBStorage: CosmosDBConfig is required.")
73
+ raise ValueError(str(storage_errors.CosmosDbConfigRequired))
73
74
  if not config.cosmos_db_endpoint:
74
- raise ValueError("CosmosDBStorage: cosmos_db_endpoint is required.")
75
+ raise ValueError(str(storage_errors.CosmosDbEndpointRequired))
75
76
  if not config.auth_key:
76
- raise ValueError("CosmosDBStorage: auth_key is required.")
77
+ raise ValueError(str(storage_errors.CosmosDbAuthKeyRequired))
77
78
  if not config.database_id:
78
- raise ValueError("CosmosDBStorage: database_id is required.")
79
+ raise ValueError(str(storage_errors.CosmosDbDatabaseIdRequired))
79
80
  if not config.container_id:
80
- raise ValueError("CosmosDBStorage: container_id is required.")
81
+ raise ValueError(str(storage_errors.CosmosDbContainerIdRequired))
81
82
 
82
83
  CosmosDBStorageConfig._validate_suffix(config)
83
84
 
@@ -85,11 +86,11 @@ class CosmosDBStorageConfig:
85
86
  def _validate_suffix(config: "CosmosDBStorageConfig") -> None:
86
87
  if config.key_suffix:
87
88
  if config.compatibility_mode:
88
- raise ValueError(
89
- "compatibilityMode cannot be true while using a keySuffix."
90
- )
89
+ raise ValueError(str(storage_errors.CosmosDbCompatibilityModeRequired))
91
90
  suffix_escaped: str = sanitize_key(config.key_suffix)
92
91
  if suffix_escaped != config.key_suffix:
93
92
  raise ValueError(
94
- f"Cannot use invalid Row Key characters: {config.key_suffix} in keySuffix."
93
+ storage_errors.CosmosDbInvalidKeySuffixCharacters.format(
94
+ config.key_suffix
95
+ )
95
96
  )
@@ -0,0 +1,15 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
4
+ """
5
+ Error resources for Microsoft Agents Storage Cosmos package.
6
+ """
7
+
8
+ from microsoft_agents.hosting.core.errors import ErrorMessage
9
+
10
+ from .error_resources import StorageErrorResources
11
+
12
+ # Singleton instance
13
+ storage_errors = StorageErrorResources()
14
+
15
+ __all__ = ["ErrorMessage", "StorageErrorResources", "storage_errors"]
@@ -0,0 +1,100 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
4
+ """
5
+ Storage error resources for Microsoft Agents SDK (CosmosDB).
6
+
7
+ Error codes are in the range -61000 to -61999.
8
+ """
9
+
10
+ from microsoft_agents.hosting.core.errors import ErrorMessage
11
+
12
+
13
+ class StorageErrorResources:
14
+ """
15
+ Error messages for storage operations (CosmosDB).
16
+
17
+ Error codes are organized in the range -61000 to -61999.
18
+ """
19
+
20
+ CosmosDbConfigRequired = ErrorMessage(
21
+ "CosmosDBStorage: CosmosDBConfig is required.",
22
+ -61000,
23
+ "storage-configuration",
24
+ )
25
+
26
+ CosmosDbEndpointRequired = ErrorMessage(
27
+ "CosmosDBStorage: cosmos_db_endpoint is required.",
28
+ -61001,
29
+ "storage-configuration",
30
+ )
31
+
32
+ CosmosDbAuthKeyRequired = ErrorMessage(
33
+ "CosmosDBStorage: auth_key is required.",
34
+ -61002,
35
+ "storage-configuration",
36
+ )
37
+
38
+ CosmosDbDatabaseIdRequired = ErrorMessage(
39
+ "CosmosDBStorage: database_id is required.",
40
+ -61003,
41
+ "storage-configuration",
42
+ )
43
+
44
+ CosmosDbContainerIdRequired = ErrorMessage(
45
+ "CosmosDBStorage: container_id is required.",
46
+ -61004,
47
+ "storage-configuration",
48
+ )
49
+
50
+ CosmosDbKeyCannotBeEmpty = ErrorMessage(
51
+ "CosmosDBStorage: Key cannot be empty.",
52
+ -61005,
53
+ "storage-configuration",
54
+ )
55
+
56
+ CosmosDbPartitionKeyInvalid = ErrorMessage(
57
+ "CosmosDBStorage: PartitionKey of {0} cannot be used with a CosmosDbPartitionedStorageOptions.PartitionKey of {1}.",
58
+ -61006,
59
+ "storage-configuration",
60
+ )
61
+
62
+ CosmosDbPartitionKeyPathInvalid = ErrorMessage(
63
+ "CosmosDBStorage: PartitionKeyPath must match cosmosDbPartitionedStorageOptions value of {0}",
64
+ -61007,
65
+ "storage-configuration",
66
+ )
67
+
68
+ CosmosDbCompatibilityModeRequired = ErrorMessage(
69
+ "CosmosDBStorage: compatibilityMode cannot be set when using partitionKey options.",
70
+ -61008,
71
+ "storage-configuration",
72
+ )
73
+
74
+ CosmosDbPartitionKeyNotFound = ErrorMessage(
75
+ "CosmosDBStorage: Partition key '{0}' missing from state, you may be missing custom state implementation.",
76
+ -61009,
77
+ "storage-configuration",
78
+ )
79
+
80
+ CosmosDbInvalidPartitionKeyValue = ErrorMessage(
81
+ "CosmosDBStorage: Invalid PartitionKey property on item with id {0}",
82
+ -61010,
83
+ "storage-configuration",
84
+ )
85
+
86
+ CosmosDbInvalidKeySuffixCharacters = ErrorMessage(
87
+ "Cannot use invalid Row Key characters: {0} in keySuffix.",
88
+ -61011,
89
+ "storage-configuration",
90
+ )
91
+
92
+ InvalidConfiguration = ErrorMessage(
93
+ "Invalid configuration: {0}",
94
+ -61012,
95
+ "configuration",
96
+ )
97
+
98
+ def __init__(self):
99
+ """Initialize StorageErrorResources."""
100
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-storage-cosmos
3
- Version: 0.6.0.dev8
3
+ Version: 0.6.0.dev10
4
4
  Summary: A Cosmos DB storage library for Microsoft Agents
5
5
  Author: Microsoft Corporation
6
6
  License-Expression: MIT
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: microsoft-agents-hosting-core==0.6.0.dev8
18
+ Requires-Dist: microsoft-agents-hosting-core==0.6.0.dev10
19
19
  Requires-Dist: azure-core
20
20
  Requires-Dist: azure-cosmos
21
21
  Dynamic: license-file
@@ -0,0 +1,11 @@
1
+ microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
2
+ microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=TLvvVKmRqKWrXsy9ddOjXPbPjPvLFXW6oB3KE9cuIC4,6753
3
+ microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=ji--EihsTE9FiGyUpeaw0or1iMN8-Z6O-gUd0fMcfx0,4210
4
+ microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
5
+ microsoft_agents/storage/cosmos/errors/__init__.py,sha256=lFjCjclpBSTAeVXTNT6QdkZORd4jDX1yeVAYGz0kCjI,413
6
+ microsoft_agents/storage/cosmos/errors/error_resources.py,sha256=yEX_ivRtOcnZ8jv-GWNM8qm-RsgfBOA5cvGsRPih9YY,2811
7
+ microsoft_agents_storage_cosmos-0.6.0.dev10.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
8
+ microsoft_agents_storage_cosmos-0.6.0.dev10.dist-info/METADATA,sha256=Vj0LewHBnPRVqBj7llp5WAvbDWL4ea9znbu1OkSHJkE,7786
9
+ microsoft_agents_storage_cosmos-0.6.0.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ microsoft_agents_storage_cosmos-0.6.0.dev10.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
11
+ microsoft_agents_storage_cosmos-0.6.0.dev10.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
2
- microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=yqU51Ji0wceuHKtppa2oQDrBqXI0LFi69OPGDe2mh8o,6529
3
- microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=a2-s7Kj5RbYnVU0CyB60dEG501-oRcSXZTQ--_QlISA,4143
4
- microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
5
- microsoft_agents_storage_cosmos-0.6.0.dev8.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
6
- microsoft_agents_storage_cosmos-0.6.0.dev8.dist-info/METADATA,sha256=LBpG-HgjHvKF8GGrYjEmcXz70WAUfZm3RXnT5CGGRpg,7784
7
- microsoft_agents_storage_cosmos-0.6.0.dev8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- microsoft_agents_storage_cosmos-0.6.0.dev8.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
9
- microsoft_agents_storage_cosmos-0.6.0.dev8.dist-info/RECORD,,