def remove(self, id_equipamento, id_egrupo): """Remove a associacao de um grupo de equipamento com um equipamento a partir do seu identificador. :param id_egrupo: Identificador do grupo de equipamento. :param id_equipamento: Identificador do equipamento. :return: None :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do grupo é 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_egrupo): raise InvalidParameterError( u'O identificador do grupo de equipamento é inválido ou não foi informado.') if not is_valid_int_param(id_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.') url = 'egrupo/equipamento/' + \ str(id_equipamento) + '/egrupo/' + str(id_egrupo) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
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)
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)
def disassociate(self, id_option_vip, id_environment_vip): """Remove a relationship of OptionVip with EnvironmentVip. :param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero. :param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero. :return: Nothing :raise InvalidParameterError: Option VIP/Environment VIP identifier is null and/or invalid. :raise OptionVipNotFoundError: Option VIP not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise OptionVipError: Option vip is not associated with the environment vip :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_vip): raise InvalidParameterError( 'The identifier of Option VIP is invalid or was not informed.') if not is_valid_int_param(id_environment_vip): raise InvalidParameterError( 'The identifier of Environment VIP is invalid or was not informed.' ) url = 'optionvip/' + \ str(id_option_vip) + '/environmentvip/' + str(id_environment_vip) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover(self, id_equipment, id_environment): """Remove Related Equipment with Environment from by the identifier. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :param id_environment: Identifier of the Environment. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid. :raise EquipamentoNotFoundError: Equipment not registered. :raise EquipamentoAmbienteNaoExisteError: Environment not registered. :raise VipIpError: IP-related equipment is being used for a request VIP. :raise XMLError: Networkapi failed to generate the XML response. :raise DataBaseError: Networkapi failed to access the database. """ if not is_valid_int_param(id_equipment): raise InvalidParameterError( 'The identifier of Equipment is invalid or was not informed.') if not is_valid_int_param(id_environment): raise InvalidParameterError( 'The identifier of Environment is invalid or was not informed.' ) url = 'equipment/' + \ str(id_equipment) + '/environment/' + str(id_environment) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remove_ipv6(self, id_equip, id_ipv6): """Remove 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: None :raise EquipamentoNaoExisteError: Equipment is not registered. :raise IpNaoExisteError: IP not registered. :raise IpError: Dont 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) + '/remove/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover(self, id_equipment, id_environment): """Remove Related Equipment with Environment from by the identifier. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :param id_environment: Identifier of the Environment. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid. :raise EquipamentoNotFoundError: Equipment not registered. :raise EquipamentoAmbienteNaoExisteError: Environment not registered. :raise VipIpError: IP-related equipment is being used for a request VIP. :raise XMLError: Networkapi failed to generate the XML response. :raise DataBaseError: Networkapi failed to access the database. """ if not is_valid_int_param(id_equipment): raise InvalidParameterError(u"The identifier of Equipment is invalid or was not informed.") if not is_valid_int_param(id_environment): raise InvalidParameterError(u"The identifier of Environment is invalid or was not informed.") url = "equipment/" + str(id_equipment) + "/environment/" + str(id_environment) + "/" code, xml = self.submit(None, "DELETE", url) return self.response(code, xml)
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)
def remover_ip(self, id_equipamento, id_ip): """Removes association of IP and Equipment. If IP has no other association with equipments, IP is also removed. :param id_equipamento: Equipment identifier :param id_ip: IP identifier. :return: None :raise VipIpError: Ip can't be removed because there is a created Vip Request. :raise IpEquipCantDissociateFromVip: Equipment is the last balancer for created Vip Request. :raise IpError: IP not associated with equipment. :raise InvalidParameterError: Equipment or IP identifier is none or invalid. :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise DataBaseError: Networkapi failed to access database. :raise XMLError: Networkapi failed to build response XML. """ if not is_valid_int_param(id_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.' ) if not is_valid_int_param(id_ip): raise InvalidParameterError( u'O identificador do ip é inválido ou não foi informado.') url = 'ip/' + str(id_ip) + '/equipamento/' + str(id_equipamento) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remove(self, id_equipamento, id_egrupo): """Remove a associacao de um grupo de equipamento com um equipamento a partir do seu identificador. :param id_egrupo: Identificador do grupo de equipamento. :param id_equipamento: Identificador do equipamento. :return: None :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do grupo é 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_egrupo): raise InvalidParameterError( 'O identificador do grupo de equipamento é inválido ou não foi informado.' ) if not is_valid_int_param(id_equipamento): raise InvalidParameterError( 'O identificador do equipamento é inválido ou não foi informado.' ) url = 'egrupo/equipamento/' + \ str(id_equipamento) + '/egrupo/' + str(id_egrupo) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
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)
def associar_ip(self, id_equipamento, id_ip): """Associa um IP a um equipamento. :param id_equipamento: Identificador do equipamento. :param id_ip: Identificador do IP. :return: Dicionário com a seguinte estrutura: {'ip_equipamento': {'id': < id_ip_do_equipamento >}} :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise IpNaoExisteError: IP não cadastrado. :raise IpError: IP já está associado ao equipamento. :raise InvalidParameterError: O identificador do equipamento e/ou do IP são nulos ou inválidos. :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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.' ) if not is_valid_int_param(id_ip): raise InvalidParameterError( u'O identificador do ip é inválido ou não foi informado.') url = 'ip/' + str(id_ip) + '/equipamento/' + str(id_equipamento) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
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)
def remover_ip(self, id_equipamento, id_ip): """Removes association of IP and Equipment. If IP has no other association with equipments, IP is also removed. :param id_equipamento: Equipment identifier :param id_ip: IP identifier. :return: None :raise VipIpError: Ip can't be removed because there is a created Vip Request. :raise IpEquipCantDissociateFromVip: Equipment is the last balancer for created Vip Request. :raise IpError: IP not associated with equipment. :raise InvalidParameterError: Equipment or IP identifier is none or invalid. :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise DataBaseError: Networkapi failed to access database. :raise XMLError: Networkapi failed to build response XML. """ if not is_valid_int_param(id_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.') if not is_valid_int_param(id_ip): raise InvalidParameterError( u'O identificador do ip é inválido ou não foi informado.') url = 'ip/' + str(id_ip) + '/equipamento/' + str(id_equipamento) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover(self, id_equipment, id_script): """Remove Related Equipment with Script from by the identifier. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :param id_script: Identifier of the Script. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Equipment or Script is null and invalid. :raise RoteiroNaoExisteError: Script not registered. :raise EquipamentoNaoExisteError: Equipment not registered. :raise EquipamentoRoteiroNaoExisteError: Equipment is not associated with the 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_equipment): raise InvalidParameterError( 'The identifier of Equipment is invalid or was not informed.') if not is_valid_int_param(id_script): raise InvalidParameterError( 'The identifier of Script is invalid or was not informed.') url = 'equipmentscript/' + \ str(id_equipment) + '/' + str(id_script) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def disassociate_environment_option_pool(self, environment_option_id): """Remove 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 Pool. Integer value and greater than zero. :return: { 'id': < environment_option_id> } :raise InvalidParameterError: Option Pool/Environment Pool identifier is null and/or invalid. :raise optionpoolNotFoundError: Option Pool not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise optionpoolError: Option pool is not 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(environment_option_id): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.' ) if not is_valid_int_param(environment_option_id): raise InvalidParameterError( u'The identifier of Environment Pool is invalid or was not informed.' ) url = 'api/pools/environment_options/' + str( environment_option_id) + '/' return self.delete(url)
def disassociate(self, id_option_vip, id_environment_vip): """Remove a relationship of OptionVip with EnvironmentVip. :param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero. :param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero. :return: Nothing :raise InvalidParameterError: Option VIP/Environment VIP identifier is null and/or invalid. :raise OptionVipNotFoundError: Option VIP not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise OptionVipError: Option vip is not associated with the environment vip :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_vip): raise InvalidParameterError(u"The identifier of Option VIP is invalid or was not informed.") if not is_valid_int_param(id_environment_vip): raise InvalidParameterError(u"The identifier of Environment VIP is invalid or was not informed.") url = "optionvip/" + str(id_option_vip) + "/environmentvip/" + str(id_environment_vip) + "/" code, xml = self.submit(None, "DELETE", url) return self.response(code, xml)
def remover(self, id_tipo_acesso, id_equipamento): """Removes relationship between equipment and access type. :param id_equipamento: Equipment identifier. :param id_tipo_acesso: Access type identifier. :return: None :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise EquipamentoAcessoNaoExisteError: Relationship between equipment and access type doesn't exist. :raise InvalidParameterError: Equipment and/or access type id is/are 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_tipo_acesso): raise InvalidParameterError(u'Access type id is invalid.') if not is_valid_int_param(id_equipamento): raise InvalidParameterError(u'Equipment id is invalid.') url = 'equipamentoacesso/' + \ str(id_equipamento) + '/' + str(id_tipo_acesso) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def associate(self, id_option_vip, id_environment_vip): """Create a relationship of OptionVip with EnvironmentVip. :param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero. :param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero. :return: Following dictionary :: {'opcoesvip_ambiente_xref': {'id': < id_opcoesvip_ambiente_xref >} } :raise InvalidParameterError: Option VIP/Environment VIP identifier is null and/or invalid. :raise OptionVipNotFoundError: Option VIP not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise OptionVipError: Option vip is already associated with the environment vip. :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_vip): raise InvalidParameterError( u'The identifier of Option VIP is invalid or was not informed.') if not is_valid_int_param(id_environment_vip): raise InvalidParameterError( u'The identifier of Environment VIP is invalid or was not informed.') url = 'optionvip/' + \ str(id_option_vip) + '/environmentvip/' + str(id_environment_vip) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
def disassociate(self, environment_id, environment_vip_id): """Remove a relationship of Environment with EnvironmentVip. :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: Nothing :raise InvalidParameterError: Environment/Environment VIP identifier is null and/or invalid. :raise EnvironmentNotFoundError: Environment not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise EnvironmentError: Option vip is not associated with the environment vip :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(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, 'DELETE', url) return self.response(code, xml)
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)
def remover_grupo(self, id_equipamento, id_grupo): """Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise EquipmentDontRemoveError: Failure to remove an association between an equipment and a group because the group is related only to a group. :raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos. :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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.' ) if not is_valid_int_param(id_grupo): raise InvalidParameterError( u'O identificador do grupo é inválido ou não foi informado.') url = 'equipamentogrupo/equipamento/' + \ str(id_equipamento) + '/egrupo/' + str(id_grupo) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def associar_ip(self, id_equipamento, id_ip): """Associa um IP a um equipamento. :param id_equipamento: Identificador do equipamento. :param id_ip: Identificador do IP. :return: Dicionário com a seguinte estrutura: {'ip_equipamento': {'id': < id_ip_do_equipamento >}} :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise IpNaoExisteError: IP não cadastrado. :raise IpError: IP já está associado ao equipamento. :raise InvalidParameterError: O identificador do equipamento e/ou do IP são nulos ou inválidos. :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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.') if not is_valid_int_param(id_ip): raise InvalidParameterError( u'O identificador do ip é inválido ou não foi informado.') url = 'ip/' + str(id_ip) + '/equipamento/' + str(id_equipamento) + '/' code, xml = self.submit(None, 'PUT', url) return self.response(code, xml)
def inserir(self, id_user, id_group): """Create a relationship between User and Group. :param id_user: Identifier of the User. Integer value and greater than zero. :param id_group: Identifier of the Group. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'user_group': {'id': < id_user_group >}} :raise InvalidParameterError: The identifier of User or Group is null and invalid. :raise GrupoUsuarioNaoExisteError: UserGroup not registered. :raise UsuarioNaoExisteError: User not registered. :raise UsuarioGrupoError: User already registered in the group. :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.') if not is_valid_int_param(id_group): raise InvalidParameterError( u'The identifier of Group is invalid or was not informed.') url = 'usergroup/user/' + \ str(id_user) + '/ugroup/' + str(id_group) + '/associate/' code, xml = self.submit(None, 'PUT', url)
def update(self, id_equipment, id_environment, is_router): """Remove Related Equipment with Environment from by the identifier. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :param id_environment: Identifier of the Environment. Integer value and greater than zero. :param is_router: Identifier of the Environment. Boolean value. :return: None :raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid. :raise EquipamentoNotFoundError: Equipment not registered. :raise EquipamentoAmbienteNaoExisteError: Environment not registered. :raise VipIpError: IP-related equipment is being used for a request VIP. :raise XMLError: Networkapi failed to generate the XML response. :raise DataBaseError: Networkapi failed to access the database. """ if not is_valid_int_param(id_equipment): raise InvalidParameterError(u"The identifier of Equipment is invalid or was not informed.") if not is_valid_int_param(id_environment): raise InvalidParameterError(u"The identifier of Environment is invalid or was not informed.") equipment_environment_map = dict() equipment_environment_map["id_equipamento"] = id_equipment equipment_environment_map["id_ambiente"] = id_environment equipment_environment_map["is_router"] = is_router code, xml = self.submit( {"equipamento_ambiente": equipment_environment_map}, "PUT", "equipamentoambiente/update/" ) return self.response(code, xml)
def remover(self, id_user, id_group): """Removes relationship between User and Group. :param id_user: Identifier of the User. Integer value and greater than zero. :param id_group: Identifier of the Group. Integer value and greater than zero. :return: None :raise UsuarioGrupoNaoExisteError: Association between user and group not registered. :raise GrupoUsuarioNaoExisteError: UserGroup not registered. :raise UsuarioNaoExisteError: User not registered. :raise UsuarioGrupoError: User already registered in the group. :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.') if not is_valid_int_param(id_group): raise InvalidParameterError( u'The identifier of Group is invalid or was not informed.') url = 'usergroup/user/' + \ str(id_user) + '/ugroup/' + str(id_group) + '/dissociate/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover_grupo(self, id_equipamento, id_grupo): """Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise EquipmentDontRemoveError: Failure to remove an association between an equipment and a group because the group is related only to a group. :raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos. :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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.') if not is_valid_int_param(id_grupo): raise InvalidParameterError( u'O identificador do grupo é inválido ou não foi informado.') url = 'equipamentogrupo/equipamento/' + \ str(id_equipamento) + '/egrupo/' + str(id_grupo) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover(self, id_tipo_acesso, id_equipamento): """Removes relationship between equipment and access type. :param id_equipamento: Equipment identifier. :param id_tipo_acesso: Access type identifier. :return: None :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise EquipamentoAcessoNaoExisteError: Relationship between equipment and access type doesn't exist. :raise InvalidParameterError: Equipment and/or access type id is/are 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_tipo_acesso): raise InvalidParameterError('Access type id is invalid.') if not is_valid_int_param(id_equipamento): raise InvalidParameterError('Equipment id is invalid.') url = 'equipamentoacesso/' + \ str(id_equipamento) + '/' + str(id_tipo_acesso) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def remover(self, id_equipment, id_script): """Remove Related Equipment with Script from by the identifier. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :param id_script: Identifier of the Script. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Equipment or Script is null and invalid. :raise RoteiroNaoExisteError: Script not registered. :raise EquipamentoNaoExisteError: Equipment not registered. :raise EquipamentoRoteiroNaoExisteError: Equipment is not associated with the 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_equipment): raise InvalidParameterError( u'The identifier of Equipment is invalid or was not informed.') if not is_valid_int_param(id_script): raise InvalidParameterError( u'The identifier of Script is invalid or was not informed.') url = 'equipmentscript/' + \ str(id_equipment) + '/' + str(id_script) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
def disassociate_environment_option_pool(self, environment_option_id): """Remove 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 Pool. Integer value and greater than zero. :return: { 'id': < environment_option_id> } :raise InvalidParameterError: Option Pool/Environment Pool identifier is null and/or invalid. :raise optionpoolNotFoundError: Option Pool not registered. :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise optionpoolError: Option pool is not 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(environment_option_id): raise InvalidParameterError( u'The identifier of Option Pool is invalid or was not informed.') if not is_valid_int_param(environment_option_id): raise InvalidParameterError( u'The identifier of Environment Pool is invalid or was not informed.') url = 'api/pools/environment_options/' + str(environment_option_id) + '/' return self.delete(url)
def insert_vlan(self, environment_id, name, number, description, acl_file, acl_file_v6, network_ipv4, network_ipv6): """Create new VLAN :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :param number: Number of Vlan :param acl_file: Acl IPv4 File name to VLAN. :param acl_file_v6: Acl IPv6 File name to VLAN. :param network_ipv4: responsible for generating a network attribute ipv4 automatically. :param network_ipv6: responsible for generating a network attribute ipv6 automatically. :return: Following dictionary: :: {'vlan': {'id': < id_vlan >, 'nome': < nome_vlan >, 'num_vlan': < num_vlan >, 'id_ambiente': < id_ambiente >, 'descricao': < descricao >, 'acl_file_name': < acl_file_name >, 'acl_valida': < acl_valida >, 'ativada': < ativada > 'acl_file_name_v6': < acl_file_name_v6 >, 'acl_valida_v6': < acl_valida_v6 >, } } :raise VlanError: VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available. :raise VlanNaoExisteError: VLAN not found. :raise AmbienteNaoExisteError: Environment not registered. :raise InvalidParameterError: Name of Vlan and/or the identifier of the Environment 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(environment_id): raise InvalidParameterError(u'Environment id is none or invalid.') if not is_valid_int_param(number): raise InvalidParameterError(u'Vlan number is none or invalid') vlan_map = dict() vlan_map['environment_id'] = environment_id vlan_map['name'] = name vlan_map['description'] = description vlan_map['acl_file'] = acl_file vlan_map['acl_file_v6'] = acl_file_v6 vlan_map['number'] = number vlan_map['network_ipv4'] = network_ipv4 vlan_map['network_ipv6'] = network_ipv6 code, xml = self.submit({'vlan': vlan_map}, 'POST', 'vlan/insert/') return self.response(code, xml)
def edit_vlan( self, environment_id, name, number, description, acl_file, acl_file_v6, id_vlan): """Edit a VLAN :param id_vlan: ID for Vlan :param environment_id: ID for Environment. :param name: The name of VLAN. :param description: Some description to VLAN. :param number: Number of Vlan :param acl_file: Acl IPv4 File name to VLAN. :param acl_file_v6: Acl IPv6 File name to VLAN. :return: None :raise VlanError: VLAN name already exists, DC division of the environment invalid or there is no VLAN number available. :raise VlanNaoExisteError: VLAN not found. :raise AmbienteNaoExisteError: Environment not registered. :raise InvalidParameterError: Name of Vlan and/or the identifier of the Environment 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_vlan): raise InvalidParameterError( u'Vlan id is invalid or was not informed.') if not is_valid_int_param(environment_id): raise InvalidParameterError(u'Environment id is none or invalid.') if not is_valid_int_param(number): raise InvalidParameterError(u'Vlan number is none or invalid') vlan_map = dict() vlan_map['vlan_id'] = id_vlan vlan_map['environment_id'] = environment_id vlan_map['name'] = name vlan_map['description'] = description vlan_map['acl_file'] = acl_file vlan_map['acl_file_v6'] = acl_file_v6 vlan_map['number'] = number code, xml = self.submit({'vlan': vlan_map}, 'POST', 'vlan/edit/') return self.response(code, xml)
def save_ipv6(self, ip6, id_equip, descricao, id_net): """ Save an IP6 and associate with equipment :param ip6: An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. :param id_equip: Equipment identifier. Integer value and greater than zero. :param descricao: IPv6 description. :param id_net: Network identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ipv6': {'id': < id >, 'block1': <block1>, 'block2': <block2>, 'block3': <block3>, 'block4': <block4>, 'block5': <block5>, 'block6': <block6>, 'block7': <block7>, 'block8': <block8>, 'descricao': < description >, 'equipamento': [ { all name equipamentos related } ], }} """ if not is_valid_int_param(id_net): raise InvalidParameterError( u'Network identifier is invalid or was not informed.') if not is_valid_int_param(id_equip): raise InvalidParameterError( u'Equipment identifier is invalid or was not informed.') if ip6 is None or ip6 == "": raise InvalidParameterError( u'IPv6 is invalid or was not informed.') ip_map = dict() ip_map['id_net'] = id_net ip_map['descricao'] = descricao ip_map['ip6'] = ip6 ip_map['id_equip'] = id_equip url = "ipv6/save/" code, xml = self.submit({'ip_map': ip_map}, 'POST', url) return self.response(code, xml)
def criar(self, id_vlan): """Create a VLAN with script 'navlan'. :param id_vlan: VLAN identifier. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} :raise VlanNaoExisteError: VLAN does not exist. :raise EquipamentoNaoExisteError: Equipment in list does not exist. :raise VlanError: VLAN is active. :raise InvalidParameterError: VLAN identifier is none or invalid. :raise InvalidParameterError: Equipment list is none or empty. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. :raise ScriptError: Failed to run the script. """ if not is_valid_int_param(id_vlan): raise InvalidParameterError( u'Vlan id is invalid or was not informed.') url = 'vlan/' + str(id_vlan) + '/criar/' code, xml = self.submit({'vlan': None}, 'PUT', url) return self.response(code, xml)
def alterar(self, id_script, id_script_type, script, description): """Change Script from by the identifier. :param id_script: Identifier of the Script. Integer value and greater than zero. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :param script: Script name. String with a minimum 3 and maximum of 40 characters :param description: Script description. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Script, script Type, script or description is null and invalid. :raise RoteiroNaoExisteError: Script not registered. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise NomeRoteiroDuplicadoError: 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): raise InvalidParameterError( u'The identifier of Script is invalid or was not informed.') script_map = dict() script_map['id_script_type'] = id_script_type script_map['script'] = script script_map['description'] = description url = 'script/' + str(id_script) + '/' code, xml = self.submit({'script': script_map}, 'PUT', url) return self.response(code, xml)
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 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 } )
def alterar(self, id_groupl3, name): """Change Group L3 from by the identifier. :param id_groupl3: Identifier of the Group L3. Integer value and greater than zero. :param name: Group L3 name. String with a minimum 2 and maximum of 80 characters :return: None :raise InvalidParameterError: The identifier of Group L3 or name is null and invalid. :raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name. :raise GrupoL3NaoExisteError: Group L3 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_groupl3): raise InvalidParameterError( u'The identifier of Group L3 is invalid or was not informed.') url = 'groupl3/' + str(id_groupl3) + '/' group_l3_map = dict() group_l3_map['name'] = name code, xml = self.submit({'groupl3': group_l3_map}, 'PUT', url) return self.response(code, xml)
def buscar_healthcheck_por_id(self, id_healthcheck): """Get HealthCheck by id. :param id_healthcheck: HealthCheck ID. :return: Following dictionary: :: {'healthcheck_expect': {'match_list': < match_list >, 'expect_string': < expect_string >, 'id': < id >, 'ambiente': < ambiente >}} :raise HealthCheckNaoExisteError: HealthCheck not registered. :raise InvalidParameterError: HealthCheck identifier is null and invalid. :raise DataBaseError: Can't connect to networkapi database. :raise XMLError: Failed to generate the XML response. """ if not is_valid_int_param(id_healthcheck): raise InvalidParameterError( 'O identificador do healthcheck é inválido ou não foi informado.' ) url = 'healthcheckexpect/get/' + str(id_healthcheck) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
def remover(self, id_equipamento): """Remove um equipamento a partir do seu identificador. Além de remover o equipamento, a API também remove: - O relacionamento do equipamento com os tipos de acessos. - O relacionamento do equipamento com os roteiros. - O relacionamento do equipamento com os IPs. - As interfaces do equipamento. - O relacionamento do equipamento com os ambientes. - O relacionamento do equipamento com os grupos. :param id_equipamento: Identificador do equipamento. :return: None :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise InvalidParameterError: O identificador do 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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.' ) url = 'equipamento/' + str(id_equipamento) + '/' code, map = self.submit(None, 'DELETE', url) return self.response(code, map)
def alterar(self, id_divisiondc, name): """Change Division Dc from by the identifier. :param id_divisiondc: Identifier of the Division Dc. Integer value and greater than zero. :param name: Division Dc name. String with a minimum 2 and maximum of 80 characters :return: None :raise InvalidParameterError: The identifier of Division Dc or name is null and invalid. :raise NomeDivisaoDcDuplicadoError: There is already a registered Division Dc with the value of name. :raise DivisaoDcNaoExisteError: Division Dc 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_divisiondc): raise InvalidParameterError( 'The identifier of Division Dc is invalid or was not informed.' ) url = 'divisiondc/' + str(id_divisiondc) + '/' division_dc_map = dict() division_dc_map['name'] = name code, xml = self.submit({'division_dc': division_dc_map}, 'PUT', url) return self.response(code, xml)
def remover(self, id_equipamento): """Remove um equipamento a partir do seu identificador. Além de remover o equipamento, a API também remove: - O relacionamento do equipamento com os tipos de acessos. - O relacionamento do equipamento com os roteiros. - O relacionamento do equipamento com os IPs. - As interfaces do equipamento. - O relacionamento do equipamento com os ambientes. - O relacionamento do equipamento com os grupos. :param id_equipamento: Identificador do equipamento. :return: None :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise InvalidParameterError: O identificador do 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_equipamento): raise InvalidParameterError( u'O identificador do equipamento é inválido ou não foi informado.') url = 'equipamento/' + str(id_equipamento) + '/' code, map = self.submit(None, 'DELETE', url) return self.response(code, map)
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)
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( '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)
def remove(self, id_vlan): """Remove a VLAN by your primary key. Execute script to remove VLAN :param id_vlan: ID for VLAN. :return: Following dictionary: :: {‘sucesso’: {‘codigo’: < codigo >, ‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}} :raise InvalidParameterError: Identifier of the VLAN is invalid. :raise VlanNaoExisteError: VLAN not found. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(id_vlan): raise InvalidParameterError( u'Parameter id_vlan is invalid. Value: ' + id_vlan) url = 'vlan/' + str(id_vlan) + '/remove/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
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)
def alter(self, id_environment_vip, finalidade_txt, cliente_txt, ambiente_p44_txt, description): """Change Environment VIP from by the identifier. :param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero. :param finalidade_txt: Finality. String with a maximum of 50 characters and respect [a-zA-Z\_-] :param cliente_txt: ID Client. String with a maximum of 50 characters and respect [a-zA-Z\_-] :param ambiente_p44_txt: Environment P44. String with a maximum of 50 characters and respect [a-zA-Z\_-] :return: None :raise InvalidParameterError: Environment VIP identifier is null and invalid. :raise InvalidParameterError: The value of finalidade_txt, cliente_txt or ambiente_p44_txt is invalid. :raise EnvironmentVipNotFoundError: Environment VIP 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_environment_vip): raise InvalidParameterError(u"The identifier of Environment VIP is invalid or was not informed.") environmentvip_map = dict() environmentvip_map["finalidade_txt"] = finalidade_txt environmentvip_map["cliente_txt"] = cliente_txt environmentvip_map["ambiente_p44_txt"] = ambiente_p44_txt environmentvip_map["description"] = description url = "environmentvip/" + str(id_environment_vip) + "/" code, xml = self.submit({"environment_vip": environmentvip_map}, "PUT", url) return self.response(code, xml)
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 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_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 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( '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)
def alterar(self, id_egrupo, nome): """Altera os dados de um grupo de equipamento a partir do seu identificador. :param id_egrupo: Identificador do grupo de equipamento. :param nome: Nome do grupo de equipamento. :return: None :raise InvalidParameterError: O identificador e/ou o nome do grupo são nulos ou inválidos. :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise NomeGrupoEquipamentoDuplicadoError: Nome do grupo de equipamento duplicado. :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. """ if not is_valid_int_param(id_egrupo): raise InvalidParameterError( 'O identificador do grupo de equipamento é inválido ou não foi informado.' ) url = 'egrupo/' + str(id_egrupo) + '/' egrupo_map = dict() egrupo_map['nome'] = nome code, xml = self.submit({'grupo': egrupo_map}, 'PUT', url) return self.response(code, xml)