Acquia\CloudApi\Client\CloudApi::getDatabaseClusterMap PHP Method

getDatabaseClusterMap() public method

This array structure is meant to be passed into the addDatabase method and provides a suitable database cluster for each environment of the specified site. When adding a database, a new database will be added to each environment, and if an attempt is made to add a database to an environment on a cluster that is not associated with that environment the addDatabase call will create a task that will fail. Getting the array from this method guarantees that each environment will have a suitable cluster_id. Any desired modifications can be made and then the database add should work correctly.
public getDatabaseClusterMap ( $site, $envs = NULL )
$site the site name (ex: tangle001, gardener, etc.)
$envs The environment list (from listEnvironments). If not provided the environments will be retrieved.
    public function getDatabaseClusterMap($site, $envs = NULL)
    {
        $result = array();
        if (empty($envs)) {
            $envs = $this->listEnvironments($site);
        }
        foreach ($envs as $env) {
            if (!empty($env->db_clusters)) {
                for ($i = 0; $i < count($env->db_clusters); $i++) {
                    $cluster = $env->db_clusters[$i];
                    if ($cluster > 0) {
                        $result[$env->name] = $cluster;
                        break;
                    }
                }
            }
        }
        return $result;
    }