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

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


    def get_network_sm_target_groups(self,
                                     network_id,
                                     with_details=None):
        """Does a GET request to /networks/{networkId}/sm/targetGroups.

        List the target groups in this network

        Args:
            network_id (string): TODO: type description here. Example: 
            with_details (bool, optional): Boolean indicating if the the ids
                of the devices or users scoped by the target group should be
                included in the response

        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}/sm/targetGroups'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'withDetails': with_details
        }
        _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 create_network_sm_target_group(self,
                                       network_id,
                                       create_network_sm_target_group=None):
        """Does a POST request to /networks/{networkId}/sm/targetGroups.

        Add a target group

        Args:
            network_id (string): TODO: type description here. Example: 
            create_network_sm_target_group (CreateNetworkSmTargetGroup,
                optional): 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}/sm/targetGroups'
        _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 headers
        _headers = {
            'content-type': 'application/json; charset=utf-8'
        }

        # Prepare and execute request
        _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(create_network_sm_target_group))
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def get_network_sm_target_group(self,
                                    network_id,
                                    target_group_id,
                                    with_details=None):
        """Does a GET request to /networks/{networkId}/sm/targetGroups/{targetGroupId}.

        Return a target group

        Args:
            network_id (string): TODO: type description here. Example: 
            target_group_id (string): TODO: type description here. Example: 
            with_details (bool, optional): Boolean indicating if the the ids
                of the devices or users scoped by the target group should be
                included in the response

        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}/sm/targetGroups/{targetGroupId}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id,
            'targetGroupId': target_group_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'withDetails': with_details
        }
        _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 update_network_sm_target_group(self,
                                       network_id,
                                       target_group_id,
                                       update_network_sm_target_group=None):
        """Does a PUT request to /networks/{networkId}/sm/targetGroups/{targetGroupId}.

        Update a target group

        Args:
            network_id (string): TODO: type description here. Example: 
            target_group_id (string): TODO: type description here. Example: 
            update_network_sm_target_group (UpdateNetworkSmTargetGroup,
                optional): 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}/sm/targetGroups/{targetGroupId}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id,
            'targetGroupId': target_group_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'content-type': 'application/json; charset=utf-8'
        }

        # Prepare and execute request
        _request = self.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(update_network_sm_target_group))
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return _context.response.raw_body

    def delete_network_sm_target_group(self,
                                       network_id,
                                       target_group_id):
        """Does a DELETE request to /networks/{networkId}/sm/targetGroups/{targetGroupId}.

        Delete a target group from a network

        Args:
            network_id (string): TODO: type description here. Example: 
            target_group_id (string): TODO: type description here. Example: 

        Returns:
            void: 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}/sm/targetGroups/{targetGroupId}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'networkId': network_id,
            'targetGroupId': target_group_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.delete(_query_url)
        CustomHeaderAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)
