{"action":"created","comment":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments/94290168","pull_request_review_id":14818634,"id":94290168,"diff_hunk":"@@ -803,13 +822,278 @@ def get(self, deployment_id, **kwargs):\n \n class Events(SecuredResource):\n \n+    \"\"\"Events resource.\n+\n+    Throgh the events endpoint a user can retrieve both events and logs as\n+    stored in the SQL database.\n+\n+    \"\"\"\n+\n     @staticmethod\n-    def _query_events():\n+    def _build_select_query(_include, filters, pagination, sort):\n+        \"\"\"Build query used to list events for a given execution.\n+\n+        :param _include:\n+            Projection used to get records from database (not currently used)\n+        :type _include: list(str)\n+        :param filters:\n+            Filter selection. It's used to decide if events:\n+                {'type': ['cloudify_event']}\n+            or both events and logs should be returned:\n+                {'type': ['cloudify_event', 'cloudify_log']}\n+        :type filters: dict(str, str)\n+        :param pagination:\n+            Parameters used to limit results returned in a single query.\n+            Expected values `size` and `offset` are mapped into SQL as `LIMIT`\n+            and `OFFSET`.\n+        :type pagination: dict(str, int)\n+        :param sort:\n+            Result sorting order. The only allowed and expected value is to\n+            sort by timestamp in ascending order:\n+                {'timestamp': 'asc'}\n+        :type sort: dict(str, str)\n+        :returns:\n+            A SQL query that returns the events found that match the conditions\n+            passed as arguments.\n+        :rtype: :class:`sqlalchemy.sql.elements.TextClause`\n+\n         \"\"\"\n-        List events for the provided Elasticsearch query\n+        if _include is not None:\n+            current_app.logger.error(\n+                'Projections with `_include` parameter are not supported')\n+            return abort(400)","path":"rest-service/manager_rest/rest/resources.py","position":85,"original_position":85,"commit_id":"f1d28ce80606e49c464bf1563d10e26b592c0d68","original_commit_id":"f1d28ce80606e49c464bf1563d10e26b592c0d68","user":{"login":"idanmo","id":1758680,"avatar_url":"https://avatars.githubusercontent.com/u/1758680?v=3","gravatar_id":"","url":"https://api.github.com/users/idanmo","html_url":"https://github.com/idanmo","followers_url":"https://api.github.com/users/idanmo/followers","following_url":"https://api.github.com/users/idanmo/following{/other_user}","gists_url":"https://api.github.com/users/idanmo/gists{/gist_id}","starred_url":"https://api.github.com/users/idanmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idanmo/subscriptions","organizations_url":"https://api.github.com/users/idanmo/orgs","repos_url":"https://api.github.com/users/idanmo/repos","events_url":"https://api.github.com/users/idanmo/events{/privacy}","received_events_url":"https://api.github.com/users/idanmo/received_events","type":"User","site_admin":false},"body":"In other request handlers a BadParametersError is raised which is then handled by the \"exceptions_handled\" decorator.. this is done in order to return a consistent JSON response in case there's an error with some known error codes. There are many examples for this in the code, just look for BadParametersError.\r\n","created_at":"2017-01-01T23:13:27Z","updated_at":"2017-01-01T23:16:39Z","html_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656#discussion_r94290168","pull_request_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656","_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments/94290168"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656#discussion_r94290168"},"pull_request":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656"}}},"pull_request":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656","id":99064268,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656","diff_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656.diff","patch_url":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656.patch","issue_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/656","number":656,"state":"open","locked":false,"title":"CFY-6091. Use postgres to get events","user":{"login":"jcollado","id":43780,"avatar_url":"https://avatars.githubusercontent.com/u/43780?v=3","gravatar_id":"","url":"https://api.github.com/users/jcollado","html_url":"https://github.com/jcollado","followers_url":"https://api.github.com/users/jcollado/followers","following_url":"https://api.github.com/users/jcollado/following{/other_user}","gists_url":"https://api.github.com/users/jcollado/gists{/gist_id}","starred_url":"https://api.github.com/users/jcollado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcollado/subscriptions","organizations_url":"https://api.github.com/users/jcollado/orgs","repos_url":"https://api.github.com/users/jcollado/repos","events_url":"https://api.github.com/users/jcollado/events{/privacy}","received_events_url":"https://api.github.com/users/jcollado/received_events","type":"User","site_admin":false},"body":"In this PR, the implementation of the `events` endpoints is updated to use a\r\nSQL database as a backend instead of elasticsearch.\r\n\r\nThe responses send back to the client are compatible with the ones previously\r\nsent when elasticsearch was the backend. Hence, no update is needed in the\r\nclients.\r\n\r\nSome comments and remaning work for future PRs:\r\n\r\n- Some work on the client would be nice to avoid converting data to have the\r\n  same format as was returned by elasticsearch.\r\n\r\n- There's quite a bit validation code that should be refactored probably with\r\n  the help of some library. `flask-restful` provides `reqparse`, but it's no\r\n  longer maintained and the documentation points to `marshmallow` (`schematics`\r\n  looks similar).\r\n\r\n- The delete events endpoint still doesn't work.\r\n\r\n- Events are now deleted on cascade with both deployments and executions, so\r\n  the ability to delete events might be no longer needed.\r\n\r\n- There's a `search` endpoint that still relies on elasticsearch. A similar\r\n  update to the one in this PR is required before being able to remove\r\n  elasticsearch as the log backend.\r\n\r\nRequires: cloudify-cosmo/cloudify-manager-blueprints#455","created_at":"2016-12-22T08:17:20Z","updated_at":"2017-01-01T23:16:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4484981fe9f7bb9f48229f71eab45e068b2b30de","assignee":{"login":"idanmo","id":1758680,"avatar_url":"https://avatars.githubusercontent.com/u/1758680?v=3","gravatar_id":"","url":"https://api.github.com/users/idanmo","html_url":"https://github.com/idanmo","followers_url":"https://api.github.com/users/idanmo/followers","following_url":"https://api.github.com/users/idanmo/following{/other_user}","gists_url":"https://api.github.com/users/idanmo/gists{/gist_id}","starred_url":"https://api.github.com/users/idanmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idanmo/subscriptions","organizations_url":"https://api.github.com/users/idanmo/orgs","repos_url":"https://api.github.com/users/idanmo/repos","events_url":"https://api.github.com/users/idanmo/events{/privacy}","received_events_url":"https://api.github.com/users/idanmo/received_events","type":"User","site_admin":false},"assignees":[{"login":"idanmo","id":1758680,"avatar_url":"https://avatars.githubusercontent.com/u/1758680?v=3","gravatar_id":"","url":"https://api.github.com/users/idanmo","html_url":"https://github.com/idanmo","followers_url":"https://api.github.com/users/idanmo/followers","following_url":"https://api.github.com/users/idanmo/following{/other_user}","gists_url":"https://api.github.com/users/idanmo/gists{/gist_id}","starred_url":"https://api.github.com/users/idanmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idanmo/subscriptions","organizations_url":"https://api.github.com/users/idanmo/orgs","repos_url":"https://api.github.com/users/idanmo/repos","events_url":"https://api.github.com/users/idanmo/events{/privacy}","received_events_url":"https://api.github.com/users/idanmo/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656/commits","review_comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656/comments","review_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/656/comments","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/f1d28ce80606e49c464bf1563d10e26b592c0d68","head":{"label":"cloudify-cosmo:CFY-6091-use-postgres-to-get-events","ref":"CFY-6091-use-postgres-to-get-events","sha":"f1d28ce80606e49c464bf1563d10e26b592c0d68","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326574,"name":"cloudify-manager","full_name":"cloudify-cosmo/cloudify-manager","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager","description":"Cloudify's manager related code","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/releases{/id}","deployments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/deployments","created_at":"2014-04-01T11:06:47Z","updated_at":"2016-10-24T17:33:27Z","pushed_at":"2017-01-01T20:05:13Z","git_url":"git://github.com/cloudify-cosmo/cloudify-manager.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-manager.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-manager.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-manager","homepage":null,"size":14231,"stargazers_count":35,"watchers_count":35,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":28,"forks":37,"open_issues":28,"watchers":35,"default_branch":"master"}},"base":{"label":"cloudify-cosmo:master","ref":"master","sha":"3dbaee5182a8a9d28af53749b28870cfe6d41f9b","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326574,"name":"cloudify-manager","full_name":"cloudify-cosmo/cloudify-manager","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-manager","description":"Cloudify's manager related code","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/releases{/id}","deployments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/deployments","created_at":"2014-04-01T11:06:47Z","updated_at":"2016-10-24T17:33:27Z","pushed_at":"2017-01-01T20:05:13Z","git_url":"git://github.com/cloudify-cosmo/cloudify-manager.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-manager.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-manager.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-manager","homepage":null,"size":14231,"stargazers_count":35,"watchers_count":35,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":28,"forks":37,"open_issues":28,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-manager/pull/656"},"issue":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/656"},"comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/issues/656/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/pulls/656/commits"},"statuses":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-manager/statuses/f1d28ce80606e49c464bf1563d10e26b592c0d68"}}}}
{"actor":{"display_login":"idanmo"}}