Skip to content
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

bucket notifications - adapt to xml conversion #8745

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

alphaprinz
Copy link
Contributor

Explain the changes

  1. Adapt get-bucket-notif reply to be converted to xml.

Issues: Fixed #xxx / Gap #xxx

  1. https://issues.redhat.com/browse/DFBUGS-1507 (partly)

Testing Instructions:

  • Doc added/updated
  • Tests added

Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

just a suggestion of how we typically build these xml results from js objects with a more functional style.

we use _.map(arr, fn) just because it won't fail if the array is undefined, while for arr.map(fn) will fail, but if you prefer you can also just do (arr || []).map(fn).

const topics = await req.object_sdk.get_bucket_notification({
    bucket_name: req.params.bucket,
});

return {
    NotificationConfiguration: _.map(topics, t => ({
        TopicConfiguration: [
            {
                Id: t.id,
                Topic: t.topic,
            },
            _.map(t.event, e => ({
                Event: e
            }))
        ]
    }))
};

//adapt to structure that xml_utils.encode_xml() will then
//encode into aws compliant reply
return {
NotificationConfiguration: [_.map(result, t => ({
Copy link
Member

Choose a reason for hiding this comment

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

no need to wrap the map with [] because it always returns an array

Suggested change
NotificationConfiguration: [_.map(result, t => ({
NotificationConfiguration: _.map(result, t => ({

Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

approved, just one minor comment

@alphaprinz alphaprinz merged commit c36719b into noobaa:master Feb 4, 2025
11 checks passed
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this pull request Feb 4, 2025
@alphaprinz alphaprinz mentioned this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants