from storage import StorableObject

class Federation(StorableObject):
    _names = 'federations'

    username = None
    password = None
    host_id = None
    name_identifiers = None

    def __init__(self, username, password, host_id, name_identifier):
        StorableObject.__init__(self)
        self.username = username
        self.password = password
        self.host_id = host_id
        self.name_identifiers = [name_identifier]

    def add_name_identifier(self, name_identifier):
        self.name_identifiers.append(name_identifier)

    def remove_name_identifier(self, name_identifier):
        self.name_identifiers.remove(name_identifier)
        if not self.name_identifiers:
            self.remove_self()
