public function AcquiaLiftAPI::updateAgentStatus in Acquia Lift Connector 7
Updates the status of an agent in Acquia Lift.
Parameters
$machine_name: The machine of the agent.
$status: The status to set the agent to.
Throws
File
- includes/
acquia_lift.classes.inc, line 475 - Provides an agent type for Acquia Lift
Class
- AcquiaLiftAPI
- @file Provides an agent type for Acquia Lift
Code
public function updateAgentStatus($machine_name, $status) {
$lift_status_code = self::mapStatus($status);
$url = $this
->generateEndpoint("/agent-api/{$machine_name}");
$agent = array(
'status' => $lift_status_code,
);
$response = $this
->httpClient()
->put($url, array(
'Content-Type' => 'application/json; charset=utf-8',
'Accept' => 'application/json',
), $agent);
$data = json_decode($response->data, TRUE);
$vars = array(
'agent' => $machine_name,
);
$success_msg = 'The new status of campaign {agent} was pushed to Acquia Lift';
$fail_msg = 'The new status of campaign {agent} could not be pushed to Acquia Lift';
if ($response->code == 200 && $data['status'] == 'ok') {
$this
->logger()
->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
}
else {
$this
->handleBadResponse($response->code, $fail_msg, $vars);
}
}