How to recover the hdp

2019-08-28 05:13发布

问题:

I have this command line to dispaly the YARN policy:

The result is:

{
    "id": 131,
    "guid": "4d9c3257-0998-42ea-8506-f773a368430d",
    "isEnabled": true,
    "version": 2,
    "service": "Namecluster_yarn",

        }
    },
    "policyItems": [
        {
            "accesses": [
                {
                    "type": "submit-app",
                    "isAllowed": true
                }
            ],
            "users": [],
            "groups": [
                "Application_Team_1"
            ],
            "conditions": [],
            "delegateAdmin": false
        }
    ],
    "denyPolicyItems": [],
    "allowExceptions": [],
    "denyExceptions": [],
    "dataMaskPolicyItems": [],
    "rowFilterPolicyItems": []
}

I would like recover just the list of the groups (in my case I have just one group is Application_Team_1).

How can I recover the list of groups via the API REST or shell if it's possible ?

回答1:

Using jq:

wget "http://myhost:6080/service/public/v2/api/service/Namecluster_yarn/policy/YARN%20_QueueName/" | jq -r '.policyItems[0].groups[0]'

Use wget or curl or something else that can output JSON data.

jq is filtering the string you want. Note the -r option to get rid of double quotes.



标签: shell rest yarn