/**
  * Retrieves an existing reverse DNS record.
  *
  * If a query is specified in the URL, all records matching the IPs or ranges
  * are returned. Multiple queries may be specified, and must be comma separated.
  *
  * If an identifier is specified, the reverse DNS record for one IP will be 
  * retrieved.
  *
  * ### Response: ###
  *
  * ~~~
  * [
  *      {
  *            "name": <string>,
  *            "ip": <ip>,
  *            "reverse_dns": <string>|null,
  *            "arpa_zone": <string>|null
  *      },0..n
  * ]
  * ~~~
  *
  * ### Errors (request without identifier): ###
  *
  * * 508 - Invalid request, missing required parameters or input validation failed.
  * * 500 - Failed to connect to database or query execution error.
  *
  * ### Errors (request with identifier): ###
  *
  * * 508 - Invalid request, missing required parameters or input validation failed.
  * * 500 - Failed to connect to database or query execution error.
  * * 404 - Could not find IP.
  *
  * @access public
  * @param mixed $request Request parameters
  * @param string $identifier IP address
  * @return Response DNS zone data if successful, error message otherwise.
  */
 public function get($request, $identifier = null)
 {
     $response = new FormattedResponse($request);
     $data = $request->parseData();
     if (empty($identifier)) {
         if ($data == null) {
             return ArpaFunctions::get_all_arpa($response, $out);
         } else {
             $validator = new ArpaValidator($data);
             if (!isset($data->query)) {
                 $response->code = Response::BADREQUEST;
                 $response->error = "Query was missing or invalid. Ensure that the body is in valid format and all required parameters are present.";
                 $response->error_detail = "ARPA_INVALID_QUERY";
                 return $response;
             }
             if (!$validator->validates()) {
                 $response->code = Response::BADREQUEST;
                 $response->error = $validator->getFormattedErrors();
                 $response->error_detail = $validator->getErrorDetails();
                 return $response;
             }
             return ArpaFunctions::query_arpa($response, $data->query, $out);
         }
     } else {
         $validator = new ArpaValidator();
         $validator->identifier = $identifier;
         if (!$validator->validates()) {
             $response->code = Response::BADREQUEST;
             $response->error = $validator->getFormattedErrors();
             $response->error_detail = $validator->getErrorDetails();
             return $response;
         }
         return ArpaFunctions::get_arpa($response, $identifier);
     }
 }
 public function delete_arpa($response, $identifier, &$out = null)
 {
     ArpaFunctions::get_arpa($response, $identifier, $o, true);
     if (empty($o)) {
         $out = false;
         return $response;
     }
     $record = new stdClass();
     $record->name = $o['name'];
     $record->type = "PTR";
     $record->content = $o['reverse_dns'];
     $record->priority = $o['priority'];
     $req = new stdClass();
     $req->records = array($record);
     $response = ZoneFunctions::delete_records($response, $o['arpa_zone'], $req, $o);
     if (empty($o)) {
         $out = false;
         return $response;
     }
     $response->code = Response::OK;
     $response->body = true;
     $response->log_message = sprintf("Deleted Arpa record for IP %s", $identifier);
     $out = true;
     return $response;
 }