AnsweredAssumed Answered

PAPI: Customer wants to get access to property in subgroup - how?

Question asked by Marc Guentgen Employee on May 27, 2016
Latest reply on May 27, 2016 by Kirsten Hunter

Our customer wants to get PAPI-access to a property in a subgroup called API.

Goal ist to clone a host in an existing property to setup new tenant in a SaaS-scenario.

 

We started with the sample papi_get_meta.py in the kickstarter project.

It traverse through the "Groups" which are groups on the top level we assume.

 

Unfortunately we cannot get into the subgroups - so we have to add an additional loop into the traversing in papi_get_meta.py.

A new method getSubGroups() try to groups by user-admin-API (as this was mentioned in PAPI-API).

 

However we get 403 by executing getSubGroups - can you explain us why?

What is recommend procedure to get to properties in a subgroup?

 

send: 'GET /user-admin/v1/accounts/act_1-4E83C5/groups/grp_17759/groups?groupId=grp_17759&contractId=ctr_3-2WWJMX HTTP/1.1\r\nHost: akab-****.luna.akamaiapis.net\r\nConnection: keep-alive\r\nAuthorization: EG1-HMAC-SHA256 client_token=akab-****;access_token=akab-****timestamp=20160527T19:33:22+0000;nonce=37bdd19b-f59d-42bc-9ae7-0ad61b787b87;signature=y9zF51S5AqdJw****\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.7.0 CPython/2.7.10 Darwin/14.5.0\r\n\r\n'

reply: 'HTTP/1.1 403 Forbidden\r\n'

header: Content-Length: 569

header: Content-Type: application/problem+json

header: Date: Fri, 27 May 2016 19:33:23 GMT

header: Connection: keep-alive

DEBUG:requests.packages.urllib3.connectionpool:"GET /user-admin/v1/accounts/act_1-4E83C5/groups/grp_17759/groups?groupId=grp_17759&contractId=ctr_3-2WWJMX HTTP/1.1" 403 569

ERROR: Call to /user-admin/v1/accounts/act_1-4E83C5/groups/grp_17759/groups failed with a 403 result

 

 

 

def getSubGroups(accountId, groupId, contractId):

        """

        Get the subgroups for the associated group/contract combination

        """

        print "Getting subgroups for group %s and contract %s" % (groupId, contractId)

        property_parameters = { "contractId":contractId, "groupId":groupId }

        subgroups_result = httpCaller.getResult('/user-admin/v1/accounts/%s/groups/%s/groups'

                                                                % (accountId, groupId),

                                                                property_parameters)

 

        if "groups" in subgroups_result:

                subgroups_result = property_result['properties']['items']

        else:

                subgroups_result = []

 

        return (subgroups_result)

 

....

 

        for group in groups:

                groupId = group["groupId"]

                print "GroupId = %s:%s" % (group["groupId"], group["groupName"])

                if "contractIds" in group:

                        for contractId in group["contractIds"]:

                                subgroups = getSubGroups(groupInfo["accountId"], groupId, contractId)

                               for subgroup in subgroups:

                                        groupId = subgroup["groupId"]

                                        properties = getProperties(groupId, contractId)

Outcomes