# -*- coding: utf-8 -*-

"""
    test_meraki

    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""

from test_meraki.api_helper import APIHelper
from test_meraki.configuration import Configuration
from test_meraki.controllers.base_controller import BaseController
from test_meraki.http.auth.custom_header_auth import CustomHeaderAuth

class MVSenseController(BaseController):

    """A Controller to access Endpoints in the test_meraki API."""


    def get_device_camera_analytics_live(self,
                                         serial):
        """Does a GET request to /devices/{serial}/camera/analytics/live.

        Returns live state from camera of analytics zones

        Args:
            serial (string): TODO: type description here. Example: 

        Returns:
            object: Response from the API. Successful operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/devices/{serial}/camera/analytics/live'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'serial': serial
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.http_client.get(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def get_device_camera_analytics_overview(self,
                                             serial,
                                             t_0=None,
                                             t_1=None,
                                             timespan=None,
                                             object_type=None):
        """Does a GET request to /devices/{serial}/camera/analytics/overview.

        Returns an overview of aggregate analytics data for a timespan

        Args:
            serial (string): TODO: type description here. Example: 
            t_0 (string, optional): The beginning of the timespan for the
                data. The maximum lookback period is 365 days from today.
            t_1 (string, optional): The end of the timespan for the data. t1
                can be a maximum of 7 days after t0.
            timespan (float, optional): The timespan for which the information
                will be fetched. If specifying timespan, do not specify
                parameters t0 and t1. The value must be in seconds and be less
                than or equal to 7 days. The default is 1 hour.
            object_type (ObjectTypeEnum, optional): [optional] The object type
                for which analytics will be retrieved. The default object type
                is person. The available types are [person, vehicle].

        Returns:
            object: Response from the API. Successful operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/devices/{serial}/camera/analytics/overview'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'serial': serial
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            't0': t_0,
            't1': t_1,
            'timespan': timespan,
            'objectType': object_type
        }
        _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
            _query_parameters, Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.http_client.get(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def get_device_camera_analytics_recent(self,
                                           serial,
                                           object_type=None):
        """Does a GET request to /devices/{serial}/camera/analytics/recent.

        Returns most recent record for analytics zones

        Args:
            serial (string): TODO: type description here. Example: 
            object_type (ObjectTypeEnum, optional): [optional] The object type
                for which analytics will be retrieved. The default object type
                is person. The available types are [person, vehicle].

        Returns:
            object: Response from the API. Successful operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/devices/{serial}/camera/analytics/recent'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'serial': serial
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'objectType': object_type
        }
        _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
            _query_parameters, Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.http_client.get(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def get_device_camera_analytics_zones(self,
                                          serial):
        """Does a GET request to /devices/{serial}/camera/analytics/zones.

        Returns all configured analytic zones for this camera

        Args:
            serial (string): TODO: type description here. Example: 

        Returns:
            object: Response from the API. Successful operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/devices/{serial}/camera/analytics/zones'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'serial': serial
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.http_client.get(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def get_device_camera_analytics_zone_history(self,
                                                 serial,
                                                 zone_id,
                                                 t_0=None,
                                                 t_1=None,
                                                 timespan=None,
                                                 resolution=None,
                                                 object_type=None):
        """Does a GET request to /devices/{serial}/camera/analytics/zones/{zoneId}/history.

        Return historical records for analytic zones

        Args:
            serial (string): TODO: type description here. Example: 
            zone_id (string): TODO: type description here. Example: 
            t_0 (string, optional): The beginning of the timespan for the
                data. The maximum lookback period is 365 days from today.
            t_1 (string, optional): The end of the timespan for the data. t1
                can be a maximum of 14 hours after t0.
            timespan (float, optional): The timespan for which the information
                will be fetched. If specifying timespan, do not specify
                parameters t0 and t1. The value must be in seconds and be less
                than or equal to 14 hours. The default is 1 hour.
            resolution (int, optional): The time resolution in seconds for
                returned data. The valid resolutions are: 60. The default is
                60.
            object_type (ObjectTypeEnum, optional): [optional] The object type
                for which analytics will be retrieved. The default object type
                is person. The available types are [person, vehicle].

        Returns:
            object: Response from the API. Successful operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/devices/{serial}/camera/analytics/zones/{zoneId}/history'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'serial': serial,
            'zoneId': zone_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            't0': t_0,
            't1': t_1,
            'timespan': timespan,
            'resolution': resolution,
            'objectType': object_type
        }
        _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
            _query_parameters, Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.http_client.get(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body
