99
1010from __future__ import annotations
1111
12+ import logging
1213from typing import Any , Optional
1314
1415from sap_cloud_sdk .agent_memory ._endpoints import (
3839)
3940from sap_cloud_sdk .core .telemetry import Module , Operation , record_metrics
4041
42+ logger = logging .getLogger (__name__ )
43+
4144
4245def _require_non_empty (** fields : str ) -> None :
4346 """Raise AgentMemoryValidationError if any named field is an empty string."""
@@ -76,16 +79,16 @@ class AgentMemoryClient:
7679 Args:
7780 transport: HTTP transport layer (injected by ``create_client``).
7881 access_strategy: Default tenant access strategy for all operations.
79- Defaults to ``SUBSCRIBER_ONLY ``. Can be overridden per method call.
82+ Defaults to ``SUBSCRIBER ``. Can be overridden per method call.
8083 tenant: Default subscriber tenant subdomain. Required when
81- ``access_strategy=SUBSCRIBER_ONLY ``. Can be overridden per method call.
84+ ``access_strategy=SUBSCRIBER ``. Can be overridden per method call.
8285 """
8386
8487 def __init__ (
8588 self ,
8689 transport : HttpTransport ,
8790 * ,
88- access_strategy : AccessStrategy = AccessStrategy .SUBSCRIBER_ONLY ,
91+ access_strategy : AccessStrategy = AccessStrategy .SUBSCRIBER ,
8992 tenant : Optional [str ] = None ,
9093 ) -> None :
9194 self ._transport = transport
@@ -112,7 +115,7 @@ def _resolve_tenant(
112115 Per-call parameters take precedence over instance defaults.
113116
114117 Raises:
115- AgentMemoryValidationError: If the effective strategy is ``SUBSCRIBER_ONLY ``
118+ AgentMemoryValidationError: If the effective strategy is ``SUBSCRIBER ``
116119 but no tenant is available.
117120 """
118121 effective_strategy = (
@@ -122,16 +125,18 @@ def _resolve_tenant(
122125 )
123126 effective_tenant = tenant if tenant is not None else self ._default_tenant
124127
125- if (
126- effective_strategy is AccessStrategy .SUBSCRIBER_ONLY
127- and not effective_tenant
128- ):
128+ if effective_strategy is AccessStrategy .SUBSCRIBER and not effective_tenant :
129129 raise AgentMemoryValidationError (
130- "tenant is required when access_strategy=SUBSCRIBER_ONLY"
130+ "tenant is required when access_strategy=SUBSCRIBER"
131+ )
132+ if effective_strategy is not AccessStrategy .SUBSCRIBER :
133+ logger .warning (
134+ "AccessStrategy.PROVIDER is active: no tenant isolation will be applied. "
135+ "Only use this strategy for provider-owned operations."
131136 )
132137 return (
133138 effective_tenant
134- if effective_strategy is AccessStrategy .SUBSCRIBER_ONLY
139+ if effective_strategy is AccessStrategy .SUBSCRIBER
135140 else None
136141 )
137142
@@ -158,14 +163,14 @@ def add_memory(
158163 access_strategy: Tenant access strategy. Overrides the client default when
159164 provided. Falls back to the default set on :func:`create_client`.
160165 tenant: Subscriber tenant subdomain. Overrides the client default when
161- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
166+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
162167
163168 Returns:
164169 The created :class:`Memory`.
165170
166171 Raises:
167172 AgentMemoryValidationError: If any required field is empty or tenant is missing
168- for ``SUBSCRIBER_ONLY ``.
173+ for ``SUBSCRIBER ``.
169174 AgentMemoryHttpError: If the request fails.
170175 """
171176 _require_non_empty (agent_id = agent_id , invoker_id = invoker_id , content = content )
@@ -197,15 +202,15 @@ def get_memory(
197202 access_strategy: Tenant access strategy. Overrides the client default when
198203 provided. Falls back to the default set on :func:`create_client`.
199204 tenant: Subscriber tenant subdomain. Overrides the client default when
200- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
205+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
201206
202207 Returns:
203208 The :class:`Memory`.
204209
205210 Raises:
206211 AgentMemoryNotFoundError: If no memory with the given ID exists.
207212 AgentMemoryValidationError: If ``memory_id`` is empty or tenant is missing
208- for ``SUBSCRIBER_ONLY ``.
213+ for ``SUBSCRIBER ``.
209214 AgentMemoryHttpError: If the request fails.
210215 """
211216 _require_non_empty (memory_id = memory_id )
@@ -234,12 +239,12 @@ def update_memory(
234239 access_strategy: Tenant access strategy. Overrides the client default when
235240 provided. Falls back to the default set on :func:`create_client`.
236241 tenant: Subscriber tenant subdomain. Overrides the client default when
237- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
242+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
238243
239244 Raises:
240245 AgentMemoryNotFoundError: If no memory with the given ID exists.
241246 AgentMemoryValidationError: If ``memory_id`` is empty, no fields are provided,
242- or tenant is missing for ``SUBSCRIBER_ONLY ``.
247+ or tenant is missing for ``SUBSCRIBER ``.
243248 AgentMemoryHttpError: If the request fails.
244249 """
245250 _require_non_empty (memory_id = memory_id )
@@ -272,12 +277,12 @@ def delete_memory(
272277 access_strategy: Tenant access strategy. Overrides the client default when
273278 provided. Falls back to the default set on :func:`create_client`.
274279 tenant: Subscriber tenant subdomain. Overrides the client default when
275- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
280+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
276281
277282 Raises:
278283 AgentMemoryNotFoundError: If no memory with the given ID exists.
279284 AgentMemoryValidationError: If ``memory_id`` is empty or tenant is missing
280- for ``SUBSCRIBER_ONLY ``.
285+ for ``SUBSCRIBER ``.
281286 AgentMemoryHttpError: If the request fails.
282287 """
283288 _require_non_empty (memory_id = memory_id )
@@ -313,14 +318,14 @@ def list_memories(
313318 access_strategy: Tenant access strategy. Overrides the client default when
314319 provided. Falls back to the default set on :func:`create_client`.
315320 tenant: Subscriber tenant subdomain. Overrides the client default when
316- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
321+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
317322
318323 Returns:
319324 List of :class:`Memory` objects.
320325
321326 Raises:
322327 AgentMemoryValidationError: If ``limit`` < 1, ``offset`` < 0, a filter
323- clause is invalid, or tenant is missing for ``SUBSCRIBER_ONLY ``.
328+ clause is invalid, or tenant is missing for ``SUBSCRIBER ``.
324329 AgentMemoryHttpError: If the request fails.
325330 """
326331 if limit < 1 :
@@ -362,13 +367,13 @@ def count_memories(
362367 access_strategy: Tenant access strategy. Overrides the client default when
363368 provided. Falls back to the default set on :func:`create_client`.
364369 tenant: Subscriber tenant subdomain. Overrides the client default when
365- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
370+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
366371
367372 Returns:
368373 Total number of matching memories.
369374
370375 Raises:
371- AgentMemoryValidationError: If tenant is missing for ``SUBSCRIBER_ONLY ``.
376+ AgentMemoryValidationError: If tenant is missing for ``SUBSCRIBER ``.
372377 AgentMemoryHttpError: If the request fails.
373378 """
374379 tenant_subdomain = self ._resolve_tenant (access_strategy , tenant )
@@ -406,15 +411,15 @@ def search_memories(
406411 access_strategy: Tenant access strategy. Overrides the client default when
407412 provided. Falls back to the default set on :func:`create_client`.
408413 tenant: Subscriber tenant subdomain. Overrides the client default when
409- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
414+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
410415
411416 Returns:
412417 List of :class:`SearchResult` objects.
413418
414419 Raises:
415420 AgentMemoryValidationError: If required fields are empty, parameters are
416421 out of range (``query`` must be 5–5000 chars, ``threshold`` 0.0–1.0,
417- ``limit`` 1–50), or tenant is missing for ``SUBSCRIBER_ONLY ``.
422+ ``limit`` 1–50), or tenant is missing for ``SUBSCRIBER ``.
418423 AgentMemoryHttpError: If the request fails.
419424 """
420425 _require_non_empty (agent_id = agent_id , invoker_id = invoker_id , query = query )
@@ -470,14 +475,14 @@ def add_message(
470475 access_strategy: Tenant access strategy. Overrides the client default when
471476 provided. Falls back to the default set on :func:`create_client`.
472477 tenant: Subscriber tenant subdomain. Overrides the client default when
473- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
478+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
474479
475480 Returns:
476481 The created :class:`Message`.
477482
478483 Raises:
479484 AgentMemoryValidationError: If any required field is empty or tenant is missing
480- for ``SUBSCRIBER_ONLY ``.
485+ for ``SUBSCRIBER ``.
481486 AgentMemoryHttpError: If the request fails.
482487 """
483488 _require_non_empty (
@@ -516,15 +521,15 @@ def get_message(
516521 access_strategy: Tenant access strategy. Overrides the client default when
517522 provided. Falls back to the default set on :func:`create_client`.
518523 tenant: Subscriber tenant subdomain. Overrides the client default when
519- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
524+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
520525
521526 Returns:
522527 The :class:`Message`.
523528
524529 Raises:
525530 AgentMemoryNotFoundError: If no message with the given ID exists.
526531 AgentMemoryValidationError: If ``message_id`` is empty or tenant is missing
527- for ``SUBSCRIBER_ONLY ``.
532+ for ``SUBSCRIBER ``.
528533 AgentMemoryHttpError: If the request fails.
529534 """
530535 _require_non_empty (message_id = message_id )
@@ -549,12 +554,12 @@ def delete_message(
549554 access_strategy: Tenant access strategy. Overrides the client default when
550555 provided. Falls back to the default set on :func:`create_client`.
551556 tenant: Subscriber tenant subdomain. Overrides the client default when
552- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
557+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
553558
554559 Raises:
555560 AgentMemoryNotFoundError: If no message with the given ID exists.
556561 AgentMemoryValidationError: If ``message_id`` is empty or tenant is missing
557- for ``SUBSCRIBER_ONLY ``.
562+ for ``SUBSCRIBER ``.
558563 AgentMemoryHttpError: If the request fails.
559564 """
560565 _require_non_empty (message_id = message_id )
@@ -594,14 +599,14 @@ def list_messages(
594599 access_strategy: Tenant access strategy. Overrides the client default when
595600 provided. Falls back to the default set on :func:`create_client`.
596601 tenant: Subscriber tenant subdomain. Overrides the client default when
597- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
602+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
598603
599604 Returns:
600605 List of :class:`Message` objects.
601606
602607 Raises:
603608 AgentMemoryValidationError: If ``limit`` < 1, ``offset`` < 0, a filter
604- clause is invalid, or tenant is missing for ``SUBSCRIBER_ONLY ``.
609+ clause is invalid, or tenant is missing for ``SUBSCRIBER ``.
605610 AgentMemoryHttpError: If the request fails.
606611 """
607612 if limit < 1 :
@@ -643,13 +648,13 @@ def get_retention_config(
643648 access_strategy: Tenant access strategy. Overrides the client default when
644649 provided. Falls back to the default set on :func:`create_client`.
645650 tenant: Subscriber tenant subdomain. Overrides the client default when
646- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
651+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
647652
648653 Returns:
649654 The current :class:`RetentionConfig`.
650655
651656 Raises:
652- AgentMemoryValidationError: If tenant is missing for ``SUBSCRIBER_ONLY ``.
657+ AgentMemoryValidationError: If tenant is missing for ``SUBSCRIBER ``.
653658 AgentMemoryHttpError: If the request fails.
654659 """
655660 tenant_subdomain = self ._resolve_tenant (access_strategy , tenant )
@@ -679,11 +684,11 @@ def update_retention_config(
679684 access_strategy: Tenant access strategy. Overrides the client default when
680685 provided. Falls back to the default set on :func:`create_client`.
681686 tenant: Subscriber tenant subdomain. Overrides the client default when
682- provided. Required (at call or client level) when strategy is ``SUBSCRIBER_ONLY ``.
687+ provided. Required (at call or client level) when strategy is ``SUBSCRIBER ``.
683688
684689 Raises:
685690 AgentMemoryValidationError: If no fields are provided, any provided value is
686- negative, or tenant is missing for ``SUBSCRIBER_ONLY ``.
691+ negative, or tenant is missing for ``SUBSCRIBER ``.
687692 AgentMemoryHttpError: If the request fails.
688693 """
689694 if message_days is None and memory_days is None and usage_log_days is None :
0 commit comments