Retrieve the cloud accounts assigned to each FlexOrg Sub org level using GraphQL Explorer
search cancel

Retrieve the cloud accounts assigned to each FlexOrg Sub org level using GraphQL Explorer

book

Article ID: 419785

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

Using GraphQL API Explorer tool under Setup/Admin you can use the query and variable below to retreive the Name and Id of each AWS Account, Azure Subscription and Google Project assigned to the 
https://apps.cloudhealthtech.com/ui/graphql-explorer/ 

Resolution

query OrganizationChildren($after: String, $sortRules: [SortRule!], $filterRules: [FilterRule!]) {
  organizations(
    after: $after
    first: 1000
    sortRules: $sortRules
    filterRules: $filterRules
  ) {
    totalCount: count
    edges {
      node {
        id
        name
        description
        defaultOrganization
        assignedUsersCount
        parentOrganizationCRN
        flexOrg
        awsAccounts {
          totalCount
          __typename
          edges{
            node{
              id
              name
            }
          }
        }
        azureSubscriptions {
          totalCount
          __typename
          edges {
            node {
              id
              name
            }
          }
        }
        gcpProjects {
          totalCount
          __typename
          edges {
            node {
              id
              name
            }
          }
        }
        __typename
      }
      __typename
    }
    pageInfo {
      hasNextPage
      endCursor
      __typename
    }
    __typename
  }
}

 

Example Variable block.

Note the 12345 in the example below should be replaced with the customer's CloudHealth ID and the Org ID can be found in the URL when clicking on each FlexOrg level. 
Format >> crn:CH ID:organization/Org ID

{
  "sortRules": [
    {
      "field": "name",
      "direction": "ASC"
    }
  ],
  "filterRules": [
    {
      "field": "parentOrganizationCRN",
      "filterType": "EQ",
      "filterValues": [
        "crn:12345:organization/21990232856974"
      ]
    }
  ]
}