You are here

function acquia_spi_send_data in Acquia Connector 7.3

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \acquia_spi_send_data()
  2. 7.2 acquia_spi/acquia_spi.module \acquia_spi_send_data()

Send data to Acquia Insight.

Note, call acquia_spi_send_full_spi() to support SPI response actions.

Parameters

array $spi: SPI data. Required parameters: 'site_key' A SHA1 hash of the Drupal private key. 'spi_data_version' @see acquia_spi_get()

Note, acquia_agent will add authenticator.

Return value

mixed FALSE if no credentials, environment change detected, or validation error else full NSPI response array.

4 calls to acquia_spi_send_data()
AcquiaSPITestCase::testAcquiaSpiMessages in acquia_spi/tests/acquia_spi.test
Needs comment.
AcquiaSPITestCase::testAcquiaSpiRevokedInstall in acquia_spi/tests/acquia_spi.test
Needs comment.
AcquiaSPITestCase::testAcquiaSpiSend in acquia_spi/tests/acquia_spi.test
Needs comment.
acquia_spi_send_full_spi in acquia_spi/acquia_spi.module
Gather full SPI data and send to Acquia Insight.

File

acquia_spi/acquia_spi.module, line 520
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_send_data(array $spi) {

  // Do nothing unless we have credentials.
  if (!acquia_agent_has_credentials()) {
    watchdog('acquia spi', 'Connect your site to a valid Acquia Subscription to send SPI data', array(), WATCHDOG_ERROR);
    return FALSE;
  }
  if (acquia_spi_environment_change_detected()) {
    watchdog('acquia spi', 'SPI data not sent, site environment change detected.', array(), WATCHDOG_ERROR);
    drupal_set_message(t('SPI data not sent, site environment change detected. Please <a href="@environment_change">indicate how you wish to proceed</a>.', array(
      '@environment_change' => url('admin/config/system/acquia-agent/environment-change'),
    )), 'error');
    return FALSE;
  }

  // acquia_agent_network_address() sets remote server protocol.
  $nspi_server = variable_get('acquia_spi_server', 'https://nspi.acquia.com');

  // Specify version 3 of the RPC, which ommits request parameters in the HMAC.
  $spi['rpc_version'] = 3;
  $response = acquia_agent_call('acquia.nspi.update', $spi, NULL, NULL, $nspi_server);

  // Validate the server response.
  if (!acquia_agent_valid_response($response, acquia_agent_settings('acquia_key'))) {

    // Acquia Agent will have logged error.
    return FALSE;
  }

  // $response contains request authenticator as well as server authenticator
  // under 'result' element so return just the server response 'body' element.
  return $response['result']['body'];
}