<reponame>rgrr/smartmeshsdk<gh_stars>10-100
# coding: utf-8

"""
MotesApi.py
Copyright 2015 SmartBear Software

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       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.
"""

from __future__ import absolute_import

import sys
import os

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class MotesApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def get_motes(self, **kwargs):
        """
        Get list of motes and their states
        

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_motes(callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param int start_index: Start index for the response elements
        :param int max_results: Maximum number of elements to return
        :return: MoteList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['start_index', 'max_results']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_motes" % key
                )
            params[key] = val
        del params['kwargs']


        resource_path = '/motes'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}

        query_params = {}
        if 'start_index' in params:
            query_params['startIndex'] = params['start_index']
        if 'max_results' in params:
            query_params['maxResults'] = params['max_results']

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='MoteList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def delete_mote(self, mac, **kwargs):
        """
        Delete a mote
        This command deletes the mote specified by MAC address from both the network and the manager's configuration. If an active mote is deleted from the network, other motes and their services may be adversely affected. For a graceful decommission process, use POST motes/m/$mac/decomission command.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `delete_mote`")

        resource_path = '/motes/m/{mac}'.replace('{format}', 'json')
        method = 'DELETE'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def send_data_packet(self, mac, body, **kwargs):
        """
        Send data payload to the mote
        This command sends a packet with specified data payload to a mote in the network. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.send_data_packet(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param DataPacketSendInfo body: Packet information (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_data_packet" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `send_data_packet`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `send_data_packet`")

        resource_path = '/motes/m/{mac}/dataPacket'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def decommission_mote(self, mac, **kwargs):
        """
        Decommission a mote
        This command triggers the manager to prepare the mote identified by its MAC address for removal from the network. The command changes the network routing to  find alternative paths for its neighbors and makes the mote a leaf node (one that not forward any other mote's traffic). Once complete, the mote enters the decommisioned state, which means it is safe to power down and physically remove from the network. A cmdFinished event is generated when the manager has finished the process. Note that this is a best-effort command, and that in some cases it may not be possible to find alternative routes for some motes.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.decommission_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method decommission_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `decommission_mote`")

        resource_path = '/motes/m/{mac}/decommission'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_mote_info(self, mac, **kwargs):
        """
        Get information about a particular mote
        Get information about a particular mote. Fields marked with *  get cleared when mote statistics are reset

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_mote_info(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: MoteInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_mote_info" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_mote_info`")

        resource_path = '/motes/m/{mac}/info'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='MoteInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def send_ip_packet(self, mac, body, **kwargs):
        """
        Send pre-formatted 6LoWPAN packet to mote
        This command sends a pre-formatted 6LoWPAN packet to a mote in the network. The application (typically a LoWPAN Border Router) is responsible for constructing a valid 6LoWPAN packet. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.send_ip_packet(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param IPPacketSendInfo body: Packet information (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_ip_packet" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `send_ip_packet`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `send_ip_packet`")

        resource_path = '/motes/m/{mac}/ipPacket'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def exchange_join_key(self, mac, body, **kwargs):
        """
        Exchange mote join key
        This command triggers the manager to send a new join key to the specified mote and update the manager's Access Control List (ACL) entry for the mote. The response contains a callbackId. A cmdFinished event notification with this callbackId will be sent when the operation is complete. This change is persistent.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.exchange_join_key(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param ExchangeKeyInfo body: New join key (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method exchange_join_key" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `exchange_join_key`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `exchange_join_key`")

        resource_path = '/motes/m/{mac}/joinKey'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_links(self, mac, **kwargs):
        """
        Get all links currently active on the mote
        

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_links(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param int start_index: Start index for the response elements
        :param int max_results: Maximum number of elements to return
        :return: LinkInfoList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'start_index', 'max_results']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_links" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_links`")

        resource_path = '/motes/m/{mac}/links'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}
        if 'start_index' in params:
            query_params['startIndex'] = params['start_index']
        if 'max_results' in params:
            query_params['maxResults'] = params['max_results']

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='LinkInfoList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def exchange_network_id_mote(self, mac, parameters, **kwargs):
        """
        Exchange network id
        This command triggers the manager to distribute a new network ID to a specific mote in the network. A callbackId is returned in the response. A cmdFinished notification with this callbackId will be sent when the operation is complete. This change is persistent. When the mote is reset, it will attempt to join the new network.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.exchange_network_id_mote(mac, parameters, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param NetworkIdInfo parameters:  (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'parameters']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method exchange_network_id_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `exchange_network_id_mote`")
        # verify the required parameter 'parameters' is set
        if ('parameters' not in params) or (params['parameters'] is None):
            raise ValueError("Missing the required parameter `parameters` when calling `exchange_network_id_mote`")

        resource_path = '/motes/m/{mac}/networkId'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'parameters' in params:
            body_params = params['parameters']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def ping_mote(self, mac, **kwargs):
        """
        Ping a mote
        This command sends a ping (echo request) to the mote specified by MAC address A unique callbackId is generated and returned with the response. Note that, contrary to other commands, a cmdFinished notification is not generated as a result of this command.  Instead, when the response is received or a timeout occurs, the manager generates a pingResponse notification  containing the callbackId, measured round trip delay, and several other informational fields. Also note that since the ping request is wirelessly sent using unacknowledged transport, the mote is not guaranteed to receive the request.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.ping_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method ping_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `ping_mote`")

        resource_path = '/motes/m/{mac}/ping'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def reset_mote(self, mac, **kwargs):
        """
        Reset a mote
        Send a reset command to the specified mote. Note that several minutes may pass before the reset takes place as there are delays in  propagation of the command, processing it, and detecting loss of connectivity to other motes. Also, since the command is sent via unreliable  transport, it is not guaranteed to reach the mote on the first try.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.reset_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method reset_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `reset_mote`")

        resource_path = '/motes/m/{mac}/reset'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type=None,
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_services(self, mac, **kwargs):
        """
        Get services for a mote
        Returns a list of elements describing the bandwidth allocated to the mote, called services. The service elements describe bandwidth allocations to the mote as well as from the mote

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_services(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: ServiceInfoList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_services" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_services`")

        resource_path = '/motes/m/{mac}/services'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='ServiceInfoList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

# coding: utf-8

"""
MotesApi.py
Copyright 2015 SmartBear Software

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       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.
"""

from __future__ import absolute_import

import sys
import os

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class MotesApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def get_motes(self, **kwargs):
        """
        Get list of motes and their states
        

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_motes(callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param int start_index: Start index for the response elements
        :param int max_results: Maximum number of elements to return
        :return: MoteList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['start_index', 'max_results']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_motes" % key
                )
            params[key] = val
        del params['kwargs']


        resource_path = '/motes'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}

        query_params = {}
        if 'start_index' in params:
            query_params['startIndex'] = params['start_index']
        if 'max_results' in params:
            query_params['maxResults'] = params['max_results']

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='MoteList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def delete_mote(self, mac, **kwargs):
        """
        Delete a mote
        This command deletes the mote specified by MAC address from both the network and the manager's configuration. If an active mote is deleted from the network, other motes and their services may be adversely affected. For a graceful decommission process, use POST motes/m/$mac/decomission command.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `delete_mote`")

        resource_path = '/motes/m/{mac}'.replace('{format}', 'json')
        method = 'DELETE'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def send_data_packet(self, mac, body, **kwargs):
        """
        Send data payload to the mote
        This command sends a packet with specified data payload to a mote in the network. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.send_data_packet(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param DataPacketSendInfo body: Packet information (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_data_packet" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `send_data_packet`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `send_data_packet`")

        resource_path = '/motes/m/{mac}/dataPacket'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def decommission_mote(self, mac, **kwargs):
        """
        Decommission a mote
        This command triggers the manager to prepare the mote identified by its MAC address for removal from the network. The command changes the network routing to  find alternative paths for its neighbors and makes the mote a leaf node (one that not forward any other mote's traffic). Once complete, the mote enters the decommisioned state, which means it is safe to power down and physically remove from the network. A cmdFinished event is generated when the manager has finished the process. Note that this is a best-effort command, and that in some cases it may not be possible to find alternative routes for some motes.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.decommission_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method decommission_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `decommission_mote`")

        resource_path = '/motes/m/{mac}/decommission'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_mote_info(self, mac, **kwargs):
        """
        Get information about a particular mote
        Get information about a particular mote. Fields marked with *  get cleared when mote statistics are reset

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_mote_info(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: MoteInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_mote_info" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_mote_info`")

        resource_path = '/motes/m/{mac}/info'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='MoteInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def send_ip_packet(self, mac, body, **kwargs):
        """
        Send pre-formatted 6LoWPAN packet to mote
        This command sends a pre-formatted 6LoWPAN packet to a mote in the network. The application (typically a LoWPAN Border Router) is responsible for constructing a valid 6LoWPAN packet. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.send_ip_packet(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param IPPacketSendInfo body: Packet information (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_ip_packet" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `send_ip_packet`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `send_ip_packet`")

        resource_path = '/motes/m/{mac}/ipPacket'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def exchange_join_key(self, mac, body, **kwargs):
        """
        Exchange mote join key
        This command triggers the manager to send a new join key to the specified mote and update the manager's Access Control List (ACL) entry for the mote. The response contains a callbackId. A cmdFinished event notification with this callbackId will be sent when the operation is complete. This change is persistent.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.exchange_join_key(mac, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param ExchangeKeyInfo body: New join key (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method exchange_join_key" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `exchange_join_key`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `exchange_join_key`")

        resource_path = '/motes/m/{mac}/joinKey'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_links(self, mac, **kwargs):
        """
        Get all links currently active on the mote
        

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_links(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param int start_index: Start index for the response elements
        :param int max_results: Maximum number of elements to return
        :return: LinkInfoList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'start_index', 'max_results']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_links" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_links`")

        resource_path = '/motes/m/{mac}/links'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}
        if 'start_index' in params:
            query_params['startIndex'] = params['start_index']
        if 'max_results' in params:
            query_params['maxResults'] = params['max_results']

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='LinkInfoList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def exchange_network_id_mote(self, mac, parameters, **kwargs):
        """
        Exchange network id
        This command triggers the manager to distribute a new network ID to a specific mote in the network. A callbackId is returned in the response. A cmdFinished notification with this callbackId will be sent when the operation is complete. This change is persistent. When the mote is reset, it will attempt to join the new network.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.exchange_network_id_mote(mac, parameters, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :param NetworkIdInfo parameters:  (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac', 'parameters']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method exchange_network_id_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `exchange_network_id_mote`")
        # verify the required parameter 'parameters' is set
        if ('parameters' not in params) or (params['parameters'] is None):
            raise ValueError("Missing the required parameter `parameters` when calling `exchange_network_id_mote`")

        resource_path = '/motes/m/{mac}/networkId'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None
        if 'parameters' in params:
            body_params = params['parameters']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def ping_mote(self, mac, **kwargs):
        """
        Ping a mote
        This command sends a ping (echo request) to the mote specified by MAC address A unique callbackId is generated and returned with the response. Note that, contrary to other commands, a cmdFinished notification is not generated as a result of this command.  Instead, when the response is received or a timeout occurs, the manager generates a pingResponse notification  containing the callbackId, measured round trip delay, and several other informational fields. Also note that since the ping request is wirelessly sent using unacknowledged transport, the mote is not guaranteed to receive the request.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.ping_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: CallbackInfo
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method ping_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `ping_mote`")

        resource_path = '/motes/m/{mac}/ping'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='CallbackInfo',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def reset_mote(self, mac, **kwargs):
        """
        Reset a mote
        Send a reset command to the specified mote. Note that several minutes may pass before the reset takes place as there are delays in  propagation of the command, processing it, and detecting loss of connectivity to other motes. Also, since the command is sent via unreliable  transport, it is not guaranteed to reach the mote on the first try.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.reset_mote(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method reset_mote" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `reset_mote`")

        resource_path = '/motes/m/{mac}/reset'.replace('{format}', 'json')
        method = 'POST'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type=None,
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response

    def get_services(self, mac, **kwargs):
        """
        Get services for a mote
        Returns a list of elements describing the bandwidth allocated to the mote, called services. The service elements describe bandwidth allocations to the mote as well as from the mote

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_services(mac, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str mac: MAC Address (required)
        :return: ServiceInfoList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['mac']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_services" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'mac' is set
        if ('mac' not in params) or (params['mac'] is None):
            raise ValueError("Missing the required parameter `mac` when calling `get_services`")

        resource_path = '/motes/m/{mac}/services'.replace('{format}', 'json')
        method = 'GET'

        path_params = {}
        if 'mac' in params:
            path_params['mac'] = params['mac']

        query_params = {}

        header_params = {}

        form_params = {}
        files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['dust_basic']

        response = self.api_client.call_api(resource_path, method,
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=files,
                                            response_type='ServiceInfoList',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        return response
# coding: utf-8 MotesApi.py Copyright 2015 SmartBear Software     Licensed under the Apache License, Version 2.0 (the "License");    you may not use this file except in compliance with the License.    You may obtain a copy of the License at         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. # python 2 and python 3 compatibility library NOTE: This class is auto generated by the swagger code generator program.     Do not edit the class manually.     Ref: https://github.com/swagger-api/swagger-codegen Get list of motes and their states                   This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.get_motes(callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param int start_index: Start index for the response elements         :param int max_results: Maximum number of elements to return         :return: MoteList                  If the method is called asynchronously,                  returns the request thread. # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Delete a mote         This command deletes the mote specified by MAC address from both the network and the manager's configuration. If an active mote is deleted from the network, other motes and their services may be adversely affected. For a graceful decommission process, use POST motes/m/$mac/decomission command.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.delete_mote(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Send data payload to the mote         This command sends a packet with specified data payload to a mote in the network. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.send_data_packet(mac, body, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :param DataPacketSendInfo body: Packet information (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # verify the required parameter 'body' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Decommission a mote         This command triggers the manager to prepare the mote identified by its MAC address for removal from the network. The command changes the network routing to  find alternative paths for its neighbors and makes the mote a leaf node (one that not forward any other mote's traffic). Once complete, the mote enters the decommisioned state, which means it is safe to power down and physically remove from the network. A cmdFinished event is generated when the manager has finished the process. Note that this is a best-effort command, and that in some cases it may not be possible to find alternative routes for some motes.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.decommission_mote(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Get information about a particular mote         Get information about a particular mote. Fields marked with *  get cleared when mote statistics are reset          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.get_mote_info(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: MoteInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Send pre-formatted 6LoWPAN packet to mote         This command sends a pre-formatted 6LoWPAN packet to a mote in the network. The application (typically a LoWPAN Border Router) is responsible for constructing a valid 6LoWPAN packet. The response contains a callbackId. When the manager injects the packet into the network, it will generate a netPacketSent notification. It is the responsibility of the customer's application layer at the mote to send a response. It is also the responsibility of the customer's application layer to timeout if no response is received at the manager if one is expected.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.send_ip_packet(mac, body, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :param IPPacketSendInfo body: Packet information (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # verify the required parameter 'body' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Exchange mote join key         This command triggers the manager to send a new join key to the specified mote and update the manager's Access Control List (ACL) entry for the mote. The response contains a callbackId. A cmdFinished event notification with this callbackId will be sent when the operation is complete. This change is persistent.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.exchange_join_key(mac, body, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :param ExchangeKeyInfo body: New join key (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # verify the required parameter 'body' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Get all links currently active on the mote                   This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.get_links(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :param int start_index: Start index for the response elements         :param int max_results: Maximum number of elements to return         :return: LinkInfoList                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Exchange network id         This command triggers the manager to distribute a new network ID to a specific mote in the network. A callbackId is returned in the response. A cmdFinished notification with this callbackId will be sent when the operation is complete. This change is persistent. When the mote is reset, it will attempt to join the new network.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.exchange_network_id_mote(mac, parameters, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :param NetworkIdInfo parameters:  (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # verify the required parameter 'parameters' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Ping a mote         This command sends a ping (echo request) to the mote specified by MAC address A unique callbackId is generated and returned with the response. Note that, contrary to other commands, a cmdFinished notification is not generated as a result of this command.  Instead, when the response is received or a timeout occurs, the manager generates a pingResponse notification  containing the callbackId, measured round trip delay, and several other informational fields. Also note that since the ping request is wirelessly sent using unacknowledged transport, the mote is not guaranteed to receive the request.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.ping_mote(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: CallbackInfo                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Reset a mote         Send a reset command to the specified mote. Note that several minutes may pass before the reset takes place as there are delays in  propagation of the command, processing it, and detecting loss of connectivity to other motes. Also, since the command is sent via unreliable  transport, it is not guaranteed to reach the mote on the first try.          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.reset_mote(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: None                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting Get services for a mote         Returns a list of elements describing the bandwidth allocated to the mote, called services. The service elements describe bandwidth allocations to the mote as well as from the mote          This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please define a `callback` function         to be invoked when receiving the response.         >>> def callback_function(response):         >>>     pprint(response)         >>>         >>> thread = api.get_services(mac, callback=callback_function)          :param callback function: The callback function             for asynchronous request. (optional)         :param str mac: MAC Address (required)         :return: ServiceInfoList                  If the method is called asynchronously,                  returns the request thread. # verify the required parameter 'mac' is set # HTTP header `Accept` # HTTP header `Content-Type` # Authentication setting