text_prompt
stringlengths
100
17.7k
code_prompt
stringlengths
7
9.86k
<SYSTEM_TASK:> List all Model by Brand. <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Inserts a new Model and returns its identifier <END_TASK> <USER_TASK:> Description: def inserir(self, id_brand, name): """Inserts a new Model and returns its identifier :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Model name. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'model': {'id': < id_model >}} :raise InvalidParameterError: The identifier of Brand or name is null and invalid. :raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand. :raise MarcaNaoExisteError: Brand not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """
model_map = dict() model_map['name'] = name model_map['id_brand'] = id_brand code, xml = self.submit({'model': model_map}, 'POST', 'model/') return self.response(code, xml)
<SYSTEM_TASK:> Change Model from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_model, id_brand, name): """Change Model from by the identifier. :param id_model: Identifier of the Model. Integer value and greater than zero. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Model name. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Model, Brand or name is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise ModeloEquipamentoNaoExisteError: Model not registered. :raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """
if not is_valid_int_param(id_model): raise InvalidParameterError( u'The identifier of Model is invalid or was not informed.') model_map = dict() model_map['name'] = name model_map['id_brand'] = id_brand url = 'model/' + str(id_model) + '/' code, xml = self.submit({'model': model_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Model from by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_model): """Remove Model from by the identifier. :param id_model: Identifier of the Model. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Model is null and invalid. :raise ModeloEquipamentoNaoExisteError: Model not registered. :raise ModeloEquipamentoError: The Model is associated with a equipment. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """
if not is_valid_int_param(id_model): raise InvalidParameterError( u'The identifier of Model is invalid or was not informed.') url = 'model/' + str(id_model) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> List all interfaces of an equipment. <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Get an interface by id. <END_TASK> <USER_TASK:> Description: def get_by_id(self, id_interface): """Get an interface by id. :param id_interface: Interface identifier. :return: Following dictionary: :: {'interface': {'id': < id >, 'interface': < interface >, 'descricao': < descricao >, 'protegida': < protegida >, 'tipo_equip': < id_tipo_equipamento >, 'equipamento': < id_equipamento >, 'equipamento_nome': < nome_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 > }} :raise InvalidParameterError: Interface 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_interface): raise InvalidParameterError( u'Interface id is invalid or was not informed.') url = 'interface/' + str(id_interface) + '/get/' code, map = self.submit(None, 'GET', url) return self.response(code, map)
<SYSTEM_TASK:> Insert new interface for an equipment. <END_TASK> <USER_TASK:> Description: def inserir( self, nome, protegida, descricao, id_ligacao_front, id_ligacao_back, id_equipamento, tipo=None, vlan=None): """Insert new interface for an equipment. :param nome: Interface name. :param protegida: Indication of protected ('0' or '1'). :param descricao: Interface description. :param id_ligacao_front: Front end link interface identifier. :param id_ligacao_back: Back end link interface identifier. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: {'interface': {'id': < id >}} :raise EquipamentoNaoExisteError: Equipment does not exist. :raise InvalidParameterError: The parameters nome, protegida and/or equipment id are none or invalid. :raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment. :raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
interface_map = dict() interface_map['nome'] = nome interface_map['protegida'] = protegida interface_map['descricao'] = descricao interface_map['id_ligacao_front'] = id_ligacao_front interface_map['id_ligacao_back'] = id_ligacao_back interface_map['id_equipamento'] = id_equipamento interface_map['tipo'] = tipo interface_map['vlan'] = vlan code, xml = self.submit( {'interface': interface_map}, 'POST', 'interface/') return self.response(code, xml)
<SYSTEM_TASK:> Edit an interface by its identifier. <END_TASK> <USER_TASK:> Description: def alterar( self, id_interface, nome, protegida, descricao, id_ligacao_front, id_ligacao_back, tipo=None, vlan=None): """Edit an interface by its identifier. Equipment identifier is not changed. :param nome: Interface name. :param protegida: Indication of protected ('0' or '1'). :param descricao: Interface description. :param id_ligacao_front: Front end link interface identifier. :param id_ligacao_back: Back end link interface identifier. :param id_interface: Interface identifier. :return: None :raise InvalidParameterError: The parameters interface id, nome and protegida are none or invalid. :raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment. :raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_interface): raise InvalidParameterError( u'Interface id is invalid or was not informed.') url = 'interface/' + str(id_interface) + '/' interface_map = dict() interface_map['nome'] = nome interface_map['protegida'] = protegida interface_map['descricao'] = descricao interface_map['id_ligacao_front'] = id_ligacao_front interface_map['id_ligacao_back'] = id_ligacao_back interface_map['tipo'] = tipo interface_map['vlan'] = vlan code, xml = self.submit({'interface': interface_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove an interface by its identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_interface): """Remove an interface by its identifier. :param id_interface: Interface identifier. :return: None :raise InterfaceNaoExisteError: Interface doesn't exist. :raise InterfaceError: Interface is linked to another interface. :raise InvalidParameterError: The interface 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_interface): raise InvalidParameterError( u'Interface id is invalid or was not informed.') url = 'interface/' + str(id_interface) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> List interfaces linked to back and front of specified interface. <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> List all Permission. <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> List all users and their user groups. <END_TASK> <USER_TASK:> Description: def list_with_usergroup(self): """List all users and their user groups. is_more -If more than 3 of groups of users or no, to control expansion Screen. :return: Dictionary with the following structure: :: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'is_more': <True ou False>, 'grupos': [nome_grupo, ...more user groups...]}, ...more user...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'usuario/get/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Get user by the ldap name. <END_TASK> <USER_TASK:> Description: def get_by_user_ldap(self, user_name): """Get user by the ldap name. is_more -If more than 3 of groups of users or no, to control expansion Screen. :return: Dictionary with the following structure: :: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'grupos': [nome_grupo, ...more user groups...], 'user_ldap': < user_ldap >}} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'user/get/ldap/' + str(user_name) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Inserts a new User and returns its identifier. <END_TASK> <USER_TASK:> Description: def inserir(self, user, pwd, name, email, user_ldap): """Inserts a new User and returns its identifier. The user will be created with active status. :param user: Username. String with a minimum 3 and maximum of 45 characters :param pwd: User password. String with a minimum 3 and maximum of 45 characters :param name: User name. String with a minimum 3 and maximum of 200 characters :param email: User Email. String with a minimum 3 and maximum of 300 characters :param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters :return: Dictionary with the following structure: :: {'usuario': {'id': < id_user >}} :raise InvalidParameterError: The identifier of User, user, pwd, name or email is null and invalid. :raise UserUsuarioDuplicadoError: There is already a registered user with the value of user. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
user_map = dict() user_map['user'] = user user_map['password'] = pwd user_map['name'] = name user_map['email'] = email user_map['user_ldap'] = user_ldap code, xml = self.submit({'user': user_map}, 'POST', 'user/') return self.response(code, xml)
<SYSTEM_TASK:> Change User from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_user, user, password, nome, ativo, email, user_ldap): """Change User from by the identifier. :param id_user: Identifier of the User. Integer value and greater than zero. :param user: Username. String with a minimum 3 and maximum of 45 characters :param password: User password. String with a minimum 3 and maximum of 45 characters :param nome: User name. String with a minimum 3 and maximum of 200 characters :param email: User Email. String with a minimum 3 and maximum of 300 characters :param ativo: Status. 0 or 1 :param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters :return: None :raise InvalidParameterError: The identifier of User, user, pwd, name, email or active is null and invalid. :raise UserUsuarioDuplicadoError: There is already a registered user with the value of user. :raise UsuarioNaoExisteError: User 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_user): raise InvalidParameterError( u'The identifier of User is invalid or was not informed.') url = 'user/' + str(id_user) + '/' user_map = dict() user_map['user'] = user user_map['password'] = password user_map['name'] = nome user_map['active'] = ativo user_map['email'] = email user_map['user_ldap'] = user_ldap code, xml = self.submit({'user': user_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Insert new access type and returns its identifier. <END_TASK> <USER_TASK:> Description: def inserir(self, protocolo): """Insert new access type and returns its identifier. :param protocolo: Protocol. :return: Dictionary with structure: {‘tipo_acesso’: {‘id’: < id >}} :raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists. :raise InvalidParameterError: Protocol value is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
tipo_acesso_map = dict() tipo_acesso_map['protocolo'] = protocolo code, xml = self.submit( {'tipo_acesso': tipo_acesso_map}, 'POST', 'tipoacesso/') return self.response(code, xml)
<SYSTEM_TASK:> Edit access type by its identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_tipo_acesso, protocolo): """Edit access type by its identifier. :param id_tipo_acesso: Access type identifier. :param protocolo: Protocol. :return: None :raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists. :raise InvalidParameterError: Protocol value is invalid or none. :raise TipoAcessoNaoExisteError: Access type doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_tipo_acesso): raise InvalidParameterError( u'Access type id is invalid or was not informed.') tipo_acesso_map = dict() tipo_acesso_map['protocolo'] = protocolo url = 'tipoacesso/' + str(id_tipo_acesso) + '/' code, xml = self.submit({'tipo_acesso': tipo_acesso_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Removes access type by its identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_tipo_acesso): """Removes access type by its identifier. :param id_tipo_acesso: Access type identifier. :return: None :raise TipoAcessoError: Access type associated with equipment, cannot be removed. :raise InvalidParameterError: Protocol value is invalid or none. :raise TipoAcessoNaoExisteError: Access type doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_tipo_acesso): raise InvalidParameterError( u'Access type id is invalid or was not informed.') url = 'tipoacesso/' + str(id_tipo_acesso) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Inserts a new Script Type and returns its identifier. <END_TASK> <USER_TASK:> Description: def inserir(self, type, description): """Inserts a new Script Type and returns its identifier. :param type: Script Type type. String with a minimum 3 and maximum of 40 characters :param description: Script Type description. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'script_type': {'id': < id_script_type >}} :raise InvalidParameterError: Type or description is null and invalid. :raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
script_type_map = dict() script_type_map['type'] = type script_type_map['description'] = description code, xml = self.submit( {'script_type': script_type_map}, 'POST', 'scripttype/') return self.response(code, xml)
<SYSTEM_TASK:> Change Script Type from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_script_type, type, description): """Change Script Type from by the identifier. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :param type: Script Type type. String with a minimum 3 and maximum of 40 characters :param description: Script Type description. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Script Type, type or description is null and invalid. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed. :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.') script_type_map = dict() script_type_map['type'] = type script_type_map['description'] = description url = 'scripttype/' + str(id_script_type) + '/' code, xml = self.submit({'script_type': script_type_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Script Type from by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_script_type): """Remove Script Type from by the identifier. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Script Type is null and invalid. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise TipoRoteiroError: Script type is associated with a script. :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 = 'scripttype/' + str(id_script_type) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Method to search pool's based on extends search. <END_TASK> <USER_TASK:> Description: def search(self, **kwargs): """ Method to search pool's based on extends search. :param search: Dict containing QuerySets to find pool's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override default fields. :param kind: Determine if result will be detailed ('detail') or basic ('basic'). :return: Dict containing pool's """
return super(ApiPool, self).get(self.prepare_url('api/v3/pool/', kwargs))
<SYSTEM_TASK:> Method to delete pool's by their ids <END_TASK> <USER_TASK:> Description: def delete(self, ids): """ Method to delete pool's by their ids :param ids: Identifiers of pool's :return: None """
url = build_uri_with_ids('api/v3/pool/%s/', ids) return super(ApiPool, self).delete(url)
<SYSTEM_TASK:> Method to create pool's <END_TASK> <USER_TASK:> Description: def create(self, pools): """ Method to create pool's :param pools: List containing pool's desired to be created on database :return: None """
data = {'server_pools': pools} return super(ApiPool, self).post('api/v3/pool/', data)
<SYSTEM_TASK:> Find reals related with equipment <END_TASK> <USER_TASK:> Description: def get_real_related(self, id_equip): """ Find reals related with equipment :param id_equip: Identifier of equipment :return: Following dictionary: :: {'vips': [{'port_real': < port_real >, 'server_pool_member_id': < server_pool_member_id >, 'ip': < ip >, 'port_vip': < port_vip >, 'host_name': < host_name >, 'id_vip': < id_vip >, ...], 'equip_name': < equip_name > }} :raise EquipamentoNaoExisteError: Equipment not registered. :raise InvalidParameterError: Some parameter was invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'equipamento/get_real_related/' + str(id_equip) + '/' code, xml = self.submit(None, 'GET', url) data = self.response(code, xml) return data
<SYSTEM_TASK:> Associates an IPv6 to a equipament. <END_TASK> <USER_TASK:> Description: def associate_ipv6(self, id_equip, id_ipv6): """Associates an IPv6 to a equipament. :param id_equip: Identifier of the equipment. Integer value and greater than zero. :param id_ipv6: Identifier of the ip. Integer value and greater than zero. :return: Dictionary with the following structure: {'ip_equipamento': {'id': < id_ip_do_equipamento >}} :raise EquipamentoNaoExisteError: Equipment is not registered. :raise IpNaoExisteError: IP not registered. :raise IpError: IP is already associated with the equipment. :raise InvalidParameterError: Identifier of the equipment and/or IP 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_equip): raise InvalidParameterError( u'The identifier of equipment is invalid or was not informed.') if not is_valid_int_param(id_ipv6): raise InvalidParameterError( u'The identifier of ip is invalid or was not informed.') url = 'ipv6/' + str(id_ipv6) + '/equipment/' + str(id_equip) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Parse data request to data from python. <END_TASK> <USER_TASK:> Description: def _parse(self, content): """ Parse data request to data from python. @param content: Context of request. @raise ParseError: """
if content: stream = BytesIO(str(content)) data = json.loads(stream.getvalue()) return data
<SYSTEM_TASK:> Remove Rack by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_rack): """Remove Rack by the identifier. :param id_rack: Identifier of the Rack. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Rack is null and invalid. :raise RackNaoExisteError: Rack not registered. :raise RackError: Rack is associated with a script. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_rack): raise InvalidParameterError( u'The identifier of Rack is invalid or was not informed.') url = 'rack/' + str(id_rack) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Insert new environment with ip config and returns your id. <END_TASK> <USER_TASK:> Description: def insert_with_ip_range( self, id_l3_group, id_logical_environment, id_division, id_ip_config, link, id_filter=None): """Insert new environment with ip config and returns your id. :param id_l3_group: Layer 3 Group ID. :param id_logical_environment: Logical Environment ID. :param id_division: Data Center Division ID. :param id_filter: Filter identifier. :param id_ip_config: IP Configuration ID. :param link: Link. :return: Following dictionary: {'ambiente': {'id': < id >}} :raise ConfigEnvironmentDuplicateError: Error saving duplicate Environment Configuration. :raise InvalidParameterError: Some parameter was invalid. :raise GrupoL3NaoExisteError: Layer 3 Group not found. :raise AmbienteLogicoNaoExisteError: Logical Environment not found. :raise DivisaoDcNaoExisteError: Data Center Division not found. :raise AmbienteDuplicadoError: Environment with this parameters already exists. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
environment_map = dict() environment_map['id_grupo_l3'] = id_l3_group environment_map['id_ambiente_logico'] = id_logical_environment environment_map['id_divisao'] = id_division environment_map['id_filter'] = id_filter environment_map['id_ip_config'] = id_ip_config environment_map['link'] = link code, xml = self.submit( {'ambiente': environment_map}, 'POST', 'ambiente/ipconfig/') return self.response(code, xml)
<SYSTEM_TASK:> Makes relationship of environment with ip config and returns your id. <END_TASK> <USER_TASK:> Description: def add_ip_range(self, id_environment, id_ip_config): """Makes relationship of environment with ip config and returns your id. :param id_environment: Environment ID. :param id_ip_config: IP Configuration ID. :return: Following dictionary: {'config_do_ambiente': {'id_config_do_ambiente': < id_config_do_ambiente >}} :raise InvalidParameterError: Some parameter was invalid. :raise ConfigEnvironmentDuplicateError: Error saving duplicate Environment Configuration. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
environment_map = dict() environment_map['id_environment'] = id_environment environment_map['id_ip_config'] = id_ip_config code, xml = self.submit( {'ambiente': environment_map}, 'POST', 'ipconfig/') return self.response(code, xml)
<SYSTEM_TASK:> Inserts a new healthckeck_expect with only expect_string. <END_TASK> <USER_TASK:> Description: def add_expect_string_healthcheck(self, expect_string): """Inserts a new healthckeck_expect with only expect_string. :param expect_string: expect_string. :return: Dictionary with the following structure: :: {'healthcheck_expect': {'id': < id >}} :raise InvalidParameterError: The value of expect_string is invalid. :raise HealthCheckExpectJaCadastradoError: There is already a healthcheck_expect registered with the same data. :raise HealthCheckExpectNaoExisteError: Healthcheck_expect not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
healthcheck_map = dict() healthcheck_map['expect_string'] = expect_string url = 'healthcheckexpect/add/expect_string/' code, xml = self.submit({'healthcheck': healthcheck_map}, 'POST', url) return self.response(code, xml)
<SYSTEM_TASK:> Get all expect_string. <END_TASK> <USER_TASK:> Description: def listar_healtchcheck_expect_distinct(self): """Get all expect_string. :return: Dictionary with the following structure: :: {'healthcheck_expect': [ 'expect_string': < expect_string >, ... demais healthcheck_expects ...]} :raise InvalidParameterError: Identifier is null and invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'healthcheckexpect/distinct/busca/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Get all distinct acl paths. <END_TASK> <USER_TASK:> Description: def list_acl_path(self): """Get all distinct acl paths. :return: Dictionary with the following structure: :: {'acl_paths': [ < acl_path >, ... ]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'environment/acl_path/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Set template value. If id_environment = 0, set '' to all environments related with the template name. <END_TASK> <USER_TASK:> Description: def set_template(self, id_environment, name, network): """Set template value. If id_environment = 0, set '' to all environments related with the template name. :param id_environment: Environment Identifier. :param name: Template Name. :param network: IPv4 or IPv6. :return: None :raise InvalidParameterError: Invalid param. :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta. """
url = 'environment/set_template/' + str(id_environment) + '/' environment_map = dict() environment_map['name'] = name environment_map['network'] = network code, xml = self.submit({'environment': environment_map}, 'POST', url) return self.response(code, xml)
<SYSTEM_TASK:> Add new prefix configuration <END_TASK> <USER_TASK:> Description: def configuration_save( self, id_environment, network, prefix, ip_version, network_type): """ Add new prefix configuration :param id_environment: Identifier of the Environment. Integer value and greater than zero. :param network: Network Ipv4 or Ipv6. :param prefix: Prefix 0-32 to Ipv4 or 0-128 to Ipv6. :param ip_version: v4 to IPv4 or v6 to IPv6 :param network_type: type network :return: Following dictionary: :: {'network':{'id_environment': <id_environment>, 'id_vlan': <id_vlan>, 'network_type': <network_type>, 'network': <network>, 'prefix': <prefix>} } :raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered. :raise InvalidValueError: Invalid Id for environment or network or network_type or prefix. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """
network_map = dict() network_map['id_environment'] = id_environment network_map['network'] = network network_map['prefix'] = prefix network_map['ip_version'] = ip_version network_map['network_type'] = network_type code, xml = self.submit( {'ambiente': network_map}, 'POST', 'environment/configuration/save/') return self.response(code, xml)
<SYSTEM_TASK:> List all prefix configurations by environment in DB <END_TASK> <USER_TASK:> Description: def configuration_list_all(self, environment_id): """ List all prefix configurations by environment in DB :return: Following dictionary: :: {'lists_configuration': [{ 'id': <id_ipconfig>, 'subnet': <subnet>, 'type': <type>, 'new_prefix': <new_prefix>, }, ... ]} :raise InvalidValueError: Invalid ID for Environment. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """
data = dict() data["environment_id"] = environment_id url = ("environment/configuration/list/%(environment_id)s/" % data) code, xml = self.submit(None, 'GET', url) return self.response(code, xml, force_list=['lists_configuration'])
<SYSTEM_TASK:> Remove Prefix Configuration <END_TASK> <USER_TASK:> Description: def configuration_remove(self, environment_id, configuration_id): """ Remove Prefix Configuration :return: None :raise InvalidValueError: Invalid Id for Environment or IpConfig. :raise IPConfigNotFoundError: Ipconfig not resgistred. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """
data = dict() data["configuration_id"] = configuration_id data["environment_id"] = environment_id url = ( "environment/configuration/remove/%(environment_id)s/%(configuration_id)s/" % data) code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Associate a news Environment on Environment VIP and returns its identifier. <END_TASK> <USER_TASK:> Description: def associate(self, environment_id, environment_vip_id): """Associate a news Environment on Environment VIP and returns its identifier. :param environment_id: Identifier of the Environment. Integer value and greater than zero. :param environment_vip_id: Identifier of the Environment VIP. Integer value and greater than zero. :return: Following dictionary: :: {'environment_environment_vip': {'id': < id >}} :raise InvalidParameterError: The value of environment_id or environment_vip_id is invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(environment_id): raise InvalidParameterError( u'The identifier of Environment VIP is invalid or was not informed.') if not is_valid_int_param(environment_vip_id): raise InvalidParameterError( u'The identifier of Environment is invalid or was not informed.') environment_environment_vip_map = dict() environment_environment_vip_map['environment_id'] = environment_id environment_environment_vip_map['environment_vip_id'] = environment_vip_id url = 'environment/{}/environmentvip/{}/'.format(environment_id, environment_vip_id) code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Get all Environment by Environment Vip. <END_TASK> <USER_TASK:> Description: def get_related_environment_list(self, environment_vip_id): """Get all Environment by Environment Vip. :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 EnvironmentVipNotFoundError: Environment VIP not registered. :raise DataBaseError: Can't connect to networkapi database. :raise XMLError: Failed to generate the XML response. """
url = 'environment/environmentvip/{}/'.format(environment_vip_id) code, xml = self.submit(None, 'GET', url) return self.response(code, xml, ['environment_related_list'])
<SYSTEM_TASK:> Return list environments related with environment vip <END_TASK> <USER_TASK:> Description: def get_equipment(self, **kwargs): """ Return list environments related with environment vip """
uri = 'api/v3/equipment/' uri = self.prepare_url(uri, kwargs) return super(ApiEquipment, self).get(uri)
<SYSTEM_TASK:> Method to undeploy pool's by their ids <END_TASK> <USER_TASK:> Description: def delete(self, ids): """ Method to undeploy pool's by their ids :param ids: Identifiers of deployed pool's :return: Empty Dict """
url = build_uri_with_ids('api/v3/pool/deploy/%s/', ids) return super(ApiPoolDeploy, self).delete(url)
<SYSTEM_TASK:> Method to deploy pool's <END_TASK> <USER_TASK:> Description: def create(self, ids): """ Method to deploy pool's :param pools: Identifiers of pool's desired to be deployed :return: Empty Dict """
url = build_uri_with_ids('api/v3/pool/deploy/%s/', ids) return super(ApiPoolDeploy, self).post(url)
<SYSTEM_TASK:> Inserts a new Brand and returns its identifier <END_TASK> <USER_TASK:> Description: def inserir(self, name): """Inserts a new Brand and returns its identifier :param name: Brand name. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'marca': {'id': < id_brand >}} :raise InvalidParameterError: Name is null and invalid. :raise NomeMarcaDuplicadoError: There is already a registered Brand with the value of name. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
brand_map = dict() brand_map['name'] = name code, xml = self.submit({'brand': brand_map}, 'POST', 'brand/') return self.response(code, xml)
<SYSTEM_TASK:> Change Brand from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_brand, name): """Change Brand from by the identifier. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Brand name. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Brand or name is null and invalid. :raise NomeMarcaDuplicadoError: There is already a registered Brand with the value of name. :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 = 'brand/' + str(id_brand) + '/' brand_map = dict() brand_map['name'] = name code, xml = self.submit({'brand': brand_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Brand from by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_brand): """Remove Brand from by the identifier. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Brand is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise MarcaError: The brand is associated with a model. :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 = 'brand/' + str(id_brand) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Acl draft by type <END_TASK> <USER_TASK:> Description: def acl_remove_draft(self, id_vlan, type_acl): """ Remove Acl draft by type :param id_vlan: Identity of Vlan :param type_acl: Acl type v4 or v6 :return: None :raise VlanDoesNotExistException: Vlan Does Not Exist. :raise InvalidIdVlanException: Invalid id for Vlan. :raise NetworkAPIException: Failed to access the data source. """
parameters = dict(id_vlan=id_vlan, type_acl=type_acl) uri = 'api/vlan/acl/remove/draft/%(id_vlan)s/%(type_acl)s/' % parameters return super(ApiVlan, self).get(uri)
<SYSTEM_TASK:> Save Acl draft by type <END_TASK> <USER_TASK:> Description: def acl_save_draft(self, id_vlan, type_acl, content_draft): """ Save Acl draft by type :param id_vlan: Identity of Vlan :param type_acl: Acl type v4 or v6 :return: None :raise VlanDoesNotExistException: Vlan Does Not Exist. :raise InvalidIdVlanException: Invalid id for Vlan. :raise NetworkAPIException: Failed to access the data source. """
parameters = dict(id_vlan=id_vlan, type_acl=type_acl) data = dict(content_draft=content_draft) uri = 'api/vlan/acl/save/draft/%(id_vlan)s/%(type_acl)s/' % parameters return super(ApiVlan, self).post(uri, data=data)
<SYSTEM_TASK:> Method to search vlan's based on extends search. <END_TASK> <USER_TASK:> Description: def search(self, **kwargs): """ Method to search vlan's based on extends search. :param search: Dict containing QuerySets to find vlan's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override default fields. :param kind: Determine if result will be detailed ('detail') or basic ('basic'). :return: Dict containing vlan's """
return super(ApiVlan, self).get(self.prepare_url('api/v3/vlan/', kwargs))
<SYSTEM_TASK:> Method to delete vlan's by their ids <END_TASK> <USER_TASK:> Description: def delete(self, ids): """ Method to delete vlan's by their ids :param ids: Identifiers of vlan's :return: None """
url = build_uri_with_ids('api/v3/vlan/%s/', ids) return super(ApiVlan, self).delete(url)
<SYSTEM_TASK:> Method to create vlan's <END_TASK> <USER_TASK:> Description: def create(self, vlans): """ Method to create vlan's :param vlans: List containing vlan's desired to be created on database :return: None """
data = {'vlans': vlans} return super(ApiVlan, self).post('api/v3/vlan/', data)
<SYSTEM_TASK:> Checks if the parameter is a valid ip version value. <END_TASK> <USER_TASK:> Description: def is_valid_version_ip(param): """Checks if the parameter is a valid ip version value. :param param: Value to be validated. :return: True if the parameter has a valid ip version value, or False otherwise. """
if param is None: return False if param == IP_VERSION.IPv4[0] or param == IP_VERSION.IPv6[0]: return True return False
<SYSTEM_TASK:> List Option Vip by Environment Vip <END_TASK> <USER_TASK:> Description: def option_vip_by_environmentvip(self, environment_vip_id): """ List Option Vip by Environment Vip param environment_vip_id: Id of Environment Vip """
uri = 'api/v3/option-vip/environment-vip/%s/' % environment_vip_id return super(ApiVipRequest, self).get(uri)
<SYSTEM_TASK:> Method to get details of vip request <END_TASK> <USER_TASK:> Description: def get_vip_request_details(self, vip_request_id): """ Method to get details of vip request param vip_request_id: vip_request id """
uri = 'api/v3/vip-request/details/%s/' % vip_request_id return super(ApiVipRequest, self).get(uri)
<SYSTEM_TASK:> Method to get vip request <END_TASK> <USER_TASK:> Description: def get_vip_request(self, vip_request_id): """ Method to get vip request param vip_request_id: vip_request id """
uri = 'api/v3/vip-request/%s/' % vip_request_id return super(ApiVipRequest, self).get(uri)
<SYSTEM_TASK:> Method to list vip request <END_TASK> <USER_TASK:> Description: def search_vip_request(self, search): """ Method to list vip request param search: search """
uri = 'api/v3/vip-request/?%s' % urllib.urlencode({'search': search}) return super(ApiVipRequest, self).get(uri)
<SYSTEM_TASK:> Method to save vip request <END_TASK> <USER_TASK:> Description: def save_vip_request(self, vip_request): """ Method to save vip request param vip_request: vip_request object """
uri = 'api/v3/vip-request/' data = dict() data['vips'] = list() data['vips'].append(vip_request) return super(ApiVipRequest, self).post(uri, data)
<SYSTEM_TASK:> Method to create vip request <END_TASK> <USER_TASK:> Description: def create_vip(self, vip_request_ids): """ Method to create vip request param vip_request_ids: vip_request ids """
uri = 'api/v3/vip-request/deploy/%s/' % vip_request_ids return super(ApiVipRequest, self).post(uri)
<SYSTEM_TASK:> Method to search vip's based on extends search. <END_TASK> <USER_TASK:> Description: def search(self, **kwargs): """ Method to search vip's based on extends search. :param search: Dict containing QuerySets to find vip's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override default fields. :param kind: Determine if result will be detailed ('detail') or basic ('basic'). :return: Dict containing vip's """
return super(ApiVipRequest, self).get(self.prepare_url('api/v3/vip-request/', kwargs))
<SYSTEM_TASK:> Method to delete vip's by their id's <END_TASK> <USER_TASK:> Description: def delete(self, ids): """ Method to delete vip's by their id's :param ids: Identifiers of vip's :return: None """
url = build_uri_with_ids('api/v3/vip-request/%s/', ids) return super(ApiVipRequest, self).delete(url)
<SYSTEM_TASK:> Method to create vip's <END_TASK> <USER_TASK:> Description: def create(self, vips): """ Method to create vip's :param vips: List containing vip's desired to be created on database :return: None """
data = {'vips': vips} return super(ApiVipRequest, self).post('api/v3/vip-request/', data)
<SYSTEM_TASK:> Method to deploy vip's <END_TASK> <USER_TASK:> Description: def deploy(self, ids): """ Method to deploy vip's :param vips: List containing vip's desired to be deployed on equipment :return: None """
url = build_uri_with_ids('api/v3/vip-request/deploy/%s/', ids) return super(ApiVipRequest, self).post(url)
<SYSTEM_TASK:> Method to undeploy vip's <END_TASK> <USER_TASK:> Description: def undeploy(self, ids, clean_up=0): """ Method to undeploy vip's :param vips: List containing vip's desired to be undeployed on equipment :return: None """
url = build_uri_with_ids('api/v3/vip-request/deploy/%s/?cleanup=%s', ids, clean_up) return super(ApiVipRequest, self).delete(url)
<SYSTEM_TASK:> Inserts a new Option Pool and returns its identifier. <END_TASK> <USER_TASK:> Description: def add(self, tipo_opcao, nome_opcao): """Inserts a new Option Pool and returns its identifier. :param tipo_opcao: Type. String with a maximum of 50 characters and respect [a-zA-Z\_-] :param nome_opcao_txt: Name Option. String with a maximum of 50 characters and respect [a-zA-Z\_-] :return: Following dictionary: :: {'id': < id > , 'type':<type>, 'name':<name>} :raise InvalidParameterError: The value of tipo_opcao or nome_opcao_txt is invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
#optionpool_map = dict() #optionpool_map['type'] = tipo_opcao #optionpool_map['name'] = nome_opcao url='api/pools/options/save/' return self.post(url, {'type': tipo_opcao, "name":nome_opcao })
<SYSTEM_TASK:> Change Option Pool from by id. <END_TASK> <USER_TASK:> Description: def modify(self, id_option_pool, tipo_opcao, nome_opcao): """Change Option Pool from by id. :param id_option_pool: Identifier of the Option Pool. Integer value and greater than zero. :param tipo_opcao: Type. String with a maximum of 50 characters and respect [a-zA-Z\_-] :param nome_opcao_txt: Name Option. String with a maximum of 50 characters and respect [a-zA-Z\_-] :return: None :raise InvalidParameterError: Option Pool identifier is null or invalid. :raise InvalidParameterError: The value of tipo_opcao or nome_opcao_txt is invalid. :raise optionpoolNotFoundError: Option pool 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_option_pool): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.') #optionpool_map = dict() #optionpool_map['type'] = tipo_opcao #optionpool_map['name'] = nome_opcao_txt url = 'api/pools/options/' + str(id_option_pool) + '/' return self.put(url,{'type': tipo_opcao, "name":nome_opcao } )
<SYSTEM_TASK:> Remove Option pool by identifier and all Environment related . <END_TASK> <USER_TASK:> Description: def remove(self, id_option_pool): """Remove Option pool by identifier and all Environment related . :param id_option_pool: Identifier of the Option Pool. Integer value and greater than zero. :return: None :raise InvalidParameterError: Option Pool identifier is null and invalid. :raise optionpoolNotFoundError: Option Pool not registered. :raise optionpoolError: Option Pool associated with Pool. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_option_pool): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.') url = 'api/pools/options/' + str(id_option_pool) + '/' return self.delete(url)
<SYSTEM_TASK:> Search Option Pool by id. <END_TASK> <USER_TASK:> Description: def get_option_pool(self, id_option_pool): """Search Option Pool by id. :param id_option_pool: Identifier of the Option Pool. Integer value and greater than zero. :return: Following dictionary: :: {‘id’: < id_option_pool >, ‘type’: < tipo_opcao >, ‘name’: < nome_opcao_txt >} :raise InvalidParameterError: Option Pool identifier is null and invalid. :raise optionpoolNotFoundError: Option Pool 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_option_pool): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.') url = 'api/pools/options/' + str(id_option_pool) + '/' return self.get(url)
<SYSTEM_TASK:> Get all Option Pool. <END_TASK> <USER_TASK:> Description: def get_all_option_pool(self, option_type=None): """Get all Option Pool. :return: Dictionary with the following structure: :: {[{‘id’: < id >, ‘type’: < tipo_opcao >, ‘name’: < nome_opcao_txt >}, ... other option pool ...] } :raise optionpoolNotFoundError: Option Pool not registered. :raise DataBaseError: Can't connect to networkapi database. :raise XMLError: Failed to generate the XML response. """
if option_type: url = 'api/pools/options/?type='+option_type else: url = 'api/pools/options/' return self.get(url)
<SYSTEM_TASK:> Get all Option VIP by Environment . <END_TASK> <USER_TASK:> Description: def get_all_environment_option_pool(self, id_environment=None, option_id=None, option_type=None): """Get all Option VIP by Environment . :return: Dictionary with the following structure: :: {[{‘id’: < id >, option: { 'id': <id> 'type':<type> 'name':<name> } environment: { 'id':<id> .... all environment info } etc to option pools ...] } :raise EnvironmentVipNotFoundError: Environment Pool not registered. :raise DataBaseError: Can't connect to networkapi database. :raise XMLError: Failed to generate the XML response. """
url='api/pools/environment_options/' if id_environment: if option_id: if option_type: url = url + "?environment_id=" + str(id_environment)+ "&option_id=" + str(option_id) + "&option_type=" + option_type else: url = url + "?environment_id=" + str(id_environment)+ "&option_id=" + str(option_id) else: if option_type: url = url + "?environment_id=" + str(id_environment) + "&option_type=" + option_type else: url = url + "?environment_id=" + str(id_environment) elif option_id: if option_type: url = url + "?option_id=" + str(option_id) + "&option_type=" + option_type else: url = url + "?option_id=" + str(option_id) elif option_type: url = url + "?option_type=" + option_type return self.get(url)
<SYSTEM_TASK:> Create a relationship of optionpool with Environment. <END_TASK> <USER_TASK:> Description: def associate_environment_option_pool(self, id_option_pool, id_environment): """Create a relationship of optionpool with Environment. :param id_option_pool: Identifier of the Option Pool. Integer value and greater than zero. :param id_environment: Identifier of the Environment . Integer value and greater than zero. :return: Dictionary with the following structure: {‘id’: < id >, option: { 'id': <id> 'type':<type> 'name':<name> } environment: { 'id':<id> .... all environment info } } :raise InvalidParameterError: Option Pool/Environment Pool identifier is null and/or invalid. :raise optionpoolNotFoundError: Option Pool not registered. :raise EnvironmentVipNotFoundError: Environment Pool not registered. :raise optionpoolError: Option Pool is already associated with the environment pool. :raise UserNotAuthorizedError: User does not have authorization to make this association. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(id_option_pool): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.') if not is_valid_int_param(id_environment): raise InvalidParameterError( u'The identifier of Environment Pool is invalid or was not informed.') url= 'api/pools/environment_options/save/' return self.post(url, {'option_id': id_option_pool,"environment_id":id_environment })
<SYSTEM_TASK:> Inserts a new Filter and returns its identifier. <END_TASK> <USER_TASK:> Description: def add(self, name, description): """Inserts a new Filter and returns its identifier. :param name: Name. String with a maximum of 100 characters and respect [a-zA-Z\_-] :param description: Description. String with a maximum of 200 characters and respect [a-zA-Z\_-] :return: Following dictionary: :: {'filter': {'id': < id >}} :raise InvalidParameterError: The value of name or description is invalid. :raise FilterDuplicateError: A filter named by name already exists. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
filter_map = dict() filter_map['name'] = name filter_map['description'] = description code, xml = self.submit({'filter': filter_map}, 'POST', 'filter/') return self.response(code, xml)
<SYSTEM_TASK:> Change Filter by the identifier. <END_TASK> <USER_TASK:> Description: def alter(self, id_filter, name, description): """Change Filter by the identifier. :param id_filter: Identifier of the Filter. Integer value and greater than zero. :param name: Name. String with a maximum of 50 characters and respect [a-zA-Z\_-] :param description: Description. String with a maximum of 50 characters and respect [a-zA-Z\_-] :return: None :raise InvalidParameterError: Filter identifier is null and invalid. :raise InvalidParameterError: The value of name or description is invalid. :raise FilterNotFoundError: Filter 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_filter): raise InvalidParameterError( u'The identifier of Filter is invalid or was not informed.') filter_map = dict() filter_map['name'] = name filter_map['description'] = description url = 'filter/' + str(id_filter) + '/' code, xml = self.submit({'filter': filter_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Filter by the identifier. <END_TASK> <USER_TASK:> Description: def remove(self, id_filter): """Remove Filter by the identifier. :param id_filter: Identifier of the Filter. Integer value and greater than zero. :return: None :raise InvalidParameterError: Filter identifier is null and invalid. :raise FilterNotFoundError: Filter 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_filter): raise InvalidParameterError( u'The identifier of Filter is invalid or was not informed.') url = 'filter/' + str(id_filter) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Get filter by id. <END_TASK> <USER_TASK:> Description: def get(self, id_filter): """Get filter by id. :param id_filter: Identifier of the Filter. Integer value and greater than zero. :return: Following dictionary: :: {‘filter’: {‘id’: < id >, ‘name’: < name >, ‘description’: < description >}} :raise InvalidParameterError: The value of id_filter is invalid. :raise FilterNotFoundError: Filter not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
url = 'filter/get/' + str(id_filter) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Create a relationship between Filter and TipoEquipamento. <END_TASK> <USER_TASK:> Description: def associate(self, et_id, id_filter): """Create a relationship between Filter and TipoEquipamento. :param et_id: Identifier of TipoEquipamento. Integer value and greater than zero. :param id_filter: Identifier of Filter. Integer value and greater than zero. :return: Following dictionary: :: {'equiptype_filter_xref': {'id': < id_equiptype_filter_xref >} } :raise InvalidParameterError: TipoEquipamento/Filter identifier is null and/or invalid. :raise TipoEquipamentoNaoExisteError: TipoEquipamento not registered. :raise FilterNotFoundError: Filter not registered. :raise FilterEqTypeAssociationError: TipoEquipamento and Filter already associated. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if not is_valid_int_param(et_id): raise InvalidParameterError( u'The identifier of TipoEquipamento is invalid or was not informed.') if not is_valid_int_param(id_filter): raise InvalidParameterError( u'The identifier of Filter is invalid or was not informed.') url = 'filter/' + str(id_filter) + '/equiptype/' + str(et_id) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Removes relationship between Filter and TipoEquipamento. <END_TASK> <USER_TASK:> Description: def dissociate(self, id_filter, id_eq_type): """Removes relationship between Filter and TipoEquipamento. :param id_filter: Identifier of Filter. Integer value and greater than zero. :param id_eq_type: Identifier of TipoEquipamento. Integer value, greater than zero. :return: None :raise FilterNotFoundError: Filter not registered. :raise TipoEquipamentoNotFoundError: TipoEquipamento 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_filter): raise InvalidParameterError( u'The identifier of Filter is invalid or was not informed.') if not is_valid_int_param(id_eq_type): raise InvalidParameterError( u'The identifier of TipoEquipamento is invalid or was not informed.') url = 'filter/' + \ str(id_filter) + '/dissociate/' + str(id_eq_type) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Search Group Equipament from by the identifier. <END_TASK> <USER_TASK:> Description: def search(self, id_egroup): """Search Group Equipament from by the identifier. :param id_egroup: Identifier of the Group Equipament. Integer value and greater than zero. :return: Following dictionary: :: {‘group_equipament’: {‘id’: < id_egrupo >, ‘nome’: < nome >} } :raise InvalidParameterError: Group Equipament identifier is null and invalid. :raise GrupoEquipamentoNaoExisteError: Group Equipament 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_egroup): raise InvalidParameterError( u'The identifier of Group Equipament is invalid or was not informed.') url = 'egroup/' + str(id_egroup) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Inserts a new Logical Environment and returns its identifier. <END_TASK> <USER_TASK:> Description: def inserir(self, name): """Inserts a new Logical Environment and returns its identifier. :param name: Logical Environment name. String with a minimum 2 and maximum of 80 characters :return: Dictionary with the following structure: :: {'logical_environment': {'id': < id_logical_environment >}} :raise InvalidParameterError: Name is null and invalid. :raise NomeAmbienteLogicoDuplicadoError: There is already a registered Logical Environment with the value of name. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
logical_environment_map = dict() logical_environment_map['name'] = name code, xml = self.submit( {'logical_environment': logical_environment_map}, 'POST', 'logicalenvironment/') return self.response(code, xml)
<SYSTEM_TASK:> Change Logical Environment from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_logicalenvironment, name): """Change Logical Environment from by the identifier. :param id_logicalenvironment: Identifier of the Logical Environment. Integer value and greater than zero. :param name: Logical Environment name. String with a minimum 2 and maximum of 80 characters :return: None :raise InvalidParameterError: The identifier of Logical Environment or name is null and invalid. :raise NomeAmbienteLogicoDuplicadoError: There is already a registered Logical Environment with the value of name. :raise AmbienteLogicoNaoExisteError: Logical Environment 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_logicalenvironment): raise InvalidParameterError( u'The identifier of Logical Environment is invalid or was not informed.') url = 'logicalenvironment/' + str(id_logicalenvironment) + '/' logical_environment_map = dict() logical_environment_map['name'] = name code, xml = self.submit( {'logical_environment': logical_environment_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Logical Environment from by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_logicalenvironment): """Remove Logical Environment from by the identifier. :param id_logicalenvironment: Identifier of the Logical Environment. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Logical Environment is null and invalid. :raise AmbienteLogicoNaoExisteError: Logical Environment 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_logicalenvironment): raise InvalidParameterError( u'The identifier of Logical Environment is invalid or was not informed.') url = 'logicalenvironment/' + str(id_logicalenvironment) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Search Administrative Permission by Group User by identifier. <END_TASK> <USER_TASK:> Description: def list_by_group(self, id_ugroup): """Search Administrative Permission by Group User by identifier. :param id_ugroup: Identifier of the Group User. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'perms': [{'ugrupo': < ugrupo_id >, 'permission': { 'function' < function >, 'id': < id > }, 'id': < id >, 'escrita': < escrita >, 'leitura': < leitura >}, ... ] } :raise InvalidParameterError: Group User is null and invalid. :raise UGrupoNotFoundError: Group User not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
if id_ugroup is None: raise InvalidParameterError( u'The identifier of Group User is invalid or was not informed.') url = 'aperms/group/' + str(id_ugroup) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Search Administrative Permission from by the identifier. <END_TASK> <USER_TASK:> Description: def search(self, id_perm): """Search Administrative Permission from by the identifier. :param id_perm: Identifier of the Administrative Permission. Integer value and greater than zero. :return: Following dictionary: :: {'perm': {'ugrupo': < ugrupo_id >, 'permission': < permission_id >, 'id': < id >, 'escrita': < escrita >, 'leitura': < leitura >}} :raise InvalidParameterError: Group User identifier is null and invalid. :raise PermissaoAdministrativaNaoExisteError: Administrative Permission 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_perm): raise InvalidParameterError( u'The identifier of Administrative Permission is invalid or was not informed.') url = 'aperms/get/' + str(id_perm) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
<SYSTEM_TASK:> Inserts a new Administrative Permission and returns its identifier. <END_TASK> <USER_TASK:> Description: def inserir(self, id_permission, read, write, id_group): """Inserts a new Administrative Permission and returns its identifier. :param id_permission: Identifier of the Permission. Integer value and greater than zero. :param read: Read. 0 or 1 :param write: Write. 0 or 1 :param id_group: Identifier of the Group of User. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'perm': {'id': < id_perm >}} :raise InvalidParameterError: The identifier of Administrative Permission, identifier of Group of User, read or write is null and invalid. :raise ValorIndicacaoPermissaoInvalidoError: The value of read or write is null and invalid. :raise PermissaoAdministrativaDuplicadaError: Function already registered for the user group. :raise GrupoUsuarioNaoExisteError: Group of User not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """
perms_map = dict() perms_map['id_permission'] = id_permission perms_map['read'] = read perms_map['write'] = write perms_map['id_group'] = id_group code, xml = self.submit( {'administrative_permission': perms_map}, 'POST', 'aperms/') return self.response(code, xml)
<SYSTEM_TASK:> Change Administrative Permission from by the identifier. <END_TASK> <USER_TASK:> Description: def alterar(self, id_perm, id_permission, read, write, id_group): """Change Administrative Permission from by the identifier. :param id_perm: Identifier of the Administrative Permission. Integer value and greater than zero. :param id_permission: Identifier of the Permission. Integer value and greater than zero. :param read: Read. 0 or 1 :param write: Write. 0 or 1 :param id_group: Identifier of the Group of User. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Administrative Permission, identifier of Permission, identifier of Group of User, read or write is null and invalid. :raise ValorIndicacaoPermissaoInvalidoError: The value of read or write is null and invalid. :raise PermissaoAdministrativaNaoExisteError: Administrative Permission not registered. :raise GrupoUsuarioNaoExisteError: Group of User 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_perm): raise InvalidParameterError( u'The identifier of Administrative Permission is invalid or was not informed.') url = 'aperms/' + str(id_perm) + '/' perms_map = dict() perms_map['id_perm'] = id_perm perms_map['id_permission'] = id_permission perms_map['read'] = read perms_map['write'] = write perms_map['id_group'] = id_group code, xml = self.submit( {'administrative_permission': perms_map}, 'PUT', url) return self.response(code, xml)
<SYSTEM_TASK:> Remove Administrative Permission from by the identifier. <END_TASK> <USER_TASK:> Description: def remover(self, id_perms): """Remove Administrative Permission from by the identifier. :param id_perms: Identifier of the Administrative Permission. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Administrative Permission is null and invalid. :raise PermissaoAdministrativaNaoExisteError: Administrative Permission 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_perms): raise InvalidParameterError( u'The identifier of Administrative Permission is invalid or was not informed.') url = 'aperms/' + str(id_perms) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
<SYSTEM_TASK:> Get an instance of ambiente_logico services facade. <END_TASK> <USER_TASK:> Description: def create_ambiente_logico(self): """Get an instance of ambiente_logico services facade."""
return AmbienteLogico( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Environment Vip services facade. <END_TASK> <USER_TASK:> Description: def create_api_environment_vip(self): """Get an instance of Api Environment Vip services facade."""
return ApiEnvironmentVip( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Environment services facade. <END_TASK> <USER_TASK:> Description: def create_api_environment(self): """Get an instance of Api Environment services facade."""
return ApiEnvironment( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api As services facade. <END_TASK> <USER_TASK:> Description: def create_api_v4_as(self): """Get an instance of Api As services facade."""
return ApiV4As( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Virtual Interface services facade. <END_TASK> <USER_TASK:> Description: def create_api_v4_virtual_interface(self): """Get an instance of Api Virtual Interface services facade."""
return ApiV4VirtualInterface( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Neighbor services facade. <END_TASK> <USER_TASK:> Description: def create_api_v4_neighbor(self): """Get an instance of Api Neighbor services facade."""
return ApiV4Neighbor( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api IPv4 services facade. <END_TASK> <USER_TASK:> Description: def create_api_ipv4(self): """Get an instance of Api IPv4 services facade."""
return ApiIPv4( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api IPv6 services facade. <END_TASK> <USER_TASK:> Description: def create_api_ipv6(self): """Get an instance of Api IPv6 services facade."""
return ApiIPv6( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api V4 IPv4 services facade. <END_TASK> <USER_TASK:> Description: def create_api_v4_ipv4(self): """Get an instance of Api V4 IPv4 services facade."""
return ApiV4IPv4( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api V4 IPv6 services facade. <END_TASK> <USER_TASK:> Description: def create_api_v4_ipv6(self): """Get an instance of Api V4 IPv6 services facade."""
return ApiV4IPv6( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Networkv4 services facade. <END_TASK> <USER_TASK:> Description: def create_api_network_ipv4(self): """Get an instance of Api Networkv4 services facade."""
return ApiNetworkIPv4( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Networkv6 services facade. <END_TASK> <USER_TASK:> Description: def create_api_network_ipv6(self): """Get an instance of Api Networkv6 services facade."""
return ApiNetworkIPv6( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Option Vip services facade. <END_TASK> <USER_TASK:> Description: def create_api_option_vip(self): """Get an instance of Api Option Vip services facade."""
return ApiOptionVip( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Pool services facade. <END_TASK> <USER_TASK:> Description: def create_api_pool(self): """Get an instance of Api Pool services facade."""
return ApiPool( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Pool Deploy services facade. <END_TASK> <USER_TASK:> Description: def create_api_pool_deploy(self): """Get an instance of Api Pool Deploy services facade."""
return ApiPoolDeploy( self.networkapi_url, self.user, self.password, self.user_ldap)
<SYSTEM_TASK:> Get an instance of Api Rack Variables services facade. <END_TASK> <USER_TASK:> Description: def create_apirack(self): """Get an instance of Api Rack Variables services facade."""
return ApiRack( self.networkapi_url, self.user, self.password, self.user_ldap)