# Path: zoe_cmd/api_lib/api_base.py
# class ZoeAPIBase:
#     """Base class for the Zoe Client API."""
#     def __init__(self, url, token):
#         self.url = url
#         self.token = token
# 
#     @retry(ZoeAPIException)
#     def _rest_get_stream(self, path):
#         """
#         :type path: str
#         :rtype: Tuple[requests.Response, int]
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.get(url, stream=True, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         return req, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_get(self, path, payload=None):
#         """
#         :type path: str
#         :type payload: dict
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.get(url, params=payload, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             data = req.json()
#         return data, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_post(self, path, payload):
#         """
#         :type path: str
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.post(url, json=payload, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             try:
#                 data = req.json()
#             except ValueError:
#                 data = None
#         return data, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_delete(self, path):
#         """
#         :type path: str
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.delete(url, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             data = None
#         return data, req.status_code
# 
# Path: zoe_lib/exceptions.py
# class ZoeAPIException(Exception):
#     """
#     An exception generated by the API (client-side).
#     """
#     def __init__(self, message):
#         super().__init__()
#         self.message = message
# 
#     def __str__(self):
#         return repr(self.message)


import logging
from zoe_cmd.api_lib.api_base import ZoeAPIBase
from zoe_lib.exceptions import ZoeAPIException
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module contains the Zoe Statistics API.
"""



log = logging.getLogger(__name__)


class ZoeStatisticsAPI(ZoeAPIBase):
    """
    The Statistics API class. This API exports dynamic information about Zoe inner status and counters.
    """
    def scheduler(self):
        """
        Queries Zoe for scheduler statistics.

        :return:
        """
        data, status_code = self._rest_get('/statistics/scheduler')
        if status_code != 200:

# Path: zoe_cmd/api_lib/api_base.py
# class ZoeAPIBase:
#     """Base class for the Zoe Client API."""
#     def __init__(self, url, token):
#         self.url = url
#         self.token = token
# 
#     @retry(ZoeAPIException)
#     def _rest_get_stream(self, path):
#         """
#         :type path: str
#         :rtype: Tuple[requests.Response, int]
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.get(url, stream=True, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         return req, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_get(self, path, payload=None):
#         """
#         :type path: str
#         :type payload: dict
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.get(url, params=payload, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             data = req.json()
#         return data, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_post(self, path, payload):
#         """
#         :type path: str
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.post(url, json=payload, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             try:
#                 data = req.json()
#             except ValueError:
#                 data = None
#         return data, req.status_code
# 
#     @retry(ZoeAPIException)
#     def _rest_delete(self, path):
#         """
#         :type path: str
#         :rtype: (dict, int)
#         """
#         url = self.url + '/api/' + ZOE_API_VERSION + path
#         try:
#             req = requests.delete(url, headers={'Cookie': self.token})
#         except requests.exceptions.Timeout:
#             raise ZoeAPIException('HTTP connection timeout')
#         except requests.exceptions.HTTPError:
#             raise ZoeAPIException('Invalid HTTP response')
#         except requests.exceptions.ConnectionError as e:
#             raise ZoeAPIException('Connection error: {}'.format(e))
# 
#         if not req.ok:
#             data = req.reason
#         else:
#             data = None
#         return data, req.status_code
# 
# Path: zoe_lib/exceptions.py
# class ZoeAPIException(Exception):
#     """
#     An exception generated by the API (client-side).
#     """
#     def __init__(self, message):
#         super().__init__()
#         self.message = message
# 
#     def __str__(self):
#         return repr(self.message)


# Path: zoe_cmd/api_lib/statistics.py
import logging
from zoe_cmd.api_lib.api_base import ZoeAPIBase
from zoe_lib.exceptions import ZoeAPIException

#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module contains the Zoe Statistics API.
"""



log = logging.getLogger(__name__)


class ZoeStatisticsAPI(ZoeAPIBase):
    """
    The Statistics API class. This API exports dynamic information about Zoe inner status and counters.
    """
    def scheduler(self):
        """
        Queries Zoe for scheduler statistics.

        :return:
        """
        data, status_code = self._rest_get('/statistics/scheduler')
        if status_code != 200:

            raise ZoeAPIException(data)