{"id":99,"date":"2018-12-31T17:33:19","date_gmt":"2018-12-31T16:33:19","guid":{"rendered":"http:\/\/deleforterie.com\/wordpress\/?p=99"},"modified":"2023-01-18T08:53:12","modified_gmt":"2023-01-18T07:53:12","slug":"bigdata-my-bigdataapi","status":"publish","type":"post","link":"https:\/\/deleforterie.com\/wordpress\/index.php\/2018\/12\/31\/bigdata-my-bigdataapi\/","title":{"rendered":"BigData &#8211; My BigDataApi"},"content":{"rendered":"<p>I have updated my python Api for managing Hortonworks Ambari and Ranger with their API.<\/p>\n<p><!--more--><\/p>\n<p>Here is the GitHub repository&nbsp;<a href=\"https:\/\/github.com\/EricDele\/BigDataApi\">https:\/\/github.com\/EricDele\/BigDataApi<\/a><\/p>\n<p>Here is an example with the Sandbox to create a policy for HDFS with the Api<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\n\nfrom ambari import AmbariApi\nfrom ranger import RangerApi\n\nif __name__ == '__main__':\n  rangerApi = RangerApi(\"http\", \"127.0.0.1\", \"6080\", \"basic\")\n  rangerApi.setCredentialsBasic(\"raj_ops\", \"raj_ops\")\n\n  result = rangerApi.postCreatePolicy(policyTemplateType = \"hdfs\", serviceName = \"Sandbox_hadoop\", policyName = \"lake_test\", \n                                      description = \"policy for the lake test\",\n                                      resources = [\"\/lake\/test\",\"\/lake\/data\"], isRecursive = False, \n                                      users = [\"it1\"], groups = [], accesses = \"r-x\")\n  print(rangerApi)\n<\/pre>\n<p>The same for creating a Hive policy<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\n\nfrom ambari import AmbariApi\nfrom ranger import RangerApi\n\nif __name__ == '__main__':\n    rangerApi = RangerApi(\"http\", \"127.0.0.1\", \"6080\", \"basic\")\n    rangerApi.setCredentialsBasic(\"raj_ops\", \"raj_ops\")\n    result = rangerApi.postCreatePolicy(policyTemplateType = \"hive\", serviceName = \"Sandbox_hive\", policyName = \"hive_test\", \n                                        description = \"policy for the hive test\",\n                                        resources = {\"column\":{\"isExcludes\":\"false\",\"value\":[\"*\"]},\"table\":{\"isExcludes\":\"false\",\"value\":[\"j*\",\"d*\"]},\"database\":{\"isExcludes\":\"false\",\"value\":[\"*\"]}}, \n                                        users = [\"it1\"], groups = [],\n                                        accesses = [\"select\",\"update\",\"create\",\"drop\",\"alter\",\"index\",\"lock\",\"all\",\"read\",\"write\"])\n    print(rangerApi)<\/pre>\n<p>Feel free to give me feedback.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have updated my python Api for managing Hortonworks Ambari and Ranger with their API.<\/p>\n","protected":false},"author":2,"featured_media":168,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[4,14,15,7,17],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata","category-hadoop","category-hortonworks","category-python","category-ranger"],"_links":{"self":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":4,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":169,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions\/169"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media\/168"}],"wp:attachment":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}