/** * @param BaseRequest|mixed $request * * @return BaseResponse|mixed */ public function deprovision($request) { $this->startTimer(); // Save results... /** @type Instance $_instance */ $_instance = $request->getInstance(); $_instance->addOperation('deprovision'); $_response = $this->doDeprovision($request); $_response->setElapsedTime($_elapsed = $this->stopTimer()); $this->audit(['elapsed' => $_elapsed, 'result' => $_result = $_response->getResult()]); // Send notification $_data = ['firstName' => $_instance->user->first_name_text, 'headTitle' => $_response->isSuccess() ? 'Retirement Complete' : 'Retirement Failure', 'contentHeader' => $_response->isSuccess() ? 'Your instance has been retired' : 'Your instance is not quite retired', 'emailBody' => $_response->isSuccess() ? '<p>Your instance <strong>' . $_instance->instance_name_text . '</strong> has been retired. A snapshot may be available in the dashboard, under <strong>Snapshots</strong>.</p>' : '<p>Your instance <strong>' . $_instance->instance_name_text . '</strong> retirement was not successful. Our engineers will examine the issue and, if necessary, notify you if/when the issue has been resolved. Mostly likely you will not have to do a thing. But we will check it out just to be safe.</p>']; $_subject = $_response->isSuccess() ? 'Instance retirement successful' : 'Instance retirement failure'; $this->notifyInstanceOwner($_instance, $_subject, $_data); return $_response; }