jerqi opened a new issue, #5129:
URL: https://github.com/apache/gravitino/issues/5129

   ### Describe the subtask
   
   ```
   {"code":1002,"type":"RuntimeException","message":"Failed to operate object 
[role1] operation [CREATE] under [metalake_demo], reason [Ranger API 
org.apache.ranger.RangerClient$API@59a7c963 failed: statusCode=400, status=Bad 
Request, response:{\"statusCode\":1,\"msgDesc\":\"(0) Validation failure: error 
code[3006], reason[Another policy already exists for this name: policy-id=[19], 
service=[hiveDev]], field[policy name], subfield[null], type[semantically 
incorrect] \
   ```
   
   I run the command
   ```
   import requests
   import json
   
   url = "http://gravitino:8090/api/metalakes/metalake_demo/roles";
   headers = {
       "Accept": "application/vnd.gravitino.v1+json",
       "Content-Type": "application/json",
   }
   data = {
       "name": "role1",
       "properties": {"k1": "v1"},
       "securableObjects": [
           {
               "fullName": "catalog_hive.access_control",
               "type": "SCHEMA",
               "privileges": [
                   {
                       "name": "CREATE_TABLE",
                       "condition": "ALLOW"
                   },
                   {
                       "name": "MODIFY_TABLE",
                       "condition": "ALLOW"
                   },
                   {
                       "name": "SELECT_TABLE",
                       "condition": "ALLOW"
                   }
               ]    
           }
       ]
   }
   
   response = requests.post(url, headers=headers, data=json.dumps(data))
   
   print(response.text)
   ```
   
   ```
   import requests
   import json
   
   url = 
"http://gravitino:8090/api/metalakes/metalake_demo/permissions/users/root/grant";
   headers = {
       "Accept": "application/vnd.gravitino.v1+json",
       "Content-Type": "application/json",
   }
   data = {
       "roleNames": ["role1"]
   }
   
   response = requests.put(url, headers=headers, data=json.dumps(data))
   
   # print status code and response text
   print(response.status_code)
   print(response.text)
   ```
   
   ```
   import requests
   import json
   
   url = "http://gravitino:8090/api/metalakes/metalake_demo/roles";
   headers = {
       "Accept": "application/vnd.gravitino.v1+json",
       "Content-Type": "application/json",
   }
   data = {
       "name": "role1",
       "properties": {"k1": "v1"},
       "securableObjects": [
           {
               "fullName": "catalog_hive.access_control",
               "type": "SCHEMA",
               "privileges": [
                   {
                       "name": "SELECT_TABLE",
                       "condition": "ALLOW"
                   }
               ]    
           }
       ]
   }
   
   response = requests.post(url, headers=headers, data=json.dumps(data))
   
   print(response.text)
   ```
   
   ### Parent issue
   
   #5115


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to