# Path: netman/core/objects/switch_descriptor.py
# class SwitchDescriptor(Model):
#     def __init__(self, model, hostname, username=None, password=None, port=None, netman_server=None):
#         self.model = model
#         self.hostname = hostname
#         self.username = username
#         self.password = password
#         self.port = port
#         self.netman_server = netman_server


import logging
from flask import request
from netman.api.api_utils import BadRequest
from netman.core.objects.switch_descriptor import SwitchDescriptor
#     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.





class SwitchApiBase(object):
    def __init__(self, switch_factory, sessions_manager):
        self.switch_factory = switch_factory
        self.sessions_manager = sessions_manager

    def hook_to(self, server):
        raise NotImplemented()

    @property
    def logger(self):
        return logging.getLogger(__name__)

    def _get_switch_descriptor_from_request_headers(self, hostname):
        headers_present = [h in request.headers for h in ['Netman-Model', 'Netman-Username', 'Netman-Password']]

        if not any(headers_present):
            return None


# Path: netman/core/objects/switch_descriptor.py
# class SwitchDescriptor(Model):
#     def __init__(self, model, hostname, username=None, password=None, port=None, netman_server=None):
#         self.model = model
#         self.hostname = hostname
#         self.username = username
#         self.password = password
#         self.port = port
#         self.netman_server = netman_server


# Path: netman/api/switch_api_base.py
import logging
from flask import request
from netman.api.api_utils import BadRequest
from netman.core.objects.switch_descriptor import SwitchDescriptor

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





class SwitchApiBase(object):
    def __init__(self, switch_factory, sessions_manager):
        self.switch_factory = switch_factory
        self.sessions_manager = sessions_manager

    def hook_to(self, server):
        raise NotImplemented()

    @property
    def logger(self):
        return logging.getLogger(__name__)

    def _get_switch_descriptor_from_request_headers(self, hostname):
        headers_present = [h in request.headers for h in ['Netman-Model', 'Netman-Username', 'Netman-Password']]

        if not any(headers_present):
            return None


        if not all(headers_present):