You are here

public function AcquiaLiftAPI::getAgent in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 includes/AcquiaLiftAPI.inc \AcquiaLiftAPI::getAgent()

Retrieves the specified agent from Acquia Lift.

Parameters

$machine_name: The machine name of the agent to retrieve.

Return value

bool|array An array representing the agent or FALSE if none was found.

File

includes/acquia_lift.classes.inc, line 773
Provides an agent type for Acquia Lift

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function getAgent($machine_name) {
  $url = $this
    ->generateEndpoint("/agent-api/{$machine_name}");
  $response = $this
    ->httpClient()
    ->get($url, array(
    'Accept' => 'application/json',
  ));
  if ($response->code == 200) {
    return json_decode($response->data, TRUE);
  }
  else {
    $this
      ->handleBadResponse($response->code, 'Could not retrieve agent from Acquia Lift', array(), FALSE);
  }
  return FALSE;
}