Skip to content

feat: support destination based configuration#169

Open
betinacosta wants to merge 10 commits into
mainfrom
feat/support-destination-based-config
Open

feat: support destination based configuration#169
betinacosta wants to merge 10 commits into
mainfrom
feat/support-destination-based-config

Conversation

@betinacosta

Copy link
Copy Markdown
Member

Description

The AuditLog NG module currently requires callers to explicitly provide endpoint, deployment_id, and namespace when calling create_client. In SPII-based deployments, these values are stored in a Destination (with tenant-specific fragments) following the ALS SPII v3.0.0 provisioning lifecycle. This change allows create_client to resolve these parameters automatically from a Destination, reducing boilerplate and avoiding misconfiguration.

Type of Change

Please check the relevant option:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

from sap_cloud_sdk.core.auditlog_ng import create_client

client = create_client(
    destination_name="AuditLogV3_Destination",
    destination_instance="default"
)

print(f"Client created: {client}")
print(f"  endpoint:      {client._config.endpoint}")
print(f"  deployment_id: {client._config.deployment_id}")
print(f"  namespace:     {client._config.namespace}")

Checklist

Before submitting your PR, please review and check the following:

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have updated documentation (if applicable)
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

Breaking Changes

If this PR introduces breaking changes, please describe:

  • What breaks
  • Migration path for users
  • Alternative approaches considered

Additional Notes

Add any additional context, screenshots, or information that would help reviewers.

@betinacosta betinacosta requested a review from a team as a code owner June 16, 2026 18:22
@betinacosta betinacosta marked this pull request as draft June 16, 2026 18:23
@betinacosta betinacosta changed the title Feat: support destination based configuration feat: support destination based configuration Jun 16, 2026
Comment thread src/sap_cloud_sdk/core/auditlog_ng/__init__.py Outdated
@betinacosta betinacosta marked this pull request as ready for review June 16, 2026 19:10

@cassiofariasmachado cassiofariasmachado left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far! I've added some comments


client = create_client(
destination_name="my-audit-destination",
destination_instance="my-binding-instance",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destination_instance could be optional also and we can use default by default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe on agw we don't have destination name and destination_instance configuration, since this is padronized on runtime.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should remove these parameters and consider them by default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the only "mandatory" parameter is destination_name if endpoint, namespace and development_id are not passed. Do you guys think it works this way?

)

dest_client = _dest_create_client(instance=destination_instance)
options = ConsumptionOptions(fragment_name=fragment_name) if fragment_name else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must also inform the fragment_level=ConsumptionLevel.SUBACCOUNT in the ConsumptionOptions.

Ignore this comment if the default level is subaccount for this parameter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragment Level is not on instance level? It should be specific to tenant if I remember correctly, and then we would need to ask this information too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested passing the fragment with subaccount level and I got the necessary information back without errors. But I don't know if this will be the case for always. I will change to have subaccount as default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's tenant specific, but it was created in the subaccount level not in the instance level during the SPII. Either the destination and the fragment are being created in the subaccount level but tenant specific.

@betinacosta betinacosta Jun 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the level to the fragment options, do you think any other information is required?

Comment thread src/sap_cloud_sdk/core/auditlog_ng/__init__.py Outdated
Comment thread src/sap_cloud_sdk/core/auditlog_ng/__init__.py Outdated
Comment thread src/sap_cloud_sdk/core/auditlog_ng/user-guide.md Outdated
ready-to-use AuditClient.

Usage:
Usage — explicit config::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just add it as Usage: and then add comments, I believe this is how we usually do, but I can be worng

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

endpoint = destination.url
props = destination.properties

deployment_id = props.get(_DESTINATION_PROP_DEPLOYMENT_ID) or ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to have an enum for this dest properties?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is better as well. Fixed.

Comment thread pyproject.toml Outdated
[project]
name = "sap-cloud-sdk"
version = "0.26.1"
version = "0.26.2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a minor since it's implementing new functionality

Suggested change
version = "0.26.2"
version = "0.27.0"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants