Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to GET Get Service Definition APIs in HDP 2.5.0

avatar
Expert Contributor

In HDP 2.5.0 we can get policy and repository through REST API, But we can't get "servicedef"

In HDP doc only Repository API and Policy API is mentioned. So we can't Get Service Definition in HDP 2.5.0 ?

Apache Ranger Public REST API

 :high_voltage: root@pravin1  /tmp  curl -u admin:admin -X GET http://172.26.74.244:6080/service/public/v2/api/servicedef/1  -v
* About to connect() to 172.26.74.244 port 6080 (#0)
*   Trying 172.26.74.244... connected
* Connected to 172.26.74.244 (172.26.74.244) port 6080 (#0)
* Server auth using Basic with user 'admin'
> GET /service/public/v2/api/servicedef/1  HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 172.26.74.244:6080
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< Set-Cookie: RANGERADMINSESSIONID=208A7798C5A8B7D23D1C030D2C42E35C; Path=/; HttpOnly
< X-Frame-Options: DENY
< Content-Length: 0
< Date: Tue, 15 Aug 2017 07:19:59 GMT
<
* Connection #0 to host 172.26.74.244 left intact
* Closing connection #0
 :high_voltage: root@pravin1  /tmp  curl -u admin:admin -X GET http://172.26.74.244:6080/service/public/v2/api/policy/1 -v
* About to connect() to 172.26.74.244 port 6080 (#0)
*   Trying 172.26.74.244... connected
* Connected to 172.26.74.244 (172.26.74.244) port 6080 (#0)
* Server auth using Basic with user 'admin'
> GET /service/public/v2/api/policy/1 HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 172.26.74.244:6080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Set-Cookie: RANGERADMINSESSIONID=6AE0364F2B3BF923582E7601060D3A32; Path=/; HttpOnly
< X-Frame-Options: DENY
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Tue, 15 Aug 2017 07:22:14 GMT
<
* Connection #0 to host 172.26.74.244 left intact
* Closing connection #0
{"id":1,"guid":"7dac9130-27f5-4fd2-a220-035f9f24bb82","isEnabled":true,"createdBy":"amb_ranger_admin","updatedBy":"Admin","createTime":1473764145000,"updateTime":1496908302000,"version":2,"service":"Sandbox_hadoop","name":"c1_bne_hadoop-1-20170427003530","policyType":0,"description":"Default Policy for Service: c1_bne_hadoop","resourceSignature":"6f956063401eda656f1eae8870c1afac","isAuditEnabled":true,"resources":{"path":{"values":["/*"],"isExcludes":false,"isRecursive":true}},"policyItems":[{"accesses":[{"type":"read","isAllowed":true},{"type":"write","isAllowed":true},{"type":"execute","isAllowed":true}],"users":["ambari-qa","testuser"],"groups":["testgroup"],"conditions":[],"delegateAdmin":true}],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[],"rowFilterPolicyItems":[]}#
1 ACCEPTED SOLUTION

avatar

It seems to work from my Mac...

hw11970:~ hosako$ curl -u admin:admin -X GET http://sandbox.hortonworks.com:6080/service/public/v2/api/servicedef/1
{"id":1,"guid":"0d047247-bafe-4cf8-8e9b-d5d377284b2d","isEnabled":true,"createTime":1473763848000,"updateTime":1473763848000,"version":1,"name":"hdfs","implClass":"org.apache.ranger.services.hdfs.RangerServiceHdfs","label":"HDFS...

View solution in original post

2 REPLIES 2

avatar

It seems to work from my Mac...

hw11970:~ hosako$ curl -u admin:admin -X GET http://sandbox.hortonworks.com:6080/service/public/v2/api/servicedef/1
{"id":1,"guid":"0d047247-bafe-4cf8-8e9b-d5d377284b2d","isEnabled":true,"createTime":1473763848000,"updateTime":1473763848000,"version":1,"name":"hdfs","implClass":"org.apache.ranger.services.hdfs.RangerServiceHdfs","label":"HDFS...

avatar
Expert Contributor

@Hajime Thanks , It worked for me. Some kind typo in copy paste.