{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/comments/286333691","pull_request_review_id":240434165,"id":286333691,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4NjMzMzY5MQ==","diff_hunk":"@@ -44,8 +44,22 @@ def show\n \n       def destroy\n         portfolio = Portfolio.find(params.require(:id))\n-        if portfolio.discard\n-          head :no_content\n+        svc = Catalog::SoftDelete.new(portfolio)\n+        key = svc.process.restore_key\n+\n+        if portfolio.discarded?\n+          render :json => { :restore_key => key }\n+        else\n+          render :json => { :errors => portfolio.errors }, :status => :unprocessable_entity","path":"app/controllers/api/v1x0/portfolios_controller.rb","position":12,"original_position":12,"commit_id":"afa06eb86d799eaf4ec047f9147fc82f2a9fa245","original_commit_id":"afa06eb86d799eaf4ec047f9147fc82f2a9fa245","user":{"login":"eclarizio","id":164557,"node_id":"MDQ6VXNlcjE2NDU1Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/164557?v=4","gravatar_id":"","url":"https://api.github.com/users/eclarizio","html_url":"https://github.com/eclarizio","followers_url":"https://api.github.com/users/eclarizio/followers","following_url":"https://api.github.com/users/eclarizio/following{/other_user}","gists_url":"https://api.github.com/users/eclarizio/gists{/gist_id}","starred_url":"https://api.github.com/users/eclarizio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclarizio/subscriptions","organizations_url":"https://api.github.com/users/eclarizio/orgs","repos_url":"https://api.github.com/users/eclarizio/repos","events_url":"https://api.github.com/users/eclarizio/events{/privacy}","received_events_url":"https://api.github.com/users/eclarizio/received_events","type":"User","site_admin":false},"body":"Is there a way we can just throw a custom error during the `SoftDelete` processing if something goes wrong and then add another `rescue_from` in the `ExceptionHandler` class? It would remove the if/else condition here (and the same thing for `SoftDeleteRestore`","created_at":"2019-05-22T06:43:02Z","updated_at":"2019-05-22T06:49:50Z","html_url":"https://github.com/ManageIQ/catalog-api/pull/296#discussion_r286333691","pull_request_url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/comments/286333691"},"html":{"href":"https://github.com/ManageIQ/catalog-api/pull/296#discussion_r286333691"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296","id":279662594,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjc5NjYyNTk0","html_url":"https://github.com/ManageIQ/catalog-api/pull/296","diff_url":"https://github.com/ManageIQ/catalog-api/pull/296.diff","patch_url":"https://github.com/ManageIQ/catalog-api/pull/296.patch","issue_url":"https://api.github.com/repos/ManageIQ/catalog-api/issues/296","number":296,"state":"open","locked":false,"title":"Add Operations to undelete discarded Portfolios","user":{"login":"lindgrenj6","id":5856504,"node_id":"MDQ6VXNlcjU4NTY1MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5856504?v=4","gravatar_id":"","url":"https://api.github.com/users/lindgrenj6","html_url":"https://github.com/lindgrenj6","followers_url":"https://api.github.com/users/lindgrenj6/followers","following_url":"https://api.github.com/users/lindgrenj6/following{/other_user}","gists_url":"https://api.github.com/users/lindgrenj6/gists{/gist_id}","starred_url":"https://api.github.com/users/lindgrenj6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindgrenj6/subscriptions","organizations_url":"https://api.github.com/users/lindgrenj6/orgs","repos_url":"https://api.github.com/users/lindgrenj6/repos","events_url":"https://api.github.com/users/lindgrenj6/events{/privacy}","received_events_url":"https://api.github.com/users/lindgrenj6/received_events","type":"User","site_admin":false},"body":"https://projects.engineering.redhat.com/browse/SSP-169\r\n\r\nBuilt off of #295, but for portfolios. That one needs to be merged first. \r\nAdds these two endpoints:\r\n\r\n~`GET /portfolios/discarded` to list the discarded portfolios~\r\n`GET /portfolios/{portfolio_id}/undelete` with params `{ :restore_key => 'someSha1Hash' }` to restore a deleted portfolio and all child portfolio items.\r\n\r\nAlso modifies the `DELETE /portfolios/{id}` method to return a 200 and a restore key so only the user who deleted the portfolio can restore it. \r\n","created_at":"2019-05-16T20:42:31Z","updated_at":"2019-05-22T06:49:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1656a7b7c297f84b8bfb81adeee54c0f3d8f804d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mkanoor","id":6452699,"node_id":"MDQ6VXNlcjY0NTI2OTk=","avatar_url":"https://avatars3.githubusercontent.com/u/6452699?v=4","gravatar_id":"","url":"https://api.github.com/users/mkanoor","html_url":"https://github.com/mkanoor","followers_url":"https://api.github.com/users/mkanoor/followers","following_url":"https://api.github.com/users/mkanoor/following{/other_user}","gists_url":"https://api.github.com/users/mkanoor/gists{/gist_id}","starred_url":"https://api.github.com/users/mkanoor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkanoor/subscriptions","organizations_url":"https://api.github.com/users/mkanoor/orgs","repos_url":"https://api.github.com/users/mkanoor/repos","events_url":"https://api.github.com/users/mkanoor/events{/privacy}","received_events_url":"https://api.github.com/users/mkanoor/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/catalog-api/issues/296/comments","statuses_url":"https://api.github.com/repos/ManageIQ/catalog-api/statuses/afa06eb86d799eaf4ec047f9147fc82f2a9fa245","head":{"label":"lindgrenj6:add_undelete_portfolios","ref":"add_undelete_portfolios","sha":"afa06eb86d799eaf4ec047f9147fc82f2a9fa245","user":{"login":"lindgrenj6","id":5856504,"node_id":"MDQ6VXNlcjU4NTY1MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5856504?v=4","gravatar_id":"","url":"https://api.github.com/users/lindgrenj6","html_url":"https://github.com/lindgrenj6","followers_url":"https://api.github.com/users/lindgrenj6/followers","following_url":"https://api.github.com/users/lindgrenj6/following{/other_user}","gists_url":"https://api.github.com/users/lindgrenj6/gists{/gist_id}","starred_url":"https://api.github.com/users/lindgrenj6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindgrenj6/subscriptions","organizations_url":"https://api.github.com/users/lindgrenj6/orgs","repos_url":"https://api.github.com/users/lindgrenj6/repos","events_url":"https://api.github.com/users/lindgrenj6/events{/privacy}","received_events_url":"https://api.github.com/users/lindgrenj6/received_events","type":"User","site_admin":false},"repo":{"id":167076702,"node_id":"MDEwOlJlcG9zaXRvcnkxNjcwNzY3MDI=","name":"catalog-api","full_name":"lindgrenj6/catalog-api","private":false,"owner":{"login":"lindgrenj6","id":5856504,"node_id":"MDQ6VXNlcjU4NTY1MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5856504?v=4","gravatar_id":"","url":"https://api.github.com/users/lindgrenj6","html_url":"https://github.com/lindgrenj6","followers_url":"https://api.github.com/users/lindgrenj6/followers","following_url":"https://api.github.com/users/lindgrenj6/following{/other_user}","gists_url":"https://api.github.com/users/lindgrenj6/gists{/gist_id}","starred_url":"https://api.github.com/users/lindgrenj6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindgrenj6/subscriptions","organizations_url":"https://api.github.com/users/lindgrenj6/orgs","repos_url":"https://api.github.com/users/lindgrenj6/repos","events_url":"https://api.github.com/users/lindgrenj6/events{/privacy}","received_events_url":"https://api.github.com/users/lindgrenj6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lindgrenj6/catalog-api","description":null,"fork":true,"url":"https://api.github.com/repos/lindgrenj6/catalog-api","forks_url":"https://api.github.com/repos/lindgrenj6/catalog-api/forks","keys_url":"https://api.github.com/repos/lindgrenj6/catalog-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lindgrenj6/catalog-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lindgrenj6/catalog-api/teams","hooks_url":"https://api.github.com/repos/lindgrenj6/catalog-api/hooks","issue_events_url":"https://api.github.com/repos/lindgrenj6/catalog-api/issues/events{/number}","events_url":"https://api.github.com/repos/lindgrenj6/catalog-api/events","assignees_url":"https://api.github.com/repos/lindgrenj6/catalog-api/assignees{/user}","branches_url":"https://api.github.com/repos/lindgrenj6/catalog-api/branches{/branch}","tags_url":"https://api.github.com/repos/lindgrenj6/catalog-api/tags","blobs_url":"https://api.github.com/repos/lindgrenj6/catalog-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lindgrenj6/catalog-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lindgrenj6/catalog-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/lindgrenj6/catalog-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lindgrenj6/catalog-api/statuses/{sha}","languages_url":"https://api.github.com/repos/lindgrenj6/catalog-api/languages","stargazers_url":"https://api.github.com/repos/lindgrenj6/catalog-api/stargazers","contributors_url":"https://api.github.com/repos/lindgrenj6/catalog-api/contributors","subscribers_url":"https://api.github.com/repos/lindgrenj6/catalog-api/subscribers","subscription_url":"https://api.github.com/repos/lindgrenj6/catalog-api/subscription","commits_url":"https://api.github.com/repos/lindgrenj6/catalog-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/lindgrenj6/catalog-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/lindgrenj6/catalog-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/lindgrenj6/catalog-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/lindgrenj6/catalog-api/contents/{+path}","compare_url":"https://api.github.com/repos/lindgrenj6/catalog-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lindgrenj6/catalog-api/merges","archive_url":"https://api.github.com/repos/lindgrenj6/catalog-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lindgrenj6/catalog-api/downloads","issues_url":"https://api.github.com/repos/lindgrenj6/catalog-api/issues{/number}","pulls_url":"https://api.github.com/repos/lindgrenj6/catalog-api/pulls{/number}","milestones_url":"https://api.github.com/repos/lindgrenj6/catalog-api/milestones{/number}","notifications_url":"https://api.github.com/repos/lindgrenj6/catalog-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lindgrenj6/catalog-api/labels{/name}","releases_url":"https://api.github.com/repos/lindgrenj6/catalog-api/releases{/id}","deployments_url":"https://api.github.com/repos/lindgrenj6/catalog-api/deployments","created_at":"2019-01-22T22:24:29Z","updated_at":"2019-05-21T20:23:15Z","pushed_at":"2019-05-21T20:23:14Z","git_url":"git://github.com/lindgrenj6/catalog-api.git","ssh_url":"git@github.com:lindgrenj6/catalog-api.git","clone_url":"https://github.com/lindgrenj6/catalog-api.git","svn_url":"https://github.com/lindgrenj6/catalog-api","homepage":null,"size":852,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"295b61cfcb117b21f5bbd82092f2a12893e65114","user":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":149674149,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk2NzQxNDk=","name":"catalog-api","full_name":"ManageIQ/catalog-api","private":false,"owner":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ManageIQ/catalog-api","description":null,"fork":false,"url":"https://api.github.com/repos/ManageIQ/catalog-api","forks_url":"https://api.github.com/repos/ManageIQ/catalog-api/forks","keys_url":"https://api.github.com/repos/ManageIQ/catalog-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/catalog-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/catalog-api/teams","hooks_url":"https://api.github.com/repos/ManageIQ/catalog-api/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/catalog-api/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/catalog-api/events","assignees_url":"https://api.github.com/repos/ManageIQ/catalog-api/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/catalog-api/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/catalog-api/tags","blobs_url":"https://api.github.com/repos/ManageIQ/catalog-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/catalog-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/catalog-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/catalog-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/catalog-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/catalog-api/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/catalog-api/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/catalog-api/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/catalog-api/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/catalog-api/subscription","commits_url":"https://api.github.com/repos/ManageIQ/catalog-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/catalog-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/catalog-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/catalog-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/catalog-api/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/catalog-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/catalog-api/merges","archive_url":"https://api.github.com/repos/ManageIQ/catalog-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/catalog-api/downloads","issues_url":"https://api.github.com/repos/ManageIQ/catalog-api/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/catalog-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/catalog-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/catalog-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/catalog-api/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/catalog-api/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/catalog-api/deployments","created_at":"2018-09-20T21:44:16Z","updated_at":"2019-05-21T19:29:32Z","pushed_at":"2019-05-21T19:29:29Z","git_url":"git://github.com/ManageIQ/catalog-api.git","ssh_url":"git@github.com:ManageIQ/catalog-api.git","clone_url":"https://github.com/ManageIQ/catalog-api.git","svn_url":"https://github.com/ManageIQ/catalog-api","homepage":null,"size":830,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":15,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":16,"open_issues":15,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296"},"html":{"href":"https://github.com/ManageIQ/catalog-api/pull/296"},"issue":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/issues/296"},"comments":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/issues/296/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/pulls/296/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/catalog-api/statuses/afa06eb86d799eaf4ec047f9147fc82f2a9fa245"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"eclarizio"}}