-
Notifications
You must be signed in to change notification settings - Fork 29
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
14
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 all commits
Commits
Show all changes
14 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 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
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, | ||
| destination_instance: str = None, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. destination_instance: Optional[str] = None |
||
| ): | ||
| """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): | ||
| """Context manager entry.""" | ||
| return self | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| """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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
| 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", | ||
| "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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even