-
Notifications
You must be signed in to change notification settings - Fork 38
feat: added output management integration #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Venkatakrishnan774
wants to merge
56
commits into
SAP:main
Choose a base branch
from
Venkatakrishnan774:sap_om_poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
6816198
added output management
Venkatakrishnan774 477e98b
updated workaround
Venkatakrishnan774 0e0bdfd
updated workaround
Venkatakrishnan774 21ec7d5
updated workaround
Venkatakrishnan774 78ce649
updated workaround
Venkatakrishnan774 ef83886
adding a logger to test access to this repo
lokeshkumarkuntal ad3c8d1
adding a logger to test access to this repo
lokeshkumarkuntal b817b56
removed harcoded values
Venkatakrishnan774 8e1da26
added pre generated attachment section
Venkatakrishnan774 6bfcf9d
added pre generated attachment section
Venkatakrishnan774 68079ab
added tests
Venkatakrishnan774 15606cd
added mcp way to communicate
Venkatakrishnan774 59426a3
added mcp way to communicate
Venkatakrishnan774 9b90568
added test
Venkatakrishnan774 d24cbf1
fixed tests
Venkatakrishnan774 db05f22
fixed test cases
Venkatakrishnan774 747705b
resolved review comments
Venkatakrishnan774 90e1c00
updated review comments
Venkatakrishnan774 1499178
updated document id
Venkatakrishnan774 5e8d7b8
fixed code quality checks
Venkatakrishnan774 aadfcd3
fixed code quality checks
Venkatakrishnan774 8608d13
Merge pull request #1 from SAP/main
Venkatakrishnan774 c02cfba
ruff checks done
Venkatakrishnan774 7ade94f
redesigned as per sdk conventions
Venkatakrishnan774 b49c131
updated tests
Venkatakrishnan774 72868ff
updated roff
Venkatakrishnan774 0cb2a35
Merge pull request #2 from SAP/main
Venkatakrishnan774 e947ce9
updated review comments
Venkatakrishnan774 4c07927
updated review comments
Venkatakrishnan774 cd90788
updated review comments
Venkatakrishnan774 8b4f46c
updated review comments
Venkatakrishnan774 0a4ff67
Merge remote-tracking branch 'origin/sap_om_poc' into sap_om_poc
Venkatakrishnan774 e9c7bb2
updated review comments
Venkatakrishnan774 82f122f
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 39b0383
Update test_operation.py
Venkatakrishnan774 bd84c91
bumped version
Venkatakrishnan774 24ff48b
added integration tests
Venkatakrishnan774 ee80146
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 f9a18d2
fixed review comments
Venkatakrishnan774 66749af
fixed tests
Venkatakrishnan774 e1a4dfd
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 72624d6
updated client
Venkatakrishnan774 c0e0202
updated client
Venkatakrishnan774 8b64331
updated client
Venkatakrishnan774 d9065bc
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 0cc186b
ruff format
Venkatakrishnan774 9045c19
updated integration tests
5ac60ed
remvoed
f22c685
fixed integration tests
2b014ee
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 6db14fa
updated test module
198f07f
Merge branch 'main' into sap_om_poc
Venkatakrishnan774 cbe3f3a
Merge branch 'main' into sap_om_poc
b276af8
Merge remote-tracking branch 'origin/sap_om_poc' into sap_om_poc
2b68d9f
Merge remote-tracking branch 'origin/sap_om_poc' into sap_om_poc
Venkatakrishnan774 7eba1f7
Merge remote-tracking branch 'origin/sap_om_poc' into sap_om_poc
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """SAP Ariba Output Management Service SDK for Python.""" | ||
|
|
||
| from .client import ( | ||
| OutputManagementServiceClient, | ||
| OutputManagementServiceDefaultClient, | ||
| ) | ||
| from .client_provider import ( | ||
| OutputManagementServiceClientProvider, | ||
| OutputManagementServiceClientProviderBuilder, | ||
| ) | ||
| from .models.output_request import OutputRequest, OutputRequestBuilder | ||
| from .models.output_response import ( | ||
| OutputResponse, | ||
| ) | ||
| from .models.email_configuration import EmailConfiguration | ||
| from .models.attachment_config import AttachmentConfig | ||
| from .models.output_management_info import OutputManagementInfo | ||
| from .models.output_request_data import OutputRequestData | ||
| from .models.direct_share_configuration import DirectShareConfiguration | ||
| from .models.form_configuration import FormConfiguration | ||
| from .clients.email_client import EmailClient | ||
| from .config.destination_credential_config import DestinationCredentialConfig | ||
| from .constants import FileFormat, Channel, Status | ||
| from .exceptions import ( | ||
| OutputManagementException, | ||
| AuthenticationException, | ||
| ValidationException, | ||
| NetworkException, | ||
| DestinationNotFoundException, | ||
| DestinationAccessException, | ||
| ) | ||
|
|
||
| __version__ = "1.0.0" | ||
|
|
||
| __all__ = [ | ||
| # Client classes | ||
| "OutputManagementServiceClient", | ||
| "OutputManagementServiceDefaultClient", | ||
| "OutputManagementServiceClientProvider", | ||
| "OutputManagementServiceClientProviderBuilder", | ||
| "EmailClient", | ||
| # Models | ||
| "OutputRequest", | ||
| "OutputRequestBuilder", | ||
| "OutputResponse", | ||
| "EmailConfiguration", | ||
| "AttachmentConfig", | ||
| "OutputManagementInfo", | ||
| "OutputRequestData", | ||
| "DirectShareConfiguration", | ||
| "FormConfiguration", | ||
| # Configuration | ||
| "DestinationCredentialConfig", | ||
| # Constants/Enums | ||
| "FileFormat", | ||
| "Channel", | ||
| "Status", | ||
| # Exceptions | ||
| "OutputManagementException", | ||
| "AuthenticationException", | ||
| "ValidationException", | ||
| "NetworkException", | ||
| "DestinationNotFoundException", | ||
| "DestinationAccessException", | ||
| ] | ||
|
|
||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """Main client classes.""" | ||
|
|
||
| import logging | ||
| import requests | ||
| from abc import ABC, abstractmethod | ||
|
|
||
| from .clients.output_requests_client import OutputRequestsClient | ||
| from .clients.output_requests_client_impl import OutputRequestsClientImpl | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class OutputManagementServiceClient(ABC): | ||
| """Abstract base class for Output Management Service client.""" | ||
|
|
||
| @abstractmethod | ||
| def get_output_requests_client(self) -> OutputRequestsClient: | ||
| """Get output requests client. | ||
|
|
||
| Returns: | ||
| Output requests client | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| @abstractmethod | ||
| def close(self) -> None: | ||
| """Close the client and release resources.""" | ||
| pass | ||
|
|
||
|
|
||
| class OutputManagementServiceDefaultClient(OutputManagementServiceClient): | ||
| """Default implementation of Output Management Service client.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| base_url: str, | ||
| destination: any = None, | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| destination_instance: str = None, | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| ): | ||
| """Initialize client. | ||
|
|
||
| Args: | ||
| base_url: Base URL of the service | ||
| destination: Optional Cloud SDK destination object for making requests | ||
| destination_instance: Optional Destination Service instance name | ||
| """ | ||
| self._base_url = base_url.rstrip("/") | ||
| self._destination = destination | ||
| self._destination_instance = destination_instance | ||
|
|
||
| # Create a simple requests session | ||
| self._session = requests.Session() | ||
|
|
||
| # Initialize output requests client | ||
| self._output_requests_client = OutputRequestsClientImpl( | ||
| self._session, | ||
| self._base_url, | ||
| self._destination, | ||
| self._destination_instance, | ||
| ) | ||
|
|
||
| logger.info(f"Initialized Output Management Service client for {base_url}") | ||
|
|
||
| def get_output_requests_client(self) -> OutputRequestsClient: | ||
| """Get output requests client.""" | ||
| return self._output_requests_client | ||
|
|
||
|
|
||
| def close(self) -> None: | ||
| """Close the client and release resources.""" | ||
| self._session.close() | ||
| logger.info("Output Management Service client closed") | ||
|
|
||
| def __enter__(self): | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| """Context manager entry.""" | ||
| return self | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| """Context manager exit.""" | ||
| self.close() | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| """Client provider and builder.""" | ||
|
|
||
| import logging | ||
|
|
||
| from .client import ( | ||
| OutputManagementServiceClient, | ||
| OutputManagementServiceDefaultClient, | ||
| ) | ||
| from .config.destination_credential_config import DestinationCredentialConfig | ||
| from .exceptions import ValidationException | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class OutputManagementServiceClientProvider: | ||
| """Provider for Output Management Service client.""" | ||
|
|
||
| def __init__(self, client: OutputManagementServiceClient): | ||
| """Initialize provider. | ||
|
|
||
| Args: | ||
| client: Output Management Service client | ||
| """ | ||
| self._client = client | ||
|
|
||
| def get_client(self) -> OutputManagementServiceClient: | ||
| """Get the client instance. | ||
|
|
||
| Returns: | ||
| Output Management Service client | ||
| """ | ||
| return self._client | ||
|
|
||
|
|
||
| class OutputManagementServiceClientProviderBuilder: | ||
| """Builder for Output Management Service client provider.""" | ||
|
|
||
| def __init__(self): | ||
| """Initialize builder.""" | ||
| self._destination_credential_config: DestinationCredentialConfig = None | ||
|
|
||
| def with_destination_credentials( | ||
| self, config: DestinationCredentialConfig | ||
| ) -> "OutputManagementServiceClientProviderBuilder": | ||
| """Configure with destination credentials. | ||
|
|
||
| Args: | ||
| config: Destination credential configuration | ||
|
|
||
| Returns: | ||
| Builder instance | ||
| """ | ||
| self._destination_credential_config = config | ||
| return self | ||
|
|
||
| def build(self) -> OutputManagementServiceClientProvider: | ||
| """Build the client provider. | ||
|
|
||
| Returns: | ||
| Client provider | ||
|
|
||
| Raises: | ||
| ValidationException: If configuration is invalid | ||
| """ | ||
| if not self._destination_credential_config: | ||
| raise ValidationException( | ||
| "Destination credentials must be configured", | ||
| error_code="MISSING_CONFIGURATION", | ||
| ) | ||
|
|
||
| # For destination credentials, use SAP Cloud SDK | ||
| logger.info("Using destination credential configuration") | ||
|
|
||
| # Get the destination object - it handles authentication automatically | ||
| http_destination = self._destination_credential_config.get_destination() | ||
|
|
||
| # Get the base URL from destinatiozxn | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| base_url = self._destination_credential_config.get_base_url() | ||
| logger.info(f"Retrieved destination base URL: {base_url}") | ||
|
|
||
| # Build client with destination object and instance name | ||
| # The destination object handles auth automatically | ||
| # Use the same instance for both destination fetch and certificate retrieval | ||
| client = OutputManagementServiceDefaultClient( | ||
| base_url=base_url, | ||
| destination=http_destination, | ||
| destination_instance=self._destination_credential_config.instance, | ||
| ) | ||
|
|
||
| logger.info("Built Output Management Service client provider") | ||
|
|
||
| return OutputManagementServiceClientProvider(client) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| """Client implementations.""" | ||
|
|
||
| from .output_requests_client import OutputRequestsClient | ||
| from .output_requests_client_impl import OutputRequestsClientImpl | ||
| from .email_client import EmailClient | ||
|
|
||
| __all__ = [ | ||
| "OutputRequestsClient", | ||
| "OutputRequestsClientImpl", | ||
|
Venkatakrishnan774 marked this conversation as resolved.
Outdated
|
||
| "EmailClient", | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.