{"action":"created","comment":{"url":"https://api.github.com/repos/conjurinc/api-python/pulls/comments/70334668","id":70334668,"diff_hunk":"@@ -28,3 +32,74 @@ def __init__(self, api, kind, identifier):\n     @property\n     def resourceid(self):\n         return \":\".join([self.api.config.account, self.kind, self.identifier])\n+\n+    def permit(self, role, privilege, grant_option=False):\n+        '''\n+        Permit `role` to perform `privilege` on this resource.  If\n+        `grant_option` is True, the role will be able to grant this\n+        permission to other resources.\n+\n+        You must own the resource or have the permission with `grant_option`\n+        to call this method.\n+        '''\n+        data = {}\n+        params = {\n+            'permit': 'true',\n+            'privilege': privilege,\n+            'role': authzid(role, 'role')\n+        }\n+        if grant_option:\n+            data['grant_option'] = 'true'\n+\n+        self.api.post(self.url(), data=data, params=params)\n+\n+    def deny(self, role, privilege):\n+        '''\n+        Deny `role` permission to perform `privilege` on this resource.\n+\n+        You must own the resource or have the permission with `grant_option`\n+        on it to call this method.\n+        '''\n+        params = {\n+            'permit': 'true',\n+            'privilege': privilege,\n+            'role': authzid(role)\n+        }\n+\n+        self.api.post(self.url(), parmas=params)\n+\n+    def check_permission(self, privilege, role=None):\n+        '''\n+        Return True if +role+ has +privilege+ on this resource.\n+\n+        +role+ may be a Role instance, an object with a +role+ method,\n+        or a role id as a string.\n+\n+        If +role+ is not given, check the permission for the currently\n+        authenticated role.\n+        '''\n+\n+        if role is None:\n+            # Handle self role check\n+            response = self.api.get(self.url(),\n+                                    params={'check': 'true',\n+                                            'privilege': privilege},\n+                                    check_errors=False)\n+            if response.status_code == 204:\n+                return True\n+            elif response.status_code in (404, 403, 409):","path":"conjur/resource.py","position":70,"original_position":70,"commit_id":"3e24733d202a1d55d18e6638558938a04ddb73eb","original_commit_id":"3e24733d202a1d55d18e6638558938a04ddb73eb","user":{"login":"kstutsman-conjur","id":14279628,"avatar_url":"https://avatars.githubusercontent.com/u/14279628?v=3","gravatar_id":"","url":"https://api.github.com/users/kstutsman-conjur","html_url":"https://github.com/kstutsman-conjur","followers_url":"https://api.github.com/users/kstutsman-conjur/followers","following_url":"https://api.github.com/users/kstutsman-conjur/following{/other_user}","gists_url":"https://api.github.com/users/kstutsman-conjur/gists{/gist_id}","starred_url":"https://api.github.com/users/kstutsman-conjur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstutsman-conjur/subscriptions","organizations_url":"https://api.github.com/users/kstutsman-conjur/orgs","repos_url":"https://api.github.com/users/kstutsman-conjur/repos","events_url":"https://api.github.com/users/kstutsman-conjur/events{/privacy}","received_events_url":"https://api.github.com/users/kstutsman-conjur/received_events","type":"User","site_admin":false},"body":"I only see 404 and 403 handled by the Ruby API, but looks like the apiary docs mention 409. We should probably sort that out one way or another.","created_at":"2016-07-11T20:52:29Z","updated_at":"2016-07-11T20:52:29Z","html_url":"https://github.com/conjurinc/api-python/pull/4#discussion_r70334668","pull_request_url":"https://api.github.com/repos/conjurinc/api-python/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/comments/70334668"},"html":{"href":"https://github.com/conjurinc/api-python/pull/4#discussion_r70334668"},"pull_request":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/conjurinc/api-python/pulls/4","id":77010840,"html_url":"https://github.com/conjurinc/api-python/pull/4","diff_url":"https://github.com/conjurinc/api-python/pull/4.diff","patch_url":"https://github.com/conjurinc/api-python/pull/4.patch","issue_url":"https://api.github.com/repos/conjurinc/api-python/issues/4","number":4,"state":"open","locked":false,"title":"Add permission check methods","user":{"login":"jjmason","id":1227992,"avatar_url":"https://avatars.githubusercontent.com/u/1227992?v=3","gravatar_id":"","url":"https://api.github.com/users/jjmason","html_url":"https://github.com/jjmason","followers_url":"https://api.github.com/users/jjmason/followers","following_url":"https://api.github.com/users/jjmason/following{/other_user}","gists_url":"https://api.github.com/users/jjmason/gists{/gist_id}","starred_url":"https://api.github.com/users/jjmason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjmason/subscriptions","organizations_url":"https://api.github.com/users/jjmason/orgs","repos_url":"https://api.github.com/users/jjmason/repos","events_url":"https://api.github.com/users/jjmason/events{/privacy}","received_events_url":"https://api.github.com/users/jjmason/received_events","type":"User","site_admin":false},"body":"This PR also brings tests (integration) into the jenkins build, cleans up code considerably, and adds a few bonus methods.\r\n\r\nDelivers [CON-3060].","created_at":"2016-07-11T19:40:45Z","updated_at":"2016-07-11T20:52:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8dcd4eb95044598b03eda3e715593737435fc8ee","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/conjurinc/api-python/pulls/4/commits","review_comments_url":"https://api.github.com/repos/conjurinc/api-python/pulls/4/comments","review_comment_url":"https://api.github.com/repos/conjurinc/api-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/conjurinc/api-python/issues/4/comments","statuses_url":"https://api.github.com/repos/conjurinc/api-python/statuses/3e24733d202a1d55d18e6638558938a04ddb73eb","head":{"label":"conjurinc:feature/permission-checks","ref":"feature/permission-checks","sha":"3e24733d202a1d55d18e6638558938a04ddb73eb","user":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"repo":{"id":17882308,"name":"api-python","full_name":"conjurinc/api-python","owner":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conjurinc/api-python","description":"A Python client for the Conjur API","fork":false,"url":"https://api.github.com/repos/conjurinc/api-python","forks_url":"https://api.github.com/repos/conjurinc/api-python/forks","keys_url":"https://api.github.com/repos/conjurinc/api-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conjurinc/api-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conjurinc/api-python/teams","hooks_url":"https://api.github.com/repos/conjurinc/api-python/hooks","issue_events_url":"https://api.github.com/repos/conjurinc/api-python/issues/events{/number}","events_url":"https://api.github.com/repos/conjurinc/api-python/events","assignees_url":"https://api.github.com/repos/conjurinc/api-python/assignees{/user}","branches_url":"https://api.github.com/repos/conjurinc/api-python/branches{/branch}","tags_url":"https://api.github.com/repos/conjurinc/api-python/tags","blobs_url":"https://api.github.com/repos/conjurinc/api-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conjurinc/api-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conjurinc/api-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/conjurinc/api-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conjurinc/api-python/statuses/{sha}","languages_url":"https://api.github.com/repos/conjurinc/api-python/languages","stargazers_url":"https://api.github.com/repos/conjurinc/api-python/stargazers","contributors_url":"https://api.github.com/repos/conjurinc/api-python/contributors","subscribers_url":"https://api.github.com/repos/conjurinc/api-python/subscribers","subscription_url":"https://api.github.com/repos/conjurinc/api-python/subscription","commits_url":"https://api.github.com/repos/conjurinc/api-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/conjurinc/api-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/conjurinc/api-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/conjurinc/api-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/conjurinc/api-python/contents/{+path}","compare_url":"https://api.github.com/repos/conjurinc/api-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conjurinc/api-python/merges","archive_url":"https://api.github.com/repos/conjurinc/api-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conjurinc/api-python/downloads","issues_url":"https://api.github.com/repos/conjurinc/api-python/issues{/number}","pulls_url":"https://api.github.com/repos/conjurinc/api-python/pulls{/number}","milestones_url":"https://api.github.com/repos/conjurinc/api-python/milestones{/number}","notifications_url":"https://api.github.com/repos/conjurinc/api-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conjurinc/api-python/labels{/name}","releases_url":"https://api.github.com/repos/conjurinc/api-python/releases{/id}","deployments_url":"https://api.github.com/repos/conjurinc/api-python/deployments","created_at":"2014-03-18T21:16:16Z","updated_at":"2016-06-14T19:34:54Z","pushed_at":"2016-07-11T19:40:45Z","git_url":"git://github.com/conjurinc/api-python.git","ssh_url":"git@github.com:conjurinc/api-python.git","clone_url":"https://github.com/conjurinc/api-python.git","svn_url":"https://github.com/conjurinc/api-python","homepage":"http://conjur.net","size":97,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"conjurinc:master","ref":"master","sha":"19145735f91a1080f7a434c7b5e11384e0a0cdc5","user":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"repo":{"id":17882308,"name":"api-python","full_name":"conjurinc/api-python","owner":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conjurinc/api-python","description":"A Python client for the Conjur API","fork":false,"url":"https://api.github.com/repos/conjurinc/api-python","forks_url":"https://api.github.com/repos/conjurinc/api-python/forks","keys_url":"https://api.github.com/repos/conjurinc/api-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conjurinc/api-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conjurinc/api-python/teams","hooks_url":"https://api.github.com/repos/conjurinc/api-python/hooks","issue_events_url":"https://api.github.com/repos/conjurinc/api-python/issues/events{/number}","events_url":"https://api.github.com/repos/conjurinc/api-python/events","assignees_url":"https://api.github.com/repos/conjurinc/api-python/assignees{/user}","branches_url":"https://api.github.com/repos/conjurinc/api-python/branches{/branch}","tags_url":"https://api.github.com/repos/conjurinc/api-python/tags","blobs_url":"https://api.github.com/repos/conjurinc/api-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conjurinc/api-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conjurinc/api-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/conjurinc/api-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conjurinc/api-python/statuses/{sha}","languages_url":"https://api.github.com/repos/conjurinc/api-python/languages","stargazers_url":"https://api.github.com/repos/conjurinc/api-python/stargazers","contributors_url":"https://api.github.com/repos/conjurinc/api-python/contributors","subscribers_url":"https://api.github.com/repos/conjurinc/api-python/subscribers","subscription_url":"https://api.github.com/repos/conjurinc/api-python/subscription","commits_url":"https://api.github.com/repos/conjurinc/api-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/conjurinc/api-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/conjurinc/api-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/conjurinc/api-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/conjurinc/api-python/contents/{+path}","compare_url":"https://api.github.com/repos/conjurinc/api-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conjurinc/api-python/merges","archive_url":"https://api.github.com/repos/conjurinc/api-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conjurinc/api-python/downloads","issues_url":"https://api.github.com/repos/conjurinc/api-python/issues{/number}","pulls_url":"https://api.github.com/repos/conjurinc/api-python/pulls{/number}","milestones_url":"https://api.github.com/repos/conjurinc/api-python/milestones{/number}","notifications_url":"https://api.github.com/repos/conjurinc/api-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conjurinc/api-python/labels{/name}","releases_url":"https://api.github.com/repos/conjurinc/api-python/releases{/id}","deployments_url":"https://api.github.com/repos/conjurinc/api-python/deployments","created_at":"2014-03-18T21:16:16Z","updated_at":"2016-06-14T19:34:54Z","pushed_at":"2016-07-11T19:40:45Z","git_url":"git://github.com/conjurinc/api-python.git","ssh_url":"git@github.com:conjurinc/api-python.git","clone_url":"https://github.com/conjurinc/api-python.git","svn_url":"https://github.com/conjurinc/api-python","homepage":"http://conjur.net","size":97,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/4"},"html":{"href":"https://github.com/conjurinc/api-python/pull/4"},"issue":{"href":"https://api.github.com/repos/conjurinc/api-python/issues/4"},"comments":{"href":"https://api.github.com/repos/conjurinc/api-python/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/conjurinc/api-python/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/conjurinc/api-python/statuses/3e24733d202a1d55d18e6638558938a04ddb73eb"}}}}
{"actor":{"display_login":"kstutsman-conjur"}}