def listar_por_grupo_equipamento(self, id_grupo_equipamento): """Lista todos os direitos de grupos de usuário em um grupo de equipamento. :param id_grupo_equipamento: Identificador do grupo de equipamento para filtrar a pesquisa. :return: Dicionário com a seguinte estrutura: :: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]} :raise InvalidParameterError: O identificador do grupo de equipamento é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_grupo_equipamento): raise InvalidParameterError( u'O identificador do grupo de equipamento é inválido ou não foi informado.') url = 'direitosgrupoequipamento/egrupo/' + \ str(id_grupo_equipamento) + '/' code, map = self.submit(None, 'GET', url) key = 'direito_grupo_equipamento' return get_list_map(self.response(code, map, [key]), key)
def listar_por_tipo(self, id_script_type): """List all Script by Script Type. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :return: Dictionary with the following structure: :: {‘script’: [{‘id’: < id >, ‘tipo_roteiro': < id_tipo_roteiro >, ‘nome': < nome >, ‘descricao’: < descricao >}, ...more Script...]} :raise InvalidParameterError: The identifier of Script Type is null and invalid. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_script_type): raise InvalidParameterError( u'The identifier of Script Type is invalid or was not informed.') url = 'script/scripttype/' + str(id_script_type) + '/' code, map = self.submit(None, 'GET', url) key = 'script' return get_list_map(self.response(code, map, [key]), key)
def list_all_available(self, id_vlan): """ List all environment vips availables :return: Following dictionary: :: {'environment_vip': [{'id': <id>, 'finalidade_txt': <finalidade_txt>, 'cliente_txt': <cliente_txt>, 'ambiente_p44_txt': <ambiente_p44_txt> } {... other environments vip ...}]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ url = "environmentvip/search/" + str(id_vlan) code, xml = self.submit(None, "GET", url) key = "environment_vip" return get_list_map(self.response(code, xml, [key]), key)
def listar(self): """Lista todos os direitos de grupos de usuário em grupos de equipamento. :return: Dicionário com a seguinte estrutura: :: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ code, map = self.submit(None, 'GET', 'direitosgrupoequipamento/') key = 'direito_grupo_equipamento' return get_list_map(self.response(code, map, [key]), key)
def listar_tipo_servidores(self): url = 'rackservers/lista-tipo-servidores/' code, map = self.submit(None, 'GET', url) key = 'tipo_servidor' return get_list_map(self.response(code, map, [key]), key)
def listar_healthcheck_expect(self, id_ambiente): """Lista os healthcheck_expect´s de um ambiente. :param id_ambiente: Identificador do ambiente. :return: Dicionário com a seguinte estrutura: :: {'healthcheck_expect': [{'id': < id_healthcheck_expect >, 'expect_string': < expect_string >, 'match_list': < match_list >, 'id_ambiente': < id_ambiente >}, ... demais healthcheck_expects ...]} :raise InvalidParameterError: O identificador do ambiente é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_ambiente): raise InvalidParameterError( 'O identificador do ambiente é inválido ou não foi informado.') url = 'healthcheckexpect/ambiente/' + str(id_ambiente) + '/' code, xml = self.submit(None, 'GET', url) key = 'healthcheck_expect' return get_list_map(self.response(code, xml, [key]), key)
def listar_por_grupo_usuario(self, id_grupo_usuario): """Lista todos os direitos de um grupo de usuário em grupos de equipamento. :param id_grupo_usuario: Identificador do grupo de usuário para filtrar a pesquisa. :return: Dicionário com a seguinte estrutura: :: {'direito_grupo_equipamento': [{'id_grupo_equipamento': < id_grupo_equipamento >, 'exclusao': < exclusao >, 'alterar_config': < alterar_config >, 'nome_grupo_equipamento': < nome_grupo_equipamento >, 'id_grupo_usuario': < id_grupo_usuario >, 'escrita': < escrita >, 'nome_grupo_usuario': < nome_grupo_usuario >, 'id': < id >, 'leitura': < leitura >}, … demais direitos …]} :raise InvalidParameterError: O identificador do grupo de usuário é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_grupo_usuario): raise InvalidParameterError( 'O identificador do grupo de usuário é inválido ou não foi informado.' ) url = 'direitosgrupoequipamento/ugrupo/' + str(id_grupo_usuario) + '/' code, map = self.submit(None, 'GET', url) key = 'direito_grupo_equipamento' return get_list_map(self.response(code, map, [key]), key)
def listar_por_equipamento(self, id_equipment): """List all Script related Equipment. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {script': [{‘id’: < id >, ‘nome’: < nome >, ‘descricao’: < descricao >, ‘id_tipo_roteiro’: < id_tipo_roteiro >, ‘nome_tipo_roteiro’: < nome_tipo_roteiro >, ‘descricao_tipo_roteiro’: < descricao_tipo_roteiro >}, ...more Script...]} :raise InvalidParameterError: The identifier of Equipment is null and invalid. :raise EquipamentoNaoExisteError: Equipment not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_equipment): raise InvalidParameterError( u'The identifier of Equipment is invalid or was not informed.') url = 'script/equipment/' + str(id_equipment) + '/' code, map = self.submit(None, 'GET', url) key = 'script' return get_list_map(self.response(code, map, [key]), key)
def list_by_equip(self, name): """ List all equipment access by equipment name :return: Dictionary with the following structure: :: {‘equipamento_acesso’:[ {'id': <id_equiptos_access>, 'equipamento': <id_equip>, 'fqdn': <fqdn>, 'user': <user>, 'password': <pass> 'tipo_acesso': <id_tipo_acesso>, 'enable_pass': <enable_pass> }]} :raise InvalidValueError: Invalid parameter. :raise EquipamentoNotFoundError: Equipment name not found in database. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ equip_access_map = dict() equip_access_map['name'] = name code, xml = self.submit( {"equipamento_acesso": equip_access_map}, 'POST', 'equipamentoacesso/name/') key = 'equipamento_acesso' return get_list_map(self.response(code, xml, [key]), key)
def list_no_blocks(self): """ List all environments in DB without blocks :return: Following dictionary: :: {'ambiente': [{'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3> 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico> 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, 'link': <link> }, ... ]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. """ url = "environment/list_no_blocks/" code, xml = self.submit(None, 'PUT', url) key = 'ambiente' return get_list_map(self.response(code, xml, [key]), key)
def find_ip4_by_network(self, id_network): """List IPv4 from network. :param id_network: Networkv ipv4 identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'id_vlan': < id_vlan >, 'oct4': < oct4 >, 'oct3': < oct3 >, 'oct2': < oct2 >, 'oct1': < oct1 >, 'descricao': < descricao > 'equipamento': [ { all name equipamentos related } ], }} :raise IpNaoExisteError: Network does not have any ips. :raise InvalidParameterError: Network identifier is none or invalid. :raise DataBaseError: Networkapi failed to access the database. """ if not is_valid_int_param(id_network): raise InvalidParameterError( u'Network identifier is invalid or was not informed.') url = 'ip/id_network_ipv4/' + str(id_network) + "/" code, xml = self.submit(None, 'GET', url) key = "ips" return get_list_map(self.response(code, xml, [key]), key)
def list_all_available(self, id_vlan): """ List all environment vips availables :return: Following dictionary: :: {'environment_vip': [{'id': <id>, 'finalidade_txt': <finalidade_txt>, 'cliente_txt': <cliente_txt>, 'ambiente_p44_txt': <ambiente_p44_txt> } {... other environments vip ...}]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ url = 'environmentvip/search/' + str(id_vlan) code, xml = self.submit(None, 'GET', url) key = 'environment_vip' return get_list_map(self.response(code, xml, [key]), key)
def listar_switch_router(self, id_equipamento): url = 'int/getbyidequip/' + str(id_equipamento) + '/' code, xml = self.submit(None, 'GET', url) key = 'interfaces' return get_list_map(self.response(code, xml, [key]), key)
def list_all(self): """ List all filters :return: Following dictionary: :: {'filter': [{'id': <id>, 'name': <name>, 'description': <description>, 'equip_types': [<TipoEquipamento>, {...demais TipoEquipamento's...}]} {... demais filters ...}] } :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ url = 'filter/all/' code, xml = self.submit(None, 'GET', url) key = 'filter' return get_list_map(self.response(code, xml, [key]), key)
def get_rack(self, name): url = 'rack/find/' + str(name) + '/' code, xml = self.submit(None, 'GET', url) key = 'rack' return get_list_map(self.response(code, xml, [key]), key)
def listar_por_equipamento(self, id_equipamento): """List all interfaces of an equipment. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: :: {'interface': [{'protegida': < protegida >, 'nome': < nome >, 'id_ligacao_front': < id_ligacao_front >, 'id_equipamento': < id_equipamento >, 'id': < id >, 'descricao': < descricao >, 'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]} :raise InvalidParameterError: Equipment identifier is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_equipamento): raise InvalidParameterError( u'Equipment id is invalid or was not informed.') url = 'interface/equipamento/' + str(id_equipamento) + '/' code, map = self.submit(None, 'GET', url) key = 'interface' return get_list_map(self.response(code, map, [key]), key)
def list_all_rack_environments(self, id_rack): url = 'rack/list-rack-environment/' + str(id_rack) + '/' code, xml = self.submit(None, 'GET', url) key = 'ambiente' return get_list_map(self.response(code, xml, [key]), key)
def list_by_equip(self, name): """ List all equipment script by equipment name :return: Dictionary with the following structure: :: {‘equipamento_roteiro’:[ {'id': <id_equipment_script>, 'roteiro_id': <id_script>, 'roteiro_name': <name_script>, 'roteiro_desc': <desc_script>, 'tipo_roteiro_id': <id_script_type>, 'tipo_roteiro_name': <name_script_type>, 'tipo_roteiro_desc': <desc_script_type>, }], 'equipamento': {'id': <id_equipment>, 'name': <name_equipment>,}} :raise InvalidParameterError: Name is null and invalid. :raise EquipamentoNotFoundError: Equipment name not found in database. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ equip_script_map = dict() equip_script_map['name'] = name code, xml = self.submit( {"equipamento_roteiro": equip_script_map}, 'POST', 'equipamentoroteiro/name/') key = 'equipamento_roteiro' return get_list_map(self.response(code, xml, [key]), key)
def listar_healthcheck_expect(self, id_ambiente): """Lista os healthcheck_expect´s de um ambiente. :param id_ambiente: Identificador do ambiente. :return: Dicionário com a seguinte estrutura: :: {'healthcheck_expect': [{'id': < id_healthcheck_expect >, 'expect_string': < expect_string >, 'match_list': < match_list >, 'id_ambiente': < id_ambiente >}, ... demais healthcheck_expects ...]} :raise InvalidParameterError: O identificador do ambiente é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_ambiente): raise InvalidParameterError( u'O identificador do ambiente é inválido ou não foi informado.') url = 'healthcheckexpect/ambiente/' + str(id_ambiente) + '/' code, xml = self.submit(None, 'GET', url) key = 'healthcheck_expect' return get_list_map(self.response(code, xml, [key]), key)
def listar(self): """List all Related Equipment with Script. Somente retorna os relacionamentos dos equipamentos que o usuário autenticado tem permissão de leitura em pelo menos um grupo do equipamento. :return: Dictionary with the following structure: :: {'equipamento_roteiro': [{'roteiro': {'nome_tipo_roteiro': < nome_tipo_roteiro >, 'descricao': < descricao >, 'nome': < nome >, 'id': < id >, 'id_tipo_roteiro': < id_tipo_roteiro >, 'descricao_tipo_roteiro': < descrição_tipo_roteiro >}, 'equipamento': {'id_modelo': < id_modelo >, 'nome': < nome >, 'nome_marca': < nome_marca >, 'nome_modelo': < nome_modelo >, 'id_marca': < id_marca >, 'nome_tipo_equipamento': < nome_tipo_equipamento >, 'id_tipo_equipamento': < id_tipo_equipamento >, 'id': < id >}}, ... demais equipamento_roteiro´s ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ code, map = self.submit(None, 'GET', 'equipmentscript/all/') key = 'equipamento_roteiro' return get_list_map(self.response(code, map, [key]), key)
def get_rack_by_equip_id(self, equip_id): url = 'rack/get-by-equip/' + str(equip_id) + '/' code, xml = self.submit(None, 'GET', url) key = 'rack' return get_list_map(self.response(code, xml, [key]), key)
def get_ipv4(self, id_ip): """Get IPv4 by id. :param id_ip: ID of IPv4. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'networkipv4': < networkipv4 >, 'oct4': < oct4 >, 'oct3': < oct3 >, 'oct2': < oct2 >, 'oct1': < oct1 >, 'descricao': < descricao >, 'equipamentos': [ { all name of equipments related } ] , }} :raise IpNaoExisteError: IP is not registered. :raise InvalidParameterError: IP identifier is null or invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_ip): raise InvalidParameterError( u'The IPv4 identifier is invalid or was not informed.') url = 'ip/get-ipv4/' + str(id_ip) + '/' code, xml = self.submit(None, 'GET', url) key = 'ipv4' return get_list_map(self.response(code, xml, ["equipamentos"]), key)
def list_all_interface_types(self): url = 'interfacetype/get-type/' code, xml = self.submit(None, 'GET', url) key = 'tipo_interface' return get_list_map(self.response(code, xml, [key]), key)
def listar(self): """List Equipment Access relationships. Return only the relationships from equipments the user have write permissions in one of the equipment groups :return: Dictionary with the following: :: {'equipamento_acesso': [{'id_equipamento': < id_equipamento >, 'fqdn': < fqdn >, 'user': < user >, 'pass': < pass >, 'id_tipo_acesso': < id_tipo_acesso >, 'enable_pass': < enable_pass >, 'protocolo_tipo_acesso': < protocol_tipo_acesso >}, ... other equipment_access ....]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ code, map = self.submit(None, 'GET', 'equipamentoacesso/') key = 'equipamento_acesso' return get_list_map(self.response(code, map, [key]), key)
def listar_por_equipamento(self, id_equipamento): """List all interfaces of an equipment. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: :: {'interface': [{'protegida': < protegida >, 'nome': < nome >, 'id_ligacao_front': < id_ligacao_front >, 'id_equipamento': < id_equipamento >, 'id': < id >, 'descricao': < descricao >, 'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]} :raise InvalidParameterError: Equipment identifier is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_equipamento): raise InvalidParameterError( 'Equipment id is invalid or was not informed.') url = 'interface/equipamento/' + str(id_equipamento) + '/' code, map = self.submit(None, 'GET', url) key = 'interface' return get_list_map(self.response(code, map, [key]), key)
def listar_por_marca(self, id_brand): """List all Model by Brand. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :return: Dictionary with the following structure: :: {‘model’: [{‘id’: < id >, ‘nome’: < nome >, ‘id_marca’: < id_marca >}, ... too Model ...]} :raise InvalidParameterError: The identifier of Brand is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ if not is_valid_int_param(id_brand): raise InvalidParameterError( u'The identifier of Brand is invalid or was not informed.') url = 'model/brand/' + str(id_brand) + '/' code, map = self.submit(None, 'GET', url) key = 'model' return get_list_map(self.response(code, map, [key]), key)
def list_by_equip(self, name): """ List all equipment script by equipment name :return: Dictionary with the following structure: :: {‘equipamento_roteiro’:[ {'id': <id_equipment_script>, 'roteiro_id': <id_script>, 'roteiro_name': <name_script>, 'roteiro_desc': <desc_script>, 'tipo_roteiro_id': <id_script_type>, 'tipo_roteiro_name': <name_script_type>, 'tipo_roteiro_desc': <desc_script_type>, }], 'equipamento': {'id': <id_equipment>, 'name': <name_equipment>,}} :raise InvalidParameterError: Name is null and invalid. :raise EquipamentoNotFoundError: Equipment name not found in database. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ equip_script_map = dict() equip_script_map['name'] = name code, xml = self.submit({"equipamento_roteiro": equip_script_map}, 'POST', 'equipamentoroteiro/name/') key = 'equipamento_roteiro' return get_list_map(self.response(code, xml, [key]), key)
def list_by_equip(self, name): """ List all equipment access by equipment name :return: Dictionary with the following structure: :: {‘equipamento_acesso’:[ {'id': <id_equiptos_access>, 'equipamento': <id_equip>, 'fqdn': <fqdn>, 'user': <user>, 'password': <pass> 'tipo_acesso': <id_tipo_acesso>, 'enable_pass': <enable_pass> }]} :raise InvalidValueError: Invalid parameter. :raise EquipamentoNotFoundError: Equipment name not found in database. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ equip_access_map = dict() equip_access_map['name'] = name code, xml = self.submit({"equipamento_acesso": equip_access_map}, 'POST', 'equipamentoacesso/name/') key = 'equipamento_acesso' return get_list_map(self.response(code, xml, [key]), key)
def find_logs(self, user_name, first_date, start_time, last_date, end_time, action, functionality, parameter, pagination): """ Search all logs, filtering by the given parameters. :param user_name: Filter by user_name :param first_date: Sets initial date for begin of the filter :param start_time: Sets initial time :param last_date: Sets final date :param end_time: Sets final time and ends the filter. That defines the searching gap :param action: Filter by action (Create, Update or Delete) :param functionality: Filter by class :param parameter: Filter by parameter :param pagination: Class with all data needed to paginate :return: Following dictionary: :: {'eventlog': {'id_usuario' : < id_user >, 'hora_evento': < hora_evento >, 'acao': < acao >, 'funcionalidade': < funcionalidade >, 'parametro_anterior': < parametro_anterior >, 'parametro_atual': < parametro_atual > } 'total' : {< total_registros >} } :raise InvalidParameterError: Some parameter was invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not isinstance(pagination, Pagination): raise InvalidParameterError( u"Invalid parameter: pagination must be a class of type 'Pagination'." ) eventlog_map = dict() eventlog_map["start_record"] = pagination.start_record eventlog_map["end_record"] = pagination.end_record eventlog_map["asorting_cols"] = pagination.asorting_cols eventlog_map["searchable_columns"] = pagination.searchable_columns eventlog_map["custom_search"] = pagination.custom_search eventlog_map["usuario"] = user_name eventlog_map["data_inicial"] = first_date eventlog_map["hora_inicial"] = start_time eventlog_map["data_final"] = last_date eventlog_map["hora_final"] = end_time eventlog_map["acao"] = action eventlog_map["funcionalidade"] = functionality eventlog_map["parametro"] = parameter url = "eventlog/find/" code, xml = self.submit({'eventlog': eventlog_map}, 'POST', url) key = "eventlog" return get_list_map(self.response(code, xml, key), key)
def get_by_script_id(self, script_id): if not is_valid_int_param(script_id): raise InvalidParameterError( u'The identifier of Script is invalid or was not informed.') url = 'model/script/' + str(script_id) + '/' code, map = self.submit(None, 'GET', url) key = 'model' return get_list_map(self.response(code, map, [key]), key)
def list_all(self): """List all Permission. :return: Dictionary with the following structure: :: {'perms': [{ 'function' < function >, 'id': < id > }, ... more permissions ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ code, map = self.submit(None, 'GET', 'perms/all/') key = 'perms' return get_list_map(self.response(code, map, [key]), key)
def list_connections(self, nome_interface, id_equipamento): """List interfaces linked to back and front of specified interface. :param nome_interface: Interface name. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: :: {'interfaces':[ {'id': < id >, 'interface': < nome >, 'descricao': < descricao >, 'protegida': < protegida >, 'equipamento': < id_equipamento >, 'tipo_equip': < id_tipo_equipamento >, 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, 'nome_equip_l_back': < equipment_name > }, ... other interfaces ...]} :raise InterfaceNaoExisteError: Interface doesn't exist or is not associated with this equipment. :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise InvalidParameterError: Interface name and/or equipment identifier are none or invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_equipamento): raise InvalidParameterError( u'Equipment identifier is none or was not informed.') if (nome_interface is None) or (nome_interface == ''): raise InvalidParameterError(u'Interface name was not informed.') # Temporário, remover. Fazer de outra forma. nome_interface = nome_interface.replace('/', 's2it_replace') url = 'interface/' + \ urllib.quote(nome_interface) + '/equipment/' + \ str(id_equipamento) + '/' code, map = self.submit(None, 'GET', url) key = 'interfaces' return get_list_map(self.response(code, map, [key]), key)
def listar(self, id_divisao=None, id_ambiente_logico=None): """Lista os ambientes filtrados conforme parâmetros informados. Se os dois parâmetros têm o valor None então retorna todos os ambientes. Se o id_divisao é diferente de None então retorna os ambientes filtrados pelo valor de id_divisao. Se o id_divisao e id_ambiente_logico são diferentes de None então retorna os ambientes filtrados por id_divisao e id_ambiente_logico. :param id_divisao: Identificador da divisão de data center. :param id_ambiente_logico: Identificador do ambiente lógico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': [{'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}, ... demais ambientes ... ]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ url = 'ambiente/' if is_valid_int_param( id_divisao) and not is_valid_int_param(id_ambiente_logico): url = 'ambiente/divisao_dc/' + str(id_divisao) + '/' elif is_valid_int_param(id_divisao) and is_valid_int_param( id_ambiente_logico): url = 'ambiente/divisao_dc/' + \ str(id_divisao) + '/ambiente_logico/' + str(id_ambiente_logico) + '/' code, xml = self.submit(None, 'GET', url) key = 'ambiente' return get_list_map(self.response(code, xml, [key]), key)
def listar(self): """List all access types. :return: Dictionary with structure: :: {‘tipo_acesso’: [{‘id’: < id >, ‘protocolo’: < protocolo >}, ... other access types ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ code, map = self.submit(None, 'GET', 'tipoacesso/') key = 'tipo_acesso' return get_list_map(self.response(code, map, [key]), key)
def listar(self): """List all Brand. :return: Dictionary with the following structure: :: {‘brand’: [{‘id’: < id >, ‘nome’: < nome >}, ... too Brands ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ code, map = self.submit(None, 'GET', 'brand/all/') key = 'brand' return get_list_map(self.response(code, map, [key]), key)
def listar(self): """List all Equipment Type. :return: Dictionary with the following structure: :: {‘equipment_type’ : [{‘id’: < id >, ‘nome’: < name >}, ... too Equipment Type ...] } :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ code, map = self.submit(None, 'GET', 'equipmenttype/all/') key = 'equipment_type' return get_list_map(self.response(code, map, [key]), key)
def listar(self, id_divisao=None, id_ambiente_logico=None): """Lista os ambientes filtrados conforme parâmetros informados. Se os dois parâmetros têm o valor None então retorna todos os ambientes. Se o id_divisao é diferente de None então retorna os ambientes filtrados pelo valor de id_divisao. Se o id_divisao e id_ambiente_logico são diferentes de None então retorna os ambientes filtrados por id_divisao e id_ambiente_logico. :param id_divisao: Identificador da divisão de data center. :param id_ambiente_logico: Identificador do ambiente lógico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': [{'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}, ... demais ambientes ... ]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ url = 'ambiente/' if is_valid_int_param(id_divisao) and not is_valid_int_param( id_ambiente_logico): url = 'ambiente/divisao_dc/' + str(id_divisao) + '/' elif is_valid_int_param(id_divisao) and is_valid_int_param(id_ambiente_logico): url = 'ambiente/divisao_dc/' + \ str(id_divisao) + '/ambiente_logico/' + str(id_ambiente_logico) + '/' code, xml = self.submit(None, 'GET', url) key = 'ambiente' return get_list_map(self.response(code, xml, [key]), key)
def get_version(self): """ Returns the API's version :return: :: {'version_api': <version_api> } """ url = "eventlog/version/" code, xml = self.submit(None, 'GET', url) key = "version" return get_list_map(self.response(code, xml, key), key)
def listar(self): """List all network types. :return: Following dictionary: :: {'net_type': [{'id': < id_tipo_rede >, 'name': < nome_tipo_rede >}, ... other network types ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ code, xml = self.submit(None, 'GET', 'net_type/') key = 'net_type' return get_list_map(self.response(code, xml, [key]), key)