<?php
namespace OpenSearch\Generated\App;

/**
 * Autogenerated by Thrift Compiler (0.10.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;


final class AppStatus {
  const AVAILABLE = 1;
  const PAUSE = 5;
  const FORBID = 6;
  const UNOPEN = 7;
  const CREATING = 8;
  const FAILED = 9;
  static public $__names = array(
    1 => 'AVAILABLE',
    5 => 'PAUSE',
    6 => 'FORBID',
    7 => 'UNOPEN',
    8 => 'CREATING',
    9 => 'FAILED',
  );
}

class Quota {
  static $_TSPEC;

  /**
   * @var double
   */
  public $doc_size = null;
  /**
   * @var int
   */
  public $qps = null;
  /**
   * @var string
   */
  public $type = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'doc_size',
          'type' => TType::DOUBLE,
          ),
        2 => array(
          'var' => 'qps',
          'type' => TType::I32,
          ),
        3 => array(
          'var' => 'type',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['doc_size'])) {
        $this->doc_size = $vals['doc_size'];
      }
      if (isset($vals['qps'])) {
        $this->qps = $vals['qps'];
      }
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
    }
  }

  public function getName() {
    return 'Quota';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::DOUBLE) {
            $xfer += $input->readDouble($this->doc_size);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->qps);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->type);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Quota');
    if ($this->doc_size !== null) {
      $xfer += $output->writeFieldBegin('doc_size', TType::DOUBLE, 1);
      $xfer += $output->writeDouble($this->doc_size);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->qps !== null) {
      $xfer += $output->writeFieldBegin('qps', TType::I32, 2);
      $xfer += $output->writeI32($this->qps);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->type !== null) {
      $xfer += $output->writeFieldBegin('type', TType::STRING, 3);
      $xfer += $output->writeString($this->type);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class Field {
  static $_TSPEC;

  /**
   * @var string
   */
  public $name = null;
  /**
   * @var string
   */
  public $type = null;
  /**
   * @var bool
   */
  public $primary_key = null;
  /**
   * @var string[]
   */
  public $join_with = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'name',
          'type' => TType::STRING,
          ),
        2 => array(
          'var' => 'type',
          'type' => TType::STRING,
          ),
        3 => array(
          'var' => 'primary_key',
          'type' => TType::BOOL,
          ),
        4 => array(
          'var' => 'join_with',
          'type' => TType::LST,
          'etype' => TType::STRING,
          'elem' => array(
            'type' => TType::STRING,
            ),
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['name'])) {
        $this->name = $vals['name'];
      }
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
      if (isset($vals['primary_key'])) {
        $this->primary_key = $vals['primary_key'];
      }
      if (isset($vals['join_with'])) {
        $this->join_with = $vals['join_with'];
      }
    }
  }

  public function getName() {
    return 'Field';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->name);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->type);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::BOOL) {
            $xfer += $input->readBool($this->primary_key);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 4:
          if ($ftype == TType::LST) {
            $this->join_with = array();
            $_size0 = 0;
            $_etype3 = 0;
            $xfer += $input->readListBegin($_etype3, $_size0);
            for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
            {
              $elem5 = null;
              $xfer += $input->readString($elem5);
              $this->join_with []= $elem5;
            }
            $xfer += $input->readListEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Field');
    if ($this->name !== null) {
      $xfer += $output->writeFieldBegin('name', TType::STRING, 1);
      $xfer += $output->writeString($this->name);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->type !== null) {
      $xfer += $output->writeFieldBegin('type', TType::STRING, 2);
      $xfer += $output->writeString($this->type);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->primary_key !== null) {
      $xfer += $output->writeFieldBegin('primary_key', TType::BOOL, 3);
      $xfer += $output->writeBool($this->primary_key);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->join_with !== null) {
      if (!is_array($this->join_with)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('join_with', TType::LST, 4);
      {
        $output->writeListBegin(TType::STRING, count($this->join_with));
        {
          foreach ($this->join_with as $iter6)
          {
            $xfer += $output->writeString($iter6);
          }
        }
        $output->writeListEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class Table {
  static $_TSPEC;

  /**
   * @var array
   */
  public $fields = null;
  /**
   * @var bool
   */
  public $primary_table = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'fields',
          'type' => TType::MAP,
          'ktype' => TType::STRING,
          'vtype' => TType::STRUCT,
          'key' => array(
            'type' => TType::STRING,
          ),
          'val' => array(
            'type' => TType::STRUCT,
            'class' => '\OpenSearch\Generated\App\Field',
            ),
          ),
        2 => array(
          'var' => 'primary_table',
          'type' => TType::BOOL,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['fields'])) {
        $this->fields = $vals['fields'];
      }
      if (isset($vals['primary_table'])) {
        $this->primary_table = $vals['primary_table'];
      }
    }
  }

  public function getName() {
    return 'Table';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::MAP) {
            $this->fields = array();
            $_size7 = 0;
            $_ktype8 = 0;
            $_vtype9 = 0;
            $xfer += $input->readMapBegin($_ktype8, $_vtype9, $_size7);
            for ($_i11 = 0; $_i11 < $_size7; ++$_i11)
            {
              $key12 = '';
              $val13 = new \OpenSearch\Generated\App\Field();
              $xfer += $input->readString($key12);
              $val13 = new \OpenSearch\Generated\App\Field();
              $xfer += $val13->read($input);
              $this->fields[$key12] = $val13;
            }
            $xfer += $input->readMapEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::BOOL) {
            $xfer += $input->readBool($this->primary_table);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Table');
    if ($this->fields !== null) {
      if (!is_array($this->fields)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('fields', TType::MAP, 1);
      {
        $output->writeMapBegin(TType::STRING, TType::STRUCT, count($this->fields));
        {
          foreach ($this->fields as $kiter14 => $viter15)
          {
            $xfer += $output->writeString($kiter14);
            $xfer += $viter15->write($output);
          }
        }
        $output->writeMapEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->primary_table !== null) {
      $xfer += $output->writeFieldBegin('primary_table', TType::BOOL, 2);
      $xfer += $output->writeBool($this->primary_table);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class SearchField {
  static $_TSPEC;

  /**
   * @var string[]
   */
  public $fields = null;
  /**
   * @var string
   */
  public $analyzer = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'fields',
          'type' => TType::LST,
          'etype' => TType::STRING,
          'elem' => array(
            'type' => TType::STRING,
            ),
          ),
        2 => array(
          'var' => 'analyzer',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['fields'])) {
        $this->fields = $vals['fields'];
      }
      if (isset($vals['analyzer'])) {
        $this->analyzer = $vals['analyzer'];
      }
    }
  }

  public function getName() {
    return 'SearchField';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::LST) {
            $this->fields = array();
            $_size16 = 0;
            $_etype19 = 0;
            $xfer += $input->readListBegin($_etype19, $_size16);
            for ($_i20 = 0; $_i20 < $_size16; ++$_i20)
            {
              $elem21 = null;
              $xfer += $input->readString($elem21);
              $this->fields []= $elem21;
            }
            $xfer += $input->readListEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->analyzer);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('SearchField');
    if ($this->fields !== null) {
      if (!is_array($this->fields)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('fields', TType::LST, 1);
      {
        $output->writeListBegin(TType::STRING, count($this->fields));
        {
          foreach ($this->fields as $iter22)
          {
            $xfer += $output->writeString($iter22);
          }
        }
        $output->writeListEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->analyzer !== null) {
      $xfer += $output->writeFieldBegin('analyzer', TType::STRING, 2);
      $xfer += $output->writeString($this->analyzer);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class Indexes {
  static $_TSPEC;

  /**
   * @var array
   */
  public $search_fields = null;
  /**
   * @var string[]
   */
  public $filter_fields = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'search_fields',
          'type' => TType::MAP,
          'ktype' => TType::STRING,
          'vtype' => TType::STRUCT,
          'key' => array(
            'type' => TType::STRING,
          ),
          'val' => array(
            'type' => TType::STRUCT,
            'class' => '\OpenSearch\Generated\App\SearchField',
            ),
          ),
        2 => array(
          'var' => 'filter_fields',
          'type' => TType::LST,
          'etype' => TType::STRING,
          'elem' => array(
            'type' => TType::STRING,
            ),
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['search_fields'])) {
        $this->search_fields = $vals['search_fields'];
      }
      if (isset($vals['filter_fields'])) {
        $this->filter_fields = $vals['filter_fields'];
      }
    }
  }

  public function getName() {
    return 'Indexes';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::MAP) {
            $this->search_fields = array();
            $_size23 = 0;
            $_ktype24 = 0;
            $_vtype25 = 0;
            $xfer += $input->readMapBegin($_ktype24, $_vtype25, $_size23);
            for ($_i27 = 0; $_i27 < $_size23; ++$_i27)
            {
              $key28 = '';
              $val29 = new \OpenSearch\Generated\App\SearchField();
              $xfer += $input->readString($key28);
              $val29 = new \OpenSearch\Generated\App\SearchField();
              $xfer += $val29->read($input);
              $this->search_fields[$key28] = $val29;
            }
            $xfer += $input->readMapEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::LST) {
            $this->filter_fields = array();
            $_size30 = 0;
            $_etype33 = 0;
            $xfer += $input->readListBegin($_etype33, $_size30);
            for ($_i34 = 0; $_i34 < $_size30; ++$_i34)
            {
              $elem35 = null;
              $xfer += $input->readString($elem35);
              $this->filter_fields []= $elem35;
            }
            $xfer += $input->readListEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Indexes');
    if ($this->search_fields !== null) {
      if (!is_array($this->search_fields)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('search_fields', TType::MAP, 1);
      {
        $output->writeMapBegin(TType::STRING, TType::STRUCT, count($this->search_fields));
        {
          foreach ($this->search_fields as $kiter36 => $viter37)
          {
            $xfer += $output->writeString($kiter36);
            $xfer += $viter37->write($output);
          }
        }
        $output->writeMapEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->filter_fields !== null) {
      if (!is_array($this->filter_fields)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('filter_fields', TType::LST, 2);
      {
        $output->writeListBegin(TType::STRING, count($this->filter_fields));
        {
          foreach ($this->filter_fields as $iter38)
          {
            $xfer += $output->writeString($iter38);
          }
        }
        $output->writeListEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class Schema {
  static $_TSPEC;

  /**
   * @var array
   */
  public $tables = null;
  /**
   * @var \OpenSearch\Generated\App\Indexes
   */
  public $indexes = null;
  /**
   * @var string
   */
  public $route_field = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'tables',
          'type' => TType::MAP,
          'ktype' => TType::STRING,
          'vtype' => TType::STRUCT,
          'key' => array(
            'type' => TType::STRING,
          ),
          'val' => array(
            'type' => TType::STRUCT,
            'class' => '\OpenSearch\Generated\App\Table',
            ),
          ),
        2 => array(
          'var' => 'indexes',
          'type' => TType::STRUCT,
          'class' => '\OpenSearch\Generated\App\Indexes',
          ),
        3 => array(
          'var' => 'route_field',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['tables'])) {
        $this->tables = $vals['tables'];
      }
      if (isset($vals['indexes'])) {
        $this->indexes = $vals['indexes'];
      }
      if (isset($vals['route_field'])) {
        $this->route_field = $vals['route_field'];
      }
    }
  }

  public function getName() {
    return 'Schema';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::MAP) {
            $this->tables = array();
            $_size39 = 0;
            $_ktype40 = 0;
            $_vtype41 = 0;
            $xfer += $input->readMapBegin($_ktype40, $_vtype41, $_size39);
            for ($_i43 = 0; $_i43 < $_size39; ++$_i43)
            {
              $key44 = '';
              $val45 = new \OpenSearch\Generated\App\Table();
              $xfer += $input->readString($key44);
              $val45 = new \OpenSearch\Generated\App\Table();
              $xfer += $val45->read($input);
              $this->tables[$key44] = $val45;
            }
            $xfer += $input->readMapEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRUCT) {
            $this->indexes = new \OpenSearch\Generated\App\Indexes();
            $xfer += $this->indexes->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->route_field);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Schema');
    if ($this->tables !== null) {
      if (!is_array($this->tables)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('tables', TType::MAP, 1);
      {
        $output->writeMapBegin(TType::STRING, TType::STRUCT, count($this->tables));
        {
          foreach ($this->tables as $kiter46 => $viter47)
          {
            $xfer += $output->writeString($kiter46);
            $xfer += $viter47->write($output);
          }
        }
        $output->writeMapEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->indexes !== null) {
      if (!is_object($this->indexes)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('indexes', TType::STRUCT, 2);
      $xfer += $this->indexes->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->route_field !== null) {
      $xfer += $output->writeFieldBegin('route_field', TType::STRING, 3);
      $xfer += $output->writeString($this->route_field);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class Group {
  static $_TSPEC;

  /**
   * @var string
   */
  public $type = "advance";
  /**
   * @var string
   */
  public $current_version = null;
  /**
   * @var string[]
   */
  public $versions = null;
  /**
   * @var int
   */
  public $switch_time = null;
  /**
   * @var string
   */
  public $id = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'type',
          'type' => TType::STRING,
          ),
        2 => array(
          'var' => 'current_version',
          'type' => TType::STRING,
          ),
        3 => array(
          'var' => 'versions',
          'type' => TType::LST,
          'etype' => TType::STRING,
          'elem' => array(
            'type' => TType::STRING,
            ),
          ),
        4 => array(
          'var' => 'switch_time',
          'type' => TType::I32,
          ),
        5 => array(
          'var' => 'id',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
      if (isset($vals['current_version'])) {
        $this->current_version = $vals['current_version'];
      }
      if (isset($vals['versions'])) {
        $this->versions = $vals['versions'];
      }
      if (isset($vals['switch_time'])) {
        $this->switch_time = $vals['switch_time'];
      }
      if (isset($vals['id'])) {
        $this->id = $vals['id'];
      }
    }
  }

  public function getName() {
    return 'Group';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->type);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->current_version);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::LST) {
            $this->versions = array();
            $_size48 = 0;
            $_etype51 = 0;
            $xfer += $input->readListBegin($_etype51, $_size48);
            for ($_i52 = 0; $_i52 < $_size48; ++$_i52)
            {
              $elem53 = null;
              $xfer += $input->readString($elem53);
              $this->versions []= $elem53;
            }
            $xfer += $input->readListEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 4:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->switch_time);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 5:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->id);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('Group');
    if ($this->type !== null) {
      $xfer += $output->writeFieldBegin('type', TType::STRING, 1);
      $xfer += $output->writeString($this->type);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->current_version !== null) {
      $xfer += $output->writeFieldBegin('current_version', TType::STRING, 2);
      $xfer += $output->writeString($this->current_version);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->versions !== null) {
      if (!is_array($this->versions)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('versions', TType::LST, 3);
      {
        $output->writeListBegin(TType::STRING, count($this->versions));
        {
          foreach ($this->versions as $iter54)
          {
            $xfer += $output->writeString($iter54);
          }
        }
        $output->writeListEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->switch_time !== null) {
      $xfer += $output->writeFieldBegin('switch_time', TType::I32, 4);
      $xfer += $output->writeI32($this->switch_time);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->id !== null) {
      $xfer += $output->writeFieldBegin('id', TType::STRING, 5);
      $xfer += $output->writeString($this->id);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class App {
  static $_TSPEC;

  /**
   * @var string
   */
  public $id = null;
  /**
   * @var string
   */
  public $name = null;
  /**
   * @var string
   */
  public $type = "advance";
  /**
   * @var \OpenSearch\Generated\App\Schema
   */
  public $schema = null;
  /**
   * @var \OpenSearch\Generated\App\Quota
   */
  public $quota = null;
  /**
   * @var string
   */
  public $description = null;
  /**
   * @var \OpenSearch\Generated\App\Group
   */
  public $group = null;
  /**
   * @var bool
   */
  public $auto_switch = null;
  /**
   * @var int
   */
  public $switch_time = null;
  /**
   * @var string[]
   */
  public $fetch_fields = null;
  /**
   * @var array
   */
  public $first_ranks = null;
  /**
   * @var string
   */
  public $virtual_cluster = null;
  /**
   * @var bool
   */
  public $realtime_shared = null;
  /**
   * @var int
   */
  public $status = null;
  /**
   * @var int
   */
  public $data_progress = null;
  /**
   * @var int
   */
  public $progress_percent = null;
  /**
   * @var bool
   */
  public $rebuilding = null;
  /**
   * @var int
   */
  public $unread_error_count = null;
  /**
   * @var int
   */
  public $action_cause = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'id',
          'type' => TType::STRING,
          ),
        10 => array(
          'var' => 'name',
          'type' => TType::STRING,
          ),
        11 => array(
          'var' => 'type',
          'type' => TType::STRING,
          ),
        12 => array(
          'var' => 'schema',
          'type' => TType::STRUCT,
          'class' => '\OpenSearch\Generated\App\Schema',
          ),
        13 => array(
          'var' => 'quota',
          'type' => TType::STRUCT,
          'class' => '\OpenSearch\Generated\App\Quota',
          ),
        14 => array(
          'var' => 'description',
          'type' => TType::STRING,
          ),
        15 => array(
          'var' => 'group',
          'type' => TType::STRUCT,
          'class' => '\OpenSearch\Generated\App\Group',
          ),
        16 => array(
          'var' => 'auto_switch',
          'type' => TType::BOOL,
          ),
        17 => array(
          'var' => 'switch_time',
          'type' => TType::I32,
          ),
        18 => array(
          'var' => 'fetch_fields',
          'type' => TType::LST,
          'etype' => TType::STRING,
          'elem' => array(
            'type' => TType::STRING,
            ),
          ),
        19 => array(
          'var' => 'first_ranks',
          'type' => TType::MAP,
          'ktype' => TType::STRING,
          'vtype' => TType::STRUCT,
          'key' => array(
            'type' => TType::STRING,
          ),
          'val' => array(
            'type' => TType::STRUCT,
            'class' => '\OpenSearch\Generated\FirstRank\FirstRank',
            ),
          ),
        20 => array(
          'var' => 'virtual_cluster',
          'type' => TType::STRING,
          ),
        21 => array(
          'var' => 'realtime_shared',
          'type' => TType::BOOL,
          ),
        100 => array(
          'var' => 'status',
          'type' => TType::I32,
          ),
        101 => array(
          'var' => 'data_progress',
          'type' => TType::I32,
          ),
        102 => array(
          'var' => 'progress_percent',
          'type' => TType::I32,
          ),
        103 => array(
          'var' => 'rebuilding',
          'type' => TType::BOOL,
          ),
        104 => array(
          'var' => 'unread_error_count',
          'type' => TType::I32,
          ),
        105 => array(
          'var' => 'action_cause',
          'type' => TType::I32,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['id'])) {
        $this->id = $vals['id'];
      }
      if (isset($vals['name'])) {
        $this->name = $vals['name'];
      }
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
      if (isset($vals['schema'])) {
        $this->schema = $vals['schema'];
      }
      if (isset($vals['quota'])) {
        $this->quota = $vals['quota'];
      }
      if (isset($vals['description'])) {
        $this->description = $vals['description'];
      }
      if (isset($vals['group'])) {
        $this->group = $vals['group'];
      }
      if (isset($vals['auto_switch'])) {
        $this->auto_switch = $vals['auto_switch'];
      }
      if (isset($vals['switch_time'])) {
        $this->switch_time = $vals['switch_time'];
      }
      if (isset($vals['fetch_fields'])) {
        $this->fetch_fields = $vals['fetch_fields'];
      }
      if (isset($vals['first_ranks'])) {
        $this->first_ranks = $vals['first_ranks'];
      }
      if (isset($vals['virtual_cluster'])) {
        $this->virtual_cluster = $vals['virtual_cluster'];
      }
      if (isset($vals['realtime_shared'])) {
        $this->realtime_shared = $vals['realtime_shared'];
      }
      if (isset($vals['status'])) {
        $this->status = $vals['status'];
      }
      if (isset($vals['data_progress'])) {
        $this->data_progress = $vals['data_progress'];
      }
      if (isset($vals['progress_percent'])) {
        $this->progress_percent = $vals['progress_percent'];
      }
      if (isset($vals['rebuilding'])) {
        $this->rebuilding = $vals['rebuilding'];
      }
      if (isset($vals['unread_error_count'])) {
        $this->unread_error_count = $vals['unread_error_count'];
      }
      if (isset($vals['action_cause'])) {
        $this->action_cause = $vals['action_cause'];
      }
    }
  }

  public function getName() {
    return 'App';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->id);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 10:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->name);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 11:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->type);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 12:
          if ($ftype == TType::STRUCT) {
            $this->schema = new \OpenSearch\Generated\App\Schema();
            $xfer += $this->schema->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 13:
          if ($ftype == TType::STRUCT) {
            $this->quota = new \OpenSearch\Generated\App\Quota();
            $xfer += $this->quota->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 14:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->description);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 15:
          if ($ftype == TType::STRUCT) {
            $this->group = new \OpenSearch\Generated\App\Group();
            $xfer += $this->group->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 16:
          if ($ftype == TType::BOOL) {
            $xfer += $input->readBool($this->auto_switch);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 17:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->switch_time);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 18:
          if ($ftype == TType::LST) {
            $this->fetch_fields = array();
            $_size55 = 0;
            $_etype58 = 0;
            $xfer += $input->readListBegin($_etype58, $_size55);
            for ($_i59 = 0; $_i59 < $_size55; ++$_i59)
            {
              $elem60 = null;
              $xfer += $input->readString($elem60);
              $this->fetch_fields []= $elem60;
            }
            $xfer += $input->readListEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 19:
          if ($ftype == TType::MAP) {
            $this->first_ranks = array();
            $_size61 = 0;
            $_ktype62 = 0;
            $_vtype63 = 0;
            $xfer += $input->readMapBegin($_ktype62, $_vtype63, $_size61);
            for ($_i65 = 0; $_i65 < $_size61; ++$_i65)
            {
              $key66 = '';
              $val67 = new \OpenSearch\Generated\FirstRank\FirstRank();
              $xfer += $input->readString($key66);
              $val67 = new \OpenSearch\Generated\FirstRank\FirstRank();
              $xfer += $val67->read($input);
              $this->first_ranks[$key66] = $val67;
            }
            $xfer += $input->readMapEnd();
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 20:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->virtual_cluster);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 21:
          if ($ftype == TType::BOOL) {
            $xfer += $input->readBool($this->realtime_shared);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 100:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->status);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 101:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->data_progress);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 102:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->progress_percent);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 103:
          if ($ftype == TType::BOOL) {
            $xfer += $input->readBool($this->rebuilding);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 104:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->unread_error_count);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 105:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->action_cause);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('App');
    if ($this->id !== null) {
      $xfer += $output->writeFieldBegin('id', TType::STRING, 1);
      $xfer += $output->writeString($this->id);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->name !== null) {
      $xfer += $output->writeFieldBegin('name', TType::STRING, 10);
      $xfer += $output->writeString($this->name);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->type !== null) {
      $xfer += $output->writeFieldBegin('type', TType::STRING, 11);
      $xfer += $output->writeString($this->type);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->schema !== null) {
      if (!is_object($this->schema)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('schema', TType::STRUCT, 12);
      $xfer += $this->schema->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->quota !== null) {
      if (!is_object($this->quota)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('quota', TType::STRUCT, 13);
      $xfer += $this->quota->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->description !== null) {
      $xfer += $output->writeFieldBegin('description', TType::STRING, 14);
      $xfer += $output->writeString($this->description);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->group !== null) {
      if (!is_object($this->group)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('group', TType::STRUCT, 15);
      $xfer += $this->group->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->auto_switch !== null) {
      $xfer += $output->writeFieldBegin('auto_switch', TType::BOOL, 16);
      $xfer += $output->writeBool($this->auto_switch);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->switch_time !== null) {
      $xfer += $output->writeFieldBegin('switch_time', TType::I32, 17);
      $xfer += $output->writeI32($this->switch_time);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->fetch_fields !== null) {
      if (!is_array($this->fetch_fields)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('fetch_fields', TType::LST, 18);
      {
        $output->writeListBegin(TType::STRING, count($this->fetch_fields));
        {
          foreach ($this->fetch_fields as $iter68)
          {
            $xfer += $output->writeString($iter68);
          }
        }
        $output->writeListEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->first_ranks !== null) {
      if (!is_array($this->first_ranks)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('first_ranks', TType::MAP, 19);
      {
        $output->writeMapBegin(TType::STRING, TType::STRUCT, count($this->first_ranks));
        {
          foreach ($this->first_ranks as $kiter69 => $viter70)
          {
            $xfer += $output->writeString($kiter69);
            $xfer += $viter70->write($output);
          }
        }
        $output->writeMapEnd();
      }
      $xfer += $output->writeFieldEnd();
    }
    if ($this->virtual_cluster !== null) {
      $xfer += $output->writeFieldBegin('virtual_cluster', TType::STRING, 20);
      $xfer += $output->writeString($this->virtual_cluster);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->realtime_shared !== null) {
      $xfer += $output->writeFieldBegin('realtime_shared', TType::BOOL, 21);
      $xfer += $output->writeBool($this->realtime_shared);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->status !== null) {
      $xfer += $output->writeFieldBegin('status', TType::I32, 100);
      $xfer += $output->writeI32($this->status);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->data_progress !== null) {
      $xfer += $output->writeFieldBegin('data_progress', TType::I32, 101);
      $xfer += $output->writeI32($this->data_progress);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->progress_percent !== null) {
      $xfer += $output->writeFieldBegin('progress_percent', TType::I32, 102);
      $xfer += $output->writeI32($this->progress_percent);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->rebuilding !== null) {
      $xfer += $output->writeFieldBegin('rebuilding', TType::BOOL, 103);
      $xfer += $output->writeBool($this->rebuilding);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->unread_error_count !== null) {
      $xfer += $output->writeFieldBegin('unread_error_count', TType::I32, 104);
      $xfer += $output->writeI32($this->unread_error_count);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->action_cause !== null) {
      $xfer += $output->writeFieldBegin('action_cause', TType::I32, 105);
      $xfer += $output->writeI32($this->action_cause);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

final class Constant extends \Thrift\Type\TConstant {
  static protected $TYPE_STANDARD;
  static protected $TYPE_ADVANCE;

  static protected function init_TYPE_STANDARD() {
    return "standard";
  }

  static protected function init_TYPE_ADVANCE() {
    return "advance";
  }
}


