PHP Class Acquia\CloudApi\Client\CloudApi

This object provides sensible method signatures for almost all of the cloudapi calls. The only one that is missing at this point is the one that installs a drupal distro. I can't see that being relevant to our work, and actually could be quite dangerous. Configuration: This class is meant to be used from the gardener. The other sites in gardens will not have the appropriate credentials. Example: $api = New CloudApi() print_r($api->listDatabases('tangle001', 'prod'));
Exibir arquivo Open project: acquia/cloudapi-php-client

Protected Properties

Property Type Description
$allCreds
$cainfo
$default_options

Public Methods

Method Description
__sleep ( ) This class is not serializable.
addDatabase ( $site, $db, $cluster_map = NULL ) Add a database
addDomain ( $site, $env, $domain ) Add a domain name.
addSSHKey ( $site, $nickname, $ssh_pub_key ) Add an SSH key
addSVNUser ( $site, $username, $password ) Add an SVN user
backupDatabase ( $site, $env, $db ) Create a database instance backup.
copyDatabase ( $site, $db, $source, $target ) Copy a database from one site environment to another
copyFiles ( $site, $source, $target ) Copy files from one site environment to another.
deleteDatabase ( $site, $db, $backup = 1 ) Delete a database
deleteDatabaseBackup ( $site, $env, $db, $backup ) Delete a site environment database instance backup.
deleteDomain ( $site, $env, $domain ) Delete a domain.
deleteSSHKey ( $site, $sshkeyid ) Delete an SSH key.
deleteSVNUser ( $site, $sshuserid ) Delete an SVN user
deployCode ( $site, $source, $target ) Deploy code from one site environment to another.
deployCodePath ( $site, $env, $path ) Deploy a specific VCS branch or tag to an environment.
getAllSiteNames ( ) Returns the set of all site names from the credentials file.
getDatabaseBackupInfo ( $site, $env, $db, $backup ) Get details about a database instance backup.
getDatabaseBackupLocation ( $site, $env, $db, $backup ) Get the location from which a backup can be downloaded.
getDatabaseClusterMap ( $site, $envs = NULL ) Returns an array of suitable database clusters for each environment.
getDatabaseInfo ( $site, $env, $db ) Get a database instance.
getDomainInfo ( $site, $env, $domain ) Get a domain record.
getEnvironmentInfo ( $site, $env ) Gets an environment record.
getInstance ( $site_name = NULL, $stage = NULL, $creds_filename = NULL ) : CloudApi Returns an instance of CloudApi, reusing a previous one if available.
getSSHKey ( $site, $sshkeyid ) Get an SSH key
getSVNUser ( $site, $svnuserid ) Get an SVN user.
getServerInfo ( $site, $env, $server ) Get a server record.
getSiteName ( {String} $site ) Returns the site name.
getSiteRecord ( $site ) Gets a site record.
getStage ( ) Returns the stage this CloudApi instance is configured to communicate with.
getTaskInfo ( $site, $task ) Get a task record.
getTasks ( $site ) List a site's tasks.
installEnvironment ( $site, $env, $type, $source ) Installs a drupal distro.
listDatabaseBackups ( $site, $env, $db ) List a site environment's database instance backups.
listDatabases ( $site, $env ) List a site environment's database instances.
listDomains ( $site, $env ) List the environment's domains.
listEnvironments ( $site ) List a site's environments.
listSSHKeys ( $site ) List a site's SSH keys.
listSVNUsers ( $site ) List a site's SVN users.
listServers ( $site, $env ) List a site environment's servers.
listSites ( $site ) Lists all sites accessible by the caller.
moveAllDomains ( string $sitegroup, string $from_env, string $to_env, boolean $skip_site_update = TRUE ) : array Moves all domains on a site atomically from one environment to another.
moveDomains ( string | array $domains, string $sitegroup, string $from_env, string $to_env, boolean $skip_site_update = TRUE ) Moves domains atomically from one environment to another.
purgeVarnish ( $site, $env, $domain ) Purge the Varnish cache for a domain.
restoreDatabase ( $site, $env, $db, $backup ) Restore a site environment database instance backup.
setCaInfo ( $path ) Set the path to a CA file for curl.
setDefaultCallOption ( $key, $value ) Set a default option for the callAcapi() method.

Private Methods

Method Description
__construct ( $site_name, $stage = NULL, $creds_filename = NULL ) Constructor.
callAcapi ( $site, $method, $resource, $params = [], $body = [], $options = [] ) Call an Acquia Cloud API resource.
getCreds ( {mixed} $site ) Returns the credentials for the specified site.

Method Details

__sleep() public method

Because CloudApi credentials are cached as part of this object, serializing it will provide those credentials in clear text.
public __sleep ( )

addDatabase() public method

Add a database
public addDatabase ( $site, $db, $cluster_map = NULL )
$site the site name (ex: tangle001, gardener, etc.)
$db the database name
$cluster_map a mapping containing all environments and the cluster to which the associated database should be created. (See getDatabaseClusterMap). Note that if more than one cluster is associated with a sitegroup, this map is required.

addDomain() public method

Add a domain name.
public addDomain ( $site, $env, $domain )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name
$domain the domain name to add

addSSHKey() public method

Add an SSH key
public addSSHKey ( $site, $nickname, $ssh_pub_key )
$site the site name (ex: tangle001, gardener, etc.)
$nickname key nickname
$ssh_pub_key SSH public key

addSVNUser() public method

Add an SVN user
public addSVNUser ( $site, $username, $password )
$site the site name (ex: tangle001, gardener, etc.)
$password user svn password

backupDatabase() public method

Create a database instance backup.
public backupDatabase ( $site, $env, $db )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name
$db the database name

copyDatabase() public method

Copy a database from one site environment to another
public copyDatabase ( $site, $db, $source, $target )
$site the site name (ex: tangle001, gardener, etc.)
$db the database name
$source the source environment name
$target the target environment name

copyFiles() public method

Copy files from one site environment to another.
public copyFiles ( $site, $source, $target )
$site the site name (ex: tangle001, gardener, etc.)
$source the source environment name
$target the target environment name

deleteDatabase() public method

Delete a database
public deleteDatabase ( $site, $db, $backup = 1 )
$site the site name (ex: tangle001, gardener, etc.)
$db the database name
$backup a final backup of the database instance in each environment is made before deletion unless this query parameter has value 0.

deleteDatabaseBackup() public method

Delete a site environment database instance backup.
public deleteDatabaseBackup ( $site, $env, $db, $backup )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$db the database name
$backup the backup id

deleteDomain() public method

Delete a domain.
public deleteDomain ( $site, $env, $domain )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$domain the domain name to delete

deleteSSHKey() public method

Delete an SSH key.
public deleteSSHKey ( $site, $sshkeyid )
$site the site name (ex: tangle001, gardener, etc.)
$sshkeyid Key id

deleteSVNUser() public method

Delete an SVN user
public deleteSVNUser ( $site, $sshuserid )
$site the site name (ex: tangle001, gardener, etc.)

deployCode() public method

Deploy code from one site environment to another.
public deployCode ( $site, $source, $target )
$site the site name (ex: tangle001, gardener, etc.)
$source the source environment name
$target the target environment name

deployCodePath() public method

Deploy a specific VCS branch or tag to an environment.
public deployCodePath ( $site, $env, $path )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name
$path the name of the branch or tag (e.g. master or tags/tagname)

getAllSiteNames() public method

Returns the set of all site names from the credentials file.
public getAllSiteNames ( )

getDatabaseBackupInfo() public method

Get details about a database instance backup.
public getDatabaseBackupInfo ( $site, $env, $db, $backup )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$db the database name (ex: 'g76')
$backup the backup id (ex: 217005)

getDatabaseBackupLocation() public method

Get the location from which a backup can be downloaded.
public getDatabaseBackupLocation ( $site, $env, $db, $backup )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$db the database name (ex: 'g76')
$backup the backup id (ex: 217005)

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.

getDatabaseInfo() public method

Get a database instance.
public getDatabaseInfo ( $site, $env, $db )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$db the database name (ex: 'g76')

getDomainInfo() public method

Get a domain record.
public getDomainInfo ( $site, $env, $domain )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$domain the domain name (ex: bar.com)

getEnvironmentInfo() public method

Gets an environment record.
public getEnvironmentInfo ( $site, $env )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)

getInstance() public static method

Returns an instance of CloudApi, reusing a previous one if available.
public static getInstance ( $site_name = NULL, $stage = NULL, $creds_filename = NULL ) : CloudApi
$site_name The name of the site for which credentials should be used.
$stage Optional. If provided a file with the suffix matching the stage will be used rather than the default cloudapi.ini file.
return CloudApi An instance of the CloudApi class.

getSSHKey() public method

Get an SSH key
public getSSHKey ( $site, $sshkeyid )
$site the site name (ex: tangle001, gardener, etc.)
$sshkeyid SSH key id

getSVNUser() public method

Get an SVN user.
public getSVNUser ( $site, $svnuserid )
$site the site name (ex: tangle001, gardener, etc.)
$svnuserid SVN user id

getServerInfo() public method

Get a server record.
public getServerInfo ( $site, $env, $server )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$server the server name

getSiteName() public method

This method allows us to do aliases in the credential files. For example we could have an entry: gardener=gardener-utest which would allow us to refer to the site as gardener in our code, and would be resolved to the correct name via the credentials file.
public getSiteName ( {String} $site )
$site {String}

getSiteRecord() public method

Gets a site record.
public getSiteRecord ( $site )
$site the site name (ex: tangle001, gardener, etc.)

getStage() public method

Returns the stage this CloudApi instance is configured to communicate with.
public getStage ( )

getTaskInfo() public method

Get a task record.
public getTaskInfo ( $site, $task )
$site the site name (ex: tangle001, gardener, etc.)
$task the task id

getTasks() public method

List a site's tasks.
public getTasks ( $site )
$site the site name (ex: tangle001, gardener, etc.)

installEnvironment() public method

Seriously, don't call this. It will throw an exception.
public installEnvironment ( $site, $env, $type, $source )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$type the type of distro source. ex: 'distro_name', 'distro_url', 'make_url'
$source a distro name, URL to a distro, or URL to a Drush make file.

listDatabaseBackups() public method

List a site environment's database instance backups.
public listDatabaseBackups ( $site, $env, $db )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$db the database name (ex: 'g76')

listDatabases() public method

List a site environment's database instances.
public listDatabases ( $site, $env )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)

listDomains() public method

List the environment's domains.
public listDomains ( $site, $env )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)

listEnvironments() public method

List a site's environments.
public listEnvironments ( $site )
$site the site name (ex: tangle001, gardener, etc.)

listSSHKeys() public method

List a site's SSH keys.
public listSSHKeys ( $site )
$site the site name (ex: tangle001, gardener, etc.)

listSVNUsers() public method

List a site's SVN users.
public listSVNUsers ( $site )
$site the site name (ex: tangle001, gardener, etc.)

listServers() public method

List a site environment's servers.
public listServers ( $site, $env )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)

listSites() public method

Lists all sites accessible by the caller.
public listSites ( $site )
$site the site name (ex: tangle001, gardener, etc.)

moveAllDomains() public method

This is just a special case of moveDomain, using the wildcard as domain.
public moveAllDomains ( string $sitegroup, string $from_env, string $to_env, boolean $skip_site_update = TRUE ) : array
$sitegroup string The hosting sitegroup name.
$from_env string The hosting environment to take domains from.
$to_env string The hosting environment to move domains to.
$skip_site_update boolean If set to TRUE (default), this will inhibit running fields-config-web.php for this domain move.
return array The task record for moving the domains.

moveDomains() public method

Moves domains atomically from one environment to another.
public moveDomains ( string | array $domains, string $sitegroup, string $from_env, string $to_env, boolean $skip_site_update = TRUE )
$domains string | array The domain name(s) as an array of strings, or the string '*' to move all domains.
$sitegroup string The hosting sitegroup name.
$from_env string The environment which currently has this domain.
$to_env string The destination environment for the domain.
$skip_site_update boolean If set to TRUE (default), this will inhibit running fields-config-web.php for this domain move.

purgeVarnish() public method

Purge the Varnish cache for a domain.
public purgeVarnish ( $site, $env, $domain )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name (ex: prod, dev)
$domain the domain name to delete

restoreDatabase() public method

Restore a site environment database instance backup.
public restoreDatabase ( $site, $env, $db, $backup )
$site the site name (ex: tangle001, gardener, etc.)
$env the environment name
$db the database name
$backup the backup id

setCaInfo() public method

This is mostly useful when using a crufty version of PHP for development and the provided CA file is outdated. You can get an updated one from http://curl.haxx.se/docs/caextract.html
public setCaInfo ( $path )
$path The path to a CA PEM file.

setDefaultCallOption() public method

Set a default option for the callAcapi() method.
public setDefaultCallOption ( $key, $value )
$key String key.
$value mixed value.

Property Details

$allCreds protected_oe static_oe property

protected static $allCreds

$cainfo protected_oe property

protected $cainfo

$default_options protected_oe property

protected $default_options