PaloAltoNetworks / prismacloud-api-python

Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs.
ISC License
61 stars 55 forks source link

PC Child Cloud Account List Capability #11

Closed jtb75 closed 2 years ago

jtb75 commented 2 years ago

Is your feature request related to a problem?

The function cloud_accounts_list_read only returns individual or parent level accounts. All accounts should be returned.

Describe the solution you'd like

If calling cloud_accounts_list_read I would expect to receive all cloud accounts or would have an option for passing in an account ID of an org/tenant and receive all children accounts.

Describe alternatives you've considered

  1. Either recursively iterate through all accountTypes of MasterServiceAccount, organization, or tenant to return comprehensive list.
  2. Modify the function to receive as an input the parent account id.
  3. Create a separate function for cloud_accounts_children_list_read
welcome-to-palo-alto-networks[bot] commented 2 years ago

:tada: Thanks for opening your first issue here! Welcome to the community!

tkishel commented 2 years ago

Since cloud_accounts_list_read() is a wrapper for one endpoint (https://prisma.pan.dev/api/cloud/cspm/cloud-accounts#operation/get-cloud-accounts) and enumerating the children accounts of a parent account requires another endpoint (https://prisma.pan.dev/api/cloud/cspm/cloud-accounts#operation/get-cloud-org-accounts) I think this could best be accomplished by adding a wrapper (organization_cloud_accounts_list_read ?) for that endpoint and adding a method to _extended.py that calls organization_cloud_accounts_list_read(cloud_type, cloud_account_id) for each account in the the result of cloud_accounts_list_read() that is a parent (maybe identified via numberOfChildAccounts > 0) ???

jtb75 commented 2 years ago

child query added is cloud_accounts_children_list_read within posture endpoints.