sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def list_by_group(self, id_egroup): """Search Group Equipment from by the identifier. :param id_egroup: Identifier of the Group Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]} :raise InvalidParameterError: Group Equipment is null and invalid. :raise GrupoEquipamentoNaoExisteError: Group Equipment not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if id_egroup is None: raise InvalidParameterError( u'The identifier of Group Equipament is invalid or was not informed.') url = 'equipment/group/' + str(id_egroup) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Search Group Equipment from by the identifier. :param id_egroup: Identifier of the Group Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]} :raise InvalidParameterError: Group Equipment is null and invalid. :raise GrupoEquipamentoNaoExisteError: Group Equipment not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response.
entailment
def get_ips_by_equipment_and_environment(self, equip_nome, id_ambiente): """Search Group Equipment from by the identifier. :param id_egroup: Identifier of the Group Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]} :raise InvalidParameterError: Group Equipment is null and invalid. :raise GrupoEquipamentoNaoExisteError: Group Equipment not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if id_ambiente is None: raise InvalidParameterError( u'The environment id is invalid or was not informed.') url = 'equipment/getipsbyambiente/' + str(equip_nome) + '/' + str(id_ambiente) code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Search Group Equipment from by the identifier. :param id_egroup: Identifier of the Group Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'equipaments': [{'nome': < name_equipament >, 'grupos': < id_group >, 'mark': {'id': < id_mark >, 'nome': < name_mark >},'modelo': < id_model >, 'tipo_equipamento': < id_type >, 'model': {'nome': , 'id': < id_model >, 'marca': < id_mark >}, 'type': {id': < id_type >, 'tipo_equipamento': < name_type >}, 'id': < id_equipment >}, ... ]} :raise InvalidParameterError: Group Equipment is null and invalid. :raise GrupoEquipamentoNaoExisteError: Group Equipment not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response.
entailment
def get(self, uri): """ Sends a GET request. @param uri: Uri of Service API. @param data: Requesting Data. Default: None @raise NetworkAPIClientError: Client failed to access the API. """ request = None try: request = requests.get( self._url(uri), auth=self._auth_basic(), headers=self._header() ) request.raise_for_status() try: return request.json() except Exception: return request except HTTPError: try: error = request.json() self.logger.error(error) err = error.get('detail', '') except: err = request raise NetworkAPIClientError(err) finally: self.logger.info('URI: %s', uri) if request: self.logger.info('Status Code: %s', request.status_code if request else '') self.logger.info('X-Request-Id: %s', request.headers.get('x-request-id')) self.logger.info('X-Request-Context: %s', request.headers.get('x-request-context'))
Sends a GET request. @param uri: Uri of Service API. @param data: Requesting Data. Default: None @raise NetworkAPIClientError: Client failed to access the API.
entailment
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
Parse data request to data from python. @param content: Context of request. @raise ParseError:
entailment
def prepare_url(self, uri, kwargs): """Convert dict for URL params """ params = dict() for key in kwargs: if key in ('include', 'exclude', 'fields'): params.update({ key: ','.join(kwargs.get(key)) }) elif key in ('search', 'kind'): params.update({ key: kwargs.get(key) }) if params: params = urlencode(params) uri = '%s?%s' % (uri, params) return uri
Convert dict for URL params
entailment
def insert_rack( self, number, name, mac_address_sw1, mac_address_sw2, mac_address_ilo, id_sw1, id_sw2, id_ilo): """Create new Rack :param number: Number of Rack :return: Following dictionary: :: {'rack': {'id': < id_rack >, 'num_rack': < num_rack >, 'name_rack': < name_rack >, 'mac_sw1': < mac_sw1 >, 'mac_sw2': < mac_sw2 >, 'mac_ilo': < mac_ilo >, 'id_sw1': < id_sw1 >, 'id_sw2': < id_sw2 >, 'id_ilo': < id_ilo >, } } :raise RacksError: Rack already registered with informed. :raise NumeroRackDuplicadoError: There is already a registered Rack with the value of number. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ if not is_valid_int_param(number): raise InvalidParameterError(u'Rack number is none or invalid') rack_map = dict() rack_map['number'] = number rack_map['name'] = name rack_map['mac_address_sw1'] = mac_address_sw1 rack_map['mac_address_sw2'] = mac_address_sw2 rack_map['mac_address_ilo'] = mac_address_ilo rack_map['id_sw1'] = id_sw1 rack_map['id_sw2'] = id_sw2 rack_map['id_ilo'] = id_ilo code, xml = self.submit({'rack': rack_map}, 'POST', 'rack/insert/') return self.response(code, xml)
Create new Rack :param number: Number of Rack :return: Following dictionary: :: {'rack': {'id': < id_rack >, 'num_rack': < num_rack >, 'name_rack': < name_rack >, 'mac_sw1': < mac_sw1 >, 'mac_sw2': < mac_sw2 >, 'mac_ilo': < mac_ilo >, 'id_sw1': < id_sw1 >, 'id_sw2': < id_sw2 >, 'id_ilo': < id_ilo >, } } :raise RacksError: Rack already registered with informed. :raise NumeroRackDuplicadoError: There is already a registered Rack with the value of number. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response.
entailment
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)
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.
entailment
def listar(self, id_divisao=None, id_ambiente_logico=None): """Lista os ambientes filtrados conforme parâmetros informados. Se os dois parâmetros têm o valor None então retorna todos os ambientes. Se o id_divisao é diferente de None então retorna os ambientes filtrados pelo valor de id_divisao. Se o id_divisao e id_ambiente_logico são diferentes de None então retorna os ambientes filtrados por id_divisao e id_ambiente_logico. :param id_divisao: Identificador da divisão de data center. :param id_ambiente_logico: Identificador do ambiente lógico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': [{'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}, ... demais ambientes ... ]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ url = 'ambiente/' if is_valid_int_param(id_divisao) and not is_valid_int_param( id_ambiente_logico): url = 'ambiente/divisao_dc/' + str(id_divisao) + '/' elif is_valid_int_param(id_divisao) and is_valid_int_param(id_ambiente_logico): url = 'ambiente/divisao_dc/' + \ str(id_divisao) + '/ambiente_logico/' + str(id_ambiente_logico) + '/' code, xml = self.submit(None, 'GET', url) key = 'ambiente' return get_list_map(self.response(code, xml, [key]), key)
Lista os ambientes filtrados conforme parâmetros informados. Se os dois parâmetros têm o valor None então retorna todos os ambientes. Se o id_divisao é diferente de None então retorna os ambientes filtrados pelo valor de id_divisao. Se o id_divisao e id_ambiente_logico são diferentes de None então retorna os ambientes filtrados por id_divisao e id_ambiente_logico. :param id_divisao: Identificador da divisão de data center. :param id_ambiente_logico: Identificador do ambiente lógico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': [{'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}, ... demais ambientes ... ]} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta.
entailment
def buscar_por_equipamento(self, nome_equipamento, ip_equipamento): """Obtém um ambiente a partir do ip e nome de um equipamento. :param nome_equipamento: Nome do equipamento. :param ip_equipamento: IP do equipamento no formato XXX.XXX.XXX.XXX. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}} :raise IpError: IP não cadastrado para o equipamento. :raise InvalidParameterError: O nome e/ou o IP do equipamento são vazios ou nulos, ou o IP é inválido. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if nome_equipamento == '' or nome_equipamento is None: raise InvalidParameterError( u'O nome do equipamento não foi informado.') if not is_valid_ip(ip_equipamento): raise InvalidParameterError( u'O IP do equipamento é inválido ou não foi informado.') url = 'ambiente/equipamento/' + \ urllib.quote(nome_equipamento) + '/ip/' + str(ip_equipamento) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Obtém um ambiente a partir do ip e nome de um equipamento. :param nome_equipamento: Nome do equipamento. :param ip_equipamento: IP do equipamento no formato XXX.XXX.XXX.XXX. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}} :raise IpError: IP não cadastrado para o equipamento. :raise InvalidParameterError: O nome e/ou o IP do equipamento são vazios ou nulos, ou o IP é inválido. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta.
entailment
def buscar_por_id(self, id_ambiente): """Obtém um ambiente a partir da chave primária (identificador). :param id_ambiente: Identificador do ambiente. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'acl_path': < acl_path >, 'ipv4_template': < ipv4_template >, 'ipv6_template': < ipv6_template >, 'ambiente_rede': < ambiente_rede >}} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidParameterError: Identificador do ambiente é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_ambiente): raise InvalidParameterError( u'O identificador do ambiente é inválido ou não foi informado.') url = 'environment/id/' + str(id_ambiente) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Obtém um ambiente a partir da chave primária (identificador). :param id_ambiente: Identificador do ambiente. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'acl_path': < acl_path >, 'ipv4_template': < ipv4_template >, 'ipv6_template': < ipv6_template >, 'ambiente_rede': < ambiente_rede >}} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidParameterError: 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.
entailment
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( u'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)
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.
entailment
def listar_por_equip(self, equip_id): """Lista todos os ambientes por equipamento especifico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if equip_id is None: raise InvalidParameterError( u'O id do equipamento não foi informado.') url = 'ambiente/equip/' + str(equip_id) + '/' code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Lista todos os ambientes por equipamento especifico. :return: Dicionário com a seguinte estrutura: :: {'ambiente': {'id': < id_ambiente >, 'link': < link >, 'id_divisao': < id_divisao >, 'nome_divisao': < nome_divisao >, 'id_ambiente_logico': < id_ambiente_logico >, 'nome_ambiente_logico': < nome_ambiente_logico >, 'id_grupo_l3': < id_grupo_l3 >, 'nome_grupo_l3': < nome_grupo_l3 >, 'id_filter': < id_filter >, 'filter_name': < filter_name >, 'ambiente_rede': < ambiente_rede >}} :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta.
entailment
def listar_healthcheck_expect(self, id_ambiente): """Lista os healthcheck_expect´s de um ambiente. :param id_ambiente: Identificador do ambiente. :return: Dicionário com a seguinte estrutura: :: {'healthcheck_expect': [{'id': < id_healthcheck_expect >, 'expect_string': < expect_string >, 'match_list': < match_list >, 'id_ambiente': < id_ambiente >}, ... demais healthcheck_expects ...]} :raise InvalidParameterError: O identificador do ambiente é nulo ou inválido. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta. """ if not is_valid_int_param(id_ambiente): raise InvalidParameterError( u'O identificador do ambiente é inválido ou não foi informado.') url = 'healthcheckexpect/ambiente/' + str(id_ambiente) + '/' code, xml = self.submit(None, 'GET', url) key = 'healthcheck_expect' return get_list_map(self.response(code, xml, [key]), key)
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.
entailment
def add_healthcheck_expect(self, id_ambiente, expect_string, match_list): """Insere um novo healthckeck_expect e retorna o seu identificador. :param expect_string: expect_string. :param id_ambiente: Identificador do ambiente lógico. :param match_list: match list. :return: Dicionário com a seguinte estrutura: {'healthcheck_expect': {'id': < id >}} :raise InvalidParameterError: O identificador do ambiente, match_lis,expect_string, são inválidos ou nulo. :raise HealthCheckExpectJaCadastradoError: Já existe um healthcheck_expect com os mesmos dados cadastrados. :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. """ healthcheck_map = dict() healthcheck_map['id_ambiente'] = id_ambiente healthcheck_map['expect_string'] = expect_string healthcheck_map['match_list'] = match_list url = 'healthcheckexpect/add/' code, xml = self.submit({'healthcheck': healthcheck_map}, 'POST', url) return self.response(code, xml)
Insere um novo healthckeck_expect e retorna o seu identificador. :param expect_string: expect_string. :param id_ambiente: Identificador do ambiente lógico. :param match_list: match list. :return: Dicionário com a seguinte estrutura: {'healthcheck_expect': {'id': < id >}} :raise InvalidParameterError: O identificador do ambiente, match_lis,expect_string, são inválidos ou nulo. :raise HealthCheckExpectJaCadastradoError: Já existe um healthcheck_expect com os mesmos dados cadastrados. :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.
entailment
def inserir( self, id_grupo_l3, id_ambiente_logico, id_divisao, link, id_filter=None, acl_path=None, ipv4_template=None, ipv6_template=None, min_num_vlan_1=None, max_num_vlan_1=None, min_num_vlan_2=None, max_num_vlan_2=None, vrf=None): """Insere um novo ambiente e retorna o seu identificador. :param id_grupo_l3: Identificador do grupo layer 3. :param id_ambiente_logico: Identificador do ambiente lógico. :param id_divisao: Identificador da divisão data center. :param id_filter: Filter identifier. :param link: Link :param acl_path: Path where the ACL will be stored :param ipv4_template: Template that will be used in Ipv6 :param ipv6_template: Template that will be used in Ipv4 :param min_num_vlan_1: Min 1 num vlan valid for this environment :param max_num_vlan_1: Max 1 num vlan valid for this environment :param min_num_vlan_2: Min 2 num vlan valid for this environment :param max_num_vlan_2: Max 2 num vlan valid for this environment :return: Dicionário com a seguinte estrutura: {'ambiente': {'id': < id >}} :raise InvalidParameterError: O identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos. :raise GrupoL3NaoExisteError: Grupo layer 3 não cadastrado. :raise AmbienteLogicoNaoExisteError: Ambiente lógico não cadastrado. :raise DivisaoDcNaoExisteError: Divisão datacenter não cadastrada. :raise AmbienteDuplicadoError: Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já 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. """ ambiente_map = dict() ambiente_map['id_grupo_l3'] = id_grupo_l3 ambiente_map['id_ambiente_logico'] = id_ambiente_logico ambiente_map['id_divisao'] = id_divisao ambiente_map['id_filter'] = id_filter ambiente_map['link'] = link ambiente_map['acl_path'] = acl_path ambiente_map['ipv4_template'] = ipv4_template ambiente_map['ipv6_template'] = ipv6_template ambiente_map['min_num_vlan_1'] = min_num_vlan_1 ambiente_map['max_num_vlan_1'] = max_num_vlan_1 ambiente_map['min_num_vlan_2'] = min_num_vlan_2 ambiente_map['max_num_vlan_2'] = max_num_vlan_2 ambiente_map['vrf'] = vrf code, xml = self.submit( {'ambiente': ambiente_map}, 'POST', 'ambiente/') return self.response(code, xml)
Insere um novo ambiente e retorna o seu identificador. :param id_grupo_l3: Identificador do grupo layer 3. :param id_ambiente_logico: Identificador do ambiente lógico. :param id_divisao: Identificador da divisão data center. :param id_filter: Filter identifier. :param link: Link :param acl_path: Path where the ACL will be stored :param ipv4_template: Template that will be used in Ipv6 :param ipv6_template: Template that will be used in Ipv4 :param min_num_vlan_1: Min 1 num vlan valid for this environment :param max_num_vlan_1: Max 1 num vlan valid for this environment :param min_num_vlan_2: Min 2 num vlan valid for this environment :param max_num_vlan_2: Max 2 num vlan valid for this environment :return: Dicionário com a seguinte estrutura: {'ambiente': {'id': < id >}} :raise InvalidParameterError: O identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos. :raise GrupoL3NaoExisteError: Grupo layer 3 não cadastrado. :raise AmbienteLogicoNaoExisteError: Ambiente lógico não cadastrado. :raise DivisaoDcNaoExisteError: Divisão datacenter não cadastrada. :raise AmbienteDuplicadoError: Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já 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.
entailment
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)
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.
entailment
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)
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.
entailment
def alterar( self, id_ambiente, id_grupo_l3, id_ambiente_logico, id_divisao, link, id_filter=None, acl_path=None, ipv4_template=None, ipv6_template=None, min_num_vlan_1=None, max_num_vlan_1=None, min_num_vlan_2=None, max_num_vlan_2=None, vrf=None): """Altera os dados de um ambiente a partir do seu identificador. :param id_ambiente: Identificador do ambiente. :param id_grupo_l3: Identificador do grupo layer 3. :param id_ambiente_logico: Identificador do ambiente lógico. :param id_divisao: Identificador da divisão data center. :param id_filter: Filter identifier. :param link: Link :param acl_path: Path where the ACL will be stored :param ipv4_template: Template that will be used in Ipv6 :param ipv6_template: Template that will be used in Ipv4 :param min_num_vlan_1: Min 1 num vlan valid for this environment :param max_num_vlan_1: Max 1 num vlan valid for this environment :param min_num_vlan_2: Min 2 num vlan valid for this environment :param max_num_vlan_2: Max 2 num vlan valid for this environment :return: None :raise InvalidParameterError: O identificador do ambiente, o identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos. :raise GrupoL3NaoExisteError: Grupo layer 3 não cadastrado. :raise AmbienteLogicoNaoExisteError: Ambiente lógico não cadastrado. :raise DivisaoDcNaoExisteError: Divisão data center não cadastrada. :raise AmbienteDuplicadoError: Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já cadastrado. :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. """ if not is_valid_int_param(id_ambiente): raise InvalidParameterError( u'O identificador do ambiente é inválido ou não foi informado.') url = 'ambiente/' + str(id_ambiente) + '/' ambiente_map = dict() ambiente_map['id_grupo_l3'] = id_grupo_l3 ambiente_map['id_ambiente_logico'] = id_ambiente_logico ambiente_map['id_divisao'] = id_divisao ambiente_map['id_filter'] = id_filter ambiente_map['link'] = link ambiente_map['vrf'] = vrf ambiente_map['acl_path'] = acl_path ambiente_map['ipv4_template'] = ipv4_template ambiente_map['ipv6_template'] = ipv6_template ambiente_map['min_num_vlan_1'] = min_num_vlan_1 ambiente_map['max_num_vlan_1'] = max_num_vlan_1 ambiente_map['min_num_vlan_2'] = min_num_vlan_2 ambiente_map['max_num_vlan_2'] = max_num_vlan_2 code, xml = self.submit({'ambiente': ambiente_map}, 'PUT', url) return self.response(code, xml)
Altera os dados de um ambiente a partir do seu identificador. :param id_ambiente: Identificador do ambiente. :param id_grupo_l3: Identificador do grupo layer 3. :param id_ambiente_logico: Identificador do ambiente lógico. :param id_divisao: Identificador da divisão data center. :param id_filter: Filter identifier. :param link: Link :param acl_path: Path where the ACL will be stored :param ipv4_template: Template that will be used in Ipv6 :param ipv6_template: Template that will be used in Ipv4 :param min_num_vlan_1: Min 1 num vlan valid for this environment :param max_num_vlan_1: Max 1 num vlan valid for this environment :param min_num_vlan_2: Min 2 num vlan valid for this environment :param max_num_vlan_2: Max 2 num vlan valid for this environment :return: None :raise InvalidParameterError: O identificador do ambiente, o identificador do grupo l3, o identificador do ambiente lógico, e/ou o identificador da divisão de data center são nulos ou inválidos. :raise GrupoL3NaoExisteError: Grupo layer 3 não cadastrado. :raise AmbienteLogicoNaoExisteError: Ambiente lógico não cadastrado. :raise DivisaoDcNaoExisteError: Divisão data center não cadastrada. :raise AmbienteDuplicadoError: Ambiente com o mesmo id_grupo_l3, id_ambiente_logico e id_divisao já cadastrado. :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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
def get_environment_template(self, name, network): """Get environments by template name :param name: Template name. :param network: IPv4 or IPv6. :return: Following dictionary: :: {'ambiente': [divisao_dc - ambiente_logico - grupo_l3, other envs...] } :raise InvalidParameterError: Invalid param. :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/get_env_template/' map_dict = dict() map_dict['name'] = name map_dict['network'] = network code, xml = self.submit({'map': map_dict}, 'PUT', url) return self.response(code, xml)
Get environments by template name :param name: Template name. :param network: IPv4 or IPv6. :return: Following dictionary: :: {'ambiente': [divisao_dc - ambiente_logico - grupo_l3, other envs...] } :raise InvalidParameterError: Invalid param. :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.
entailment
def save_blocks(self, id_env, blocks): """ Save blocks from environment :param id_env: Environment id :param blocks: Lists of blocks in order. Ex: ['content one', 'content two', ...] :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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/save_blocks/' map_dict = dict() map_dict['id_env'] = id_env map_dict['blocks'] = blocks code, xml = self.submit({'map': map_dict}, 'POST', url) return self.response(code, xml)
Save blocks from environment :param id_env: Environment id :param blocks: Lists of blocks in order. Ex: ['content one', 'content two', ...] :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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.
entailment
def get_rule_by_pk(self, id_rule): """ Get a rule by its identifier :param id_rule: Rule identifier. :return: Seguinte estrutura :: { 'rule': {'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > }} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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 = 'rule/get_by_id/' + str(id_rule) code, xml = self.submit(None, 'GET', url) return self.response(code, xml)
Get a rule by its identifier :param id_rule: Rule identifier. :return: Seguinte estrutura :: { 'rule': {'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > }} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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.
entailment
def save_rule(self, name, id_env, contents, blocks_id): """ Save an environment rule :param name: Name of the rule :param id_env: Environment id :param contents: Lists of contents in order. Ex: ['content one', 'content two', ...] :param blocks_id: Lists of blocks id or 0 if is as custom content. Ex: ['0', '5', '0' ...] :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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 = 'rule/save/' map_dict = dict() map_dict['name'] = name map_dict['id_env'] = id_env map_dict['contents'] = contents map_dict['blocks_id'] = blocks_id code, xml = self.submit({'map': map_dict}, 'POST', url) return self.response(code, xml)
Save an environment rule :param name: Name of the rule :param id_env: Environment id :param contents: Lists of contents in order. Ex: ['content one', 'content two', ...] :param blocks_id: Lists of blocks id or 0 if is as custom content. Ex: ['0', '5', '0' ...] :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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.
entailment
def update_rule(self, name, id_env, contents, blocks_id, id_rule): """ Save an environment rule :param name: Name of the rule :param id_env: Environment id :param contents: Lists of contents in order. Ex: ['content one', 'content two', ...] :param blocks_id: Lists of blocks id or 0 if is as custom content. Ex: ['0', '5', '0' ...] :param id_rule: Rule id :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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 = 'rule/update/' map_dict = dict() map_dict['name'] = name map_dict['id_env'] = id_env map_dict['contents'] = contents map_dict['blocks_id'] = blocks_id map_dict['id_rule'] = id_rule try: code, xml = self.submit({'map': map_dict}, 'PUT', url) except Exception as e: raise e return self.response(code, xml)
Save an environment rule :param name: Name of the rule :param id_env: Environment id :param contents: Lists of contents in order. Ex: ['content one', 'content two', ...] :param blocks_id: Lists of blocks id or 0 if is as custom content. Ex: ['0', '5', '0' ...] :param id_rule: Rule id :return: None :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise InvalidValueError: Invalid parameter. :raise UserNotAuthorizedError: Permissão negada. :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.
entailment
def get_all_rules(self, id_env): """Save an environment rule :param id_env: Environment id :return: Estrutura: :: { 'rules': [{'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > },... ]} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise UserNotAuthorizedError: Permissão negada. :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 = 'rule/all/' + str(id_env) code, xml = self.submit(None, 'GET', url) return self.response(code, xml, ['rules'])
Save an environment rule :param id_env: Environment id :return: Estrutura: :: { 'rules': [{'id': < id >, 'environment': < Environment Object >, 'content': < content >, 'name': < name >, 'custom': < custom > },... ]} :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise UserNotAuthorizedError: Permissão negada. :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.
entailment
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)
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.
entailment
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'])
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.
entailment
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)
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.
entailment
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)
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.
entailment
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'])
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.
entailment
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)
Return list environments related with environment vip
entailment
def search(self, **kwargs): """ Method to search equipments based on extends search. :param search: Dict containing QuerySets to find equipments. :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 equipments """ return super(ApiEquipment, self).get(self.prepare_url('api/v3/equipment/', kwargs))
Method to search equipments based on extends search. :param search: Dict containing QuerySets to find equipments. :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 equipments
entailment
def delete(self, ids): """ Method to delete equipments by their id's :param ids: Identifiers of equipments :return: None """ url = build_uri_with_ids('api/v3/equipment/%s/', ids) return super(ApiEquipment, self).delete(url)
Method to delete equipments by their id's :param ids: Identifiers of equipments :return: None
entailment
def create(self, equipments): """ Method to create equipments :param equipments: List containing equipments desired to be created on database :return: None """ data = {'equipments': equipments} return super(ApiEquipment, self).post('api/v3/equipment/', data)
Method to create equipments :param equipments: List containing equipments desired to be created on database :return: None
entailment
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)
Method to undeploy pool's by their ids :param ids: Identifiers of deployed pool's :return: Empty Dict
entailment
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)
Method to deploy pool's :param pools: Identifiers of pool's desired to be deployed :return: Empty Dict
entailment
def edit_reals( self, id_vip, method_bal, reals, reals_prioritys, reals_weights, alter_priority=0): """Execute the script 'gerador_vips' several times with options -real, -add and -del to adjust vip request reals. :param id_vip: Identifier of the VIP. Integer value and greater than zero. :param method_bal: method_bal. :param reals: List of reals. Ex: [{'real_name':'Teste1', 'real_ip':'10.10.10.1'},{'real_name':'Teste2', 'real_ip':'10.10.10.2'}] :param reals_prioritys: List of reals_priority. Ex: ['1','5','3']. :param reals_weights: List of reals_weight. Ex: ['1','5','3']. :param alter_priority: 1 if priority has changed and 0 if hasn't changed. :return: None :raise VipNaoExisteError: Request VIP not registered. :raise InvalidParameterError: Identifier of the request is invalid or null VIP. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. :raise EnvironmentVipError: The combination of finality, client and environment is invalid. :raise InvalidTimeoutValueError: The value of timeout is invalid. :raise InvalidBalMethodValueError: The value of method_bal is invalid. :raise InvalidCacheValueError: The value of cache is invalid. :raise InvalidPersistenceValueError: The value of persistence is invalid. :raise InvalidPriorityValueError: One of the priority values is invalid. :raise EquipamentoNaoExisteError: The equipment associated with this Vip Request doesn't exist. :raise IpEquipmentError: Association between equipment and ip of this Vip Request doesn't exist. :raise IpError: IP not registered. :raise RealServerPriorityError: Vip Request priority list has an error. :raise RealServerWeightError: Vip Request weight list has an error. :raise RealServerPortError: Vip Request port list has an error. :raise RealParameterValueError: Vip Request real server parameter list has an error. :raise RealServerScriptError: Vip Request real server script execution error. """ if not is_valid_int_param(id_vip): raise InvalidParameterError( u'The identifier of vip is invalid or was not informed.') vip_map = dict() vip_map['vip_id'] = id_vip # vip_map['metodo_bal'] = method_bal vip_map['reals'] = {'real': reals} vip_map['reals_prioritys'] = {'reals_priority': reals_prioritys} vip_map['reals_weights'] = {'reals_weight': reals_weights} vip_map['alter_priority'] = alter_priority url = 'vip/real/edit/' code, xml = self.submit({'vip': vip_map}, 'PUT', url) return self.response(code, xml)
Execute the script 'gerador_vips' several times with options -real, -add and -del to adjust vip request reals. :param id_vip: Identifier of the VIP. Integer value and greater than zero. :param method_bal: method_bal. :param reals: List of reals. Ex: [{'real_name':'Teste1', 'real_ip':'10.10.10.1'},{'real_name':'Teste2', 'real_ip':'10.10.10.2'}] :param reals_prioritys: List of reals_priority. Ex: ['1','5','3']. :param reals_weights: List of reals_weight. Ex: ['1','5','3']. :param alter_priority: 1 if priority has changed and 0 if hasn't changed. :return: None :raise VipNaoExisteError: Request VIP not registered. :raise InvalidParameterError: Identifier of the request is invalid or null VIP. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. :raise EnvironmentVipError: The combination of finality, client and environment is invalid. :raise InvalidTimeoutValueError: The value of timeout is invalid. :raise InvalidBalMethodValueError: The value of method_bal is invalid. :raise InvalidCacheValueError: The value of cache is invalid. :raise InvalidPersistenceValueError: The value of persistence is invalid. :raise InvalidPriorityValueError: One of the priority values is invalid. :raise EquipamentoNaoExisteError: The equipment associated with this Vip Request doesn't exist. :raise IpEquipmentError: Association between equipment and ip of this Vip Request doesn't exist. :raise IpError: IP not registered. :raise RealServerPriorityError: Vip Request priority list has an error. :raise RealServerWeightError: Vip Request weight list has an error. :raise RealServerPortError: Vip Request port list has an error. :raise RealParameterValueError: Vip Request real server parameter list has an error. :raise RealServerScriptError: Vip Request real server script execution error.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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))
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
entailment
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)
Method to delete vlan's by their ids :param ids: Identifiers of vlan's :return: None
entailment
def update(self, vlans): """ Method to update vlan's :param vlans: List containing vlan's desired to updated :return: None """ data = {'vlans': vlans} vlans_ids = [str(vlan.get('id')) for vlan in vlans] return super(ApiVlan, self).put('api/v3/vlan/%s/' % ';'.join(vlans_ids), data)
Method to update vlan's :param vlans: List containing vlan's desired to updated :return: None
entailment
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)
Method to create vlan's :param vlans: List containing vlan's desired to be created on database :return: None
entailment
def is_valid_int_param(param): """Verifica se o parâmetro é um valor inteiro válido. :param param: Valor para ser validado. :return: True se o parâmetro tem um valor inteiro válido, ou False, caso contrário. """ if param is None: return False try: param = int(param) if param < 0: return False except (TypeError, ValueError): return False return True
Verifica se o parâmetro é um valor inteiro válido. :param param: Valor para ser validado. :return: True se o parâmetro tem um valor inteiro válido, ou False, caso contrário.
entailment
def is_valid_ip(address): """Verifica se address é um endereço ip válido. O valor é considerado válido se tiver no formato XXX.XXX.XXX.XXX, onde X é um valor entre 0 e 9. :param address: Endereço IP. :return: True se o parâmetro é um IP válido, ou False, caso contrário. """ if address is None: return False pattern = r'\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b' return re.match(pattern, address)
Verifica se address é um endereço ip válido. O valor é considerado válido se tiver no formato XXX.XXX.XXX.XXX, onde X é um valor entre 0 e 9. :param address: Endereço IP. :return: True se o parâmetro é um IP válido, ou False, caso contrário.
entailment
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
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.
entailment
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)
List Option Vip by Environment Vip param environment_vip_id: Id of Environment Vip
entailment
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)
Method to get details of vip request param vip_request_id: vip_request id
entailment
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)
Method to get vip request param vip_request_id: vip_request id
entailment
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)
Method to list vip request param search: search
entailment
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)
Method to save vip request param vip_request: vip_request object
entailment
def update_vip_request(self, vip_request, vip_request_id): """ Method to update vip request param vip_request: vip_request object param vip_request_id: vip_request id """ uri = 'api/v3/vip-request/%s/' % vip_request_id data = dict() data['vips'] = list() data['vips'].append(vip_request) return super(ApiVipRequest, self).put(uri, data)
Method to update vip request param vip_request: vip_request object param vip_request_id: vip_request id
entailment
def delete_vip_request(self, vip_request_ids): """ Method to delete vip request param vip_request_ids: vip_request ids """ uri = 'api/v3/vip-request/%s/' % vip_request_ids return super(ApiVipRequest, self).delete(uri)
Method to delete vip request param vip_request_ids: vip_request ids
entailment
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)
Method to create vip request param vip_request_ids: vip_request ids
entailment
def remove_vip(self, vip_request_ids): """ Method to delete vip request param vip_request_ids: vip_request ids """ uri = 'api/v3/vip-request/deploy/%s/' % vip_request_ids return super(ApiVipRequest, self).delete(uri)
Method to delete vip request param vip_request_ids: vip_request ids
entailment
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))
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
entailment
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)
Method to delete vip's by their id's :param ids: Identifiers of vip's :return: None
entailment
def update(self, vips): """ Method to update vip's :param vips: List containing vip's desired to updated :return: None """ data = {'vips': vips} vips_ids = [str(vip.get('id')) for vip in vips] return super(ApiVipRequest, self).put('api/v3/vip-request/%s/' % ';'.join(vips_ids), data)
Method to update vip's :param vips: List containing vip's desired to updated :return: None
entailment
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)
Method to create vip's :param vips: List containing vip's desired to be created on database :return: None
entailment
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)
Method to deploy vip's :param vips: List containing vip's desired to be deployed on equipment :return: None
entailment
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)
Method to undeploy vip's :param vips: List containing vip's desired to be undeployed on equipment :return: None
entailment
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 })
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.
entailment
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 } )
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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 })
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.
entailment
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)
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.
entailment
def modify_environment_option_pool(self, environment_option_id, id_option_pool,id_environment ): """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: 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 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 Environment Option Pool is invalid or was not informed.') #optionpool_map = dict() #optionpool_map['option'] = option_id #optionpool_map['environment'] = environment_id url = 'api/pools/environment_options/' + str(environment_option_id) + '/' return self.put(url, {'option_id': id_option_pool,"environment_id":id_environment })
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: 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 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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
def inserir(self, nome): """Insere um novo grupo de equipamento e retorna o seu identificador. :param nome: Nome do grupo de equipamento. :return: Dicionário com a seguinte estrutura: {'grupo': {'id': < id >}} :raise InvalidParameterError: Nome do grupo é nulo ou vazio. :raise NomeGrupoEquipamentoDuplicadoError: Nome do grupo de equipmaneto 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. """ egrupo_map = dict() egrupo_map['nome'] = nome code, xml = self.submit({'grupo': egrupo_map}, 'POST', 'egrupo/') return self.response(code, xml)
Insere um novo grupo de equipamento e retorna o seu identificador. :param nome: Nome do grupo de equipamento. :return: Dicionário com a seguinte estrutura: {'grupo': {'id': < id >}} :raise InvalidParameterError: Nome do grupo é nulo ou vazio. :raise NomeGrupoEquipamentoDuplicadoError: Nome do grupo de equipmaneto 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.
entailment
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( u'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)
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.
entailment
def remover(self, id_egrupo): """Remove um grupo de equipamento a partir do seu identificador. :param id_egrupo: Identificador do grupo de equipamento. :return: None :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do grupo é nulo ou inválido. :raise GroupDontRemoveError: :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.') url = 'egrupo/' + str(id_egrupo) + '/' code, xml = self.submit(None, 'DELETE', url) return self.response(code, xml)
Remove um grupo de equipamento a partir do seu identificador. :param id_egrupo: Identificador do grupo de equipamento. :return: None :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do grupo é nulo ou inválido. :raise GroupDontRemoveError: :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao gerar o XML de resposta.
entailment
def associa_equipamento(self, id_equip, id_grupo_equipamento): """Associa um equipamento a um grupo. :param id_equip: Identificador do equipamento. :param id_grupo_equipamento: Identificador do grupo de equipamento. :return: Dicionário com a seguinte estrutura: {'equipamento_grupo':{'id': < id_equip_do_grupo >}} :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise EquipamentoError: Equipamento já está associado ao grupo. :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. """ equip_map = dict() equip_map['id_grupo'] = id_grupo_equipamento equip_map['id_equipamento'] = id_equip code, xml = self.submit( {'equipamento_grupo': equip_map}, 'POST', 'equipamentogrupo/associa/') return self.response(code, xml)
Associa um equipamento a um grupo. :param id_equip: Identificador do equipamento. :param id_grupo_equipamento: Identificador do grupo de equipamento. :return: Dicionário com a seguinte estrutura: {'equipamento_grupo':{'id': < id_equip_do_grupo >}} :raise GrupoEquipamentoNaoExisteError: Grupo de equipamento não cadastrado. :raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos. :raise EquipamentoNaoExisteError: Equipamento não cadastrado. :raise EquipamentoError: Equipamento já está associado ao grupo. :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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
def handle(cls, code, description): '''Recebe o código e a descrição do erro da networkAPI e lança a exceção correspondente. :param code: Código de erro retornado pela networkAPI. :param description: Descrição do erro. :return: None ''' if code is None: raise NetworkAPIClientError(description) if int(code) in cls.errors: raise cls.errors[int(code)](description) else: raise NetworkAPIClientError(description)
Recebe o código e a descrição do erro da networkAPI e lança a exceção correspondente. :param code: Código de erro retornado pela networkAPI. :param description: Descrição do erro. :return: None
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
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)
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.
entailment
def create_ambiente(self): """Get an instance of ambiente services facade.""" return Ambiente( self.networkapi_url, self.user, self.password, self.user_ldap)
Get an instance of ambiente services facade.
entailment
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)
Get an instance of ambiente_logico services facade.
entailment
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)
Get an instance of Api Environment Vip services facade.
entailment