sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject [10/13] sentry git commit: Added command documentation
Date Thu, 11 May 2017 06:45:15 GMT
Added command documentation


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/0a75c8c6
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/0a75c8c6
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/0a75c8c6

Branch: refs/heads/akolb-ha-cli
Commit: 0a75c8c6d2b1219e4d73694fe4696e6d3601c1f2
Parents: d6e9098
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Wed Dec 14 12:50:36 2016 -0800
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Wed May 10 23:28:29 2017 -0700

----------------------------------------------------------------------
 .../org/apache/sentry/shell/PrivsShell.java     | 19 +++++++++++---
 .../java/org/apache/sentry/shell/ShellUtil.java |  3 +++
 .../org/apache/sentry/shell/TopLevelShell.java  | 27 ++++++++++++++++----
 3 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/0a75c8c6/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
index 82369cd..9d8b9d9 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
@@ -19,6 +19,7 @@
 package org.apache.sentry.shell;
 
 import com.budhash.cliche.Command;
+import com.budhash.cliche.Param;
 import com.budhash.cliche.Shell;
 import com.budhash.cliche.ShellDependent;
 import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient;
@@ -30,7 +31,12 @@ public class PrivsShell implements ShellDependent {
     Shell shell;
 
     @Command(description = "Grant privilege to role")
-    public void grant(String roleName, String privilege) {
+    public void grant(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "privilege",
+                    description = "privilege string, e.g. server=s1->db=foo")
+            String privilege) {
         tools.grantPrivilegeToRole(roleName, privilege);
     }
 
@@ -40,12 +46,19 @@ public class PrivsShell implements ShellDependent {
     }
 
     @Command
-    public List<String> list(String roleName) {
+    public List<String> list(
+            @Param(name = "roleName")
+            String roleName) {
         return tools.listPrivileges(roleName);
     }
 
     @Command
-    public void revoke(String roleName, String privilege) {
+    public void revoke(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "privilege",
+                    description = "privilege string, e.g. server=s1->db=foo")
+            String privilege) {
         tools.revokePrivilegeFromRole(roleName, privilege);
     }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/0a75c8c6/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
index 4decf28..007975c 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
@@ -236,6 +236,9 @@ class ShellUtil {
         List<String> result = new LinkedList<>();
         for (TSentryPrivilege privilege : privileges) {
             String privilegeStr =  convertTSentryPrivilegeToStr(privilege);
+            if (privilegeStr.isEmpty()) {
+                continue;
+            }
             result.add(privilegeStr);
         }
         return result;

http://git-wip-us.apache.org/repos/asf/sentry/blob/0a75c8c6/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
index d5d74b4..ef5313a 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
@@ -84,13 +84,20 @@ public class TopLevelShell implements ShellDependent, Runnable {
     }
 
     @Command(description = "Grant role to groups")
-    public void grantRole(String roleName, String ...groups) {
+    public void grantRole(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "group...") String ...groups) {
         tools.grantGroupsToRole(roleName, groups);
     }
 
     @Command(abbrev = "grm",
             description = "Revoke role from groups")
-    public void revokeRole(String roleName, String ...groups) {
+    public void revokeRole(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "group...")
+            String ...groups) {
         tools.revokeGroupsFromRole(roleName, groups);
     }
 
@@ -114,17 +121,27 @@ public class TopLevelShell implements ShellDependent, Runnable {
     }
 
     @Command(description = "list Sentry privileges")
-    public List<String> listPrivileges(String roleName) {
+    public List<String> listPrivileges(
+            @Param(name = "roleName")
+            String roleName) {
         return tools.listPrivileges(roleName);
     }
 
     @Command(description = "Grant privilege to role")
-    public void grantPrivilege(String roleName, String privilege) {
+    public void grantPrivilege(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "privilege", description = "privilege string, e.g. server=s1->db=foo")
+            String privilege) {
         tools.grantPrivilegeToRole(roleName, privilege);
     }
 
     @Command
-    public void revokePrivilege(String roleName, String privilege) {
+    public void revokePrivilege(
+            @Param(name = "roleName")
+            String roleName,
+            @Param(name = "privilege", description = "privilege string, e.g. server=s1->db=foo")
+            String privilege) {
         tools.revokePrivilegeFromRole(roleName, privilege);
     }
 


Mime
View raw message