"""
Autogenerated python message buffer code.
Source: clad/gateway/switchboard.clad
Full command line: victor-clad/tools/message-buffers/emitters/Python_emitter.py -C src -I clad/src lib/util/source/anki/clad robot/clad/src coretech/vision/clad_src coretech/common/clad_src -o generated/cladPython clad/gateway/switchboard.clad
"""

from __future__ import absolute_import
from __future__ import print_function

def _modify_path():
  import inspect, os, sys
  search_paths = [
    '../..',
    '../../../../victor-clad/tools/message-buffers/support/python',
  ]
  currentpath = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())))
  for search_path in search_paths:
    search_path = os.path.normpath(os.path.abspath(os.path.realpath(os.path.join(currentpath, search_path))))
    if search_path not in sys.path:
      sys.path.insert(0, search_path)
_modify_path()

import msgbuffers

Anki = msgbuffers.Namespace()
Anki.Switchboard = msgbuffers.Namespace()
Anki.Vector = msgbuffers.Namespace()

from clad.cloud.token import Anki as _Anki
Anki.update(_Anki.deep_clone())

class SwitchboardError(object):
  "Generated message-passing message."

  __slots__ = ()

  def __init__(self):
    pass

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SwitchboardError from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SwitchboardError.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SwitchboardError from the given BinaryReader."
    return cls()

  def pack(self):
    "Writes the current SwitchboardError, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SwitchboardError to the given BinaryWriter."

  def __eq__(self, other):
    if type(self) is type(other):
      return True
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return 0

  def __str__(self):
    return '{type}()'.format(type=type(self).__name__)

  def __repr__(self):
    return '{type}()'.format(type=type(self).__name__)

Anki.Switchboard.SwitchboardError = SwitchboardError
del SwitchboardError


class ExternalConnectionRequest(object):
  "Generated message-passing message."

  __slots__ = ()

  def __init__(self):
    pass

  @classmethod
  def unpack(cls, buffer):
    "Reads a new ExternalConnectionRequest from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('ExternalConnectionRequest.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new ExternalConnectionRequest from the given BinaryReader."
    return cls()

  def pack(self):
    "Writes the current ExternalConnectionRequest, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current ExternalConnectionRequest to the given BinaryWriter."

  def __eq__(self, other):
    if type(self) is type(other):
      return True
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return 0

  def __str__(self):
    return '{type}()'.format(type=type(self).__name__)

  def __repr__(self):
    return '{type}()'.format(type=type(self).__name__)

Anki.Switchboard.ExternalConnectionRequest = ExternalConnectionRequest
del ExternalConnectionRequest


class ExternalConnectionResponse(object):
  "Generated message-passing message."

  __slots__ = (
    '_isConnected',  # bool
    '_connectionId', # string[uint_16]
  )

  @property
  def isConnected(self):
    "bool isConnected struct property."
    return self._isConnected

  @isConnected.setter
  def isConnected(self, value):
    self._isConnected = msgbuffers.validate_bool(
      'ExternalConnectionResponse.isConnected', value)

  @property
  def connectionId(self):
    "string[uint_16] connectionId struct property."
    return self._connectionId

  @connectionId.setter
  def connectionId(self, value):
    self._connectionId = msgbuffers.validate_string(
      'ExternalConnectionResponse.connectionId', value, 65535)

  def __init__(self, isConnected=False, connectionId=''):
    self.isConnected = isConnected
    self.connectionId = connectionId

  @classmethod
  def unpack(cls, buffer):
    "Reads a new ExternalConnectionResponse from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('ExternalConnectionResponse.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new ExternalConnectionResponse from the given BinaryReader."
    _isConnected = bool(reader.read('b'))
    _connectionId = reader.read_string('H')
    return cls(_isConnected, _connectionId)

  def pack(self):
    "Writes the current ExternalConnectionResponse, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current ExternalConnectionResponse to the given BinaryWriter."
    writer.write(int(self._isConnected), 'b')
    writer.write_string(self._connectionId, 'H')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._isConnected == other._isConnected and
        self._connectionId == other._connectionId)
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size(self._isConnected, 'b') +
      msgbuffers.size_string(self._connectionId, 'H'))

  def __str__(self):
    return '{type}(isConnected={isConnected}, connectionId={connectionId})'.format(
      type=type(self).__name__,
      isConnected=self._isConnected,
      connectionId=msgbuffers.shorten_string(self._connectionId))

  def __repr__(self):
    return '{type}(isConnected={isConnected}, connectionId={connectionId})'.format(
      type=type(self).__name__,
      isConnected=repr(self._isConnected),
      connectionId=repr(self._connectionId))

Anki.Switchboard.ExternalConnectionResponse = ExternalConnectionResponse
del ExternalConnectionResponse


class ClientGuidRefreshRequest(object):
  "Generated message-passing message."

  __slots__ = ()

  def __init__(self):
    pass

  @classmethod
  def unpack(cls, buffer):
    "Reads a new ClientGuidRefreshRequest from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('ClientGuidRefreshRequest.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new ClientGuidRefreshRequest from the given BinaryReader."
    return cls()

  def pack(self):
    "Writes the current ClientGuidRefreshRequest, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current ClientGuidRefreshRequest to the given BinaryWriter."

  def __eq__(self, other):
    if type(self) is type(other):
      return True
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return 0

  def __str__(self):
    return '{type}()'.format(type=type(self).__name__)

  def __repr__(self):
    return '{type}()'.format(type=type(self).__name__)

Anki.Switchboard.ClientGuidRefreshRequest = ClientGuidRefreshRequest
del ClientGuidRefreshRequest


class ClientGuidRefreshResponse(object):
  "Generated message-passing message."

  __slots__ = ()

  def __init__(self):
    pass

  @classmethod
  def unpack(cls, buffer):
    "Reads a new ClientGuidRefreshResponse from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('ClientGuidRefreshResponse.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new ClientGuidRefreshResponse from the given BinaryReader."
    return cls()

  def pack(self):
    "Writes the current ClientGuidRefreshResponse, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current ClientGuidRefreshResponse to the given BinaryWriter."

  def __eq__(self, other):
    if type(self) is type(other):
      return True
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return 0

  def __str__(self):
    return '{type}()'.format(type=type(self).__name__)

  def __repr__(self):
    return '{type}()'.format(type=type(self).__name__)

Anki.Switchboard.ClientGuidRefreshResponse = ClientGuidRefreshResponse
del ClientGuidRefreshResponse


class SdkProxyRequest(object):
  "Generated message-passing message."

  __slots__ = (
    '_clientGuid', # string[uint_8]
    '_messageId',  # string[uint_8]
    '_path',       # string[uint_8]
    '_json',       # string[uint_16]
  )

  @property
  def clientGuid(self):
    "string[uint_8] clientGuid struct property."
    return self._clientGuid

  @clientGuid.setter
  def clientGuid(self, value):
    self._clientGuid = msgbuffers.validate_string(
      'SdkProxyRequest.clientGuid', value, 255)

  @property
  def messageId(self):
    "string[uint_8] messageId struct property."
    return self._messageId

  @messageId.setter
  def messageId(self, value):
    self._messageId = msgbuffers.validate_string(
      'SdkProxyRequest.messageId', value, 255)

  @property
  def path(self):
    "string[uint_8] path struct property."
    return self._path

  @path.setter
  def path(self, value):
    self._path = msgbuffers.validate_string(
      'SdkProxyRequest.path', value, 255)

  @property
  def json(self):
    "string[uint_16] json struct property."
    return self._json

  @json.setter
  def json(self, value):
    self._json = msgbuffers.validate_string(
      'SdkProxyRequest.json', value, 65535)

  def __init__(self, clientGuid='', messageId='', path='', json=''):
    self.clientGuid = clientGuid
    self.messageId = messageId
    self.path = path
    self.json = json

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SdkProxyRequest from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SdkProxyRequest.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SdkProxyRequest from the given BinaryReader."
    _clientGuid = reader.read_string('B')
    _messageId = reader.read_string('B')
    _path = reader.read_string('B')
    _json = reader.read_string('H')
    return cls(_clientGuid, _messageId, _path, _json)

  def pack(self):
    "Writes the current SdkProxyRequest, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SdkProxyRequest to the given BinaryWriter."
    writer.write_string(self._clientGuid, 'B')
    writer.write_string(self._messageId, 'B')
    writer.write_string(self._path, 'B')
    writer.write_string(self._json, 'H')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._clientGuid == other._clientGuid and
        self._messageId == other._messageId and
        self._path == other._path and
        self._json == other._json)
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size_string(self._clientGuid, 'B') +
      msgbuffers.size_string(self._messageId, 'B') +
      msgbuffers.size_string(self._path, 'B') +
      msgbuffers.size_string(self._json, 'H'))

  def __str__(self):
    return '{type}(clientGuid={clientGuid}, messageId={messageId}, path={path}, json={json})'.format(
      type=type(self).__name__,
      clientGuid=msgbuffers.shorten_string(self._clientGuid),
      messageId=msgbuffers.shorten_string(self._messageId),
      path=msgbuffers.shorten_string(self._path),
      json=msgbuffers.shorten_string(self._json))

  def __repr__(self):
    return '{type}(clientGuid={clientGuid}, messageId={messageId}, path={path}, json={json})'.format(
      type=type(self).__name__,
      clientGuid=repr(self._clientGuid),
      messageId=repr(self._messageId),
      path=repr(self._path),
      json=repr(self._json))

Anki.Switchboard.SdkProxyRequest = SdkProxyRequest
del SdkProxyRequest


class SdkProxyResponse(object):
  "Generated message-passing message."

  __slots__ = (
    '_messageId',   # string[uint_8]
    '_statusCode',  # uint_16
    '_contentType', # string[uint_8]
    '_content',     # string[uint_16]
  )

  @property
  def messageId(self):
    "string[uint_8] messageId struct property."
    return self._messageId

  @messageId.setter
  def messageId(self, value):
    self._messageId = msgbuffers.validate_string(
      'SdkProxyResponse.messageId', value, 255)

  @property
  def statusCode(self):
    "uint_16 statusCode struct property."
    return self._statusCode

  @statusCode.setter
  def statusCode(self, value):
    self._statusCode = msgbuffers.validate_integer(
      'SdkProxyResponse.statusCode', value, 0, 65535)

  @property
  def contentType(self):
    "string[uint_8] contentType struct property."
    return self._contentType

  @contentType.setter
  def contentType(self, value):
    self._contentType = msgbuffers.validate_string(
      'SdkProxyResponse.contentType', value, 255)

  @property
  def content(self):
    "string[uint_16] content struct property."
    return self._content

  @content.setter
  def content(self, value):
    self._content = msgbuffers.validate_string(
      'SdkProxyResponse.content', value, 65535)

  def __init__(self, messageId='', statusCode=0, contentType='', content=''):
    self.messageId = messageId
    self.statusCode = statusCode
    self.contentType = contentType
    self.content = content

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SdkProxyResponse from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SdkProxyResponse.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SdkProxyResponse from the given BinaryReader."
    _messageId = reader.read_string('B')
    _statusCode = reader.read('H')
    _contentType = reader.read_string('B')
    _content = reader.read_string('H')
    return cls(_messageId, _statusCode, _contentType, _content)

  def pack(self):
    "Writes the current SdkProxyResponse, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SdkProxyResponse to the given BinaryWriter."
    writer.write_string(self._messageId, 'B')
    writer.write(self._statusCode, 'H')
    writer.write_string(self._contentType, 'B')
    writer.write_string(self._content, 'H')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._messageId == other._messageId and
        self._statusCode == other._statusCode and
        self._contentType == other._contentType and
        self._content == other._content)
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size_string(self._messageId, 'B') +
      msgbuffers.size(self._statusCode, 'H') +
      msgbuffers.size_string(self._contentType, 'B') +
      msgbuffers.size_string(self._content, 'H'))

  def __str__(self):
    return '{type}(messageId={messageId}, statusCode={statusCode}, contentType={contentType}, content={content})'.format(
      type=type(self).__name__,
      messageId=msgbuffers.shorten_string(self._messageId),
      statusCode=self._statusCode,
      contentType=msgbuffers.shorten_string(self._contentType),
      content=msgbuffers.shorten_string(self._content))

  def __repr__(self):
    return '{type}(messageId={messageId}, statusCode={statusCode}, contentType={contentType}, content={content})'.format(
      type=type(self).__name__,
      messageId=repr(self._messageId),
      statusCode=repr(self._statusCode),
      contentType=repr(self._contentType),
      content=repr(self._content))

Anki.Switchboard.SdkProxyResponse = SdkProxyResponse
del SdkProxyResponse


class SwitchboardRequest(object):
  "Generated message-passing union."

  __slots__ = ('_tag', '_data')

  class Tag(object):
    "The type indicator for this union."
    SwitchboardError           = 0x1 # Anki.Switchboard.SwitchboardError
    AuthRequest                = 0x2 # Anki.Vector.AuthRequest
    JwtRequest                 = 0x3 # Anki.Vector.JwtRequest
    ExternalConnectionRequest  = 0x4 # Anki.Switchboard.ExternalConnectionRequest
    ExternalConnectionResponse = 0x5 # Anki.Switchboard.ExternalConnectionResponse
    ClientGuidRefreshResponse  = 0x6 # Anki.Switchboard.ClientGuidRefreshResponse
    SdkProxyResponse           = 0x7 # Anki.Switchboard.SdkProxyResponse

  @property
  def tag(self):
    "The current tag for this union."
    return self._tag

  @property
  def tag_name(self):
    "The name of the current tag for this union."
    if self._tag in self._tags_by_value:
      return self._tags_by_value[self._tag]
    else:
      return None

  @property
  def data(self):
    "The data held by this union. None if no data is set."
    return self._data

  @property
  def SwitchboardError(self):
    "Anki.Switchboard.SwitchboardError SwitchboardError union property."
    msgbuffers.safety_check_tag('SwitchboardError', self._tag, self.Tag.SwitchboardError, self._tags_by_value)
    return self._data

  @SwitchboardError.setter
  def SwitchboardError(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.SwitchboardError', value, Anki.Switchboard.SwitchboardError)
    self._tag = self.Tag.SwitchboardError

  @property
  def AuthRequest(self):
    "Anki.Vector.AuthRequest AuthRequest union property."
    msgbuffers.safety_check_tag('AuthRequest', self._tag, self.Tag.AuthRequest, self._tags_by_value)
    return self._data

  @AuthRequest.setter
  def AuthRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.AuthRequest', value, Anki.Vector.AuthRequest)
    self._tag = self.Tag.AuthRequest

  @property
  def JwtRequest(self):
    "Anki.Vector.JwtRequest JwtRequest union property."
    msgbuffers.safety_check_tag('JwtRequest', self._tag, self.Tag.JwtRequest, self._tags_by_value)
    return self._data

  @JwtRequest.setter
  def JwtRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.JwtRequest', value, Anki.Vector.JwtRequest)
    self._tag = self.Tag.JwtRequest

  @property
  def ExternalConnectionRequest(self):
    "Anki.Switchboard.ExternalConnectionRequest ExternalConnectionRequest union property."
    msgbuffers.safety_check_tag('ExternalConnectionRequest', self._tag, self.Tag.ExternalConnectionRequest, self._tags_by_value)
    return self._data

  @ExternalConnectionRequest.setter
  def ExternalConnectionRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.ExternalConnectionRequest', value, Anki.Switchboard.ExternalConnectionRequest)
    self._tag = self.Tag.ExternalConnectionRequest

  @property
  def ExternalConnectionResponse(self):
    "Anki.Switchboard.ExternalConnectionResponse ExternalConnectionResponse union property."
    msgbuffers.safety_check_tag('ExternalConnectionResponse', self._tag, self.Tag.ExternalConnectionResponse, self._tags_by_value)
    return self._data

  @ExternalConnectionResponse.setter
  def ExternalConnectionResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.ExternalConnectionResponse', value, Anki.Switchboard.ExternalConnectionResponse)
    self._tag = self.Tag.ExternalConnectionResponse

  @property
  def ClientGuidRefreshResponse(self):
    "Anki.Switchboard.ClientGuidRefreshResponse ClientGuidRefreshResponse union property."
    msgbuffers.safety_check_tag('ClientGuidRefreshResponse', self._tag, self.Tag.ClientGuidRefreshResponse, self._tags_by_value)
    return self._data

  @ClientGuidRefreshResponse.setter
  def ClientGuidRefreshResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.ClientGuidRefreshResponse', value, Anki.Switchboard.ClientGuidRefreshResponse)
    self._tag = self.Tag.ClientGuidRefreshResponse

  @property
  def SdkProxyResponse(self):
    "Anki.Switchboard.SdkProxyResponse SdkProxyResponse union property."
    msgbuffers.safety_check_tag('SdkProxyResponse', self._tag, self.Tag.SdkProxyResponse, self._tags_by_value)
    return self._data

  @SdkProxyResponse.setter
  def SdkProxyResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardRequest.SdkProxyResponse', value, Anki.Switchboard.SdkProxyResponse)
    self._tag = self.Tag.SdkProxyResponse

  def __init__(self, **kwargs):
    if not kwargs:
      self._tag = None
      self._data = None

    elif len(kwargs) == 1:
      key, value = next(iter(kwargs.items()))
      if key not in self._tags_by_name:
        raise TypeError("'{argument}' is an invalid keyword argument for this method.".format(argument=key))
      # calls the correct property
      setattr(self, key, value)

    else:
      raise TypeError('This method only accepts up to one keyword argument.')

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SwitchboardRequest from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SwitchboardRequest.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SwitchboardRequest from the given BinaryReader."
    tag = reader.read('B')
    if tag in cls._tags_by_value:
      value = cls()
      setattr(value, cls._tags_by_value[tag], cls._tag_unpack_methods[tag](reader))
      return value
    else:
      raise ValueError('SwitchboardRequest attempted to unpack unknown tag {tag}.'.format(tag=tag))

  def pack(self):
    "Writes the current SwitchboardRequest, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SampleUnion to the given BinaryWriter."
    if self._tag in self._tags_by_value:
      writer.write(self._tag, 'B')
      self._tag_pack_methods[self._tag](writer, self._data)
    else:
      raise ValueError('Cannot pack an empty SwitchboardRequest.')

  def clear(self):
    self._tag = None
    self._data = None

  @classmethod
  def typeByTag(cls, tag):
    return cls._type_by_tag_value[tag]()

  def __eq__(self, other):
    if type(self) is type(other):
      return self._tag == other._tag and self._data == other._data
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    if 0 <= self._tag < 7:
      return self._tag_size_methods[self._tag](self._data)
    else:
      return 1

  def __str__(self):
    if 0 <= self._tag < 7:
      return '{type}({name}={value})'.format(
        type=type(self).__name__,
        name=self.tag_name,
        value=self._data)
    else:
      return '{type}()'.format(
        type=type(self).__name__)

  def __repr__(self):
    if 0 <= self._tag < 7:
      return '{type}({name}={value})'.format(
        type=type(self).__name__,
        name=self.tag_name,
        value=repr(self._data))
    else:
      return '{type}()'.format(
        type=type(self).__name__)

  _tags_by_name = dict(
    SwitchboardError=1,
    AuthRequest=2,
    JwtRequest=3,
    ExternalConnectionRequest=4,
    ExternalConnectionResponse=5,
    ClientGuidRefreshResponse=6,
    SdkProxyResponse=7,
  )

  _tags_by_value = dict()
  _tags_by_value[1] = 'SwitchboardError'
  _tags_by_value[2] = 'AuthRequest'
  _tags_by_value[3] = 'JwtRequest'
  _tags_by_value[4] = 'ExternalConnectionRequest'
  _tags_by_value[5] = 'ExternalConnectionResponse'
  _tags_by_value[6] = 'ClientGuidRefreshResponse'
  _tags_by_value[7] = 'SdkProxyResponse'
  

  _tag_unpack_methods = dict()
  _tag_unpack_methods[1] = lambda reader: reader.read_object(Anki.Switchboard.SwitchboardError.unpack_from)
  _tag_unpack_methods[2] = lambda reader: reader.read_object(Anki.Vector.AuthRequest.unpack_from)
  _tag_unpack_methods[3] = lambda reader: reader.read_object(Anki.Vector.JwtRequest.unpack_from)
  _tag_unpack_methods[4] = lambda reader: reader.read_object(Anki.Switchboard.ExternalConnectionRequest.unpack_from)
  _tag_unpack_methods[5] = lambda reader: reader.read_object(Anki.Switchboard.ExternalConnectionResponse.unpack_from)
  _tag_unpack_methods[6] = lambda reader: reader.read_object(Anki.Switchboard.ClientGuidRefreshResponse.unpack_from)
  _tag_unpack_methods[7] = lambda reader: reader.read_object(Anki.Switchboard.SdkProxyResponse.unpack_from)
  

  _tag_pack_methods = dict()
  _tag_pack_methods[1] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[2] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[3] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[4] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[5] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[6] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[7] = lambda writer, value: writer.write_object(value)
  

  _tag_size_methods = dict()
  _tag_size_methods[1] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[2] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[3] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[4] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[5] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[6] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[7] = lambda value: msgbuffers.size_object(value)
  

  _type_by_tag_value = dict()
  _type_by_tag_value[1] = lambda : Anki.Switchboard.SwitchboardError
  _type_by_tag_value[2] = lambda : Anki.Vector.AuthRequest
  _type_by_tag_value[3] = lambda : Anki.Vector.JwtRequest
  _type_by_tag_value[4] = lambda : Anki.Switchboard.ExternalConnectionRequest
  _type_by_tag_value[5] = lambda : Anki.Switchboard.ExternalConnectionResponse
  _type_by_tag_value[6] = lambda : Anki.Switchboard.ClientGuidRefreshResponse
  _type_by_tag_value[7] = lambda : Anki.Switchboard.SdkProxyResponse
  

Anki.Switchboard.SwitchboardRequest = SwitchboardRequest
del SwitchboardRequest


class SwitchboardResponse(object):
  "Generated message-passing union."

  __slots__ = ('_tag', '_data')

  class Tag(object):
    "The type indicator for this union."
    SwitchboardError           = 0x1 # Anki.Switchboard.SwitchboardError
    AuthResponse               = 0x2 # Anki.Vector.AuthResponse
    JwtResponse                = 0x3 # Anki.Vector.JwtResponse
    ExternalConnectionRequest  = 0x4 # Anki.Switchboard.ExternalConnectionRequest
    ExternalConnectionResponse = 0x5 # Anki.Switchboard.ExternalConnectionResponse
    ClientGuidRefreshRequest   = 0x6 # Anki.Switchboard.ClientGuidRefreshRequest
    SdkProxyRequest            = 0x7 # Anki.Switchboard.SdkProxyRequest

  @property
  def tag(self):
    "The current tag for this union."
    return self._tag

  @property
  def tag_name(self):
    "The name of the current tag for this union."
    if self._tag in self._tags_by_value:
      return self._tags_by_value[self._tag]
    else:
      return None

  @property
  def data(self):
    "The data held by this union. None if no data is set."
    return self._data

  @property
  def SwitchboardError(self):
    "Anki.Switchboard.SwitchboardError SwitchboardError union property."
    msgbuffers.safety_check_tag('SwitchboardError', self._tag, self.Tag.SwitchboardError, self._tags_by_value)
    return self._data

  @SwitchboardError.setter
  def SwitchboardError(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.SwitchboardError', value, Anki.Switchboard.SwitchboardError)
    self._tag = self.Tag.SwitchboardError

  @property
  def AuthResponse(self):
    "Anki.Vector.AuthResponse AuthResponse union property."
    msgbuffers.safety_check_tag('AuthResponse', self._tag, self.Tag.AuthResponse, self._tags_by_value)
    return self._data

  @AuthResponse.setter
  def AuthResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.AuthResponse', value, Anki.Vector.AuthResponse)
    self._tag = self.Tag.AuthResponse

  @property
  def JwtResponse(self):
    "Anki.Vector.JwtResponse JwtResponse union property."
    msgbuffers.safety_check_tag('JwtResponse', self._tag, self.Tag.JwtResponse, self._tags_by_value)
    return self._data

  @JwtResponse.setter
  def JwtResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.JwtResponse', value, Anki.Vector.JwtResponse)
    self._tag = self.Tag.JwtResponse

  @property
  def ExternalConnectionRequest(self):
    "Anki.Switchboard.ExternalConnectionRequest ExternalConnectionRequest union property."
    msgbuffers.safety_check_tag('ExternalConnectionRequest', self._tag, self.Tag.ExternalConnectionRequest, self._tags_by_value)
    return self._data

  @ExternalConnectionRequest.setter
  def ExternalConnectionRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.ExternalConnectionRequest', value, Anki.Switchboard.ExternalConnectionRequest)
    self._tag = self.Tag.ExternalConnectionRequest

  @property
  def ExternalConnectionResponse(self):
    "Anki.Switchboard.ExternalConnectionResponse ExternalConnectionResponse union property."
    msgbuffers.safety_check_tag('ExternalConnectionResponse', self._tag, self.Tag.ExternalConnectionResponse, self._tags_by_value)
    return self._data

  @ExternalConnectionResponse.setter
  def ExternalConnectionResponse(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.ExternalConnectionResponse', value, Anki.Switchboard.ExternalConnectionResponse)
    self._tag = self.Tag.ExternalConnectionResponse

  @property
  def ClientGuidRefreshRequest(self):
    "Anki.Switchboard.ClientGuidRefreshRequest ClientGuidRefreshRequest union property."
    msgbuffers.safety_check_tag('ClientGuidRefreshRequest', self._tag, self.Tag.ClientGuidRefreshRequest, self._tags_by_value)
    return self._data

  @ClientGuidRefreshRequest.setter
  def ClientGuidRefreshRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.ClientGuidRefreshRequest', value, Anki.Switchboard.ClientGuidRefreshRequest)
    self._tag = self.Tag.ClientGuidRefreshRequest

  @property
  def SdkProxyRequest(self):
    "Anki.Switchboard.SdkProxyRequest SdkProxyRequest union property."
    msgbuffers.safety_check_tag('SdkProxyRequest', self._tag, self.Tag.SdkProxyRequest, self._tags_by_value)
    return self._data

  @SdkProxyRequest.setter
  def SdkProxyRequest(self, value):
    self._data = msgbuffers.validate_object(
      'SwitchboardResponse.SdkProxyRequest', value, Anki.Switchboard.SdkProxyRequest)
    self._tag = self.Tag.SdkProxyRequest

  def __init__(self, **kwargs):
    if not kwargs:
      self._tag = None
      self._data = None

    elif len(kwargs) == 1:
      key, value = next(iter(kwargs.items()))
      if key not in self._tags_by_name:
        raise TypeError("'{argument}' is an invalid keyword argument for this method.".format(argument=key))
      # calls the correct property
      setattr(self, key, value)

    else:
      raise TypeError('This method only accepts up to one keyword argument.')

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SwitchboardResponse from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SwitchboardResponse.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SwitchboardResponse from the given BinaryReader."
    tag = reader.read('B')
    if tag in cls._tags_by_value:
      value = cls()
      setattr(value, cls._tags_by_value[tag], cls._tag_unpack_methods[tag](reader))
      return value
    else:
      raise ValueError('SwitchboardResponse attempted to unpack unknown tag {tag}.'.format(tag=tag))

  def pack(self):
    "Writes the current SwitchboardResponse, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SampleUnion to the given BinaryWriter."
    if self._tag in self._tags_by_value:
      writer.write(self._tag, 'B')
      self._tag_pack_methods[self._tag](writer, self._data)
    else:
      raise ValueError('Cannot pack an empty SwitchboardResponse.')

  def clear(self):
    self._tag = None
    self._data = None

  @classmethod
  def typeByTag(cls, tag):
    return cls._type_by_tag_value[tag]()

  def __eq__(self, other):
    if type(self) is type(other):
      return self._tag == other._tag and self._data == other._data
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    if 0 <= self._tag < 7:
      return self._tag_size_methods[self._tag](self._data)
    else:
      return 1

  def __str__(self):
    if 0 <= self._tag < 7:
      return '{type}({name}={value})'.format(
        type=type(self).__name__,
        name=self.tag_name,
        value=self._data)
    else:
      return '{type}()'.format(
        type=type(self).__name__)

  def __repr__(self):
    if 0 <= self._tag < 7:
      return '{type}({name}={value})'.format(
        type=type(self).__name__,
        name=self.tag_name,
        value=repr(self._data))
    else:
      return '{type}()'.format(
        type=type(self).__name__)

  _tags_by_name = dict(
    SwitchboardError=1,
    AuthResponse=2,
    JwtResponse=3,
    ExternalConnectionRequest=4,
    ExternalConnectionResponse=5,
    ClientGuidRefreshRequest=6,
    SdkProxyRequest=7,
  )

  _tags_by_value = dict()
  _tags_by_value[1] = 'SwitchboardError'
  _tags_by_value[2] = 'AuthResponse'
  _tags_by_value[3] = 'JwtResponse'
  _tags_by_value[4] = 'ExternalConnectionRequest'
  _tags_by_value[5] = 'ExternalConnectionResponse'
  _tags_by_value[6] = 'ClientGuidRefreshRequest'
  _tags_by_value[7] = 'SdkProxyRequest'
  

  _tag_unpack_methods = dict()
  _tag_unpack_methods[1] = lambda reader: reader.read_object(Anki.Switchboard.SwitchboardError.unpack_from)
  _tag_unpack_methods[2] = lambda reader: reader.read_object(Anki.Vector.AuthResponse.unpack_from)
  _tag_unpack_methods[3] = lambda reader: reader.read_object(Anki.Vector.JwtResponse.unpack_from)
  _tag_unpack_methods[4] = lambda reader: reader.read_object(Anki.Switchboard.ExternalConnectionRequest.unpack_from)
  _tag_unpack_methods[5] = lambda reader: reader.read_object(Anki.Switchboard.ExternalConnectionResponse.unpack_from)
  _tag_unpack_methods[6] = lambda reader: reader.read_object(Anki.Switchboard.ClientGuidRefreshRequest.unpack_from)
  _tag_unpack_methods[7] = lambda reader: reader.read_object(Anki.Switchboard.SdkProxyRequest.unpack_from)
  

  _tag_pack_methods = dict()
  _tag_pack_methods[1] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[2] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[3] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[4] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[5] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[6] = lambda writer, value: writer.write_object(value)
  _tag_pack_methods[7] = lambda writer, value: writer.write_object(value)
  

  _tag_size_methods = dict()
  _tag_size_methods[1] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[2] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[3] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[4] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[5] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[6] = lambda value: msgbuffers.size_object(value)
  _tag_size_methods[7] = lambda value: msgbuffers.size_object(value)
  

  _type_by_tag_value = dict()
  _type_by_tag_value[1] = lambda : Anki.Switchboard.SwitchboardError
  _type_by_tag_value[2] = lambda : Anki.Vector.AuthResponse
  _type_by_tag_value[3] = lambda : Anki.Vector.JwtResponse
  _type_by_tag_value[4] = lambda : Anki.Switchboard.ExternalConnectionRequest
  _type_by_tag_value[5] = lambda : Anki.Switchboard.ExternalConnectionResponse
  _type_by_tag_value[6] = lambda : Anki.Switchboard.ClientGuidRefreshRequest
  _type_by_tag_value[7] = lambda : Anki.Switchboard.SdkProxyRequest
  

Anki.Switchboard.SwitchboardResponse = SwitchboardResponse
del SwitchboardResponse


