/**
  * Retrieves an existing DNS zone.
  *
  * If no identifier is specified and no body is supplied, all zones will be
  * retrieved without records.
  *
  * ### Response: ###
  *
  * ~~~
  * [
  *      {
  *            "name": <string>,
  *            "type": MASTER|SLAVE|NATIVE,
  *            "master": <ipv4 optional>,
  *            "last_check": <int optional>,
  *            "notified_serial": <int optional>
  *      },0..n
  * ]
  * ~~~
  *
  * If a query is specified in the URL,  all zones matching the given wildcard
  * are returned. The * wildcard is supported.
  *
  * If an identifier is specified, one zone will be retrieved with records.
  *
  * ### Response: ###
  *
  * ~~~
  * {
  *      "name": <string>,
  *      "type": MASTER|SLAVE|NATIVE,
  *      "master": <ipv4>,
  *      "last_check": <int>,
  *      "records": [ {
  *              "name": <string>,
  *              "type": <string>,
  *              "content": <string>,
  *              "ttl": <int optional>,
  *              "priority: <int optional>,
  *              "change_date": <int optional>
  *      },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 zone.
  *
  * @access public
  * @param mixed $request Request parameters
  * @param string $identifier Zone identifier
  * @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 ZoneFunctions::get_all_zones($response);
         } else {
             $validator = new ZoneValidator($data);
             if (!isset($data->query)) {
                 $response->code = Response::BADREQUEST;
                 $response->error = "Query was missing. Ensure that the body is in valid format and all required parameters are present.";
                 $response->error_detail = "BODY_MALFORMED";
                 return $response;
             }
             if (!$validator->validates()) {
                 $response->code = Response::BADREQUEST;
                 $response->error = $validator->getFormattedErrors();
                 $response->error_detail = $validator->getErrorDetails();
                 return $response;
             }
             return ZoneFunctions::query_zones($response, $data->query);
         }
     } else {
         $validator = new ZoneValidator();
         $validator->identifier = $identifier;
         if (!$validator->validates()) {
             $response->code = Response::BADREQUEST;
             $response->error = $validator->getFormattedErrors();
             $response->error_detail = $validator->getErrorDetails();
             return $response;
         }
         return ZoneFunctions::get_zone($response, $identifier);
     }
 }
 public function query_zones($response, $query, &$out = null)
 {
     return ZoneFunctions::get_all_zones($response, $out, $query);
 }