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

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


    def get_network_client_security_events(self,
                                           network_id,
                                           client_id,
                                           t_0=None,
                                           t_1=None,
                                           timespan=None,
                                           per_page=None,
                                           starting_after=None,
                                           ending_before=None):
        """Does a GET request to /networks/{networkId}/clients/{clientId}/securityEvents.

        List the security events for a client. Clients can be identified by a
        client key or either the MAC or IP depending on whether the network
        uses Track-by-IP.

        Args:
            network_id (string): TODO: type description here. Example: 
            client_id (string): TODO: type description here. Example: 
            t_0 (string, optional): The beginning of the timespan for the
                data. The maximum lookback period is 791 days from today.
            t_1 (string, optional): The end of the timespan for the data. t1
                can be a maximum of 791 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 791 days. The default is 31 days.
            per_page (int, optional): The number of entries per page returned.
                Acceptable range is 3 - 1000. Default is 100.
            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}/clients/{clientId}/securityEvents'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id,
            'clientId': client_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            't0': t_0,
            't1': t_1,
            'timespan': timespan,
            '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_security_events(self,
                                    network_id,
                                    t_0=None,
                                    t_1=None,
                                    timespan=None,
                                    per_page=None,
                                    starting_after=None,
                                    ending_before=None):
        """Does a GET request to /networks/{networkId}/securityEvents.

        List the security events for a network

        Args:
            network_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 365 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 365 days. The default is 31 days.
            per_page (int, optional): The number of entries per page returned.
                Acceptable range is 3 - 1000. Default is 100.
            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}/securityEvents'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            't0': t_0,
            't1': t_1,
            'timespan': timespan,
            '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_organization_security_events(self,
                                         organization_id,
                                         t_0=None,
                                         t_1=None,
                                         timespan=None,
                                         per_page=None,
                                         starting_after=None,
                                         ending_before=None):
        """Does a GET request to /organizations/{organizationId}/securityEvents.

        List the security events for an organization

        Args:
            organization_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 365 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 365 days. The default is 31 days.
            per_page (int, optional): The number of entries per page returned.
                Acceptable range is 3 - 1000. Default is 100.
            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 = '/organizations/{organizationId}/securityEvents'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'organizationId': organization_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            't0': t_0,
            't1': t_1,
            'timespan': timespan,
            '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
