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

transformation mappings edit action #467

Merged
merged 2 commits into from
Sep 24, 2018

Conversation

AparnaKarve
Copy link
Contributor

@AparnaKarve AparnaKarve commented Sep 12, 2018

EDIT API for transformation_mappings

POST /api/transformation_mappings/<id>
{
  "action": "edit",
  "name": "updated name",
  "transformation_mapping_items": [
    { source: source_href1, destination: destination_href1 },
    { source: source_href2, destination: destination_href2 },
    { source: source_href3, destination: destination_href3 }
  ]
}

@AparnaKarve
Copy link
Contributor Author

@abellotti Can you review this?

transformation_mapping = fetch_transformation_mapping(type, id)

updated_data = data.except("transformation_mapping_items")
transformation_mapping.update_attributes!(updated_data) if data.present?
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be if updated_data.present ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct.

I have fixed that.

@@ -49,5 +63,9 @@ def fetch_mapping_resource(href)
raise "Invalid source or destination type #{resource_href.subject}" unless collection_config.collection?(resource_href.subject)
resource_search(resource_href.subject_id, resource_href.subject, collection_class(resource_href.subject.to_sym))
end

def fetch_transformation_mapping(type, id)
resource_search(id, type, collection_class(type))
Copy link
Member

Choose a reason for hiding this comment

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

I'd drop this method since it's a one-liner and just call resource_search.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, makes sense

api_basic_authorize(action_identifier(:transformation_mappings, :edit, :resource_actions))

request = {
'action' => 'edit',
Copy link
Member

Choose a reason for hiding this comment

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

maybe use " for consistency with the rest of the hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@miq-bot
Copy link
Member

miq-bot commented Sep 18, 2018

Checked commits AparnaKarve/manageiq-api@3e579e4~...6cbadf2 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@AparnaKarve
Copy link
Contributor Author

@abellotti I have made the suggested changes. Thanks!

@AparnaKarve
Copy link
Contributor Author

@abellotti This should be GTG -- seems to work OK from the UI

@abellotti abellotti self-requested a review September 24, 2018 19:55
@abellotti abellotti added this to the Sprint 95 Ending Sep 24, 2018 milestone Sep 24, 2018
@abellotti
Copy link
Member

Thanks @AparnaKarve for the API Enhancement. This LGTM!! 👍

@abellotti abellotti merged commit d716804 into ManageIQ:master Sep 24, 2018
@AparnaKarve AparnaKarve deleted the edit_transformation_mappings branch September 24, 2018 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants