# -*- 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 EventsController(BaseController):

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


    def get_network_events(self,
                           network_id,
                           product_type=None,
                           included_event_types=None,
                           excluded_event_types=None,
                           device_mac=None,
                           device_serial=None,
                           device_name=None,
                           client_ip=None,
                           client_mac=None,
                           client_name=None,
                           sm_device_mac=None,
                           sm_device_name=None,
                           per_page=None,
                           starting_after=None,
                           ending_before=None):
        """Does a GET request to /networks/{networkId}/events.

        List the events for the network

        Args:
            network_id (string): TODO: type description here. Example: 
            product_type (string, optional): The product type to fetch events
                for. This parameter is required for networks with multiple
                device types. Valid types are wireless, appliance, switch,
                systemsManager, and camera
            included_event_types (list of string, optional): A list of event
                types. The returned events will be filtered to only include
                events with these types.
            excluded_event_types (list of string, optional): A list of event
                types. The returned events will be filtered to exclude events
                with these types.
            device_mac (string, optional): The MAC address of the Meraki
                device which the list of events will be filtered with
            device_serial (string, optional): The serial of the Meraki device
                which the list of events will be filtered with
            device_name (string, optional): The name of the Meraki device
                which the list of events will be filtered with
            client_ip (string, optional): The IP of the client which the list
                of events will be filtered with. Only supported for
                track-by-IP networks.
            client_mac (string, optional): The MAC address of the client which
                the list of events will be filtered with. Only supported for
                track-by-MAC networks.
            client_name (string, optional): The name, or partial name, of the
                client which the list of events will be filtered with
            sm_device_mac (string, optional): The MAC address of the Systems
                Manager device which the list of events will be filtered with
            sm_device_name (string, optional): The name of the Systems Manager
                device which the list of events will be filtered with
            per_page (int, optional): The number of entries per page returned.
                Acceptable range is 3 - 1000. Default is 10.
            starting_after (string, optional): A token used by the server to
                indicate the start of the page. Often this is a timestamp or
                an ID but it is not limited to those. This parameter should
                not be defined by client applications. The link for the first,
                last, prev, or next page in the HTTP Link header should define
                it.
            ending_before (string, optional): A token used by the server to
                indicate the end of the page. Often this is a timestamp or an
                ID but it is not limited to those. This parameter should not
                be defined by client applications. The link for the first,
                last, prev, or next page in the HTTP Link header should define
                it.

        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 = '/networks/{networkId}/events'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'productType': product_type,
            'includedEventTypes': included_event_types,
            'excludedEventTypes': excluded_event_types,
            'deviceMac': device_mac,
            'deviceSerial': device_serial,
            'deviceName': device_name,
            'clientIp': client_ip,
            'clientMac': client_mac,
            'clientName': client_name,
            'smDeviceMac': sm_device_mac,
            'smDeviceName': sm_device_name,
            'perPage': per_page,
            'startingAfter': starting_after,
            'endingBefore': ending_before
        }
        _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_network_events_event_types(self,
                                       network_id):
        """Does a GET request to /networks/{networkId}/events/eventTypes.

        List the event type to human-readable description

        Args:
            network_id (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 = '/networks/{networkId}/events/eventTypes'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id
        })
        _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
