Skip to content

Commit 7ade94f

Browse files
redesigned as per sdk conventions
1 parent c02cfba commit 7ade94f

27 files changed

Lines changed: 1680 additions & 1782 deletions

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies = [
2828
"opentelemetry-api>=1.42.1",
2929
"opentelemetry-sdk>=1.42.1",
3030
"mcp>=1.1.0",
31+
"cryptography>=46.0.3",
3132
]
3233

3334
[project.optional-dependencies]

src/sap_cloud_sdk/core/telemetry/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Module(str, Enum):
1717
DMS = "dms"
1818
EXTENSIBILITY = "extensibility"
1919
OBJECTSTORE = "objectstore"
20+
OUTPUT_MANAGEMENT = "outputmanagement"
2021
PRINT = "print"
2122
TELEMETRY = "telemetry"
2223

src/sap_cloud_sdk/outputmanagement/__init__.py

Lines changed: 117 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
"""SAP Ariba Output Management Service SDK for Python."""
22

3-
from .client import (
4-
OutputManagementServiceClient,
5-
OutputManagementServiceDefaultClient,
6-
)
7-
from .client_provider import (
8-
OutputManagementServiceClientProvider,
9-
OutputManagementServiceClientProviderBuilder,
10-
)
11-
from .models.output_request import OutputRequest, OutputRequestBuilder
12-
from .models.output_response import (
3+
import logging
4+
import os
5+
from typing import Optional
6+
7+
from .client import OutputManagementClient
8+
from ._service_client import OutputManagementServiceClient
9+
from ._models import (
10+
OutputRequest,
11+
OutputRequestBuilder,
1312
OutputResponse,
13+
EmailConfiguration,
14+
AttachmentConfig,
15+
OutputManagementInfo,
16+
OutputRequestData,
17+
DirectShareConfiguration,
18+
FormConfiguration,
1419
)
15-
from .models.email_configuration import EmailConfiguration
16-
from .models.attachment_config import AttachmentConfig
17-
from .models.output_management_info import OutputManagementInfo
18-
from .models.output_request_data import OutputRequestData
19-
from .models.direct_share_configuration import DirectShareConfiguration
20-
from .models.form_configuration import FormConfiguration
21-
from .clients.email_client import EmailClient
22-
from .config.destination_credential_config import DestinationCredentialConfig
20+
from .config import DestinationCredentialConfig
2321
from .constants import FileFormat, Channel
2422
from .exceptions import (
2523
OutputManagementException,
@@ -30,15 +28,109 @@
3028
DestinationAccessException,
3129
)
3230

33-
__version__ = "1.0.0"
31+
logger = logging.getLogger(__name__)
32+
33+
34+
def create_client(
35+
destination_name: Optional[str] = None,
36+
access_strategy: Optional[str] = None,
37+
instance: Optional[str] = None,
38+
) -> OutputManagementClient:
39+
"""
40+
Create an Output Management client with configuration from environment or parameters.
41+
42+
This is the recommended factory function for creating clients. It follows the SDK's
43+
standard pattern of reading configuration from environment variables with optional overrides.
44+
45+
Environment Variables:
46+
- CLOUD_SDK_OMS_DESTINATION_NAME: Default destination name
47+
- CLOUD_SDK_OMS_ACCESS_STRATEGY: Default access strategy (PROVIDER_ONLY or SUBSCRIBER_ONLY)
48+
- CLOUD_SDK_OMS_INSTANCE: Default destination service instance name
49+
50+
Args:
51+
destination_name: Name of the destination. If not provided, reads from
52+
CLOUD_SDK_OMS_DESTINATION_NAME environment variable.
53+
access_strategy: Destination access strategy. If not provided, reads from
54+
CLOUD_SDK_OMS_ACCESS_STRATEGY environment variable or defaults to "PROVIDER_ONLY".
55+
instance: Destination service instance name. If not provided, reads from
56+
CLOUD_SDK_OMS_INSTANCE environment variable or defaults to "default".
57+
58+
Returns:
59+
Configured OutputManagementClient instance
60+
61+
Raises:
62+
ValidationException: If destination_name is not provided and not found in environment
63+
64+
Example:
65+
```python
66+
from sap_cloud_sdk.outputmanagement import create_client
67+
68+
# Using environment variables
69+
client = create_client()
70+
71+
# With explicit parameters
72+
client = create_client(
73+
destination_name="MY_OMS_DESTINATION",
74+
access_strategy="PROVIDER_ONLY",
75+
instance="default"
76+
)
77+
78+
# Use the client's 4 methods
79+
response = client.send_email(
80+
notification_template_key="PO_NOTIFICATION",
81+
to=["user@example.com"],
82+
business_document={"PurchaseOrder": {"id": "PO-123"}}
83+
)
84+
```
85+
"""
86+
# Read from environment variables with parameter overrides
87+
dest_name = destination_name or os.getenv("CLOUD_SDK_OMS_DESTINATION_NAME")
88+
access_strat = access_strategy or os.getenv(
89+
"CLOUD_SDK_OMS_ACCESS_STRATEGY", "PROVIDER_ONLY"
90+
)
91+
inst = instance or os.getenv("CLOUD_SDK_OMS_INSTANCE", "default")
92+
93+
if not dest_name:
94+
raise ValidationException(
95+
"Destination name must be provided either as parameter or via "
96+
"CLOUD_SDK_OMS_DESTINATION_NAME environment variable",
97+
error_code="MISSING_DESTINATION_NAME",
98+
)
99+
100+
logger.info(
101+
f"Creating Output Management client with destination '{dest_name}', "
102+
f"access_strategy '{access_strat}', instance '{inst}'"
103+
)
104+
105+
# Create destination config
106+
destination_config = DestinationCredentialConfig(
107+
destination_name=dest_name,
108+
access_strategy=access_strat,
109+
instance=inst,
110+
)
111+
112+
# Get the destination object
113+
http_destination = destination_config.get_destination()
114+
115+
# Get the base URL from destination
116+
base_url = destination_config.get_base_url()
117+
logger.info(f"Retrieved destination base URL: {base_url}")
118+
119+
# Create service client directly
120+
service_client = OutputManagementServiceClient(
121+
base_url=base_url,
122+
destination=http_destination,
123+
destination_instance=inst,
124+
)
125+
126+
# Wrap it in the unified OutputManagementClient
127+
return OutputManagementClient(service_client)
128+
34129

35130
__all__ = [
36-
# Client classes
37-
"OutputManagementServiceClient",
38-
"OutputManagementServiceDefaultClient",
39-
"OutputManagementServiceClientProvider",
40-
"OutputManagementServiceClientProviderBuilder",
41-
"EmailClient",
131+
# Main client and factory function
132+
"OutputManagementClient",
133+
"create_client",
42134
# Models
43135
"OutputRequest",
44136
"OutputRequestBuilder",

0 commit comments

Comments
 (0)